diff options
author | 2017-09-28 10:03:36 -0700 | |
---|---|---|
committer | 2017-09-28 10:13:44 -0700 | |
commit | 6996992c9553c8d4c2cd94007e18000ff1214850 (patch) | |
tree | a7ff8d2f9a0e7a2a6f1c8fd9d1e235555349d9b7 | |
parent | f7529f63608e4ba55c51478263d6a93f36e575c3 (diff) |
initial seed code commit VVP-2
Change-Id: Ie4dfa1d0c2016f58f01c1150d791abbaaec31969
Signed-off-by: Paul McGoldrick <paul.mcgoldrick@att.com>
36 files changed, 2860 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100755 index 0000000..e8210f8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,18 @@ +.project +.pydevproject +*.pyc +*.pyo +*.db +.DS_Store +.coverage +#local_settings.py +/static + +# Distribution / packaging +.Python +.cache +# Django stuff: +.log + +# pyenv +django/static/media/uploads/gallery/* diff --git a/Dockerfile b/Dockerfile new file mode 100755 index 0000000..5017392 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,71 @@ +# ============LICENSE_START========================================== +# org.onap.vvp/cms +# =================================================================== +# Copyright © 2017 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the “License”); +# you may not use this software except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the “License”); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END============================================ +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. +FROM python:alpine + +RUN apk add --no-cache \ + autoconf \ + gcc \ + git \ + jpeg-dev \ + libpq \ + linux-headers \ + musl-dev \ + postgresql-dev \ + zlib-dev \ + && : + +COPY docker-entrypoint.sh / +COPY django /srv/ + +RUN ln -s -f /opt/configmaps/settings/__init__.py /srv/cms/settings/__init__.py; \ + ln -s -f /opt/configmaps/settings/storage.py /srv/cms/settings/storage.py + +RUN pip install --upgrade setuptools && \ + pip install uwsgi && \ + pip install -r /srv/requirements.txt + +#Git is required only for pulling the mezzanine api from forked project +RUN apk del \ + autoconf \ + gcc \ + git \ + linux-headers \ + musl-dev \ + postgresql-dev \ + && : +ENTRYPOINT ["/docker-entrypoint.sh"] diff --git a/LICENSE.TXT b/LICENSE.TXT new file mode 100755 index 0000000..52ff78f --- /dev/null +++ b/LICENSE.TXT @@ -0,0 +1,38 @@ +# -*- coding: utf8 -*- +# ============LICENSE_START========================================== +# org.onap.vvp/cms +# =================================================================== +# Copyright © 2017 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the “License”); +# you may not use this software except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the “License”); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END============================================ +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. diff --git a/LICENSE.uWSGI b/LICENSE.uWSGI new file mode 100755 index 0000000..ff68963 --- /dev/null +++ b/LICENSE.uWSGI @@ -0,0 +1,363 @@ +When installed using the included Dockerfile, +this project installs and uses the uWSGI application server container, +available at https://github.com/unbit/uwsgi. +uWSGI is provided under the GNU General Public License version 2 +with a linking exception, as listed below. +uWSGI code is not included in or distributed as a part of this repository. + +You can find a copy of this license at: https://github.com/unbit/uwsgi/blob/master/LICENSE +---------------------------------------------------------------------- + +LINKING EXCEPTION + + In addition to the permissions in the GNU General Public License, + the authors give you unlimited permission to link the compiled + version of this library into combinations with other programs, + and to distribute those combinations without any restriction + coming from the use of this file. (The General Public License + restrictions do apply in other respects; for example, they cover + modification of the file, and distribution when not linked into + a combined executable.) + +---------------------------------------------------------------------- + + + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + <signature of Ty Coon>, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/README.md b/README.md new file mode 100755 index 0000000..d5cb843 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# rkt-ice-cms diff --git a/django/README.md b/django/README.md new file mode 100755 index 0000000..d5cb843 --- /dev/null +++ b/django/README.md @@ -0,0 +1 @@ +# rkt-ice-cms diff --git a/django/cms/__init__.py b/django/cms/__init__.py new file mode 100755 index 0000000..d01d0f0 --- /dev/null +++ b/django/cms/__init__.py @@ -0,0 +1,37 @@ +# ============LICENSE_START========================================== +# org.onap.vvp/cms +# =================================================================== +# Copyright © 2017 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the “License”); +# you may not use this software except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the “License”); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END============================================ +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. diff --git a/django/cms/envbool.py b/django/cms/envbool.py new file mode 100755 index 0000000..72994d8 --- /dev/null +++ b/django/cms/envbool.py @@ -0,0 +1,60 @@ +# ============LICENSE_START========================================== +# org.onap.vvp/cms +# =================================================================== +# Copyright © 2017 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the “License”); +# you may not use this software except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the “License”); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END============================================ +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. +import os + +def envbool(key, default=False, unknown=True): + """Return a boolean value based on that of an environment variable. + + Environment variables have no native boolean type. They are always strings, and may be empty or + unset (which differs from empty.) Furthermore, notions of what is "truthy" in shell script + differ from that of python. + + This function converts environment variables to python boolean True or False in + case-insensitive, expected ways to avoid pitfalls: + + "True", "true", and "1" become True + "False", "false", and "0" become False + unset or empty becomes False by default (toggle with 'default' parameter.) + any other value becomes True by default (toggle with 'unknown' parameter.) + + """ + return { + 'true': True, '1': True, # 't': True, + 'false': False, '0': False, # 'f': False. + '': default, + }.get(os.getenv(key, '').lower(), unknown) diff --git a/django/cms/management/__init__.py b/django/cms/management/__init__.py new file mode 100755 index 0000000..d01d0f0 --- /dev/null +++ b/django/cms/management/__init__.py @@ -0,0 +1,37 @@ +# ============LICENSE_START========================================== +# org.onap.vvp/cms +# =================================================================== +# Copyright © 2017 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the “License”); +# you may not use this software except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the “License”); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END============================================ +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. diff --git a/django/cms/management/commands/__init__.py b/django/cms/management/commands/__init__.py new file mode 100755 index 0000000..d01d0f0 --- /dev/null +++ b/django/cms/management/commands/__init__.py @@ -0,0 +1,37 @@ +# ============LICENSE_START========================================== +# org.onap.vvp/cms +# =================================================================== +# Copyright © 2017 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the “License”); +# you may not use this software except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the “License”); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END============================================ +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. diff --git a/django/cms/management/commands/import_categories.py b/django/cms/management/commands/import_categories.py new file mode 100755 index 0000000..5fc9b9d --- /dev/null +++ b/django/cms/management/commands/import_categories.py @@ -0,0 +1,57 @@ +# ============LICENSE_START========================================== +# org.onap.vvp/cms +# =================================================================== +# Copyright © 2017 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the “License”); +# you may not use this software except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the “License”); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END============================================ +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. +from mezzanine.blog.management.base import BaseImporterCommand +from mezzanine.blog.models import BlogCategory + + +class Command(BaseImporterCommand): + """ + Import posts categories into Ice CMS app. + """ + + def handle(self, *args, **options): + categories = ["News", "Announcement", "FAQ"] + prompt = options.get("interactive") + + for name in categories: + cat = self.trunc(BlogCategory, prompt, title=name) + if not cat["title"]: + continue + cat, created = BlogCategory.objects.get_or_create(**cat) + if created: + print("Imported category: %s" % cat) diff --git a/django/cms/management/commands/import_pages.py b/django/cms/management/commands/import_pages.py new file mode 100755 index 0000000..c1fe799 --- /dev/null +++ b/django/cms/management/commands/import_pages.py @@ -0,0 +1,51 @@ +# ============LICENSE_START========================================== +# org.onap.vvp/cms +# =================================================================== +# Copyright © 2017 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the “License”); +# you may not use this software except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the “License”); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END============================================ +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. +from django.core.management import BaseCommand +from mezzanine.pages.models import RichTextPage + + +class Command(BaseCommand): + """ + Import pages into Ice CMS app. + """ + + def handle(self, *args, **options): + name = "Documentation" + content = "<p>This is the default content of Documentation1 page - you can change it through CMS.</p>" + page = RichTextPage.objects.get_or_create(title=name, defaults={'content': content, 'login_required': True}) + print("Created Ice page: %s" % page[0].title) diff --git a/django/cms/migrations/0001_initial.py b/django/cms/migrations/0001_initial.py new file mode 100755 index 0000000..ba1bcb9 --- /dev/null +++ b/django/cms/migrations/0001_initial.py @@ -0,0 +1,48 @@ +# ============LICENSE_START========================================== +# org.onap.vvp/cms +# =================================================================== +# Copyright © 2017 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the “License”); +# you may not use this software except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the “License”); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END============================================ +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. +from __future__ import unicode_literals + +from django.db import migrations + +class Migration(migrations.Migration): + + dependencies = [ + ] + + operations = [ + ] diff --git a/django/cms/migrations/0002_user_application.py b/django/cms/migrations/0002_user_application.py new file mode 100755 index 0000000..b0e8e1f --- /dev/null +++ b/django/cms/migrations/0002_user_application.py @@ -0,0 +1,95 @@ +# ============LICENSE_START========================================== +# org.onap.vvp/cms +# =================================================================== +# Copyright © 2017 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the “License”); +# you may not use this software except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the “License”); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END============================================ +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. +from __future__ import unicode_literals +from django.db import migrations +from django.contrib.auth import get_user_model +from oauth2_provider.models import get_application_model, Application + +from django.conf import settings + +#This migration file creates default admin user for the mezzanine server and default EM client app and default categories + +DEFAULT_USERNAME = settings.CMS_APP_USER +DEFAULT_PASSWORD = settings.CMS_APP_USER_PASSWORD +DEFAULT_EMAIL = settings.CMS_APP_USER_MAIL +DEFAULT_CLIENT_ID = settings.CMS_APP_CLIENT_ID +DEFAULT_CLIENT_SECRET = settings.CMS_APP_CLIENT_SECRET +CMS_APP_NAME = settings.CMS_APP_NAME + +''' +Create the admin user for the CSM server +''' +def create_emuser(apps, schema_editor): + User = get_user_model() + args = (DEFAULT_USERNAME, DEFAULT_EMAIL, DEFAULT_PASSWORD) + try: + User.objects.get(username=DEFAULT_USERNAME) + except: + User.objects.create_superuser(*args) + +''' +Create the EM application which acts as a client to the CSM server +''' +def create_emapp(apps, schema_editor): + + Application = get_application_model() + application=None + try: + application = Application.objects.get(client_id=DEFAULT_CLIENT_ID) + except: + # If client_secret and client_id not supplied, a unique one will be generated + application = Application.objects.create( + name=CMS_APP_NAME, + client_type=Application.CLIENT_CONFIDENTIAL, + authorization_grant_type=Application.GRANT_CLIENT_CREDENTIALS, + client_secret=DEFAULT_CLIENT_SECRET, + client_id=DEFAULT_CLIENT_ID, + ) + print("Created ICE application="+str(application)) + +class Migration(migrations.Migration): + + dependencies = [ ('cms', '0001_initial'), + ('twitter' , '0001_initial' ), + ('oauth2_provider' , '0004_auto_20160525_1623'), + ] + + operations = [ + migrations.RunPython(create_emapp), + migrations.RunPython(create_emuser), + ] diff --git a/django/cms/migrations/0003_categories.py b/django/cms/migrations/0003_categories.py new file mode 100755 index 0000000..386a1f9 --- /dev/null +++ b/django/cms/migrations/0003_categories.py @@ -0,0 +1,56 @@ +# ============LICENSE_START========================================== +# org.onap.vvp/cms +# =================================================================== +# Copyright © 2017 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the “License”); +# you may not use this software except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the “License”); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END============================================ +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. +from __future__ import unicode_literals +from django.db import migrations +from mezzanine.blog.models import BlogCategory +from django.contrib.sites.models import Site + +#This migration file creates default categories +''' +Creating ICE default categories +''' +def create_categories(apps, schema_editor): + print("Used to create the categories but now we will create them with command") + +class Migration(migrations.Migration): + + dependencies = [ ('cms', '0002_user_application'), ] + + operations = [ + migrations.RunPython(create_categories), + ] diff --git a/django/cms/migrations/0004_pages.py b/django/cms/migrations/0004_pages.py new file mode 100755 index 0000000..f064f00 --- /dev/null +++ b/django/cms/migrations/0004_pages.py @@ -0,0 +1,58 @@ +# ============LICENSE_START========================================== +# org.onap.vvp/cms +# =================================================================== +# Copyright © 2017 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the “License”); +# you may not use this software except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the “License”); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END============================================ +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. +from __future__ import unicode_literals +from django.db import migrations +from mezzanine.pages.models import RichTextPage +from django.contrib.sites.models import Site + +# This migration file creates default pages +''' +Creating ICE default pages +''' + + +def create_pages(apps, schema_editor): + print("Used to create the pages but now we will create them with command") + + +class Migration(migrations.Migration): + dependencies = [('cms', '0003_categories'), ] + + operations = [ + migrations.RunPython(create_pages), + ] diff --git a/django/cms/migrations/__init__.py b/django/cms/migrations/__init__.py new file mode 100755 index 0000000..d01d0f0 --- /dev/null +++ b/django/cms/migrations/__init__.py @@ -0,0 +1,37 @@ +# ============LICENSE_START========================================== +# org.onap.vvp/cms +# =================================================================== +# Copyright © 2017 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the “License”); +# you may not use this software except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the “License”); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END============================================ +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. diff --git a/django/cms/serializers.py b/django/cms/serializers.py new file mode 100755 index 0000000..6520998 --- /dev/null +++ b/django/cms/serializers.py @@ -0,0 +1,49 @@ +# ============LICENSE_START========================================== +# org.onap.vvp/cms +# =================================================================== +# Copyright © 2017 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the “License”); +# you may not use this software except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the “License”); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END============================================ +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. +from rest_framework import serializers +from mezzanine.pages.models import Page + + +class SearchPageSerializer(serializers.ModelSerializer): + """ + Serializing thin version of the search in pages + """ + + class Meta: + model = Page + fields = ('id', 'title', '_order', ) diff --git a/django/cms/services/__init__.py b/django/cms/services/__init__.py new file mode 100755 index 0000000..d01d0f0 --- /dev/null +++ b/django/cms/services/__init__.py @@ -0,0 +1,37 @@ +# ============LICENSE_START========================================== +# org.onap.vvp/cms +# =================================================================== +# Copyright © 2017 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the “License”); +# you may not use this software except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the “License”); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END============================================ +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. diff --git a/django/cms/services/page_service.py b/django/cms/services/page_service.py new file mode 100755 index 0000000..36e3269 --- /dev/null +++ b/django/cms/services/page_service.py @@ -0,0 +1,53 @@ +# ============LICENSE_START========================================== +# org.onap.vvp/cms +# =================================================================== +# Copyright © 2017 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the “License”); +# you may not use this software except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the “License”); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END============================================ +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. +from django.db.models import Q +from mezzanine.pages.models import Page, RichTextPage + +from cms.serializers import SearchPageSerializer + + +class PageService: + def __init__(self): + pass + + @staticmethod + def search(keyword): + pages = RichTextPage.objects.published().filter(Q(title__icontains=keyword) | + Q(content__icontains=keyword)) + + return SearchPageSerializer(pages.values(), many=True).data diff --git a/django/cms/settings/__init__.py b/django/cms/settings/__init__.py new file mode 100755 index 0000000..a53c7b3 --- /dev/null +++ b/django/cms/settings/__init__.py @@ -0,0 +1,44 @@ +# ============LICENSE_START========================================== +# org.onap.vvp/cms +# =================================================================== +# Copyright © 2017 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the “License”); +# you may not use this software except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the “License”); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END============================================ +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. + +# Settings file for ICE CMS +# +# You should arrange to overwrite this file with one containing settings for your environment. +# +# In Kubernetes, for example, this means mount a configMap volume to /srv/settings containing +# settings in the file __init__.py. diff --git a/django/cms/urls.py b/django/cms/urls.py new file mode 100755 index 0000000..97f9d63 --- /dev/null +++ b/django/cms/urls.py @@ -0,0 +1,147 @@ +# ============LICENSE_START========================================== +# org.onap.vvp/cms +# =================================================================== +# Copyright © 2017 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the “License”); +# you may not use this software except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the “License”); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END============================================ +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. +from __future__ import unicode_literals + +from django.conf.urls import include, url +from django.conf.urls.i18n import i18n_patterns +from django.contrib import admin +from django.views.i18n import set_language + +from mezzanine.core.views import direct_to_template +from mezzanine.conf import settings + +from cms.views.pages import PageSearch + +admin.autodiscover() + +# Add the urlpatterns for any custom Django applications here. +# You can also change the ``home`` view to add your own functionality +# to the project's homepage. + +urlpatterns = i18n_patterns( + # Change the admin prefix here to use an alternate URL for the + # admin interface, which would be marginally more secure. + url("^admin/", include(admin.site.urls)), +) + +if settings.USE_MODELTRANSLATION: + urlpatterns += [ + url('^i18n/$', set_language, name='set_language'), + ] + +urlpatterns += [ + # REST API URLs + url(r'^api/pages/search/?$', PageSearch.as_view()), + url("^api/", include("mezzanine_api.urls")), + + # We don't want to presume how your homepage works, so here are a + # few patterns you can use to set it up. + + # HOMEPAGE AS STATIC TEMPLATE + # --------------------------- + # This pattern simply loads the index.html template. It isn't + # commented out like the others, so it's the default. You only need + # one homepage pattern, so if you use a different one, comment this + # one out. + + url("^$", direct_to_template, {"template": "index.html"}, name="home"), + + # HOMEPAGE AS AN EDITABLE PAGE IN THE PAGE TREE + # --------------------------------------------- + # This pattern gives us a normal ``Page`` object, so that your + # homepage can be managed via the page tree in the admin. If you + # use this pattern, you'll need to create a page in the page tree, + # and specify its URL (in the Meta Data section) as "/", which + # is the value used below in the ``{"slug": "/"}`` part. + # Also note that the normal rule of adding a custom + # template per page with the template name using the page's slug + # doesn't apply here, since we can't have a template called + # "/.html" - so for this case, the template "pages/index.html" + # should be used if you want to customize the homepage's template. + # NOTE: Don't forget to import the view function too! + + # url("^$", mezzanine.pages.views.page, {"slug": "/"}, name="home"), + + # HOMEPAGE FOR A BLOG-ONLY SITE + # ----------------------------- + # This pattern points the homepage to the blog post listing page, + # and is useful for sites that are primarily blogs. If you use this + # pattern, you'll also need to set BLOG_SLUG = "" in your + # ``settings.py`` module, and delete the blog page object from the + # page tree in the admin if it was installed. + # NOTE: Don't forget to import the view function too! + + # url("^$", mezzanine.blog.views.blog_post_list, name="home"), + + # MEZZANINE'S URLS + # ---------------- + # ADD YOUR OWN URLPATTERNS *ABOVE* THE LINE BELOW. + # ``mezzanine.urls`` INCLUDES A *CATCH ALL* PATTERN + # FOR PAGES, SO URLPATTERNS ADDED BELOW ``mezzanine.urls`` + # WILL NEVER BE MATCHED! + + # If you'd like more granular control over the patterns in + # ``mezzanine.urls``, go right ahead and take the parts you want + # from it, and use them directly below instead of using + # ``mezzanine.urls``. + url("^", include("mezzanine.urls")), + + # MOUNTING MEZZANINE UNDER A PREFIX + # --------------------------------- + # You can also mount all of Mezzanine's urlpatterns under a + # URL prefix if desired. When doing this, you need to define the + # ``SITE_PREFIX`` setting, which will contain the prefix. Eg: + # SITE_PREFIX = "my/site/prefix" + # For convenience, and to avoid repeating the prefix, use the + # commented out pattern below (commenting out the one above of course) + # which will make use of the ``SITE_PREFIX`` setting. Make sure to + # add the import ``from django.conf import settings`` to the top + # of this file as well. + # Note that for any of the various homepage patterns above, you'll + # need to use the ``SITE_PREFIX`` setting as well. + + # ("^%s/" % settings.SITE_PREFIX, include("mezzanine.urls")) + + + +] + +# Adds ``STATIC_URL`` to the context of error pages, so that error +# pages can use JS, CSS and images. +handler404 = "mezzanine.core.views.page_not_found" +handler500 = "mezzanine.core.views.server_error" diff --git a/django/cms/views/__init__.py b/django/cms/views/__init__.py new file mode 100755 index 0000000..d01d0f0 --- /dev/null +++ b/django/cms/views/__init__.py @@ -0,0 +1,37 @@ +# ============LICENSE_START========================================== +# org.onap.vvp/cms +# =================================================================== +# Copyright © 2017 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the “License”); +# you may not use this software except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the “License”); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END============================================ +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. diff --git a/django/cms/views/pages.py b/django/cms/views/pages.py new file mode 100755 index 0000000..987cfec --- /dev/null +++ b/django/cms/views/pages.py @@ -0,0 +1,53 @@ +# ============LICENSE_START========================================== +# org.onap.vvp/cms +# =================================================================== +# Copyright © 2017 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the “License”); +# you may not use this software except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the “License”); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END============================================ +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. +from rest_framework.views import APIView +from rest_framework.response import Response +from cms.services.page_service import PageService + + +class PageSearch(APIView): + page_service = PageService() + + def get(self, request): + keyword = request.GET.get('keyword', "") + result = [] + + if keyword: + result = self.page_service.search(keyword) + + return Response(result) diff --git a/django/cms/wsgi.py b/django/cms/wsgi.py new file mode 100755 index 0000000..11ea1f9 --- /dev/null +++ b/django/cms/wsgi.py @@ -0,0 +1,53 @@ +# ============LICENSE_START========================================== +# org.onap.vvp/cms +# =================================================================== +# Copyright © 2017 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the “License”); +# you may not use this software except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the “License”); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END============================================ +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. +""" +WSGI config for cms project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/1.10/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cms.settings") + +application = get_wsgi_application() diff --git a/django/deploy/crontab.template b/django/deploy/crontab.template new file mode 100755 index 0000000..dc11b0d --- /dev/null +++ b/django/deploy/crontab.template @@ -0,0 +1,40 @@ +# ============LICENSE_START========================================== +# org.onap.vvp/cms +# =================================================================== +# Copyright © 2017 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the “License”); +# you may not use this software except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the “License”); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END============================================ +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. +# Poll Twitter every 5 minutes +# Comment-out if you don't use Mezzanine's Twitter app +*/5 * * * * %(user)s %(manage)s poll_twitter diff --git a/django/deploy/gunicorn.conf.py.template b/django/deploy/gunicorn.conf.py.template new file mode 100755 index 0000000..20e4b46 --- /dev/null +++ b/django/deploy/gunicorn.conf.py.template @@ -0,0 +1,45 @@ +# ============LICENSE_START========================================== +# org.onap.vvp/cms +# =================================================================== +# Copyright © 2017 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the “License”); +# you may not use this software except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the “License”); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END============================================ +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. +from __future__ import unicode_literals +import multiprocessing + +bind = "unix:%(proj_path)s/gunicorn.sock" +workers = %(num_workers)s +errorlog = "/home/%(user)s/logs/%(proj_name)s_error.log" +loglevel = "error" +proc_name = "%(proj_name)s" diff --git a/django/deploy/local_settings.py.template b/django/deploy/local_settings.py.template new file mode 100755 index 0000000..217fd2b --- /dev/null +++ b/django/deploy/local_settings.py.template @@ -0,0 +1,74 @@ +# ============LICENSE_START========================================== +# org.onap.vvp/cms +# =================================================================== +# Copyright © 2017 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the “License”); +# you may not use this software except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the “License”); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END============================================ +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. +from __future__ import unicode_literals + +SECRET_KEY = "%(secret_key)s" +NEVERCACHE_KEY = "%(nevercache_key)s" +ALLOWED_HOSTS = [%(domains_python)s] + +DATABASES = { + "default": { + # Ends with "postgresql_psycopg2", "mysql", "sqlite3" or "oracle". + "ENGINE": "django.db.backends.postgresql_psycopg2", + # DB name or path to database file if using sqlite3. + "NAME": "%(proj_name)s", + # Not used with sqlite3. + "USER": "%(proj_name)s", + # Not used with sqlite3. + "PASSWORD": "%(db_pass)s", + # Set to empty string for localhost. Not used with sqlite3. + "HOST": "127.0.0.1", + # Set to empty string for default. Not used with sqlite3. + "PORT": "", + } +} + +SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTOCOL", "https") + +CACHE_MIDDLEWARE_SECONDS = 60 + +CACHE_MIDDLEWARE_KEY_PREFIX = "%(proj_name)s" + +CACHES = { + "default": { + "BACKEND": "django.core.cache.backends.memcached.MemcachedCache", + "LOCATION": "127.0.0.1:11211", + } +} + +SESSION_ENGINE = "django.contrib.sessions.backends.cache" diff --git a/django/deploy/nginx.conf.template b/django/deploy/nginx.conf.template new file mode 100755 index 0000000..7e35a7c --- /dev/null +++ b/django/deploy/nginx.conf.template @@ -0,0 +1,93 @@ +# ============LICENSE_START========================================== +# org.onap.vvp/cms +# =================================================================== +# Copyright © 2017 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the “License”); +# you may not use this software except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the “License”); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END============================================ +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. + +upstream %(proj_name)s { + server unix:%(proj_path)s/gunicorn.sock fail_timeout=0; +} + +server { + + listen 80; + %(ssl_disabled)s listen 443 ssl; + server_name %(domains_nginx)s; + client_max_body_size 10M; + keepalive_timeout 15; + error_log /home/%(user)s/logs/%(proj_name)s_error_nginx.log info; + + %(ssl_disabled)s ssl_certificate conf/%(proj_name)s.crt; + %(ssl_disabled)s ssl_certificate_key conf/%(proj_name)s.key; + %(ssl_disabled)s ssl_session_cache shared:SSL:10m; + %(ssl_disabled)s ssl_session_timeout 10m; + %(ssl_disabled)s ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA; + %(ssl_disabled)s ssl_prefer_server_ciphers on; + %(ssl_disabled)s ssl_protocols TLSv1.2 TLSv1.1 TLSv1; + + # Deny illegal Host headers + if ($host !~* ^(%(domains_regex)s)$) { + return 444; + } + + location / { + proxy_redirect off; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Protocol $scheme; + proxy_pass http://%(proj_name)s; + } + + location /static/ { + root %(proj_path)s; + access_log off; + log_not_found off; + expires 30d; + } + + location /robots.txt { + root %(proj_path)s/static; + access_log off; + log_not_found off; + } + + location /favicon.ico { + root %(proj_path)s/static/img; + access_log off; + log_not_found off; + } + +} diff --git a/django/deploy/supervisor.conf.template b/django/deploy/supervisor.conf.template new file mode 100755 index 0000000..a2d0960 --- /dev/null +++ b/django/deploy/supervisor.conf.template @@ -0,0 +1,46 @@ +# ============LICENSE_START========================================== +# org.onap.vvp/cms +# =================================================================== +# Copyright © 2017 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the “License”); +# you may not use this software except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the “License”); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END============================================ +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. +[program:gunicorn_%(proj_name)s] +command=%(venv_path)s/bin/gunicorn -c gunicorn.conf.py -p gunicorn.pid %(proj_app)s.wsgi:application +directory=%(proj_path)s +user=%(user)s +autostart=true +stdout_logfile = /home/%(user)s/logs/%(proj_name)s_supervisor +autorestart=true +redirect_stderr=true +environment=LANG="%(locale)s",LC_ALL="%(locale)s",LC_LANG="%(locale)s" diff --git a/django/fabfile.py b/django/fabfile.py new file mode 100755 index 0000000..8dd73c8 --- /dev/null +++ b/django/fabfile.py @@ -0,0 +1,721 @@ +# ============LICENSE_START========================================== +# org.onap.vvp/cms +# =================================================================== +# Copyright © 2017 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the “License”); +# you may not use this software except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the “License”); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END============================================ +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. +from __future__ import print_function, unicode_literals +from future.builtins import open + +import os +import re +import sys +from contextlib import contextmanager +from functools import wraps +from getpass import getpass, getuser +from glob import glob +from importlib import import_module +from posixpath import join + +from mezzanine.utils.conf import real_project_name + +from fabric.api import abort, env, cd, prefix, sudo as _sudo, run as _run, \ + hide, task, local +from fabric.context_managers import settings as fab_settings +from fabric.contrib.console import confirm +from fabric.contrib.files import exists, upload_template +from fabric.contrib.project import rsync_project +from fabric.colors import yellow, green, blue, red +from fabric.decorators import hosts + + +################ +# Config setup # +################ + +env.proj_app = real_project_name("cms") + +conf = {} +if sys.argv[0].split(os.sep)[-1] in ("fab", "fab-script.py"): + # Ensure we import settings from the current dir + try: + conf = import_module("%s.settings" % env.proj_app).FABRIC + try: + conf["HOSTS"][0] + except (KeyError, ValueError): + raise ImportError + except (ImportError, AttributeError): + print("Aborting, no hosts defined.") + exit() + +env.db_pass = conf.get("DB_PASS", None) +env.admin_pass = conf.get("ADMIN_PASS", None) +env.user = conf.get("SSH_USER", getuser()) +env.password = conf.get("SSH_PASS", None) +env.key_filename = conf.get("SSH_KEY_PATH", None) +env.hosts = conf.get("HOSTS", [""]) + +env.proj_name = conf.get("PROJECT_NAME", env.proj_app) +env.venv_home = conf.get("VIRTUALENV_HOME", "/home/%s/.virtualenvs" % env.user) +env.venv_path = join(env.venv_home, env.proj_name) +env.proj_path = "/home/%s/mezzanine/%s" % (env.user, env.proj_name) +env.manage = "%s/bin/python %s/manage.py" % (env.venv_path, env.proj_path) +env.domains = conf.get("DOMAINS", [conf.get("LIVE_HOSTNAME", env.hosts[0])]) +env.domains_nginx = " ".join(env.domains) +env.domains_regex = "|".join(env.domains) +env.domains_python = ", ".join(["'%s'" % s for s in env.domains]) +env.ssl_disabled = "#" if len(env.domains) > 1 else "" +env.vcs_tools = ["git", "hg"] +env.deploy_tool = conf.get("DEPLOY_TOOL", "rsync") +env.reqs_path = conf.get("REQUIREMENTS_PATH", None) +env.locale = conf.get("LOCALE", "en_US.UTF-8") +env.num_workers = conf.get("NUM_WORKERS", + "multiprocessing.cpu_count() * 2 + 1") + +env.secret_key = conf.get("SECRET_KEY", "") +env.nevercache_key = conf.get("NEVERCACHE_KEY", "") + +# Remote git repos need to be "bare" and reside separated from the project +if env.deploy_tool == "git": + env.repo_path = "/home/%s/git/%s.git" % (env.user, env.proj_name) +else: + env.repo_path = env.proj_path + + +################## +# Template setup # +################## + +# Each template gets uploaded at deploy time, only if their +# contents has changed, in which case, the reload command is +# also run. + +templates = { + "nginx": { + "local_path": "deploy/nginx.conf.template", + "remote_path": "/etc/nginx/sites-enabled/%(proj_name)s.conf", + "reload_command": "service nginx restart", + }, + "supervisor": { + "local_path": "deploy/supervisor.conf.template", + "remote_path": "/etc/supervisor/conf.d/%(proj_name)s.conf", + "reload_command": "supervisorctl update gunicorn_%(proj_name)s", + }, + "cron": { + "local_path": "deploy/crontab.template", + "remote_path": "/etc/cron.d/%(proj_name)s", + "owner": "root", + "mode": "600", + }, + "gunicorn": { + "local_path": "deploy/gunicorn.conf.py.template", + "remote_path": "%(proj_path)s/gunicorn.conf.py", + }, + "settings": { + "local_path": "deploy/local_settings.py.template", + "remote_path": "%(proj_path)s/%(proj_app)s/local_settings.py", + }, +} + + +###################################### +# Context for virtualenv and project # +###################################### + +@contextmanager +def virtualenv(): + """ + Runs commands within the project's virtualenv. + """ + with cd(env.venv_path): + with prefix("source %s/bin/activate" % env.venv_path): + yield + + +@contextmanager +def project(): + """ + Runs commands within the project's directory. + """ + with virtualenv(): + with cd(env.proj_path): + yield + + +@contextmanager +def update_changed_requirements(): + """ + Checks for changes in the requirements file across an update, + and gets new requirements if changes have occurred. + """ + reqs_path = join(env.proj_path, env.reqs_path) + get_reqs = lambda: run("cat %s" % reqs_path, show=False) + old_reqs = get_reqs() if env.reqs_path else "" + yield + if old_reqs: + new_reqs = get_reqs() + if old_reqs == new_reqs: + # Unpinned requirements should always be checked. + for req in new_reqs.split("\n"): + if req.startswith("-e"): + if "@" not in req: + # Editable requirement without pinned commit. + break + elif req.strip() and not req.startswith("#"): + if not set(">=<") & set(req): + # PyPI requirement without version. + break + else: + # All requirements are pinned. + return + pip("-r %s/%s" % (env.proj_path, env.reqs_path)) + + +########################################### +# Utils and wrappers for various commands # +########################################### + +def _print(output): + print() + print(output) + print() + + +def print_command(command): + _print(blue("$ ", bold=True) + + yellow(command, bold=True) + + red(" ->", bold=True)) + + +@task +def run(command, show=True, *args, **kwargs): + """ + Runs a shell comand on the remote server. + """ + if show: + print_command(command) + with hide("running"): + return _run(command, *args, **kwargs) + + +@task +def sudo(command, show=True, *args, **kwargs): + """ + Runs a command as sudo on the remote server. + """ + if show: + print_command(command) + with hide("running"): + return _sudo(command, *args, **kwargs) + + +def log_call(func): + @wraps(func) + def logged(*args, **kawrgs): + header = "-" * len(func.__name__) + _print(green("\n".join([header, func.__name__, header]), bold=True)) + return func(*args, **kawrgs) + return logged + + +def get_templates(): + """ + Returns each of the templates with env vars injected. + """ + injected = {} + for name, data in templates.items(): + injected[name] = dict([(k, v % env) for k, v in data.items()]) + return injected + + +def upload_template_and_reload(name): + """ + Uploads a template only if it has changed, and if so, reload the + related service. + """ + template = get_templates()[name] + local_path = template["local_path"] + if not os.path.exists(local_path): + project_root = os.path.dirname(os.path.abspath(__file__)) + local_path = os.path.join(project_root, local_path) + remote_path = template["remote_path"] + reload_command = template.get("reload_command") + owner = template.get("owner") + mode = template.get("mode") + remote_data = "" + if exists(remote_path): + with hide("stdout"): + remote_data = sudo("cat %s" % remote_path, show=False) + with open(local_path, "r") as f: + local_data = f.read() + # Escape all non-string-formatting-placeholder occurrences of '%': + local_data = re.sub(r"%(?!\(\w+\)s)", "%%", local_data) + if "%(db_pass)s" in local_data: + env.db_pass = db_pass() + local_data %= env + clean = lambda s: s.replace("\n", "").replace("\r", "").strip() + if clean(remote_data) == clean(local_data): + return + upload_template(local_path, remote_path, env, use_sudo=True, backup=False) + if owner: + sudo("chown %s %s" % (owner, remote_path)) + if mode: + sudo("chmod %s %s" % (mode, remote_path)) + if reload_command: + sudo(reload_command) + + +def rsync_upload(): + """ + Uploads the project with rsync excluding some files and folders. + """ + excludes = ["*.pyc", "*.pyo", "*.db", ".DS_Store", ".coverage", + "local_settings.py", "/static", "/.git", "/.hg"] + local_dir = os.getcwd() + os.sep + return rsync_project(remote_dir=env.proj_path, local_dir=local_dir, + exclude=excludes) + + +def vcs_upload(): + """ + Uploads the project with the selected VCS tool. + """ + if env.deploy_tool == "git": + remote_path = "ssh://%s@%s%s" % (env.user, env.host_string, + env.repo_path) + if not exists(env.repo_path): + run("mkdir -p %s" % env.repo_path) + with cd(env.repo_path): + run("git init --bare") + local("git push -f %s master" % remote_path) + with cd(env.repo_path): + run("GIT_WORK_TREE=%s git checkout -f master" % env.proj_path) + run("GIT_WORK_TREE=%s git reset --hard" % env.proj_path) + elif env.deploy_tool == "hg": + remote_path = "ssh://%s@%s/%s" % (env.user, env.host_string, + env.repo_path) + with cd(env.repo_path): + if not exists("%s/.hg" % env.repo_path): + run("hg init") + print(env.repo_path) + with fab_settings(warn_only=True): + push = local("hg push -f %s" % remote_path) + if push.return_code == 255: + abort() + run("hg update") + + +def db_pass(): + """ + Prompts for the database password if unknown. + """ + if not env.db_pass: + env.db_pass = getpass("Enter the database password: ") + return env.db_pass + + +@task +def apt(packages): + """ + Installs one or more system packages via apt. + """ + return sudo("apt-get install -y -q " + packages) + + +@task +def pip(packages): + """ + Installs one or more Python packages within the virtual environment. + """ + with virtualenv(): + return run("pip install %s" % packages) + + +def postgres(command): + """ + Runs the given command as the postgres user. + """ + show = not command.startswith("psql") + return sudo(command, show=show, user="postgres") + + +@task +def psql(sql, show=True): + """ + Runs SQL against the project's database. + """ + out = postgres('psql -c "%s"' % sql) + if show: + print_command(sql) + return out + + +@task +def backup(filename): + """ + Backs up the project database. + """ + tmp_file = "/tmp/%s" % filename + # We dump to /tmp because user "postgres" can't write to other user folders + # We cd to / because user "postgres" might not have read permissions + # elsewhere. + with cd("/"): + postgres("pg_dump -Fc %s > %s" % (env.proj_name, tmp_file)) + run("cp %s ." % tmp_file) + sudo("rm -f %s" % tmp_file) + + +@task +def restore(filename): + """ + Restores the project database from a previous backup. + """ + return postgres("pg_restore -c -d %s %s" % (env.proj_name, filename)) + + +@task +def python(code, show=True): + """ + Runs Python code in the project's virtual environment, with Django loaded. + """ + setup = "import os;" \ + "os.environ[\'DJANGO_SETTINGS_MODULE\']=\'%s.settings\';" \ + "import django;" \ + "django.setup();" % env.proj_app + full_code = 'python -c "%s%s"' % (setup, code.replace("`", "\\\`")) + with project(): + if show: + print_command(code) + result = run(full_code, show=False) + return result + + +def static(): + """ + Returns the live STATIC_ROOT directory. + """ + return python("from django.conf import settings;" + "print(settings.STATIC_ROOT)", show=False).split("\n")[-1] + + +@task +def manage(command): + """ + Runs a Django management command. + """ + return run("%s %s" % (env.manage, command)) + + +########################### +# Security best practices # +########################### + +@task +@log_call +@hosts(["root@%s" % host for host in env.hosts]) +def secure(new_user=env.user): + """ + Minimal security steps for brand new servers. + Installs system updates, creates new user (with sudo privileges) for future + usage, and disables root login via SSH. + """ + run("apt-get update -q") + run("apt-get upgrade -y -q") + run("adduser --gecos '' %s" % new_user) + run("usermod -G sudo %s" % new_user) + run("sed -i 's:RootLogin yes:RootLogin no:' /etc/ssh/sshd_config") + run("service ssh restart") + print(green("Security steps completed. Log in to the server as '%s' from " + "now on." % new_user, bold=True)) + + +######################### +# Install and configure # +######################### + +@task +@log_call +def install(): + """ + Installs the base system and Python requirements for the entire server. + """ + # Install system requirements + sudo("apt-get update -y -q") + apt("nginx libjpeg-dev python-dev python-setuptools git-core " + "postgresql libpq-dev memcached supervisor python-pip") + run("mkdir -p /home/%s/logs" % env.user) + + # Install Python requirements + sudo("pip install -U pip virtualenv virtualenvwrapper mercurial") + + # Set up virtualenv + run("mkdir -p %s" % env.venv_home) + run("echo 'export WORKON_HOME=%s' >> /home/%s/.bashrc" % (env.venv_home, + env.user)) + run("echo 'source /usr/local/bin/virtualenvwrapper.sh' >> " + "/home/%s/.bashrc" % env.user) + print(green("Successfully set up git, mercurial, pip, virtualenv, " + "supervisor, memcached.", bold=True)) + + +@task +@log_call +def create(): + """ + Creates the environment needed to host the project. + The environment consists of: system locales, virtualenv, database, project + files, SSL certificate, and project-specific Python requirements. + """ + # Generate project locale + locale = env.locale.replace("UTF-8", "utf8") + with hide("stdout"): + if locale not in run("locale -a"): + sudo("locale-gen %s" % env.locale) + sudo("update-locale %s" % env.locale) + sudo("service postgresql restart") + run("exit") + + # Create project path + run("mkdir -p %s" % env.proj_path) + + # Set up virtual env + run("mkdir -p %s" % env.venv_home) + with cd(env.venv_home): + if exists(env.proj_name): + if confirm("Virtualenv already exists in host server: %s" + "\nWould you like to replace it?" % env.proj_name): + run("rm -rf %s" % env.proj_name) + else: + abort() + run("virtualenv %s" % env.proj_name) + + # Upload project files + if env.deploy_tool in env.vcs_tools: + vcs_upload() + else: + rsync_upload() + + # Create DB and DB user + pw = db_pass() + user_sql_args = (env.proj_name, pw.replace("'", "\'")) + user_sql = "CREATE USER %s WITH ENCRYPTED PASSWORD '%s';" % user_sql_args + psql(user_sql, show=False) + shadowed = "*" * len(pw) + print_command(user_sql.replace("'%s'" % pw, "'%s'" % shadowed)) + psql("CREATE DATABASE %s WITH OWNER %s ENCODING = 'UTF8' " + "LC_CTYPE = '%s' LC_COLLATE = '%s' TEMPLATE template0;" % + (env.proj_name, env.proj_name, env.locale, env.locale)) + + # Set up SSL certificate + if not env.ssl_disabled: + conf_path = "/etc/nginx/conf" + if not exists(conf_path): + sudo("mkdir %s" % conf_path) + with cd(conf_path): + crt_file = env.proj_name + ".crt" + key_file = env.proj_name + ".key" + if not exists(crt_file) and not exists(key_file): + try: + crt_local, = glob(join("deploy", "*.crt")) + key_local, = glob(join("deploy", "*.key")) + except ValueError: + parts = (crt_file, key_file, env.domains[0]) + sudo("openssl req -new -x509 -nodes -out %s -keyout %s " + "-subj '/CN=%s' -days 3650" % parts) + else: + upload_template(crt_local, crt_file, use_sudo=True) + upload_template(key_local, key_file, use_sudo=True) + + # Install project-specific requirements + upload_template_and_reload("settings") + with project(): + if env.reqs_path: + pip("-r %s/%s" % (env.proj_path, env.reqs_path)) + pip("gunicorn setproctitle psycopg2 " + "django-compressor python-memcached") + # Bootstrap the DB + manage("createdb --noinput --nodata") + python("from django.conf import settings;" + "from django.contrib.sites.models import Site;" + "Site.objects.filter(id=settings.SITE_ID).update(domain='%s');" + % env.domains[0]) + for domain in env.domains: + python("from django.contrib.sites.models import Site;" + "Site.objects.get_or_create(domain='%s');" % domain) + if env.admin_pass: + pw = env.admin_pass + user_py = ("from django.contrib.auth import get_user_model;" + "User = get_user_model();" + "u, _ = User.objects.get_or_create(username='admin');" + "u.is_staff = u.is_superuser = True;" + "u.set_password('%s');" + "u.save();" % pw) + python(user_py, show=False) + shadowed = "*" * len(pw) + print_command(user_py.replace("'%s'" % pw, "'%s'" % shadowed)) + + return True + + +@task +@log_call +def remove(): + """ + Blow away the current project. + """ + if exists(env.venv_path): + run("rm -rf %s" % env.venv_path) + if exists(env.proj_path): + run("rm -rf %s" % env.proj_path) + for template in get_templates().values(): + remote_path = template["remote_path"] + if exists(remote_path): + sudo("rm %s" % remote_path) + if exists(env.repo_path): + run("rm -rf %s" % env.repo_path) + sudo("supervisorctl update") + psql("DROP DATABASE IF EXISTS %s;" % env.proj_name) + psql("DROP USER IF EXISTS %s;" % env.proj_name) + + +############## +# Deployment # +############## + +@task +@log_call +def restart(): + """ + Restart gunicorn worker processes for the project. + If the processes are not running, they will be started. + """ + pid_path = "%s/gunicorn.pid" % env.proj_path + if exists(pid_path): + run("kill -HUP `cat %s`" % pid_path) + else: + sudo("supervisorctl update") + + +@task +@log_call +def deploy(): + """ + Deploy latest version of the project. + Backup current version of the project, push latest version of the project + via version control or rsync, install new requirements, sync and migrate + the database, collect any new static assets, and restart gunicorn's worker + processes for the project. + """ + if not exists(env.proj_path): + if confirm("Project does not exist in host server: %s" + "\nWould you like to create it?" % env.proj_name): + create() + else: + abort() + + # Backup current version of the project + with cd(env.proj_path): + backup("last.db") + if env.deploy_tool in env.vcs_tools: + with cd(env.repo_path): + if env.deploy_tool == "git": + run("git rev-parse HEAD > %s/last.commit" % env.proj_path) + elif env.deploy_tool == "hg": + run("hg id -i > last.commit") + with project(): + static_dir = static() + if exists(static_dir): + run("tar -cf static.tar --exclude='*.thumbnails' %s" % + static_dir) + else: + with cd(join(env.proj_path, "..")): + excludes = ["*.pyc", "*.pio", "*.thumbnails"] + exclude_arg = " ".join("--exclude='%s'" % e for e in excludes) + run("tar -cf {0}.tar {1} {0}".format(env.proj_name, exclude_arg)) + + # Deploy latest version of the project + with update_changed_requirements(): + if env.deploy_tool in env.vcs_tools: + vcs_upload() + else: + rsync_upload() + with project(): + manage("collectstatic -v 0 --noinput") + manage("migrate --noinput") + for name in get_templates(): + upload_template_and_reload(name) + restart() + return True + + +@task +@log_call +def rollback(): + """ + Reverts project state to the last deploy. + When a deploy is performed, the current state of the project is + backed up. This includes the project files, the database, and all static + files. Calling rollback will revert all of these to their state prior to + the last deploy. + """ + with update_changed_requirements(): + if env.deploy_tool in env.vcs_tools: + with cd(env.repo_path): + if env.deploy_tool == "git": + run("GIT_WORK_TREE={0} git checkout -f " + "`cat {0}/last.commit`".format(env.proj_path)) + elif env.deploy_tool == "hg": + run("hg update -C `cat last.commit`") + with project(): + with cd(join(static(), "..")): + run("tar -xf %s/static.tar" % env.proj_path) + else: + with cd(env.proj_path.rsplit("/", 1)[0]): + run("rm -rf %s" % env.proj_name) + run("tar -xf %s.tar" % env.proj_name) + with cd(env.proj_path): + restore("last.db") + restart() + + +@task +@log_call +def all(): + """ + Installs everything required on a new system and deploy. + From the base software, up to the deployed project. + """ + install() + if create(): + deploy() diff --git a/django/manage.py b/django/manage.py new file mode 100755 index 0000000..fcf5aa7 --- /dev/null +++ b/django/manage.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python +# ============LICENSE_START========================================== +# org.onap.vvp/cms +# =================================================================== +# Copyright © 2017 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the “License”); +# you may not use this software except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the “License”); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END============================================ +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. +import os +import sys + +if __name__ == "__main__": + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cms.settings") + + from django.core.management import execute_from_command_line + + execute_from_command_line(sys.argv) diff --git a/django/requirements.txt b/django/requirements.txt new file mode 100755 index 0000000..8a00ac1 --- /dev/null +++ b/django/requirements.txt @@ -0,0 +1,43 @@ +# ============LICENSE_START========================================== +# org.onap.vvp/cms +# =================================================================== +# Copyright © 2017 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the “License”); +# you may not use this software except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the “License”); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END============================================ +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. +Django==1.10.6 +Mezzanine==4.2.3 +git+https://github.com/att-innovate/mezzanine-api.git@master +psycopg2 +boto +django-storages diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100755 index 0000000..75aa5c7 --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,72 @@ +#!/bin/sh +# ============LICENSE_START========================================== +# org.onap.vvp/cms +# =================================================================== +# Copyright © 2017 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the “License”); +# you may not use this software except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the “License”); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END============================================ +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. + +set -e + +# Since: +# - Kubernetes' volumeMount creates symlinks for configMapped files at the +# target directory. +# - Alpine's update-ca-certificates ignores symlinks. +# So we contrive to copy the contents of the mounted cert symlink into place as +# a normal file. How would we fix this if we didn't have write access to this +# container?? +dev_cert=/opt/secrets/site-crt/site.crt +if [ -e "$dev_cert" ]; then + echo >&2 $0: Updating certificates... + cp -L "$dev_cert" /usr/local/share/ca-certificates/ + update-ca-certificates +fi + +# Perform bootstrap operations if needed +echo >&2 $0: Checking if collectstatic is needed +if [ "$STATIC_ROOT" ]; then + echo >&2 $0: Running collectstatic... + mkdir -p "$STATIC_ROOT" + python /srv/manage.py collectstatic --no-input +fi +echo >&2 $0: Running manage.py check... +python /srv/manage.py check +echo >&2 $0: Running manage.py createdb/migrate... +python /srv/manage.py createdb --noinput || python /srv/manage.py migrate --no-input +python /srv/manage.py import_categories +python /srv/manage.py import_pages + +# Execute arguments +echo >&2 $0: Continuing with "$@"... +exec "$@" @@ -0,0 +1,122 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.onap.oparent</groupId> + <artifactId>oparent</artifactId> + <version>1.0.0-SNAPSHOT</version> + </parent> + + <groupId>org.openecomp.vvp</groupId> + <artifactId>vvp-cms</artifactId> + <packaging>pom</packaging> + <version>1.0.0-SNAPSHOT</version> + <name>vvp-cms</name> + + <properties> + <!--nexus--> + <sitePath>/content/sites/site/org/openecomp/vvp/${project.artifactId}/${project.version}</sitePath> + <!--maven--> + <timestamp>${maven.build.timestamp}</timestamp> + <maven.build.timestamp.format>yyyy.MM.dd.HH.mm</maven.build.timestamp.format> + <!--docker--> + <docker.tag>${project.version}-${timestamp}</docker.tag> + <docker.latest.tag>${project.version}-latest</docker.latest.tag> + </properties> + + <build> + <plugins> + <plugin> + <groupId>org.sonatype.plugins</groupId> + <artifactId>nexus-staging-maven-plugin</artifactId> + <version>1.6.7</version> + <extensions>true</extensions> + <configuration> + <nexusUrl>${onap.nexus.url}</nexusUrl> + <stagingProfileId>176c31dfe190a</stagingProfileId> + <serverId>ecomp-staging</serverId> + </configuration> + </plugin> + <plugin> + <groupId>io.fabric8</groupId> + <artifactId>docker-maven-plugin</artifactId> + <version>0.19.1</version> + <configuration> + <verbose>true</verbose> + <apiVersion>1.23</apiVersion> + <registry>nexus3.onap.org:10003</registry> + <images> + <image> + <name>openecomp/vvp-cms</name> + <alias>vvp-cms</alias> + <build> + <cleanup>true</cleanup> + <tags> + <tag>${docker.tag}</tag> + <tag>${docker.latest.tag}</tag> + </tags> + <dockerFileDir>${project.basedir}</dockerFileDir> + </build> + </image> + </images> + </configuration> + <executions> + <execution> + <id>clean-images</id> + <phase>pre-clean</phase> + <goals> + <goal>remove</goal> + </goals> + <configuration> + <removeAll>true</removeAll> + </configuration> + </execution> + + <execution> + <id>generate-images</id> + <phase>package</phase> + <goals> + <goal>build</goal> + </goals> + </execution> + + <execution> + <id>push-images</id> + <phase>deploy</phase> + <goals> + <goal>build</goal> + <goal>push</goal> + </goals> + <configuration> + <image>openecomp/vvp-cms</image> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + <distributionManagement> + <site> + <id>ecomp-site</id> + <url>dav:${onap.nexus.url}${sitePath}</url> + </site> + </distributionManagement> + <repositories> + <repository> + <id>ecomp-releases</id> + <name>ECOMP Release Repository</name> + <url>${onap.nexus.url}/content/repositories/releases/</url> + </repository> + <repository> + <id>ecomp-snapshots</id> + <name>ECOMP Snapshot Repository</name> + <url>${onap.nexus.url}/content/repositories/snapshots/</url> + </repository> + <repository> + <id>ecomp-staging</id> + <name>ECOMP Staging Repository</name> + <url>${onap.nexus.url}/content/repositories/staging/</url> + </repository> + </repositories> +</project> + @@ -0,0 +1,19 @@ +[tox] +skipsdist=True +envlist = py27,py3,style +setupdir = cms/ + +[testenv] +distribute = False +commands = + {envpython} --version +deps = flake8 + +[testenv:style] +commands = flake8 + +[testenv:py27] +basepython=python2.7 + +[testenv:py3] +basepython=python3.6 |