diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 8fb83f9..0000000 --- a/.gitignore +++ /dev/null @@ -1,64 +0,0 @@ -# Fuel Plugins -fpb_venv -*.rpm -*.deb -built_plugins/ -.build/ -*.fp - -*.py[cod] - -# C extensions -*.so - -# Packages -*.egg* -*.egg-info -dist -build -eggs -parts -bin -var -sdist -develop-eggs -.installed.cfg -lib -lib64 - -# Installer logs -pip-log.txt - -# Unit test / coverage reports -cover/ -.coverage* -!.coveragerc -.tox -nosetests.xml -.testrepository -.venv - -# Translations -*.mo - -# Mr Developer -.mr.developer.cfg -.project -.pydevproject - -# Complexity -output/*.html -output/*/index.html - -# Sphinx -doc/build - -# pbr generates these -AUTHORS -ChangeLog - -# Editors -*~ -.*.swp -.*sw? -.idea diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index e980d4c..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,182 +0,0 @@ -# Changelog - -## 4.2.0 (2017-01-02) - -New package version "4.2.0" includes the following features: - -- Added new plugin version with node & nic attributes support - -Bugfixes: - -- Move Release.mako into v1 template dir - [LP1655289](https://bugs.launchpad.net/fuel/+bug/1655289) -- Make ubuntu repo similar for all plugin versions - [LP1650551](https://bugs.launchpad.net/fuel/+bug/1650551) -- Show team and repo badges on `README` -- Remove reboot task from plugin example version "3.0.0" - [LP1625244](https://bugs.launchpad.net/fuel/+bug/1625244) -- Files with no code must be left completely empty -- Legacy deployment tasks are turned back for plugin example version "3.0.0" - [LP1625244](https://bugs.launchpad.net/fuel/+bug/1625244) -- `tasks.yaml` was commented for plugin example version "3.0.0" - [LP1625244](https://bugs.launchpad.net/fuel/+bug/1625244) -- Allow unauthenticated packages in the deployment scripts - [LP1622506](https://bugs.launchpad.net/fuel/+bug/1622506) -- Allow arrays in 'value' in environment_config.yaml - [LP1616466](https://bugs.launchpad.net/fuel/+bug/1616466) -- Old `tasks.yaml` content is commented for plugins packages version "4.0.0" - [LP1619255](https://bugs.launchpad.net/fuel/+bug/1619255) -- Allow possibility to provide rpm `Release` version - [LP1616929](https://bugs.launchpad.net/fuel/+bug/1616929) -- Rename existing BaseValidator to LegacyBaseValidator - [LP1534126](https://bugs.launchpad.net/fuel/+bug/1534126) -- Fix a word spell error in `README.rst` -- Support multi versions of package in fuel plugin - [LP1599896](https://bugs.launchpad.net/fuel/+bug/1599896) - -## 4.1.0 (2016-06-29) - -Bugfixes: - -- `tasks.yaml` is now optional for package version "4.0.0" - [LP1552248](https://bugs.launchpad.net/fuel/+bug/1552248) -- Fuel Mitaka (9.0) is supported by default in package version "4.0.0" - [LP1549276](https://bugs.launchpad.net/fuel/+bug/1549276) -- Use more reliable way to check for `fpm` Ruby GEM - [LP1561069](https://bugs.launchpad.net/fuel/+bug/1561069) -- Add ability for role to conflict with all roles by using `*` sign - [LP1547590](https://bugs.launchpad.net/fuel/+bug/1547590) -- Do not execute `uninstall.sh` on plugin upgrade - [LP1564123](https://bugs.launchpad.net/fuel/+bug/1564123) -- Add possiblity to use generators in `environment_config.yaml` - [LP1557562](https://bugs.launchpad.net/fuel/+bug/1557562) -- Don't put any code to PREUN section if `uninstall.sh` doesn't exist or empty - [LP1574478](https://bugs.launchpad.net/fuel/+bug/1574478) -- Allow a user to specify any arbitrary string as role name for cross-deps - [LP1557997](https://bugs.launchpad.net/fuel/+bug/1557997) -- Add deployment tasks v2.1 validation support - [LP1590389](https://bugs.launchpad.net/fuel/+bug/1590389) - -## 4.0.0 (2016-02-26) - -New package version "4.0.0" includes the following features: - -- New flag `is_hotpluggable` in `metadata.yaml` that allows to install and use - plugin on previously deployed environments. -- Plugin can specify settings group using "group" field in metadata in - environment_config.yaml file. -- New group `equipment` added to groups list in `metadata.yaml`. -- New `components.yaml` file that allows to declare new components. - -Bugfixes: - -- Fix of missing strategy parameter in V3 and V4 deployment tasks - [LP1522785](https://bugs.launchpad.net/fuel/+bug/1522785) - -## 3.0.0 (2014-09-16) - -New package version "3.0.0" includes the following features: - -- New `node_roles.yaml` file that allows to add new node roles. -- New `volumes.yaml` file that allows to add new volumes and/or define - "node roles <-> volumes" mapping. -- New `deployment_tasks.yaml` file that allows to declare pre/post- and - regular deployment tasks for any node role. Unlike `tasks.yaml`, the - tasks go through global deployment graph and that provides ability - to execute task at any place during deployment, or overwrite/skip - already existing ones. -- New `network_roles.yaml` file that allows to add new network roles - and reserve some VIPs, to be proceed by plugin. - -Bugfixes: - -- Fix executing of `deploy.sh` deployment script - [LP1463441](https://bugs.launchpad.net/fuel/+bug/1463441) -- Remove "Origin" field from Ubuntu's `Release` file in order to reduce - probability of broken apt pinning - [LP1475665](https://bugs.launchpad.net/fuel/+bug/1475665) - -## 2.0.4 (2014-06-23) - -- Fix, remove plugin package from previous build - https://bugs.launchpad.net/fuel/+bug/1464143 - -## 2.0.3 (2014-06-08) - -- New "monitoring" group - https://bugs.launchpad.net/fuel/+bug/1458592 -- Fix, fail build, if there are invalid deb packages for ubuntu repository - https://bugs.launchpad.net/fuel/+bug/1447981 -- Fix dependency package name for newer CentOS - https://bugs.launchpad.net/fuel/+bug/1455882 - -## 2.0.2 (2014-05-15) - -- Reverted fix for https://bugs.launchpad.net/fuel/+bug/1447981 - because it caused creation of broken ubuntu repository - https://bugs.launchpad.net/fuel-plugins/+bug/1455130 - -## 2.0.1 (2014-05-08) - -- Fix, fail build, if there are invalid deb packages for ubuntu repository - https://bugs.launchpad.net/fuel/+bug/1447981 -- Fix validation for UI restrictions - https://bugs.launchpad.net/fuel/+bug/1448147 -- Fix packages duplication after plugin build - https://bugs.launchpad.net/fuel/+bug/1451751 -- Fix plugin name validation - https://bugs.launchpad.net/fuel/+bug/1439760 - -## 2.0.0 (2014-04-30) - -- New package version "2.0.0", which is generated by default -- For plugins with 2.0.0 package version, fpb builds rpm packages - instead of *.fp archives. It was required for plugins updates - https://github.com/stackforge/fuel-specs/blob/master/specs/6.1/plugins-security-fixes.rst -- New "reboot" task for 2.0.0 plugins, which can reboot the node - and wait until reboot process is finished, see more details in the specification - https://github.com/stackforge/fuel-specs/blob/master/specs/6.1/reboot-task-type-for-plugin-developers.rst -- New required field groups, now you can specify a list of groups - which your plugin implements, see more details in the specification - https://github.com/stackforge/fuel-specs/blob/master/specs/6.1/plugin-groups.rst -- New required field authors (for plugins with 2.0.0 package version) -- New required field licenses (for plugins with 2.0.0 package version) -- New required field homepage (for plugins with 2.0.0 package version) -- New parameter "--package-version", to generate the plugins in old - format (e.g. package version 1.0.0) -- Fixed, plugins with package version 2.0.0, generate Release file - for Ubuntu repositories - https://bugs.launchpad.net/fuel/+bug/1435892 -- New format of stages for plugins with package version 2.0.0, - added numerical postfixes - https://github.com/stackforge/fuel-specs/blob/master/specs/6.1/plugins-deployment-order.rst - -## 1.0.2 (2014-12-19) - -- Show correct message, if 'timeout' field is not specified for - task in tasks.yaml - https://bugs.launchpad.net/fuel/+bug/1396234 -- Print error messages to stderr instead of stdout -- Fixed validation for environment_config.yaml file, "attributes" - field is optional - https://bugs.launchpad.net/fuel/+bug/1396491 -- Improved validation for environment_config.yaml file, added - required fields for attributes -- Generate file with SHA1 checksums for each file in the plugin - https://bugs.launchpad.net/fuel/+bug/1403960 - -## 1.0.1 (2014-11-20) - -- Show instruction for CentOS if not all requirements are installed -- Fixed bug, deploy.sh doesn't have execution permission - https://bugs.launchpad.net/fuel/+bug/1392736 -- Fixed bug, don't fail validation if environment_config.yaml file has checkbox - https://bugs.launchpad.net/fuel/+bug/1392807 - -## 1.0.0 (2014-11-13) - -Initial public release - -- Plugin create -- Plugin build -- Plugin check diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst deleted file mode 100644 index 0e9946c..0000000 --- a/CONTRIBUTING.rst +++ /dev/null @@ -1,17 +0,0 @@ -If you would like to contribute to the development of OpenStack, you must -follow the steps in this page: - - http://docs.openstack.org/infra/manual/developers.html - -If you already have a good understanding of how the system works and your -OpenStack accounts are set up, you can skip to the development workflow -section of this documentation to learn how changes to OpenStack should be -submitted for review via the Gerrit tool: - - http://docs.openstack.org/infra/manual/developers.html#development-workflow - -Pull requests submitted through GitHub will be ignored. - -Bugs should be filed on Launchpad, not GitHub: - - https://bugs.launchpad.net/fuel diff --git a/HACKING.rst b/HACKING.rst deleted file mode 100644 index 2cc0996..0000000 --- a/HACKING.rst +++ /dev/null @@ -1,4 +0,0 @@ -Fuel Plugins Style Commandments -=============================== - -Read the OpenStack Style Commandments http://docs.openstack.org/developer/hacking/ diff --git a/LICENSE b/LICENSE deleted file mode 100644 index e06d208..0000000 --- a/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ -Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file 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. - diff --git a/MAINTAINERS b/MAINTAINERS deleted file mode 100644 index 56c9a27..0000000 --- a/MAINTAINERS +++ /dev/null @@ -1,37 +0,0 @@ ---- -description: - For Fuel team structure and contribution policy, see [1]. - - This is repository level MAINTAINERS file. All contributions to this - repository must be approved by one or more Core Reviewers [2]. - If you are contributing to files (or create new directories) in - root folder of this repository, please contact Core Reviewers for - review and merge requests. - - If you are contributing to subfolders of this repository, please - check 'maintainers' section of this file in order to find maintainers - for those specific modules. - - It is mandatory to get +1 from one or more maintainers before asking - Core Reviewers for review/merge in order to decrease a load on Core Reviewers [3]. - Exceptions are when maintainers are actually cores, or when maintainers - are not available for some reason (e.g. on vacation). - - [1] http://specs.fuel-infra.org/fuel-specs-master/policy/team-structure.html - [2] https://review.openstack.org/#/admin/groups/661,members - [3] http://lists.openstack.org/pipermail/openstack-dev/2015-August/072406.html - - Please keep this file in YAML format in order to allow helper scripts - to read this as a configuration data. - -maintainers: - -- ./: - - - name: Andrii Popovych - email: apopovych@mirantis.com - IRC: apopovych - - - name: Ilya Kutukov - email: ikutukov@mirantis.com - IRC: ikutukov diff --git a/README.rst b/README.rst index 72a0c83..86e34d6 100644 --- a/README.rst +++ b/README.rst @@ -1,98 +1,10 @@ -======================== -Team and repository tags -======================== +This project is no longer maintained. -.. image:: http://governance.openstack.org/badges/fuel-plugins.svg - :target: http://governance.openstack.org/reference/tags/index.html +The contents of this repository are still available in the Git +source code management system. To see the contents of this +repository before it reached its end of life, please check out the +previous commit with "git checkout HEAD^1". -.. Change things from this point on - -Fuel Plugins -============ - -Starting with version 6.0, Fuel supports a Pluggable architecture. - -Fuel plugins allow you to install and configure additional capabilities for -your cloud, such as additional storage types and networking functionality. -For example, a Load Balancing as a Service (LBaaS) plugin allows you to add -network load balancing functionality to your cloud so that incoming traffic -can be spread across multiple nodes. Or you might want to use a GlusterFS -plugin so that you can use a Gluster file system as backend for Cinder -volumes. - - -Finding Plugins ---------------- - -For production versions of plugins, including certified plugins, see -`Released Plugins Catalog`_. - -For instructions on installing Fuel plugins, see `Installing Plugins`_. - - -Finding documentation ---------------------- - -You can find Fuel Plugins documentation in the following sources: - -* Development issues - `Plugins Wiki`_ page. -* Common installation instructions - `Install Fuel Plugins`_ and - `CLI command reference`_ sections in the User Guide. -* Specific installation instructions - `Fuel Plugins Catalog`_. - - -OpenStack Fuel-plugins Repository ---------------------------------- - -This repository contains plugin example, and the Fuel plugin builder tool -(fpb). The plugin code here might not be suitable for production use please -see `Released Plugins Catalog`_ to download release versions of these and -other Fuel plugins. - - -Creating your own plugins -------------------------- - -Detailed instructions can be found in the `Plugins Wiki`_ page. - -Plugins should be built using the ``fuel-plugin-builder`` (fpb) utility -found in this repoistory or via ``pip``. ``fpb`` will ensure that build -steps as well as validation is performed prior to assembling a package. - -Abbreviated instructions: - -.. code:: bash - - pip install fuel-plugin-builder - fpb --create fuel_plugin_name - fpb --build - -This will: - -* install fuel-plugin-builder -* clone the fuel_plugin_example plugin with the name fuel_plugin_name -* build the plugin ``.rpm`` package. - -Examples -```````` - -Simple Fuel plugin examples you can find here: - -https://github.com/openstack/fuel-plugins/tree/master/examples - -Other Plugin repositories -````````````````````````` - -Other locations known to have Fuel plugins. *Note, these may not be supported -by the Fuel team* - -* `Community Plugins`_ - - -.. _Released Plugins Catalog: https://www.fuel-infra.org/plugins/catalog.html -.. _Installing Plugins: https://wiki.openstack.org/wiki/Fuel/Plugins#Installation_procedure -.. _Plugins Wiki: http://wiki.openstack.org/Fuel/Plugins -.. _Install Fuel Plugins: http://docs.mirantis.com/openstack/fuel/fuel-master/user-guide.html#install-fuel-plugins -.. _CLI command reference: http://docs.mirantis.com/openstack/fuel/fuel-master/user-guide.html#fuel-plugins-cli -.. _Fuel Plugins Catalog: https://software.mirantis.com/download-mirantis-openstack-fuel-plug-ins/ -.. _Community Plugins: https://github.com/openstack/?query=fuel-plugin +For any further questions, please email +openstack-discuss@lists.openstack.org or join #openstack-dev on +Freenode. diff --git a/examples/fuel_plugin_example_v1/LICENSE b/examples/fuel_plugin_example_v1/LICENSE deleted file mode 100644 index e06d208..0000000 --- a/examples/fuel_plugin_example_v1/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ -Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file 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. - diff --git a/examples/fuel_plugin_example_v1/README.md b/examples/fuel_plugin_example_v1/README.md deleted file mode 100644 index 4b058b6..0000000 --- a/examples/fuel_plugin_example_v1/README.md +++ /dev/null @@ -1,4 +0,0 @@ -fuel_plugin_example -============ - -Plugin description \ No newline at end of file diff --git a/examples/fuel_plugin_example_v1/deployment_scripts/deploy.sh b/examples/fuel_plugin_example_v1/deployment_scripts/deploy.sh deleted file mode 100755 index 601749f..0000000 --- a/examples/fuel_plugin_example_v1/deployment_scripts/deploy.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -set -eux - -# It's a script which deploys your plugin -echo fuel_plugin_example > /tmp/fuel_plugin_example - -OS_NAME='' -if grep -i CentOS /etc/issue.net >/dev/null; then - OS_NAME='centos'; -elif grep -i Ubuntu /etc/issue.net >/dev/null; then - OS_NAME='ubuntu'; -fi - -function install_package { - if [ $OS_NAME == 'ubuntu' ]; then - apt-get install -y --force-yes -o 'APT::Get::AllowUnauthenticated=1' fuel-simple-service - elif [ $OS_NAME == 'centos' ]; then - yum install -y fuel-simple-service - fi -} - -install_package -fuel-simple-service.py & diff --git a/examples/fuel_plugin_example_v1/environment_config.yaml b/examples/fuel_plugin_example_v1/environment_config.yaml deleted file mode 100644 index c22f37d..0000000 --- a/examples/fuel_plugin_example_v1/environment_config.yaml +++ /dev/null @@ -1,48 +0,0 @@ -attributes: - - fuel_plugin_example_text: - type: "text" - weight: 10 - value: "Default text" - label: "Text field label" - description: "Field description" - regex: - source: '\S' - error: "Error field cannot be empty" - - fuel_plugin_example_select: - type: "select" - weight: 20 - value: "value2" - label: "Select label" - description: "Select description" - values: - - data: "value1" - label: "Value 1 label" - - data: "value2" - label: "Value 2 label" - - data: "value3" - label: "Value 3 label" - - fuel_plugin_example_checkbox: - type: "checkbox" - weight: 30 - value: false - label: "Checkbox label" - description: "Checkbox description" - - fuel_plugin_example_radio: - type: "radio" - weight: 40 - value: "disabled" - label: "Radio buttons label" - values: - - data: "data1" - label: "Label data1" - description: "Description data1" - - data: "data2" - label: "Label data2" - description: "Description data2" - - data: "data3" - label: "Label data3" - description: "Description data3" diff --git a/examples/fuel_plugin_example_v1/fuel-simple-service.py b/examples/fuel_plugin_example_v1/fuel-simple-service.py deleted file mode 100755 index 247a2d6..0000000 --- a/examples/fuel_plugin_example_v1/fuel-simple-service.py +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env python -# -*- encoding: utf-8 -*- - -from wsgiref.simple_server import make_server - -def web_app(environ, start_response): - status = '200 OK' - headers = [('Content-type', 'text/plain')] - - start_response(status, headers) - - return open('/etc/astute.yaml').read() - - -def start_server(host, port): - httpd = make_server(host, port, web_app) - print 'Started server 8234' - httpd.serve_forever() - - -def main(): - start_server('', 8234) - - -if __name__ == '__main__': - main() diff --git a/examples/fuel_plugin_example_v1/metadata.yaml b/examples/fuel_plugin_example_v1/metadata.yaml deleted file mode 100644 index 2a320d6..0000000 --- a/examples/fuel_plugin_example_v1/metadata.yaml +++ /dev/null @@ -1,56 +0,0 @@ -# Plugin name -name: fuel_plugin_example -title: Fuel plugin example -# Plugin version -version: '1.0.0' -# Description -description: Plugin example which installs simple service on controllers -# Minimum required fuel version -fuel_version: ['6.0'] - -# The plugin is compatible with releases in the list -releases: - - os: ubuntu - version: 2014.2-6.0 - mode: ['ha', 'multinode'] - deployment_scripts_path: deployment_scripts/ - repository_path: repositories/ubuntu - - os: centos - version: 2014.2-6.0 - mode: ['ha', 'multinode'] - deployment_scripts_path: deployment_scripts/ - repository_path: repositories/centos - - os: ubuntu - version: 2014.2-6.1 - mode: ['ha'] - deployment_scripts_path: deployment_scripts/ - repository_path: repositories/ubuntu - - os: centos - version: 2014.2-6.1 - mode: ['ha'] - deployment_scripts_path: deployment_scripts/ - repository_path: repositories/centos - - os: ubuntu - version: 2015.1.0-7.0 - mode: ['ha'] - deployment_scripts_path: deployment_scripts/ - repository_path: repositories/ubuntu - - os: ubuntu - version: liberty-8.0 - mode: ['ha'] - deployment_scripts_path: deployment_scripts/ - repository_path: repositories/ubuntu - - os: ubuntu - version: mitaka-9.0 - mode: ['ha'] - deployment_scripts_path: deployment_scripts/ - repository_path: repositories/ubuntu - - os: ubuntu - version: newton-10.0 - mode: ['ha'] - deployment_scripts_path: deployment_scripts/ - repository_path: repositories/ubuntu - - -# Version of plugin package -package_version: '1.0.0' diff --git a/examples/fuel_plugin_example_v1/pre_build_hook b/examples/fuel_plugin_example_v1/pre_build_hook deleted file mode 100755 index c556d17..0000000 --- a/examples/fuel_plugin_example_v1/pre_build_hook +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -set -eux - -command -v fpm >/dev/null 2>&1 || { - echo >&2 "Install 'fpm' to build this plugin. Aborting."; exit 1; -} - -ruby -e "require 'fpm'" 2>&1 || { - echo >&2 "'Fpm' binary file is present, but gem seems to be broken! Aborting."; exit 1; -} - -ROOT=$(dirname `readlink -f $0`) - -UBUNTU_REPO_PATH=$ROOT/repositories/ubuntu -CENTOS_REPO_PATH=$ROOT/repositories/centos - -rm -f $UBUNTU_REPO_PATH/*.deb -rm -f $CENTOS_REPO_PATH/*.rpm - -fpm -t deb -p $UBUNTU_REPO_PATH -n fuel-simple-service -v 1.0.0 -s dir $ROOT/fuel-simple-service.py=/usr/bin/fuel-simple-service.py -fpm -t rpm -p $CENTOS_REPO_PATH -n fuel-simple-service -v 1.0.0 -s dir $ROOT/fuel-simple-service.py=/usr/bin/fuel-simple-service.py diff --git a/examples/fuel_plugin_example_v1/repositories/centos/.gitkeep b/examples/fuel_plugin_example_v1/repositories/centos/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/examples/fuel_plugin_example_v1/repositories/ubuntu/.gitkeep b/examples/fuel_plugin_example_v1/repositories/ubuntu/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/examples/fuel_plugin_example_v1/tasks.yaml b/examples/fuel_plugin_example_v1/tasks.yaml deleted file mode 100644 index a10551f..0000000 --- a/examples/fuel_plugin_example_v1/tasks.yaml +++ /dev/null @@ -1,14 +0,0 @@ -# This tasks will be applied on controller nodes -- role: ['controller'] - stage: post_deployment - type: shell - parameters: - cmd: bash deploy.sh - timeout: 42 -# Task is applied for all roles -- role: '*' - stage: pre_deployment - type: shell - parameters: - cmd: echo all > /tmp/plugin.all - timeout: 42 diff --git a/examples/fuel_plugin_example_v2/.gitignore b/examples/fuel_plugin_example_v2/.gitignore deleted file mode 100644 index daedd39..0000000 --- a/examples/fuel_plugin_example_v2/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -.tox -.build -*.pyc diff --git a/examples/fuel_plugin_example_v2/LICENSE b/examples/fuel_plugin_example_v2/LICENSE deleted file mode 100644 index e06d208..0000000 --- a/examples/fuel_plugin_example_v2/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ -Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file 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. - diff --git a/examples/fuel_plugin_example_v2/README.md b/examples/fuel_plugin_example_v2/README.md deleted file mode 100644 index 51d213c..0000000 --- a/examples/fuel_plugin_example_v2/README.md +++ /dev/null @@ -1,4 +0,0 @@ -fuel_plugin_example -=================== - -Plugin description \ No newline at end of file diff --git a/examples/fuel_plugin_example_v2/deployment_scripts/deploy.sh b/examples/fuel_plugin_example_v2/deployment_scripts/deploy.sh deleted file mode 100755 index 601749f..0000000 --- a/examples/fuel_plugin_example_v2/deployment_scripts/deploy.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -set -eux - -# It's a script which deploys your plugin -echo fuel_plugin_example > /tmp/fuel_plugin_example - -OS_NAME='' -if grep -i CentOS /etc/issue.net >/dev/null; then - OS_NAME='centos'; -elif grep -i Ubuntu /etc/issue.net >/dev/null; then - OS_NAME='ubuntu'; -fi - -function install_package { - if [ $OS_NAME == 'ubuntu' ]; then - apt-get install -y --force-yes -o 'APT::Get::AllowUnauthenticated=1' fuel-simple-service - elif [ $OS_NAME == 'centos' ]; then - yum install -y fuel-simple-service - fi -} - -install_package -fuel-simple-service.py & diff --git a/examples/fuel_plugin_example_v2/environment_config.yaml b/examples/fuel_plugin_example_v2/environment_config.yaml deleted file mode 100644 index 0857e0e..0000000 --- a/examples/fuel_plugin_example_v2/environment_config.yaml +++ /dev/null @@ -1,7 +0,0 @@ -attributes: - fuel_plugin_example: - value: 'Set default value' - label: 'Text field' - description: 'Description for text field' - weight: 25 - type: "text" diff --git a/examples/fuel_plugin_example_v2/fuel-simple-service.py b/examples/fuel_plugin_example_v2/fuel-simple-service.py deleted file mode 100755 index 247a2d6..0000000 --- a/examples/fuel_plugin_example_v2/fuel-simple-service.py +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env python -# -*- encoding: utf-8 -*- - -from wsgiref.simple_server import make_server - -def web_app(environ, start_response): - status = '200 OK' - headers = [('Content-type', 'text/plain')] - - start_response(status, headers) - - return open('/etc/astute.yaml').read() - - -def start_server(host, port): - httpd = make_server(host, port, web_app) - print 'Started server 8234' - httpd.serve_forever() - - -def main(): - start_server('', 8234) - - -if __name__ == '__main__': - main() diff --git a/examples/fuel_plugin_example_v2/metadata.yaml b/examples/fuel_plugin_example_v2/metadata.yaml deleted file mode 100644 index a184093..0000000 --- a/examples/fuel_plugin_example_v2/metadata.yaml +++ /dev/null @@ -1,54 +0,0 @@ -# Plugin name -name: fuel_plugin_example -# Human-readable name for your plugin -title: Title for fuel_plugin_example plugin -# Plugin version -version: '2.0.0' -# Description -description: Please describe your plugin here -# Minimum required fuel version -fuel_version: ['6.1'] -# Specify license of your plugin -licenses: ['Apache License Version 2.0'] -# Specify author or company name -authors: ['Specify author or company name'] -# A link to the plugin's page -homepage: 'https://github.com/stackforge/fuel-plugins' -groups: [] - -# The plugin is compatible with releases in the list -releases: - - os: ubuntu - version: 2014.2-6.1 - mode: ['ha', 'multinode'] - deployment_scripts_path: deployment_scripts/ - repository_path: repositories/ubuntu - - os: centos - version: 2014.2-6.1 - mode: ['ha', 'multinode'] - deployment_scripts_path: deployment_scripts/ - repository_path: repositories/centos - - os: ubuntu - version: 2015.1.0-7.0 - mode: ['ha'] - deployment_scripts_path: deployment_scripts/ - repository_path: repositories/ubuntu - - os: ubuntu - version: liberty-8.0 - mode: ['ha'] - deployment_scripts_path: deployment_scripts/ - repository_path: repositories/ubuntu - - os: ubuntu - version: mitaka-9.0 - mode: ['ha'] - deployment_scripts_path: deployment_scripts/ - repository_path: repositories/ubuntu - - os: ubuntu - version: newton-10.0 - mode: ['ha'] - deployment_scripts_path: deployment_scripts/ - repository_path: repositories/ubuntu - - -# Version of plugin package -package_version: '2.0.0' diff --git a/examples/fuel_plugin_example_v2/pre_build_hook b/examples/fuel_plugin_example_v2/pre_build_hook deleted file mode 100755 index 9787c03..0000000 --- a/examples/fuel_plugin_example_v2/pre_build_hook +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -set -eux - -command -v fpm >/dev/null 2>&1 || { - echo >&2 "Install 'fpm' to build this plugin. Aborting."; exit 1; -} - -ruby -e "require 'fpm'" 2>&1 || { - echo >&2 "'Fpm' binary file is present, but gem seems to be broken! Aborting."; exit 1; -} - -ROOT=$(dirname `readlink -f $0`) - -UBUNTU_REPO_PATH=$ROOT/repositories/ubuntu -CENTOS_REPO_PATH=$ROOT/repositories/centos - -rm -f $UBUNTU_REPO_PATH/*.deb -rm -f $CENTOS_REPO_PATH/*.rpm - -fpm -t deb -p $UBUNTU_REPO_PATH -n fuel-simple-service -v 2.0.0 -s dir $ROOT/fuel-simple-service.py=/usr/bin/fuel-simple-service.py -fpm -t rpm -p $CENTOS_REPO_PATH -n fuel-simple-service -v 2.0.0 -s dir $ROOT/fuel-simple-service.py=/usr/bin/fuel-simple-service.py diff --git a/examples/fuel_plugin_example_v2/repositories/centos/.gitkeep b/examples/fuel_plugin_example_v2/repositories/centos/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/examples/fuel_plugin_example_v2/repositories/ubuntu/.gitkeep b/examples/fuel_plugin_example_v2/repositories/ubuntu/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/examples/fuel_plugin_example_v2/tasks.yaml b/examples/fuel_plugin_example_v2/tasks.yaml deleted file mode 100644 index 3d9ef52..0000000 --- a/examples/fuel_plugin_example_v2/tasks.yaml +++ /dev/null @@ -1,20 +0,0 @@ -# This tasks will be applied on controller nodes -- role: ['primary-controller', 'controller'] - stage: post_deployment - type: shell - parameters: - cmd: bash deploy.sh - timeout: 42 -# Task is applied for all roles -- role: '*' - stage: pre_deployment - type: shell - parameters: - cmd: echo all > /tmp/plugin.all - timeout: 42 -# "reboot" task reboots the nodes and waits until they get back online -# - role: '*' -# stage: pre_deployment -# type: reboot -# parameters: -# timeout: 600 diff --git a/examples/fuel_plugin_example_v2_update/.gitignore b/examples/fuel_plugin_example_v2_update/.gitignore deleted file mode 100644 index daedd39..0000000 --- a/examples/fuel_plugin_example_v2_update/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -.tox -.build -*.pyc diff --git a/examples/fuel_plugin_example_v2_update/LICENSE b/examples/fuel_plugin_example_v2_update/LICENSE deleted file mode 100644 index e06d208..0000000 --- a/examples/fuel_plugin_example_v2_update/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ -Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file 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. - diff --git a/examples/fuel_plugin_example_v2_update/README.md b/examples/fuel_plugin_example_v2_update/README.md deleted file mode 100644 index 51d213c..0000000 --- a/examples/fuel_plugin_example_v2_update/README.md +++ /dev/null @@ -1,4 +0,0 @@ -fuel_plugin_example -=================== - -Plugin description \ No newline at end of file diff --git a/examples/fuel_plugin_example_v2_update/deployment_scripts/deploy.sh b/examples/fuel_plugin_example_v2_update/deployment_scripts/deploy.sh deleted file mode 100755 index 601749f..0000000 --- a/examples/fuel_plugin_example_v2_update/deployment_scripts/deploy.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -set -eux - -# It's a script which deploys your plugin -echo fuel_plugin_example > /tmp/fuel_plugin_example - -OS_NAME='' -if grep -i CentOS /etc/issue.net >/dev/null; then - OS_NAME='centos'; -elif grep -i Ubuntu /etc/issue.net >/dev/null; then - OS_NAME='ubuntu'; -fi - -function install_package { - if [ $OS_NAME == 'ubuntu' ]; then - apt-get install -y --force-yes -o 'APT::Get::AllowUnauthenticated=1' fuel-simple-service - elif [ $OS_NAME == 'centos' ]; then - yum install -y fuel-simple-service - fi -} - -install_package -fuel-simple-service.py & diff --git a/examples/fuel_plugin_example_v2_update/environment_config.yaml b/examples/fuel_plugin_example_v2_update/environment_config.yaml deleted file mode 100644 index 0857e0e..0000000 --- a/examples/fuel_plugin_example_v2_update/environment_config.yaml +++ /dev/null @@ -1,7 +0,0 @@ -attributes: - fuel_plugin_example: - value: 'Set default value' - label: 'Text field' - description: 'Description for text field' - weight: 25 - type: "text" diff --git a/examples/fuel_plugin_example_v2_update/fuel-simple-service.py b/examples/fuel_plugin_example_v2_update/fuel-simple-service.py deleted file mode 100755 index 247a2d6..0000000 --- a/examples/fuel_plugin_example_v2_update/fuel-simple-service.py +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env python -# -*- encoding: utf-8 -*- - -from wsgiref.simple_server import make_server - -def web_app(environ, start_response): - status = '200 OK' - headers = [('Content-type', 'text/plain')] - - start_response(status, headers) - - return open('/etc/astute.yaml').read() - - -def start_server(host, port): - httpd = make_server(host, port, web_app) - print 'Started server 8234' - httpd.serve_forever() - - -def main(): - start_server('', 8234) - - -if __name__ == '__main__': - main() diff --git a/examples/fuel_plugin_example_v2_update/metadata.yaml b/examples/fuel_plugin_example_v2_update/metadata.yaml deleted file mode 100644 index a5d2424..0000000 --- a/examples/fuel_plugin_example_v2_update/metadata.yaml +++ /dev/null @@ -1,54 +0,0 @@ -# Plugin name -name: fuel_plugin_example -# Human-readable name for your plugin -title: Title for fuel_plugin_example plugin -# Plugin version -version: '2.0.2' -# Description -description: Please describe your plugin here -# Minimum required fuel version -fuel_version: ['6.1'] -# Specify license of your plugin -licenses: ['Apache License Version 2.0'] -# Specify author or company name -authors: ['Specify author or company name'] -# A link to the plugin's page -homepage: 'https://github.com/stackforge/fuel-plugins' -groups: [] - -# The plugin is compatible with releases in the list -releases: - - os: ubuntu - version: 2014.2-6.1 - mode: ['ha', 'multinode'] - deployment_scripts_path: deployment_scripts/ - repository_path: repositories/ubuntu - - os: centos - version: 2014.2-6.1 - mode: ['ha', 'multinode'] - deployment_scripts_path: deployment_scripts/ - repository_path: repositories/centos - - os: ubuntu - version: 2015.1.0-7.0 - mode: ['ha'] - deployment_scripts_path: deployment_scripts/ - repository_path: repositories/ubuntu - - os: ubuntu - version: liberty-8.0 - mode: ['ha'] - deployment_scripts_path: deployment_scripts/ - repository_path: repositories/ubuntu - - os: ubuntu - version: mitaka-9.0 - mode: ['ha'] - deployment_scripts_path: deployment_scripts/ - repository_path: repositories/ubuntu - - os: ubuntu - version: newton-10.0 - mode: ['ha'] - deployment_scripts_path: deployment_scripts/ - repository_path: repositories/ubuntu - - -# Version of plugin package -package_version: '2.0.0' diff --git a/examples/fuel_plugin_example_v2_update/pre_build_hook b/examples/fuel_plugin_example_v2_update/pre_build_hook deleted file mode 100755 index 381a309..0000000 --- a/examples/fuel_plugin_example_v2_update/pre_build_hook +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -set -eux - -command -v fpm >/dev/null 2>&1 || { - echo >&2 "Install 'fpm' to build this plugin. Aborting."; exit 1; -} - -ruby -e "require 'fpm'" 2>&1 || { - echo >&2 "'Fpm' binary file is present, but gem seems to be broken! Aborting."; exit 1; -} - -ROOT=$(dirname `readlink -f $0`) - -UBUNTU_REPO_PATH=$ROOT/repositories/ubuntu -CENTOS_REPO_PATH=$ROOT/repositories/centos - -rm -f $UBUNTU_REPO_PATH/*.deb -rm -f $CENTOS_REPO_PATH/*.rpm - -fpm -t deb -p $UBUNTU_REPO_PATH -n fuel-simple-service -v 2.0.2 -s dir $ROOT/fuel-simple-service.py=/usr/bin/fuel-simple-service.py -fpm -t rpm -p $CENTOS_REPO_PATH -n fuel-simple-service -v 2.0.2 -s dir $ROOT/fuel-simple-service.py=/usr/bin/fuel-simple-service.py diff --git a/examples/fuel_plugin_example_v2_update/repositories/centos/.gitkeep b/examples/fuel_plugin_example_v2_update/repositories/centos/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/examples/fuel_plugin_example_v2_update/repositories/ubuntu/.gitkeep b/examples/fuel_plugin_example_v2_update/repositories/ubuntu/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/examples/fuel_plugin_example_v2_update/tasks.yaml b/examples/fuel_plugin_example_v2_update/tasks.yaml deleted file mode 100644 index 109163f..0000000 --- a/examples/fuel_plugin_example_v2_update/tasks.yaml +++ /dev/null @@ -1,34 +0,0 @@ -# This tasks will be applied on controller nodes -- role: ['primary-controller', 'controller'] - stage: post_deployment - type: shell - parameters: - cmd: bash deploy.sh - timeout: 42 - -- role: '*' - stage: pre_deployment/100 - type: shell - parameters: - cmd: echo all > /tmp/plugin+100.all - timeout: 42 - -- role: '*' - stage: pre_deployment/+101.0 - type: shell - parameters: - cmd: echo all > /tmp/plugin+100.0.all - timeout: 42 - -- role: '*' - stage: pre_deployment/-100 - type: shell - parameters: - cmd: echo all > /tmp/plugin-100.all - timeout: 42 - -- role: '*' - stage: pre_deployment - type: reboot - parameters: - timeout: 600 diff --git a/examples/fuel_plugin_example_v3/.gitignore b/examples/fuel_plugin_example_v3/.gitignore deleted file mode 100644 index daedd39..0000000 --- a/examples/fuel_plugin_example_v3/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -.tox -.build -*.pyc diff --git a/examples/fuel_plugin_example_v3/LICENSE b/examples/fuel_plugin_example_v3/LICENSE deleted file mode 100644 index e06d208..0000000 --- a/examples/fuel_plugin_example_v3/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ -Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file 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. - diff --git a/examples/fuel_plugin_example_v3/README.md b/examples/fuel_plugin_example_v3/README.md deleted file mode 100644 index 9e74a21..0000000 --- a/examples/fuel_plugin_example_v3/README.md +++ /dev/null @@ -1,4 +0,0 @@ -fuel_plugin_example_v3 -============ - -Plugin description \ No newline at end of file diff --git a/examples/fuel_plugin_example_v3/deployment_scripts/deploy.pp b/examples/fuel_plugin_example_v3/deployment_scripts/deploy.pp deleted file mode 100644 index 1cae283..0000000 --- a/examples/fuel_plugin_example_v3/deployment_scripts/deploy.pp +++ /dev/null @@ -1,12 +0,0 @@ -notice('PLUGIN: fuel_plugin_example_v3 - deploy.pp') - -class fuel_plugin_example_v3 { - file { '/tmp/fuel_plugin_example_v3_puppet': - owner => 'root', - group => 'root', - mode => 0644, - content => "fuel_plugin_example_v3\n", - } -} - -class {'fuel_plugin_example_v3': } diff --git a/examples/fuel_plugin_example_v3/deployment_scripts/deploy.sh b/examples/fuel_plugin_example_v3/deployment_scripts/deploy.sh deleted file mode 100755 index 7f22244..0000000 --- a/examples/fuel_plugin_example_v3/deployment_scripts/deploy.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -set -eux - -# It's a script which deploys your plugin -echo fuel_plugin_example_v3 > /tmp/fuel_plugin_example_v3_sh - -OS_NAME='' -if grep -i CentOS /etc/issue.net >/dev/null; then - OS_NAME='centos'; -elif grep -i Ubuntu /etc/issue.net >/dev/null; then - OS_NAME='ubuntu'; -fi - -function install_package { - if [ $OS_NAME == 'ubuntu' ]; then - apt-get install -y --force-yes -o 'APT::Get::AllowUnauthenticated=1' fuel-simple-service - elif [ $OS_NAME == 'centos' ]; then - yum install -y fuel-simple-service - fi -} - -install_package -fuel-simple-service.py & diff --git a/examples/fuel_plugin_example_v3/deployment_tasks.yaml b/examples/fuel_plugin_example_v3/deployment_tasks.yaml deleted file mode 100644 index bcbb2e2..0000000 --- a/examples/fuel_plugin_example_v3/deployment_tasks.yaml +++ /dev/null @@ -1,86 +0,0 @@ -- id: fuel_plugin_example_v3 - type: group - role: [fuel_plugin_example_v3] - tasks: - - hiera - - globals - required_for: [deploy_end] - requires: [deploy_start] - parameters: - strategy: - type: parallel - -- id: fuel_plugin_example_v3-controller-deployment - type: puppet - groups: [primary-controller, controller] - required_for: [connectivity_tests, deploy_end] - requires: [netconfig, deploy_start] - parameters: - puppet_manifest: "deploy.pp" - puppet_modules: "." - timeout: 3600 - -- id: fuel_plugin_example_v3-deployment - type: puppet - groups: [fuel_plugin_example_v3] - required_for: [deploy_end] - requires: [deploy_start] - parameters: - puppet_manifest: "deploy.pp" - puppet_modules: "." - timeout: 3600 - retries: 10 - -- id: fuel_plugin_example_v3-post-deployment-sh - type: shell - role: [fuel_plugin_example_v3] - required_for: [post_deployment_end] - requires: [post_deployment_start] - parameters: - cmd: bash deploy.sh - retries: 3 - interval: 20 - timeout: 180 - -# This legacy tasks will be applied on controller nodes -- id: fuel_plugin_example_v3-legacy-1 - role: ['primary-controller', 'controller'] - stage: post_deployment - type: shell - parameters: - cmd: bash deploy.sh - timeout: 42 - -- id: fuel_plugin_example_v3-legacy-2 - role: '*' - stage: pre_deployment/100 - type: shell - parameters: - cmd: echo all > /tmp/plugin+100.all - timeout: 42 - -- id: fuel_plugin_example_v3-legacy-3 - role: '*' - stage: pre_deployment/+101.0 - type: shell - parameters: - cmd: echo all > /tmp/plugin+100.0.all - timeout: 42 - -- id: fuel_plugin_example_v3-legacy-4 - role: '*' - stage: pre_deployment/-100 - type: shell - parameters: - cmd: echo all > /tmp/plugin-100.all - timeout: 42 - -- id: fuel_plugin_example_v3-legacy-5 - role: [compute] - stage: pre_deployment/-101 - type: puppet - parameters: - puppet_manifest: "deploy.pp" - puppet_modules: "." - timeout: 3600 - retries: 2 diff --git a/examples/fuel_plugin_example_v3/environment_config.yaml b/examples/fuel_plugin_example_v3/environment_config.yaml deleted file mode 100644 index 9c19dc8..0000000 --- a/examples/fuel_plugin_example_v3/environment_config.yaml +++ /dev/null @@ -1,7 +0,0 @@ -attributes: - fuel_plugin_example_v3_text: - value: 'Set default value' - label: 'Text field' - description: 'Description for text field' - weight: 25 - type: "text" diff --git a/examples/fuel_plugin_example_v3/fuel-simple-service.py b/examples/fuel_plugin_example_v3/fuel-simple-service.py deleted file mode 100755 index 247a2d6..0000000 --- a/examples/fuel_plugin_example_v3/fuel-simple-service.py +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env python -# -*- encoding: utf-8 -*- - -from wsgiref.simple_server import make_server - -def web_app(environ, start_response): - status = '200 OK' - headers = [('Content-type', 'text/plain')] - - start_response(status, headers) - - return open('/etc/astute.yaml').read() - - -def start_server(host, port): - httpd = make_server(host, port, web_app) - print 'Started server 8234' - httpd.serve_forever() - - -def main(): - start_server('', 8234) - - -if __name__ == '__main__': - main() diff --git a/examples/fuel_plugin_example_v3/metadata.yaml b/examples/fuel_plugin_example_v3/metadata.yaml deleted file mode 100644 index 8ff9ad3..0000000 --- a/examples/fuel_plugin_example_v3/metadata.yaml +++ /dev/null @@ -1,46 +0,0 @@ -# Plugin name -name: fuel_plugin_example_v3 -# Human-readable name for your plugin -title: Title for fuel_plugin_example_v3 plugin -# Plugin version -version: '3.0.0' -# Description -description: Please describe your plugin here -# Minimum required fuel version -fuel_version: ['7.0'] -# Specify license of your plugin -licenses: ['Apache License Version 2.0'] -# Specify author or company name -authors: ['Specify author or company name'] -# A link to the plugin's page -homepage: 'https://github.com/stackforge/fuel-plugins' -# Specify a group which your plugin implements, possible options: -# network, storage, storage::cinder, storage::glance, hypervisor -groups: [] - -# The plugin is compatible with releases in the list -releases: - - os: ubuntu - version: 2015.1.0-7.0 - mode: ['ha'] - deployment_scripts_path: deployment_scripts/ - repository_path: repositories/ubuntu - - os: ubuntu - version: liberty-8.0 - mode: ['ha'] - deployment_scripts_path: deployment_scripts/ - repository_path: repositories/ubuntu - - os: ubuntu - version: mitaka-9.0 - mode: ['ha'] - deployment_scripts_path: deployment_scripts/ - repository_path: repositories/ubuntu - - os: ubuntu - version: newton-10.0 - mode: ['ha'] - deployment_scripts_path: deployment_scripts/ - repository_path: repositories/ubuntu - - -# Version of plugin package -package_version: '3.0.0' diff --git a/examples/fuel_plugin_example_v3/network_roles.yaml b/examples/fuel_plugin_example_v3/network_roles.yaml deleted file mode 100644 index 3d27965..0000000 --- a/examples/fuel_plugin_example_v3/network_roles.yaml +++ /dev/null @@ -1,21 +0,0 @@ -# Unique network role name -- id: "fuel_plugin_example_v3" - # Role mapping to network - default_mapping: "public" - properties: - # Should be true if network role requires subnet being set - subnet: true - # Should be true if network role requires gateway being set - gateway: false - # List of VIPs to be allocated - vip: - # Unique VIP name - - name: "vip_name" - # Optional linux namespace for VIP - namespace: "haproxy" - # Optional alias so VIP can be queried via API - alias: "vip_name" - # Optional node role list to map VIP to (defaults to - # primary-controller and controller) - node_roles: - - "fuel_plugin_example_v3" diff --git a/examples/fuel_plugin_example_v3/node_roles.yaml b/examples/fuel_plugin_example_v3/node_roles.yaml deleted file mode 100644 index dc425f4..0000000 --- a/examples/fuel_plugin_example_v3/node_roles.yaml +++ /dev/null @@ -1,6 +0,0 @@ -fuel_plugin_example_v3: - name: "Set here the name for the role. This name will be displayed in the Fuel web UI." - description: "Write description for your role" - has_primary: false # whether has primary role or not - public_ip_required: false # whether requires public net or not - weight: 100 # weight that will be used for ordering on fuel ui diff --git a/examples/fuel_plugin_example_v3/pre_build_hook b/examples/fuel_plugin_example_v3/pre_build_hook deleted file mode 100755 index 93df91b..0000000 --- a/examples/fuel_plugin_example_v3/pre_build_hook +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -set -eux - -command -v fpm >/dev/null 2>&1 || { - echo >&2 "Install 'fpm' to build this plugin. Aborting."; exit 1; -} - -ruby -e "require 'fpm'" 2>&1 || { - echo >&2 "'Fpm' binary file is present, but gem seems to be broken! Aborting."; exit 1; -} - -ROOT=$(dirname `readlink -f $0`) - -UBUNTU_REPO_PATH=$ROOT/repositories/ubuntu -CENTOS_REPO_PATH=$ROOT/repositories/centos - -rm -f $UBUNTU_REPO_PATH/*.deb -rm -f $CENTOS_REPO_PATH/*.rpm - -fpm -t deb -p $UBUNTU_REPO_PATH -n fuel-simple-service -v 3.0.0 -s dir $ROOT/fuel-simple-service.py=/usr/bin/fuel-simple-service.py -fpm -t rpm -p $CENTOS_REPO_PATH -n fuel-simple-service -v 3.0.0 -s dir $ROOT/fuel-simple-service.py=/usr/bin/fuel-simple-service.py diff --git a/examples/fuel_plugin_example_v3/repositories/centos/.gitkeep b/examples/fuel_plugin_example_v3/repositories/centos/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/examples/fuel_plugin_example_v3/repositories/ubuntu/.gitkeep b/examples/fuel_plugin_example_v3/repositories/ubuntu/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/examples/fuel_plugin_example_v3/tasks.yaml b/examples/fuel_plugin_example_v3/tasks.yaml deleted file mode 100644 index d110cb3..0000000 --- a/examples/fuel_plugin_example_v3/tasks.yaml +++ /dev/null @@ -1,7 +0,0 @@ -# WARNING: `tasks.yaml` will be deprecated in further releases. -# Please, use `deployment_tasks.yaml` to describe tasks instead. - -# This file is left only as an example of what you could -# meet during plugins development and support. - -[] \ No newline at end of file diff --git a/examples/fuel_plugin_example_v3/volumes.yaml b/examples/fuel_plugin_example_v3/volumes.yaml deleted file mode 100644 index 650464e..0000000 --- a/examples/fuel_plugin_example_v3/volumes.yaml +++ /dev/null @@ -1,6 +0,0 @@ -# Set here new volumes for your role -volumes: [] -volumes_roles_mapping: - fuel_plugin_example_v3: - # Default role mapping - - {allocate_size: "min", id: "os"} diff --git a/examples/fuel_plugin_example_v4/LICENSE b/examples/fuel_plugin_example_v4/LICENSE deleted file mode 100644 index e06d208..0000000 --- a/examples/fuel_plugin_example_v4/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ -Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file 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. - diff --git a/examples/fuel_plugin_example_v4/README.md b/examples/fuel_plugin_example_v4/README.md deleted file mode 100644 index 3d0e9c9..0000000 --- a/examples/fuel_plugin_example_v4/README.md +++ /dev/null @@ -1,4 +0,0 @@ -fuel_plugin_example_v4 -====================== - -Plugin description diff --git a/examples/fuel_plugin_example_v4/components.yaml b/examples/fuel_plugin_example_v4/components.yaml deleted file mode 100644 index a3c4ea7..0000000 --- a/examples/fuel_plugin_example_v4/components.yaml +++ /dev/null @@ -1,17 +0,0 @@ -# This file contains wizard components descriptions that are pretty similar to -# the `environment_config.yaml`. -# Please, take a look at following link for the details: -# - https://blueprints.launchpad.net/fuel/+spec/component-registry -# - https://specs.openstack.org/openstack/fuel-specs/specs/8.0/component-registry.html - -- name: additional_service:service_plugin_v4_component - label: "Title for service_plugin_v4_component component." - description: "Description for service_plugin_v4_component component." - compatible: - - name: "hypervisor:xxx" - requires: - - name: "hypervisor:xxx" - message: "service_plugin_v4_component requires XXX compute." - incompatible: - - name: "network:neutron:*" - message: "service_plugin_v4_component incompatible with Neutron network." \ No newline at end of file diff --git a/examples/fuel_plugin_example_v4/deployment_scripts/deploy.pp b/examples/fuel_plugin_example_v4/deployment_scripts/deploy.pp deleted file mode 100644 index 1c162a9..0000000 --- a/examples/fuel_plugin_example_v4/deployment_scripts/deploy.pp +++ /dev/null @@ -1,14 +0,0 @@ -# This puppet manifest creates example file in /tmp folder. - -notice('PLUGIN: fuel_plugin_example_v4 - deploy.pp') - -class fuel_plugin_example_v4 { - file { '/tmp/fuel_plugin_example_v4_puppet': - owner => 'root', - group => 'root', - mode => 0644, - content => "fuel_plugin_example_v4\n", - } -} - -class {'fuel_plugin_example_v4': } diff --git a/examples/fuel_plugin_example_v4/deployment_scripts/deploy.sh b/examples/fuel_plugin_example_v4/deployment_scripts/deploy.sh deleted file mode 100755 index cdd2614..0000000 --- a/examples/fuel_plugin_example_v4/deployment_scripts/deploy.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -set -eux - -# It's a script which deploys your plugin -echo fuel_plugin_example_v4 > /tmp/fuel_plugin_example_v4_sh - -OS_NAME='' -if grep -i CentOS /etc/issue.net >/dev/null; then - OS_NAME='centos'; -elif grep -i Ubuntu /etc/issue.net >/dev/null; then - OS_NAME='ubuntu'; -fi - -function install_package { - if [ $OS_NAME == 'ubuntu' ]; then - apt-get install -y --force-yes -o 'APT::Get::AllowUnauthenticated=1' fuel-simple-service - elif [ $OS_NAME == 'centos' ]; then - yum install -y fuel-simple-service - fi -} - -install_package -fuel-simple-service.py & diff --git a/examples/fuel_plugin_example_v4/deployment_tasks.yaml b/examples/fuel_plugin_example_v4/deployment_tasks.yaml deleted file mode 100644 index 5bc085c..0000000 --- a/examples/fuel_plugin_example_v4/deployment_tasks.yaml +++ /dev/null @@ -1,46 +0,0 @@ -- id: fuel_plugin_example_v4 - type: group - role: [fuel_plugin_example_v4] - tasks: - - hiera - - globals - required_for: [deploy_end] - requires: [deploy_start] - parameters: - strategy: - type: parallel - -- id: fuel_plugin_example_v4-controller-deployment - type: puppet - version: 2.0.0 - groups: [primary-controller, controller] - required_for: [connectivity_tests, deploy_end] - requires: [netconfig, deploy_start] - parameters: - puppet_manifest: "deploy.pp" - puppet_modules: "." - timeout: 3600 - -- id: fuel_plugin_example_v4-deployment - type: puppet - version: 2.0.0 - groups: [fuel_plugin_example_v4] - required_for: [deploy_end] - requires: [deploy_start] - parameters: - puppet_manifest: "deploy.pp" - puppet_modules: "." - timeout: 3600 - retries: 10 - -- id: fuel_plugin_example_v4-post-deployment-sh - type: shell - version: 2.0.0 - role: [fuel_plugin_example_v4] - required_for: [post_deployment_end] - requires: [post_deployment_start] - parameters: - cmd: bash deploy.sh - retries: 3 - interval: 20 - timeout: 180 diff --git a/examples/fuel_plugin_example_v4/environment_config.yaml b/examples/fuel_plugin_example_v4/environment_config.yaml deleted file mode 100644 index fab282f..0000000 --- a/examples/fuel_plugin_example_v4/environment_config.yaml +++ /dev/null @@ -1,15 +0,0 @@ -# This file describes additional attributes that will appear on the Settings -# tab of the Fuel web UI. When the environment is deployed, these attributes -# are passed to the task executor so that the data is available -# in the /etc/astute.yaml file on each target node and can be accessed from -# your bash or puppet scripts. - -attributes: - metadata: - group: 'other' - fuel_plugin_example_v4_text: - value: 'Set default value' - label: 'Text field' - description: 'Description for text field' - weight: 25 - type: "text" diff --git a/examples/fuel_plugin_example_v4/fuel-simple-service.py b/examples/fuel_plugin_example_v4/fuel-simple-service.py deleted file mode 100755 index 247a2d6..0000000 --- a/examples/fuel_plugin_example_v4/fuel-simple-service.py +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env python -# -*- encoding: utf-8 -*- - -from wsgiref.simple_server import make_server - -def web_app(environ, start_response): - status = '200 OK' - headers = [('Content-type', 'text/plain')] - - start_response(status, headers) - - return open('/etc/astute.yaml').read() - - -def start_server(host, port): - httpd = make_server(host, port, web_app) - print 'Started server 8234' - httpd.serve_forever() - - -def main(): - start_server('', 8234) - - -if __name__ == '__main__': - main() diff --git a/examples/fuel_plugin_example_v4/metadata.yaml b/examples/fuel_plugin_example_v4/metadata.yaml deleted file mode 100644 index 0cb32e2..0000000 --- a/examples/fuel_plugin_example_v4/metadata.yaml +++ /dev/null @@ -1,45 +0,0 @@ -# Plugin name -name: fuel_plugin_example_v4 -# Human-readable name for your plugin -title: Title for fuel_plugin_example_v4 plugin -# Plugin version -version: '4.0.0' -# Description -description: Please describe your plugin here -# Minimum required fuel version -fuel_version: ['8.0'] -# Specify license of your plugin -licenses: ['Apache License Version 2.0'] -# Specify author or company name -authors: ['Specify author or company name'] -# A link to the plugin's page -homepage: 'https://github.com/openstack/fuel-plugins' -# Specify a group which your plugin implements, possible options: -# network, storage, storage::cinder, storage::glance, hypervisor, -# equipment -groups: [] -# Change `false` to `true` if the plugin can be installed in the environment -# after the deployment. -is_hotpluggable: false - -# The plugin is compatible with releases in the list -releases: - - os: ubuntu - version: liberty-8.0 - mode: ['ha'] - deployment_scripts_path: deployment_scripts/ - repository_path: repositories/ubuntu - - os: ubuntu - version: mitaka-9.0 - mode: ['ha'] - deployment_scripts_path: deployment_scripts/ - repository_path: repositories/ubuntu - - os: ubuntu - version: newton-10.0 - mode: ['ha'] - deployment_scripts_path: deployment_scripts/ - repository_path: repositories/ubuntu - - -# Version of plugin package -package_version: '4.0.0' diff --git a/examples/fuel_plugin_example_v4/network_roles.yaml b/examples/fuel_plugin_example_v4/network_roles.yaml deleted file mode 100644 index 021b65f..0000000 --- a/examples/fuel_plugin_example_v4/network_roles.yaml +++ /dev/null @@ -1,24 +0,0 @@ -# `network_roles.yaml` file is used to declare VIP addresses and link -# them with networks and nodes. - -# Unique network role name -- id: "fuel_plugin_example_v4_network_role" - # Role mapping to network - default_mapping: "public" - properties: - # Should be true if network role requires subnet being set - subnet: true - # Should be true if network role requires gateway being set - gateway: false - # List of VIPs to be allocated - vip: - # Unique VIP name - - name: "vip_name" - # Optional linux namespace for VIP - namespace: "haproxy" - # Optional alias so VIP can be queried via API - alias: "vip_name" - # Optional node role list to map VIP to (defaults to - # primary-controller and controller) - node_roles: - - "fuel_plugin_example_v4_role" diff --git a/examples/fuel_plugin_example_v4/node_roles.yaml b/examples/fuel_plugin_example_v4/node_roles.yaml deleted file mode 100644 index 607fccd..0000000 --- a/examples/fuel_plugin_example_v4/node_roles.yaml +++ /dev/null @@ -1,6 +0,0 @@ -fuel_plugin_example_v4: - name: "Set here the name for the role. This name will be displayed in the Fuel web UI." - description: "Write description for your role" - has_primary: false # whether has primary role or not - public_ip_required: false # whether requires public net or not - weight: 100 # weight that will be used for ordering on fuel ui diff --git a/examples/fuel_plugin_example_v4/pre_build_hook b/examples/fuel_plugin_example_v4/pre_build_hook deleted file mode 100755 index 519416c..0000000 --- a/examples/fuel_plugin_example_v4/pre_build_hook +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -set -eux - -command -v fpm >/dev/null 2>&1 || { - echo >&2 "Install 'fpm' to build this plugin. Aborting."; exit 1; -} - -ruby -e "require 'fpm'" 2>&1 || { - echo >&2 "'Fpm' binary file is present, but gem seems to be broken! Aborting."; exit 1; -} - -ROOT=$(dirname `readlink -f $0`) - -UBUNTU_REPO_PATH=$ROOT/repositories/ubuntu -CENTOS_REPO_PATH=$ROOT/repositories/centos - -rm -f $UBUNTU_REPO_PATH/*.deb -rm -f $CENTOS_REPO_PATH/*.rpm - -fpm -t deb -p $UBUNTU_REPO_PATH -n fuel-simple-service -v 4.0.0 -s dir $ROOT/fuel-simple-service.py=/usr/bin/fuel-simple-service.py -fpm -t rpm -p $CENTOS_REPO_PATH -n fuel-simple-service -v 4.0.0 -s dir $ROOT/fuel-simple-service.py=/usr/bin/fuel-simple-service.py diff --git a/examples/fuel_plugin_example_v4/repositories/centos/.gitkeep b/examples/fuel_plugin_example_v4/repositories/centos/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/examples/fuel_plugin_example_v4/repositories/ubuntu/.gitkeep b/examples/fuel_plugin_example_v4/repositories/ubuntu/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/examples/fuel_plugin_example_v4/tasks.yaml b/examples/fuel_plugin_example_v4/tasks.yaml deleted file mode 100644 index a29a79b..0000000 --- a/examples/fuel_plugin_example_v4/tasks.yaml +++ /dev/null @@ -1,5 +0,0 @@ -# WARNING: `tasks.yaml` will be deprecated in further releases. -# Please, use `deployment_tasks.yaml` to describe tasks instead. - -# This file is left only as an example of what you could -# meet during plugins development and support. diff --git a/examples/fuel_plugin_example_v4/volumes.yaml b/examples/fuel_plugin_example_v4/volumes.yaml deleted file mode 100644 index b42b196..0000000 --- a/examples/fuel_plugin_example_v4/volumes.yaml +++ /dev/null @@ -1,6 +0,0 @@ -# Set here new volumes for your role -volumes: [] -volumes_roles_mapping: - fuel_plugin_example_v4_role: - # Default role mapping - - {allocate_size: "min", id: "os"} diff --git a/examples/fuel_plugin_example_v5/LICENSE b/examples/fuel_plugin_example_v5/LICENSE deleted file mode 100644 index e06d208..0000000 --- a/examples/fuel_plugin_example_v5/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ -Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file 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. - diff --git a/examples/fuel_plugin_example_v5/README.md b/examples/fuel_plugin_example_v5/README.md deleted file mode 100644 index 029d73b..0000000 --- a/examples/fuel_plugin_example_v5/README.md +++ /dev/null @@ -1,4 +0,0 @@ -fuel_plugin_example_v5 -====================== - -Plugin description diff --git a/examples/fuel_plugin_example_v5/bond_config.yaml b/examples/fuel_plugin_example_v5/bond_config.yaml deleted file mode 100644 index d2a9782..0000000 --- a/examples/fuel_plugin_example_v5/bond_config.yaml +++ /dev/null @@ -1,18 +0,0 @@ -# This file contains additional bond attributes provided by plugin. -# Please, take a look at following link for the details: -# - https://blueprints.launchpad.net/fuel/+spec/nics-and-nodes-attributes-via-plugin -# - https://specs.openstack.org/openstack/fuel-specs/specs/10.0/nics-and-nodes-attributes-via-plugin.html - -attribute_a: - label: "Bond attribute A" - description: "Some description" - type: "text" - value: "" - restrictions: - - condition: "settings:common.libvirt_type.value != 'kvm'" - action: "hide" -attribute_b: - label: "Bond attribute B" - description: "Some description" - type: "checkbox" - value: false diff --git a/examples/fuel_plugin_example_v5/components.yaml b/examples/fuel_plugin_example_v5/components.yaml deleted file mode 100644 index ca8000d..0000000 --- a/examples/fuel_plugin_example_v5/components.yaml +++ /dev/null @@ -1,17 +0,0 @@ -# This file contains wizard components descriptions that are pretty similar to -# the `environment_config.yaml`. -# Please, take a look at following link for the details: -# - https://blueprints.launchpad.net/fuel/+spec/component-registry -# - https://specs.openstack.org/openstack/fuel-specs/specs/8.0/component-registry.html - -- name: additional_service:service_plugin_v5_component - label: "Title for service_plugin_v5_component component." - description: "Description for service_plugin_v5_component component." - compatible: - - name: "hypervisor:xxx" - requires: - - name: "hypervisor:xxx" - message: "service_plugin_v5_component requires XXX compute." - incompatible: - - name: "network:neutron:*" - message: "service_plugin_v5_component incompatible with Neutron network." \ No newline at end of file diff --git a/examples/fuel_plugin_example_v5/deployment_scripts/deploy.pp b/examples/fuel_plugin_example_v5/deployment_scripts/deploy.pp deleted file mode 100644 index 1b462b5..0000000 --- a/examples/fuel_plugin_example_v5/deployment_scripts/deploy.pp +++ /dev/null @@ -1,14 +0,0 @@ -# This puppet manifest creates example file in /tmp folder. - -notice('PLUGIN: fuel_plugin_example_v5 - deploy.pp') - -class fuel_plugin_example_v5 { - file { '/tmp/fuel_plugin_example_v5_puppet': - owner => 'root', - group => 'root', - mode => 0644, - content => "fuel_plugin_example_v5\n", - } -} - -class {'fuel_plugin_example_v5': } diff --git a/examples/fuel_plugin_example_v5/deployment_scripts/deploy.sh b/examples/fuel_plugin_example_v5/deployment_scripts/deploy.sh deleted file mode 100644 index c0e0cb1..0000000 --- a/examples/fuel_plugin_example_v5/deployment_scripts/deploy.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -set -eux - -# It's a script which deploys your plugin -echo fuel_plugin_example_v5 > /tmp/fuel_plugin_example_v5_sh - -OS_NAME='' -if grep -i CentOS /etc/issue.net >/dev/null; then - OS_NAME='centos'; -elif grep -i Ubuntu /etc/issue.net >/dev/null; then - OS_NAME='ubuntu'; -fi - -function install_package { - if [ $OS_NAME == 'ubuntu' ]; then - apt-get install -y --force-yes -o 'APT::Get::AllowUnauthenticated=1' fuel-simple-service - elif [ $OS_NAME == 'centos' ]; then - yum install -y fuel-simple-service - fi -} - -install_package -fuel-simple-service.py & diff --git a/examples/fuel_plugin_example_v5/deployment_tasks.yaml b/examples/fuel_plugin_example_v5/deployment_tasks.yaml deleted file mode 100644 index 6a34329..0000000 --- a/examples/fuel_plugin_example_v5/deployment_tasks.yaml +++ /dev/null @@ -1,46 +0,0 @@ -- id: fuel_plugin_example_v5 - type: group - role: [fuel_plugin_example_v5] - tasks: - - hiera - - globals - required_for: [deploy_end] - requires: [deploy_start] - parameters: - strategy: - type: parallel - -- id: fuel_plugin_example_v5-controller-deployment - type: puppet - version: 2.0.0 - groups: [primary-controller, controller] - required_for: [connectivity_tests, deploy_end] - requires: [netconfig, deploy_start] - parameters: - puppet_manifest: "deploy.pp" - puppet_modules: "." - timeout: 3600 - -- id: fuel_plugin_example_v5-deployment - type: puppet - version: 2.0.0 - groups: [fuel_plugin_example_v5] - required_for: [deploy_end] - requires: [deploy_start] - parameters: - puppet_manifest: "deploy.pp" - puppet_modules: "." - timeout: 3600 - retries: 10 - -- id: fuel_plugin_example_v5-post-deployment-sh - type: shell - version: 2.0.0 - role: [fuel_plugin_example_v5] - required_for: [post_deployment_end] - requires: [post_deployment_start] - parameters: - cmd: bash deploy.sh - retries: 3 - interval: 20 - timeout: 180 diff --git a/examples/fuel_plugin_example_v5/environment_config.yaml b/examples/fuel_plugin_example_v5/environment_config.yaml deleted file mode 100644 index 147eb0d..0000000 --- a/examples/fuel_plugin_example_v5/environment_config.yaml +++ /dev/null @@ -1,15 +0,0 @@ -# This file describes additional attributes that will appear on the Settings -# tab of the Fuel web UI. When the environment is deployed, these attributes -# are passed to the task executor so that the data is available -# in the /etc/astute.yaml file on each target node and can be accessed from -# your bash or puppet scripts. - -attributes: - metadata: - group: 'other' - fuel_plugin_example_v5_text: - value: 'Set default value' - label: 'Text field' - description: 'Description for text field' - weight: 25 - type: "text" diff --git a/examples/fuel_plugin_example_v5/fuel-simple-service.py b/examples/fuel_plugin_example_v5/fuel-simple-service.py deleted file mode 100644 index 247a2d6..0000000 --- a/examples/fuel_plugin_example_v5/fuel-simple-service.py +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env python -# -*- encoding: utf-8 -*- - -from wsgiref.simple_server import make_server - -def web_app(environ, start_response): - status = '200 OK' - headers = [('Content-type', 'text/plain')] - - start_response(status, headers) - - return open('/etc/astute.yaml').read() - - -def start_server(host, port): - httpd = make_server(host, port, web_app) - print 'Started server 8234' - httpd.serve_forever() - - -def main(): - start_server('', 8234) - - -if __name__ == '__main__': - main() diff --git a/examples/fuel_plugin_example_v5/metadata.yaml b/examples/fuel_plugin_example_v5/metadata.yaml deleted file mode 100644 index ac1586f..0000000 --- a/examples/fuel_plugin_example_v5/metadata.yaml +++ /dev/null @@ -1,40 +0,0 @@ -# Plugin name -name: fuel_plugin_example_v5 -# Human-readable name for your plugin -title: Title for fuel_plugin_example_v5 plugin -# Plugin version -version: '1.0.0' -# Description -description: Please describe your plugin here -# Minimum required fuel version -fuel_version: ['9.0', '10.0'] -# Specify license of your plugin -licenses: ['Apache License Version 2.0'] -# Specify author or company name -authors: ['Specify author or company name'] -# A link to the plugin's page -homepage: 'https://github.com/openstack/fuel-plugins' -# Specify a group which your plugin implements, possible options: -# network, storage, storage::cinder, storage::glance, hypervisor, -# equipment -groups: [] -# Change `false` to `true` if the plugin can be installed in the environment -# after the deployment. -is_hotpluggable: false - -# The plugin is compatible with releases in the list -releases: - - os: ubuntu - version: mitaka-9.0 - mode: ['ha'] - deployment_scripts_path: deployment_scripts/ - repository_path: repositories/ubuntu - - os: ubuntu - version: newton-10.0 - mode: ['ha'] - deployment_scripts_path: deployment_scripts/ - repository_path: repositories/ubuntu - - -# Version of plugin package -package_version: '5.0.0' diff --git a/examples/fuel_plugin_example_v5/network_roles.yaml b/examples/fuel_plugin_example_v5/network_roles.yaml deleted file mode 100644 index 5a1f277..0000000 --- a/examples/fuel_plugin_example_v5/network_roles.yaml +++ /dev/null @@ -1,24 +0,0 @@ -# `network_roles.yaml` file is used to declare VIP addresses and link -# them with networks and nodes. - -# Unique network role name -- id: "fuel_plugin_example_v5_network_role" - # Role mapping to network - default_mapping: "public" - properties: - # Should be true if network role requires subnet being set - subnet: true - # Should be true if network role requires gateway being set - gateway: false - # List of VIPs to be allocated - vip: - # Unique VIP name - - name: "vip_name" - # Optional linux namespace for VIP - namespace: "haproxy" - # Optional alias so VIP can be queried via API - alias: "vip_name" - # Optional node role list to map VIP to (defaults to - # primary-controller and controller) - node_roles: - - "fuel_plugin_example_v5_role" diff --git a/examples/fuel_plugin_example_v5/nic_config.yaml b/examples/fuel_plugin_example_v5/nic_config.yaml deleted file mode 100644 index b9d05e1..0000000 --- a/examples/fuel_plugin_example_v5/nic_config.yaml +++ /dev/null @@ -1,18 +0,0 @@ -# This file contains additional nic attributes provided by plugin. -# Please, take a look at following link for the details: -# - https://blueprints.launchpad.net/fuel/+spec/nics-and-nodes-attributes-via-plugin -# - https://specs.openstack.org/openstack/fuel-specs/specs/10.0/nics-and-nodes-attributes-via-plugin.html - -attribute_a: - label: "NIC attribute A" - description: "Some description" - type: "text" - value: "" - restrictions: - - condition: "settings:common.libvirt_type.value != 'kvm'" - action: "hide" -attribute_b: - label: "NIC attribute B" - description: "Some description" - type: "checkbox" - value: false diff --git a/examples/fuel_plugin_example_v5/node_config.yaml b/examples/fuel_plugin_example_v5/node_config.yaml deleted file mode 100644 index f7bfc42..0000000 --- a/examples/fuel_plugin_example_v5/node_config.yaml +++ /dev/null @@ -1,25 +0,0 @@ -# This file contains additional node's attributes provided by plugin. -# Please, take a look at following link for the details: -# - https://blueprints.launchpad.net/fuel/+spec/nics-and-nodes-attributes-via-plugin -# - https://specs.openstack.org/openstack/fuel-specs/specs/10.0/nics-and-nodes-attributes-via-plugin.html - -plugin_section_a: - metadata: - group: "some_new_section" - label: "Section A" - restrictions: - - condition: "settings:common.libvirt_type.value != 'kvm'" - action: "hide" - attribute_a: - label: "Node attribute A for section A" - description: "Some description" - type: "text" - value: "" - restrictions: - - condition: "false" - action: "hide" - attribute_b: - label: "Node attribute B for section A" - description: "Some description" - type: "checkbox" - value: "" diff --git a/examples/fuel_plugin_example_v5/node_roles.yaml b/examples/fuel_plugin_example_v5/node_roles.yaml deleted file mode 100644 index 0b71763..0000000 --- a/examples/fuel_plugin_example_v5/node_roles.yaml +++ /dev/null @@ -1,6 +0,0 @@ -fuel_plugin_example_v5: - name: "Set here the name for the role. This name will be displayed in the Fuel web UI." - description: "Write description for your role" - has_primary: false # whether has primary role or not - public_ip_required: false # whether requires public net or not - weight: 100 # weight that will be used for ordering on fuel ui diff --git a/examples/fuel_plugin_example_v5/pre_build_hook b/examples/fuel_plugin_example_v5/pre_build_hook deleted file mode 100644 index 2afa2aa..0000000 --- a/examples/fuel_plugin_example_v5/pre_build_hook +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -set -eux - -command -v fpm >/dev/null 2>&1 || { - echo >&2 "Install 'fpm' to build this plugin. Aborting."; exit 1; -} - -ruby -e "require 'fpm'" 2>&1 || { - echo >&2 "'Fpm' binary file is present, but gem seems to be broken! Aborting."; exit 1; -} - -ROOT=$(dirname `readlink -f $0`) - -UBUNTU_REPO_PATH=$ROOT/repositories/ubuntu -CENTOS_REPO_PATH=$ROOT/repositories/centos - -rm -f $UBUNTU_REPO_PATH/*.deb -rm -f $CENTOS_REPO_PATH/*.rpm - -fpm -t deb -p $UBUNTU_REPO_PATH -n fuel-simple-service -v 5.0.0 -s dir $ROOT/fuel-simple-service.py=/usr/bin/fuel-simple-service.py -fpm -t rpm -p $CENTOS_REPO_PATH -n fuel-simple-service -v 5.0.0 -s dir $ROOT/fuel-simple-service.py=/usr/bin/fuel-simple-service.py diff --git a/examples/fuel_plugin_example_v5/repositories/centos/.gitkeep b/examples/fuel_plugin_example_v5/repositories/centos/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/examples/fuel_plugin_example_v5/repositories/ubuntu/.gitkeep b/examples/fuel_plugin_example_v5/repositories/ubuntu/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/examples/fuel_plugin_example_v5/volumes.yaml b/examples/fuel_plugin_example_v5/volumes.yaml deleted file mode 100644 index b83b3ba..0000000 --- a/examples/fuel_plugin_example_v5/volumes.yaml +++ /dev/null @@ -1,6 +0,0 @@ -# Set here new volumes for your role -volumes: [] -volumes_roles_mapping: - fuel_plugin_example_v5_role: - # Default role mapping - - {allocate_size: "min", id: "os"} diff --git a/fuel_plugin_builder/__init__.py b/fuel_plugin_builder/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/fuel_plugin_builder/actions/__init__.py b/fuel_plugin_builder/actions/__init__.py deleted file mode 100644 index e9da6e4..0000000 --- a/fuel_plugin_builder/actions/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright 2014 Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file 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. - - -from fuel_plugin_builder.actions.base import BaseAction -from fuel_plugin_builder.actions.create import CreatePlugin -from fuel_plugin_builder.actions.build import BuildPluginV1 -from fuel_plugin_builder.actions.build import BuildPluginV2 -from fuel_plugin_builder.actions.build import BuildPluginV3 -from fuel_plugin_builder.actions.build import BuildPluginV4 -from fuel_plugin_builder.actions.build import BuildPluginV5 -from fuel_plugin_builder.actions.build import make_builder diff --git a/fuel_plugin_builder/actions/base.py b/fuel_plugin_builder/actions/base.py deleted file mode 100644 index 5a822c5..0000000 --- a/fuel_plugin_builder/actions/base.py +++ /dev/null @@ -1,32 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2014 Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file 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. - -import abc -import six - - -@six.add_metaclass(abc.ABCMeta) -class BaseAction(object): - - @abc.abstractmethod - def check(self): - """Check if it's possible to perform an action. - """ - - @abc.abstractmethod - def run(self): - """Run an action. - """ diff --git a/fuel_plugin_builder/actions/build.py b/fuel_plugin_builder/actions/build.py deleted file mode 100644 index ca9a9bc..0000000 --- a/fuel_plugin_builder/actions/build.py +++ /dev/null @@ -1,276 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2014 Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file 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. - -from __future__ import unicode_literals - -import abc -import logging -import os - -from os.path import join as join_path - -from fuel_plugin_builder.actions import BaseAction -from fuel_plugin_builder import errors -from fuel_plugin_builder import utils -from fuel_plugin_builder.validators import ValidatorManager -from fuel_plugin_builder import version_mapping - - -logger = logging.getLogger(__name__) - - -def get_template_path(file_name): - return os.path.abspath(join_path( - os.path.dirname(__file__), '..', 'templates', file_name)) - - -class BaseBuildPlugin(BaseAction): - - release_tmpl_src_path = get_template_path('base/build/Release.mako') - - @abc.abstractproperty - def requires(self): - """Should return a list of commands which - are required for the builder - """ - - @abc.abstractproperty - def result_package_mask(self): - """Should return mask for built package - """ - - @abc.abstractmethod - def make_package(self): - """Method should be implemented in child classes - """ - - def __init__(self, plugin_path): - self.plugin_path = plugin_path - - self.pre_build_hook_cmd = './pre_build_hook' - self.meta = utils.parse_yaml( - join_path(self.plugin_path, 'metadata.yaml') - ) - self.build_dir = join_path(self.plugin_path, '.build') - self.build_src_dir = join_path(self.build_dir, 'src') - self.checksums_path = join_path(self.build_src_dir, 'checksums.sha1') - self.name = self.meta['name'] - - self.plugin_version, self.full_version = utils.version_split_name_rpm( - self.meta['version']) - - def run(self): - logger.debug('Start plugin building "%s"', self.plugin_path) - self.clean() - self.run_pre_build_hook() - self.check() - self.build_repos() - self.add_checksums_file() - self.make_package() - - def clean(self): - utils.remove(self.build_dir) - utils.create_dir(self.build_dir) - utils.remove_by_mask(self.result_package_mask) - - def run_pre_build_hook(self): - if utils.which(join_path(self.plugin_path, self.pre_build_hook_cmd)): - utils.exec_cmd(self.pre_build_hook_cmd, self.plugin_path) - - def add_checksums_file(self): - utils.create_checksums_file(self.build_src_dir, self.checksums_path) - - def build_repos(self): - utils.create_dir(self.build_src_dir) - - utils.copy_files_in_dir( - join_path(self.plugin_path, '*'), - self.build_src_dir) - - releases_paths = {} - for release in self.meta['releases']: - releases_paths.setdefault(release['os'], []) - releases_paths[release['os']].append( - join_path(self.build_src_dir, release['repository_path'])) - - self.build_ubuntu_repos(releases_paths.get('ubuntu', [])) - self.build_centos_repos(releases_paths.get('centos', [])) - - def build_ubuntu_repos(self, releases_paths): - for repo_path in releases_paths: - utils.exec_piped_cmds( - ['dpkg-scanpackages -m .', 'gzip -c9 > Packages.gz'], - cwd=repo_path) - release_path = join_path(repo_path, 'Release') - utils.render_to_file( - self.release_tmpl_src_path, - release_path, - {'plugin_name': self.meta['name'], - 'major_version': self.plugin_version}) - - @classmethod - def build_centos_repos(cls, releases_paths): - for repo_path in releases_paths: - repo_packages = join_path(repo_path, 'Packages') - utils.create_dir(repo_packages) - utils.move_files_in_dir( - join_path(repo_path, '*.rpm'), - repo_packages) - utils.exec_cmd('createrepo -o {0} {0}'.format(repo_path)) - - def check(self): - self._check_requirements() - self._check_structure() - - def _check_requirements(self): - not_found = filter(lambda r: not utils.which(r), self.requires) - - if not_found: - raise errors.FuelCannotFindCommandError( - 'Cannot find commands "{0}", ' - 'install required commands and try again'.format( - ', '.join(not_found))) - - def _check_structure(self): - ValidatorManager(self.plugin_path).get_validator().validate() - - -class BuildPluginV1(BaseBuildPlugin): - - requires = ['rpm', 'createrepo', 'dpkg-scanpackages'] - - @property - def result_package_mask(self): - return join_path(self.plugin_path, '{0}-*.fp'.format(self.name)) - - def make_package(self): - full_name = '{0}-{1}'.format(self.meta['name'], - self.meta['version']) - tar_name = '{0}.fp'.format(full_name) - tar_path = join_path( - self.plugin_path, - tar_name) - - utils.make_tar_gz(self.build_src_dir, tar_path, full_name) - - -class BuildPluginV2(BuildPluginV1): - - requires = ['rpmbuild', 'rpm', 'createrepo', 'dpkg-scanpackages'] - - rpm_spec_src_path = get_template_path('v2/build/plugin_rpm.spec.mako') - - def __init__(self, *args, **kwargs): - super(BuildPluginV2, self).__init__(*args, **kwargs) - - self.rpm_path = os.path.abspath( - join_path(self.plugin_path, '.build', 'rpm')) - - self.rpm_src_path = join_path(self.rpm_path, 'SOURCES') - self.full_name = '{0}-{1}'.format( - self.meta['name'], self.plugin_version) - - tar_name = '{0}.fp'.format(self.full_name) - self.tar_path = join_path(self.rpm_src_path, tar_name) - - self.spec_dst = join_path(self.rpm_path, 'plugin_rpm.spec') - - self.rpm_packages_mask = join_path( - self.rpm_path, 'RPMS', 'noarch', '*.rpm') - - @property - def result_package_mask(self): - return join_path( - self.plugin_path, '{0}-*.noarch.rpm'.format(self.name)) - - def make_package(self): - """Builds rpm package - """ - utils.create_dir(self.rpm_src_path) - - utils.make_tar_gz(self.build_src_dir, self.tar_path, self.full_name) - utils.render_to_file( - self.rpm_spec_src_path, - self.spec_dst, - self._make_data_for_template()) - - utils.exec_cmd( - 'rpmbuild -vv --nodeps --define "_topdir {0}" ' - '-bb {1}'.format(self.rpm_path, self.spec_dst)) - utils.copy_files_in_dir(self.rpm_packages_mask, self.plugin_path) - - def _make_data_for_template(self): - """Generates data for spec template - - :returns: dictionary with required data - """ - return { - 'name': self.full_name, - 'version': self.full_version, - 'summary': self.meta['title'], - 'description': self.meta['description'], - 'license': ' and '.join(self.meta.get('licenses', [])), - 'homepage': self.meta.get('homepage'), - 'vendor': ', '.join(self.meta.get('authors', [])), - 'year': utils.get_current_year()} - - -class BuildPluginV3(BuildPluginV2): - - rpm_spec_src_path = get_template_path('v3/build/plugin_rpm.spec.mako') - - def _make_data_for_template(self): - data = super(BuildPluginV3, self)._make_data_for_template() - - uninst = utils.read_if_exist( - join_path(self.plugin_path, "uninstall.sh")) - - preinst = utils.read_if_exist( - join_path(self.plugin_path, "pre_install.sh")) - - postinst = utils.read_if_exist( - join_path(self.plugin_path, "post_install.sh")) - - plugin_build_version = str(self.meta.get('build_version', '1')) - - data.update( - {'postinstall_hook': postinst, - 'preinstall_hook': preinst, - 'uninstall_hook': uninst, - 'build_version': plugin_build_version} - ) - - return data - - -class BuildPluginV4(BuildPluginV3): - pass - - -class BuildPluginV5(BuildPluginV4): - pass - - -def make_builder(plugin_path): - """Creates build object. - - :param str plugin_path: path to the plugin - :returns: specific version of builder object - """ - builder = version_mapping.get_version_mapping_from_plugin( - plugin_path)['builder'] - - return builder(plugin_path) diff --git a/fuel_plugin_builder/actions/create.py b/fuel_plugin_builder/actions/create.py deleted file mode 100644 index 9ce9e51..0000000 --- a/fuel_plugin_builder/actions/create.py +++ /dev/null @@ -1,65 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2014 Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file 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. - -import logging -import os -import re - -from fuel_plugin_builder.actions import BaseAction -from fuel_plugin_builder import consts -from fuel_plugin_builder import errors -from fuel_plugin_builder import messages -from fuel_plugin_builder import utils -from fuel_plugin_builder import version_mapping - -logger = logging.getLogger(__name__) - - -class CreatePlugin(BaseAction): - - plugin_name_pattern = re.compile(consts.PLUGIN_NAME_PATTERN) - - def __init__(self, plugin_path, package_version=None): - self.plugin_name = utils.basename(plugin_path.rstrip('/')) - self.plugin_path = plugin_path - self.package_version = (package_version or - version_mapping.latest_version) - - self.render_ctx = {'plugin_name': self.plugin_name} - self.template_paths = version_mapping.get_plugin_for_version( - self.package_version)['templates'] - - def check(self): - if utils.exists(self.plugin_path): - raise errors.PluginDirectoryExistsError( - 'Plugins directory {0} already exists, ' - 'choose another name'.format(self.plugin_path)) - - if not self.plugin_name_pattern.match(self.plugin_name): - raise errors.ValidationError( - messages.PLUGIN_WRONG_NAME_EXCEPTION_MESSAGE) - - def run(self): - logger.debug('Start plugin creation "%s"', self.plugin_path) - self.check() - - for template_path in self.template_paths: - - template_dir = os.path.join( - os.path.dirname(__file__), '..', template_path) - - utils.copy(template_dir, self.plugin_path) - utils.render_files_in_dir(self.plugin_path, self.render_ctx) diff --git a/fuel_plugin_builder/cli.py b/fuel_plugin_builder/cli.py deleted file mode 100644 index 18b4dae..0000000 --- a/fuel_plugin_builder/cli.py +++ /dev/null @@ -1,128 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2014 Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file 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. - -import argparse -import logging -import six -import sys - -from fuel_plugin_builder import actions -from fuel_plugin_builder import errors -from fuel_plugin_builder import messages -from fuel_plugin_builder.validators import ValidatorManager - -from fuel_plugin_builder.logger import configure_logger - -logger = logging.getLogger(__name__) - - -def print_err(line): - sys.stderr.write(six.text_type(line)) - sys.stderr.write('\n') - - -def handle_exception(exc): - logger.exception(exc) - - if isinstance(exc, errors.FuelCannotFindCommandError): - print_err(messages.HEADER) - print_err(messages.INSTALL_REQUIRED_PACKAGES) - - elif isinstance(exc, errors.ValidationError): - print_err('Validation failed') - print_err(exc) - - else: - print_err('Unexpected error') - print_err(exc) - - sys.exit(-1) - - -def decode_string(string): - """Custom type for add_argument method - """ - return unicode(string, 'utf-8') - - -def parse_args(): - """Parse arguments and return them - """ - parser = argparse.ArgumentParser( - description='fpb is a fuel plugin builder which ' - 'helps you create plugin for Fuel') - - # TODO(vsharshov): we should move to subcommands instead of - # exclusive group, because in this case we could not - # support such behavior [-a xxx | [-b yyy -c zzz]] - group = parser.add_mutually_exclusive_group(required=True) - - group.add_argument( - '--create', help='create a plugin skeleton', - type=decode_string, metavar='plugin_name') - group.add_argument( - '--build', help='build a plugin', - type=decode_string, metavar='path_to_directory') - group.add_argument( - '--check', help='check that plugin is valid', - type=decode_string, metavar='path_to_directory') - - parser.add_argument( - '--debug', help='enable debug mode', - action="store_true") - - parser.add_argument( - '--package-version', help='which package version to use', - type=decode_string) - - result = parser.parse_args() - package_version_check(result, parser) - - return result - - -def perform_action(args): - """Performs an action - - :param args: argparse object - """ - if args.create: - actions.CreatePlugin(args.create, args.package_version).run() - print('Plugin is created') - elif args.build: - actions.make_builder(args.build).run() - print('Plugin is built') - elif args.check: - ValidatorManager(args.check).get_validator().validate() - print('Plugin is valid') - - -def package_version_check(args, parser): - """Check exclusive nature of --package-version argument - """ - if (args.build or args.check) and args.package_version: - parser.error('--package-version works only with --create') - - -def main(): - """Entry point - """ - try: - args = parse_args() - configure_logger(debug=args.debug) - perform_action(args) - except Exception as exc: - handle_exception(exc) diff --git a/fuel_plugin_builder/consts.py b/fuel_plugin_builder/consts.py deleted file mode 100644 index 6239e79..0000000 --- a/fuel_plugin_builder/consts.py +++ /dev/null @@ -1,18 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2015 Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file 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. - -# Only lower case letters, numbers, '_', '-' symbols -PLUGIN_NAME_PATTERN = '^[a-z0-9_-]+$' diff --git a/fuel_plugin_builder/errors.py b/fuel_plugin_builder/errors.py deleted file mode 100644 index 12c0df9..0000000 --- a/fuel_plugin_builder/errors.py +++ /dev/null @@ -1,63 +0,0 @@ -# Copyright 2014 Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file 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. - - -class FuelPluginException(Exception): - pass - - -class FuelCannotFindCommandError(FuelPluginException): - pass - - -class ExecutedErrorNonZeroExitCode(FuelPluginException): - pass - - -class PluginDirectoryExistsError(FuelPluginException): - pass - - -class ValidationError(FuelPluginException): - pass - - -class TaskFieldError(ValidationError): - pass - - -class FileIsEmpty(ValidationError): - def __init__(self, file_path): - super(FileIsEmpty, self).__init__( - "File '{0}' is empty".format(file_path) - ) - - -class FileDoesNotExist(ValidationError): - def __init__(self, file_path): - super(FileDoesNotExist, self).__init__( - "File '{0}' does not exist".format(file_path) - ) - - -class WrongPackageVersionError(FuelPluginException): - pass - - -class ReleasesDirectoriesError(FuelPluginException): - pass - - -class WrongPluginDirectoryError(FuelPluginException): - pass diff --git a/fuel_plugin_builder/logger.py b/fuel_plugin_builder/logger.py deleted file mode 100644 index 85a9650..0000000 --- a/fuel_plugin_builder/logger.py +++ /dev/null @@ -1,36 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2014 Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file 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. - -import logging - - -def configure_logger(debug=False): - logger = logging.getLogger('fuel_plugin_builder') - - logger.setLevel(logging.INFO) - if debug: - logger.setLevel(logging.DEBUG) - - formatter = logging.Formatter( - '%(asctime)s %(levelname)s %(process)d (%(module)s) %(message)s', - "%Y-%m-%d %H:%M:%S") - - stream_handler = logging.StreamHandler() - stream_handler.setLevel(logging.DEBUG) - stream_handler.setFormatter(formatter) - logger.addHandler(stream_handler) - - return logger diff --git a/fuel_plugin_builder/messages.py b/fuel_plugin_builder/messages.py deleted file mode 100644 index 48294bc..0000000 --- a/fuel_plugin_builder/messages.py +++ /dev/null @@ -1,33 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2014 Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file 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. - - -HEADER = '=' * 50 -INSTALL_REQUIRED_PACKAGES = """ -Was not able to find required packages. - -If you use Ubuntu, run: - - # sudo apt-get install createrepo rpm dpkg-dev - -If you use CentOS, run: - - # yum install createrepo dpkg-devel dpkg-dev rpm rpm-build - -""" -PLUGIN_WRONG_NAME_EXCEPTION_MESSAGE = ("Plugin name is invalid, use only " - "lower case letters, numbers, '_', '-' " - "symbols") diff --git a/fuel_plugin_builder/templates/base/.gitignore b/fuel_plugin_builder/templates/base/.gitignore deleted file mode 100644 index daedd39..0000000 --- a/fuel_plugin_builder/templates/base/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -.tox -.build -*.pyc diff --git a/fuel_plugin_builder/templates/base/build/Release.mako b/fuel_plugin_builder/templates/base/build/Release.mako deleted file mode 100644 index 65a9a7d..0000000 --- a/fuel_plugin_builder/templates/base/build/Release.mako +++ /dev/null @@ -1,2 +0,0 @@ -Label: ${plugin_name} -Version: ${major_version} diff --git a/fuel_plugin_builder/templates/base/plugin_data/LICENSE b/fuel_plugin_builder/templates/base/plugin_data/LICENSE deleted file mode 100644 index e06d208..0000000 --- a/fuel_plugin_builder/templates/base/plugin_data/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ -Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file 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. - diff --git a/fuel_plugin_builder/templates/base/plugin_data/README.md.mako b/fuel_plugin_builder/templates/base/plugin_data/README.md.mako deleted file mode 100644 index 560fd46..0000000 --- a/fuel_plugin_builder/templates/base/plugin_data/README.md.mako +++ /dev/null @@ -1,4 +0,0 @@ -${plugin_name} -============ - -Plugin description \ No newline at end of file diff --git a/fuel_plugin_builder/templates/base/plugin_data/deployment_scripts/deploy.sh.mako b/fuel_plugin_builder/templates/base/plugin_data/deployment_scripts/deploy.sh.mako deleted file mode 100755 index 1a669d1..0000000 --- a/fuel_plugin_builder/templates/base/plugin_data/deployment_scripts/deploy.sh.mako +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -# It's a script which deploys your plugin -echo ${plugin_name} > /tmp/${plugin_name} diff --git a/fuel_plugin_builder/templates/base/plugin_data/environment_config.yaml.mako b/fuel_plugin_builder/templates/base/plugin_data/environment_config.yaml.mako deleted file mode 100644 index 72ef4ab..0000000 --- a/fuel_plugin_builder/templates/base/plugin_data/environment_config.yaml.mako +++ /dev/null @@ -1,7 +0,0 @@ -attributes: - ${plugin_name}_text: - value: 'Set default value' - label: 'Text field' - description: 'Description for text field' - weight: 25 - type: "text" diff --git a/fuel_plugin_builder/templates/base/plugin_data/pre_build_hook b/fuel_plugin_builder/templates/base/plugin_data/pre_build_hook deleted file mode 100755 index dc05e98..0000000 --- a/fuel_plugin_builder/templates/base/plugin_data/pre_build_hook +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -# Add here any the actions which are required before plugin build -# like packages building, packages downloading from mirrors and so on. -# The script should return 0 if there were no errors. diff --git a/fuel_plugin_builder/templates/base/plugin_data/repositories/centos/.gitkeep b/fuel_plugin_builder/templates/base/plugin_data/repositories/centos/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/fuel_plugin_builder/templates/base/plugin_data/repositories/ubuntu/.gitkeep b/fuel_plugin_builder/templates/base/plugin_data/repositories/ubuntu/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/fuel_plugin_builder/templates/v1/plugin_data/metadata.yaml.mako b/fuel_plugin_builder/templates/v1/plugin_data/metadata.yaml.mako deleted file mode 100644 index df9b788..0000000 --- a/fuel_plugin_builder/templates/v1/plugin_data/metadata.yaml.mako +++ /dev/null @@ -1,26 +0,0 @@ -# Plugin name -name: ${plugin_name} -# Human-readable name for your plugin -title: Title for ${plugin_name} plugin -# Plugin version -version: '1.0.0' -# Description -description: Please describe your plugin here -# Required fuel version -fuel_version: ['6.0'] - -# The plugin is compatible with releases in the list -releases: - - os: ubuntu - version: 2014.2-6.0 - mode: ['ha', 'multinode'] - deployment_scripts_path: deployment_scripts/ - repository_path: repositories/ubuntu - - os: centos - version: 2014.2-6.0 - mode: ['ha', 'multinode'] - deployment_scripts_path: deployment_scripts/ - repository_path: repositories/centos - -# Version of plugin package -package_version: '1.0.0' diff --git a/fuel_plugin_builder/templates/v1/plugin_data/tasks.yaml b/fuel_plugin_builder/templates/v1/plugin_data/tasks.yaml deleted file mode 100644 index bfa8873..0000000 --- a/fuel_plugin_builder/templates/v1/plugin_data/tasks.yaml +++ /dev/null @@ -1,17 +0,0 @@ -# This tasks will be applied on controller nodes, -# here you can also specify several roles, for example -# ['cinder', 'compute'] will be applied only on -# cinder and compute nodes -- role: ['controller'] - stage: post_deployment - type: shell - parameters: - cmd: bash deploy.sh - timeout: 42 -# Task is applied for all roles -- role: '*' - stage: pre_deployment - type: shell - parameters: - cmd: echo all > /tmp/plugin.all - timeout: 42 diff --git a/fuel_plugin_builder/templates/v2/build/plugin_rpm.spec.mako b/fuel_plugin_builder/templates/v2/build/plugin_rpm.spec.mako deleted file mode 100644 index 57434ce..0000000 --- a/fuel_plugin_builder/templates/v2/build/plugin_rpm.spec.mako +++ /dev/null @@ -1,44 +0,0 @@ -# -# The spec is generated automatically by Fuel Plugin Builder tool -# https://github.com/stackforge/fuel-plugins -# -# RPM spec file for package ${ name } -# -# Copyright (c) ${ year }, ${ license }, ${ vendor } -# - -Name: ${ name } -Version: ${ version } -Url: ${ homepage } -Summary: ${ summary } -License: ${ license } -Source0: ${ name }.fp -Vendor: ${ vendor } -BuildRoot: %{_tmppath}/%{name}-%{version}-build -Group: Development/Libraries -Release: 1 -BuildArch: noarch - -# This will allow arch binaries to be included as part of the plugin package -# otherwise the build of the plugin fails. -%%define _binaries_in_noarch_packages_terminate_build 0 - -%%description -${ description } - -%%prep -rm -rf %{name}-%{version} -mkdir %{name}-%{version} - -tar -vxf %{SOURCE0} -C %{name}-%{version} - -%%install -cd %{name}-%{version} -mkdir -p %{buildroot}/var/www/nailgun/plugins/ -cp -r ${ name } %{buildroot}/var/www/nailgun/plugins/ - -%%clean -rm -rf %{buildroot} - -%%files -/var/www/nailgun/plugins/${ name } diff --git a/fuel_plugin_builder/templates/v2/plugin_data/metadata.yaml.mako b/fuel_plugin_builder/templates/v2/plugin_data/metadata.yaml.mako deleted file mode 100644 index 29d889f..0000000 --- a/fuel_plugin_builder/templates/v2/plugin_data/metadata.yaml.mako +++ /dev/null @@ -1,35 +0,0 @@ -# Plugin name -name: ${plugin_name} -# Human-readable name for your plugin -title: Title for ${plugin_name} plugin -# Plugin version -version: '1.0.0' -# Description -description: Please describe your plugin here -# Required fuel version -fuel_version: ['6.1'] -# Specify license of your plugin -licenses: ['Apache License Version 2.0'] -# Specify author or company name -authors: ['Specify author or company name'] -# A link to the plugin's page -homepage: 'https://github.com/stackforge/fuel-plugins' -# Specify a group which your plugin implements, possible options: -# network, storage, storage::cinder, storage::glance, hypervisor -groups: [] - -# The plugin is compatible with releases in the list -releases: - - os: ubuntu - version: 2014.2-6.1 - mode: ['ha', 'multinode'] - deployment_scripts_path: deployment_scripts/ - repository_path: repositories/ubuntu - - os: centos - version: 2014.2-6.1 - mode: ['ha', 'multinode'] - deployment_scripts_path: deployment_scripts/ - repository_path: repositories/centos - -# Version of plugin package -package_version: '2.0.0' diff --git a/fuel_plugin_builder/templates/v2/plugin_data/tasks.yaml b/fuel_plugin_builder/templates/v2/plugin_data/tasks.yaml deleted file mode 100644 index 15d2712..0000000 --- a/fuel_plugin_builder/templates/v2/plugin_data/tasks.yaml +++ /dev/null @@ -1,23 +0,0 @@ -# This tasks will be applied on controller nodes, -# here you can also specify several roles, for example -# ['cinder', 'compute'] will be applied only on -# cinder and compute nodes -- role: ['controller'] - stage: post_deployment - type: shell - parameters: - cmd: bash deploy.sh - timeout: 42 -# Task is applied for all roles -- role: '*' - stage: pre_deployment - type: shell - parameters: - cmd: echo all > /tmp/plugin.all - timeout: 42 -# "reboot" task reboots the nodes and waits until they get back online -# - role: '*' -# stage: pre_deployment -# type: reboot -# parameters: -# timeout: 600 diff --git a/fuel_plugin_builder/templates/v3/build/plugin_rpm.spec.mako b/fuel_plugin_builder/templates/v3/build/plugin_rpm.spec.mako deleted file mode 100644 index 6ac24e5..0000000 --- a/fuel_plugin_builder/templates/v3/build/plugin_rpm.spec.mako +++ /dev/null @@ -1,64 +0,0 @@ -# -# The spec is generated automatically by Fuel Plugin Builder tool -# https://github.com/stackforge/fuel-plugins -# -# RPM spec file for package ${ name } -# -# Copyright (c) ${ year }, ${ license }, ${ vendor } -# - -Name: ${ name } -Version: ${ version } -Url: ${ homepage } -Summary: ${ summary } -License: ${ license } -Source0: ${ name }.fp -Vendor: ${ vendor } -BuildRoot: %{_tmppath}/%{name}-%{version}-build -Group: Development/Libraries -Release: ${ build_version } -BuildArch: noarch -AutoReq: no - -# This will allow arch binaries to be included as part of the plugin package -# otherwise the build of the plugin fails. -%%define _binaries_in_noarch_packages_terminate_build 0 - -%%description -${ description } - -%%prep -rm -rf %{name}-%{version} -mkdir %{name}-%{version} - -tar -vxf %{SOURCE0} -C %{name}-%{version} - -%%install -cd %{name}-%{version} -mkdir -p %{buildroot}/var/www/nailgun/plugins/ -cp -r ${ name } %{buildroot}/var/www/nailgun/plugins/ - -%%clean -rm -rf %{buildroot} - -%%pre -${ preinstall_hook } - -%%post -${ postinstall_hook } - -%%preun -# Values of $1: -# install: (N/A) -# upgrade: 1 -# uninstall: 0 -% if uninstall_hook: -if [ $1 -eq 0 ]; then - # insert no-op to allow empty or comment-only uninstall hooks - : - ${ uninstall_hook } -fi -% endif - -%%files -/var/www/nailgun/plugins/${ name } diff --git a/fuel_plugin_builder/templates/v3/plugin_data/deployment_tasks.yaml.mako b/fuel_plugin_builder/templates/v3/plugin_data/deployment_tasks.yaml.mako deleted file mode 100644 index c29fbb9..0000000 --- a/fuel_plugin_builder/templates/v3/plugin_data/deployment_tasks.yaml.mako +++ /dev/null @@ -1,41 +0,0 @@ -# These tasks will be merged into deployment graph. Here you -# can specify new tasks for any roles, even built-in ones. - -- id: ${plugin_name} - type: group - role: [${plugin_name}] - parameters: - strategy: - type: parallel - -- id: ${plugin_name}-deployment-puppet - type: puppet - groups: [${plugin_name}] - required_for: [deploy_end] - requires: [deploy_start] - parameters: - puppet_manifest: "deploy.pp" - puppet_modules: "." - timeout: 3600 - -#- id: ${plugin_name}-post-deployment-sh -# type: shell -# role: [${plugin_name}] -# required_for: [post_deployment_end] -# requires: [post_deployment_start] -# parameters: -# cmd: echo post_deployment_task_executed > /tmp/post_deployment -# retries: 3 -# interval: 20 -# timeout: 180 - -#- id: ${plugin_name}-pre-deployment-sh -# type: shell -# role: [${plugin_name}] -# required_for: [pre_deployment_end] -# requires: [pre_deployment_start] -# parameters: -# cmd: echo pre_deployment_task_executed > /tmp/pre_deployment -# retries: 3 -# interval: 20 -# timeout: 180 diff --git a/fuel_plugin_builder/templates/v3/plugin_data/metadata.yaml.mako b/fuel_plugin_builder/templates/v3/plugin_data/metadata.yaml.mako deleted file mode 100644 index 7c27b77..0000000 --- a/fuel_plugin_builder/templates/v3/plugin_data/metadata.yaml.mako +++ /dev/null @@ -1,35 +0,0 @@ -# Plugin name -name: ${plugin_name} -# Human-readable name for your plugin -title: Title for ${plugin_name} plugin -# Plugin version -version: '1.0.0' -# Description -description: Please describe your plugin here -# Required fuel version -fuel_version: ['7.0', '8.0'] -# Specify license of your plugin -licenses: ['Apache License Version 2.0'] -# Specify author or company name -authors: ['Specify author or company name'] -# A link to the plugin's page -homepage: 'https://github.com/stackforge/fuel-plugins' -# Specify a group which your plugin implements, possible options: -# network, storage, storage::cinder, storage::glance, hypervisor -groups: [] - -# The plugin is compatible with releases in the list -releases: - - os: ubuntu - version: 2015.1.0-7.0 - mode: ['ha'] - deployment_scripts_path: deployment_scripts/ - repository_path: repositories/ubuntu - - os: ubuntu - version: liberty-8.0 - mode: ['ha'] - deployment_scripts_path: deployment_scripts/ - repository_path: repositories/ubuntu - -# Version of plugin package -package_version: '3.0.0' diff --git a/fuel_plugin_builder/templates/v3/plugin_data/network_roles.yaml b/fuel_plugin_builder/templates/v3/plugin_data/network_roles.yaml deleted file mode 100644 index d9d5565..0000000 --- a/fuel_plugin_builder/templates/v3/plugin_data/network_roles.yaml +++ /dev/null @@ -1,15 +0,0 @@ -# Unique network role name -- id: "example_net_role" - # Role mapping to network - default_mapping: "public" - properties: - # Should be true if network role requires subnet being set - subnet: true - # Should be true if network role requires gateway being set - gateway: false - # List of VIPs to be allocated - vip: - # Unique VIP name - - name: "vip_name" - # Optional linux namespace for VIP - namespace: "haproxy" diff --git a/fuel_plugin_builder/templates/v3/plugin_data/node_roles.yaml.mako b/fuel_plugin_builder/templates/v3/plugin_data/node_roles.yaml.mako deleted file mode 100644 index 1602307..0000000 --- a/fuel_plugin_builder/templates/v3/plugin_data/node_roles.yaml.mako +++ /dev/null @@ -1,13 +0,0 @@ -${plugin_name}: - # Role name - name: "Set here the name for the role. This name will be displayed in the Fuel web UI" - # Role description - description: "Write description for your role" - # If primaty then during orchestration this role will be - # splitted into primary-role and role - has_primary: false - # Assign public IP to node if true - public_ip_required: false - # Weight that will be used to sort out the - # roles on the Fuel web UI - weight: 1000 diff --git a/fuel_plugin_builder/templates/v3/plugin_data/volumes.yaml.mako b/fuel_plugin_builder/templates/v3/plugin_data/volumes.yaml.mako deleted file mode 100644 index 5fdf0d8..0000000 --- a/fuel_plugin_builder/templates/v3/plugin_data/volumes.yaml.mako +++ /dev/null @@ -1,7 +0,0 @@ -volumes_roles_mapping: - # Default role mapping - ${plugin_name}: - - {allocate_size: "min", id: "os"} - -# Set here new volumes for your role -volumes: [] diff --git a/fuel_plugin_builder/templates/v4/plugin_data/components.yaml.mako b/fuel_plugin_builder/templates/v4/plugin_data/components.yaml.mako deleted file mode 100644 index fb7a353..0000000 --- a/fuel_plugin_builder/templates/v4/plugin_data/components.yaml.mako +++ /dev/null @@ -1,12 +0,0 @@ -# This file contains wizard components descriptions that are pretty similar to -# the `environment_config.yaml`. -# Please, take a look at following link for the details: -# - https://blueprints.launchpad.net/fuel/+spec/component-registry -# - https://specs.openstack.org/openstack/fuel-specs/specs/8.0/component-registry.html - -- name: additional_service:${plugin_name} - compatible: [] - requires: [] - incompatible: [] - label: "Plugin label, that will be shown on UI" - description: "Component description (optional)" diff --git a/fuel_plugin_builder/templates/v4/plugin_data/deployment_tasks.yaml.mako b/fuel_plugin_builder/templates/v4/plugin_data/deployment_tasks.yaml.mako deleted file mode 100644 index e1742dd..0000000 --- a/fuel_plugin_builder/templates/v4/plugin_data/deployment_tasks.yaml.mako +++ /dev/null @@ -1,62 +0,0 @@ -# These tasks will be merged into deployment graph. Here you -# can specify new tasks for any roles, even built-in ones. - -- id: ${plugin_name}_role - type: group - role: [${plugin_name}_role] - parameters: - strategy: - type: parallel - -- id: ${plugin_name}-deployment-puppet - type: puppet - role: [${plugin_name}_role] - -# If you do not want to use task-based deployment that is introduced as experimental -# in fuel v8.0 comment code section below this comment, uncomment two lines below it -# and do the same for tasks below. - - version: 2.0.0 - cross-depends: - - name: deploy_start - cross-depended-by: - - name: deploy_end -# requires: [deploy_start] # version 1.0.0 -# required_for: [deploy_end] - - parameters: - puppet_manifest: "deploy.pp" - puppet_modules: "." - timeout: 3600 - -#- id: ${plugin_name}-post-deployment-sh -# type: shell -# role: [${plugin_name}_role] -# version: 2.0.0 -# cross-depends: -# - name: post_deployment_start -# cross-depended-by: -# - name: post_deployment_end -# # requires: [post_deployment_start] -# # required_for: [post_deployment_end] -# parameters: -# cmd: echo post_deployment_task_executed > /tmp/post_deployment -# retries: 3 -# interval: 20 -# timeout: 180 - -#- id: ${plugin_name}-pre-deployment-sh -# type: shell -# role: [${plugin_name}_role] -# version: 2.0.0 -# cross-depends: -# - name: pre_deployment_start -# cross-depended-by: -# - name: pre_deployment_end -# # requires: [pre_deployment_start] -# # required_for: [pre_deployment_end] -# parameters: -# cmd: echo pre_deployment_task_executed > /tmp/pre_deployment -# retries: 3 -# interval: 20 -# timeout: 180 diff --git a/fuel_plugin_builder/templates/v4/plugin_data/environment_config.yaml.mako b/fuel_plugin_builder/templates/v4/plugin_data/environment_config.yaml.mako deleted file mode 100644 index 7a03aa9..0000000 --- a/fuel_plugin_builder/templates/v4/plugin_data/environment_config.yaml.mako +++ /dev/null @@ -1,11 +0,0 @@ -attributes: - metadata: - # Settings group can be one of "general", "security", "compute", "network", - # "storage", "logging", "openstack_services" and "other". - group: 'other' - ${plugin_name}_text: - value: 'Set default value' - label: 'Text field' - description: 'Description for text field' - weight: 25 - type: "text" diff --git a/fuel_plugin_builder/templates/v4/plugin_data/metadata.yaml.mako b/fuel_plugin_builder/templates/v4/plugin_data/metadata.yaml.mako deleted file mode 100644 index 6d069cc..0000000 --- a/fuel_plugin_builder/templates/v4/plugin_data/metadata.yaml.mako +++ /dev/null @@ -1,34 +0,0 @@ -# Plugin name -name: ${plugin_name} -# Human-readable name for your plugin -title: Title for ${plugin_name} plugin -# Plugin version -version: '1.0.0' -# Description -description: Please describe your plugin here -# Required fuel version -fuel_version: ['8.0'] -# Specify license of your plugin -licenses: ['Apache License Version 2.0'] -# Specify author or company name -authors: ['Specify author or company name'] -# A link to the plugin's page -homepage: 'https://github.com/openstack/fuel-plugins' -# Specify a group which your plugin implements, possible options: -# network, storage, storage::cinder, storage::glance, hypervisor, -# equipment -groups: [] -# Change `false` to `true` if the plugin can be installed in the environment -# after the deployment. -is_hotpluggable: false - -# The plugin is compatible with releases in the list -releases: - - os: ubuntu - version: mitaka-9.0 - mode: ['ha'] - deployment_scripts_path: deployment_scripts/ - repository_path: repositories/ubuntu - -# Version of plugin package -package_version: '4.0.0' diff --git a/fuel_plugin_builder/templates/v4/plugin_data/node_roles.yaml.mako b/fuel_plugin_builder/templates/v4/plugin_data/node_roles.yaml.mako deleted file mode 100644 index 6995d04..0000000 --- a/fuel_plugin_builder/templates/v4/plugin_data/node_roles.yaml.mako +++ /dev/null @@ -1,13 +0,0 @@ -${plugin_name}_role: - # Role name - name: "Set here the name for the role. This name will be displayed in the Fuel web UI" - # Role description - description: "Write description for your role" - # If primary then during orchestration this role will be - # separated into primary-role and role - has_primary: false - # Assign public IP to node if true - public_ip_required: false - # Weight that will be used to sort out the - # roles on the Fuel web UI - weight: 1000 diff --git a/fuel_plugin_builder/templates/v4/plugin_data/tasks.yaml b/fuel_plugin_builder/templates/v4/plugin_data/tasks.yaml deleted file mode 100644 index 3ffb6d0..0000000 --- a/fuel_plugin_builder/templates/v4/plugin_data/tasks.yaml +++ /dev/null @@ -1,29 +0,0 @@ -# WARNING: `tasks.yaml` will be deprecated in further releases. -# Please, use `deployment_tasks.yaml` to describe tasks instead. - -# This file is left only as an example of the old tasks format what you could -# meet during plugins development and support. - -## This tasks will be applied on controller nodes, -## here you can also specify several roles, for example -## ['cinder', 'compute'] will be applied only on -## cinder and compute nodes -#- role: ['controller'] -# stage: post_deployment -# type: shell -# parameters: -# cmd: bash deploy.sh -# timeout: 42 -## Task is applied for all roles -#- role: '*' -# stage: pre_deployment -# type: shell -# parameters: -# cmd: echo all > /tmp/plugin.all -# timeout: 42 -## "reboot" task reboots the nodes and waits until they get back online -## - role: '*' -## stage: pre_deployment -## type: reboot -## parameters: -## timeout: 600 diff --git a/fuel_plugin_builder/templates/v4/plugin_data/volumes.yaml.mako b/fuel_plugin_builder/templates/v4/plugin_data/volumes.yaml.mako deleted file mode 100644 index 2c05e0f..0000000 --- a/fuel_plugin_builder/templates/v4/plugin_data/volumes.yaml.mako +++ /dev/null @@ -1,7 +0,0 @@ -volumes_roles_mapping: - # Default role mapping - ${plugin_name}_role: - - {allocate_size: "min", id: "os"} - -# Set here new volumes for your role -volumes: [] diff --git a/fuel_plugin_builder/templates/v5/plugin_data/bond_config.yaml.mako b/fuel_plugin_builder/templates/v5/plugin_data/bond_config.yaml.mako deleted file mode 100644 index 15fcff5..0000000 --- a/fuel_plugin_builder/templates/v5/plugin_data/bond_config.yaml.mako +++ /dev/null @@ -1,15 +0,0 @@ -# This file contains additional bond attributes provided by plugin. -# Please, take a look at following link for the details: -# - https://blueprints.launchpad.net/fuel/+spec/nics-and-nodes-attributes-via-plugin -# - https://specs.openstack.org/openstack/fuel-specs/specs/10.0/nics-and-nodes-attributes-via-plugin.html - -attribute_a: - label: "Bond attribute A" - description: "Some description" - type: "text" - value: "" -attribute_b: - label: "Bond attribute B" - description: "Some description" - type: "checkbox" - value: false diff --git a/fuel_plugin_builder/templates/v5/plugin_data/metadata.yaml.mako b/fuel_plugin_builder/templates/v5/plugin_data/metadata.yaml.mako deleted file mode 100644 index dde87b1..0000000 --- a/fuel_plugin_builder/templates/v5/plugin_data/metadata.yaml.mako +++ /dev/null @@ -1,38 +0,0 @@ -# Plugin name -name: ${plugin_name} -# Human-readable name for your plugin -title: Title for ${plugin_name} plugin -# Plugin version -version: '1.0.0' -# Description -description: Please describe your plugin here -# Required fuel version -fuel_version: ['9.0', '10.0'] -# Specify license of your plugin -licenses: ['Apache License Version 2.0'] -# Specify author or company name -authors: ['Specify author or company name'] -# A link to the plugin's page -homepage: 'https://github.com/stackforge/fuel-plugins' -# Specify a group which your plugin implements, possible options: -# network, storage, storage::cinder, storage::glance, hypervisor -groups: [] -# Change `false` to `true` if the plugin can be installed in the environment -# after the deployment. -is_hotpluggable: false - -# The plugin is compatible with releases in the list -releases: - - os: ubuntu - version: mitaka-9.0 - mode: ['ha'] - deployment_scripts_path: deployment_scripts/ - repository_path: repositories/ubuntu - - os: ubuntu - version: newton-10.0 - mode: ['ha'] - deployment_scripts_path: deployment_scripts/ - repository_path: repositories/ubuntu - -# Version of plugin package -package_version: '5.0.0' diff --git a/fuel_plugin_builder/templates/v5/plugin_data/nic_config.yaml.mako b/fuel_plugin_builder/templates/v5/plugin_data/nic_config.yaml.mako deleted file mode 100644 index a3c351a..0000000 --- a/fuel_plugin_builder/templates/v5/plugin_data/nic_config.yaml.mako +++ /dev/null @@ -1,15 +0,0 @@ -# This file contains additional nic attributes provided by plugin. -# Please, take a look at following link for the details: -# - https://blueprints.launchpad.net/fuel/+spec/nics-and-nodes-attributes-via-plugin -# - https://specs.openstack.org/openstack/fuel-specs/specs/10.0/nics-and-nodes-attributes-via-plugin.html - -attribute_a: - label: "NIC attribute A" - description: "Some description" - type: "text" - value: "" -attribute_b: - label: "NIC attribute B" - description: "Some description" - type: "checkbox" - value: false diff --git a/fuel_plugin_builder/templates/v5/plugin_data/node_config.yaml.mako b/fuel_plugin_builder/templates/v5/plugin_data/node_config.yaml.mako deleted file mode 100644 index 7c4aeae..0000000 --- a/fuel_plugin_builder/templates/v5/plugin_data/node_config.yaml.mako +++ /dev/null @@ -1,19 +0,0 @@ -# This file contains additional node's attributes provided by plugin. -# Please, take a look at following link for the details: -# - https://blueprints.launchpad.net/fuel/+spec/nics-and-nodes-attributes-via-plugin -# - https://specs.openstack.org/openstack/fuel-specs/specs/10.0/nics-and-nodes-attributes-via-plugin.html - -plugin_section_a: - metadata: - group: "some_new_section" - label: "Section A" - attribute_a: - label: "Node attribute A for section A" - description: "Some description" - type: "text" - value: "" - attribute_b: - label: "Node attribute B for section A" - description: "Some description" - type: "checkbox" - value: "" diff --git a/fuel_plugin_builder/tests/__init__.py b/fuel_plugin_builder/tests/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/fuel_plugin_builder/tests/base.py b/fuel_plugin_builder/tests/base.py deleted file mode 100644 index da195cc..0000000 --- a/fuel_plugin_builder/tests/base.py +++ /dev/null @@ -1,248 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2014 Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file 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. - -try: - from unittest.case import TestCase -except ImportError: - # Required for python 2.6 - from unittest2.case import TestCase - -import mock -from StringIO import StringIO - -from fuel_plugin_builder import errors - - -class FakeFile(StringIO): - """It's a fake file which returns StringIO - when file opens with 'with' statement. - - NOTE(eli): We cannot use mock_open from mock library - here, because it hangs when we use 'with' statement, - and when we want to read file by chunks. - """ - def __enter__(self): - return self - - def __exit__(self, *args): - pass - - def writelines(self, lines): - self.write(''.join(lines)) - - -class BaseTestCase(TestCase): - """Base class for test cases - """ - - def method_was_not_called(self, method): - """Checks that mocked method was not called - """ - self.assertEqual(method.call_count, 0) - - def called_times(self, method, count): - """Checks that mocked method was called `count` times - """ - self.assertEqual(method.call_count, count) - - def mock_open(self, text, filename='some.yaml'): - """Mocks builtin open function. - - Usage example: - - with mock.patch( - '__builtin__.open', - self.mock_open('file content') - ): - # call some methods that are used open() to read some - # stuff internally - """ - fileobj = FakeFile(text) - setattr(fileobj, 'name', filename) - return mock.MagicMock(return_value=fileobj) - - def mock_methods(self, obj, methods): - """Mocks methods for object - - :param obj: object for mocking - :param methods: list of methods for mocking - """ - for method in methods: - setattr(obj, method, mock.MagicMock()) - - -@mock.patch('fuel_plugin_builder.validators.base.utils') -class LegacyBaseValidatorTestCase(BaseTestCase): - - __test__ = False - validator_class = None - schema_class = None - - def setUp(self): - self.plugin_path = '/tmp/plugin_path' - self.validator = self.validator_class(self.plugin_path) - - def test_validate(self, _): - mocked_methods = [ - 'check_schemas', - 'check_tasks', - 'check_releases_paths', - 'check_compatibility', - ] - self.check_validate(mocked_methods) - - def test_check_schemas(self, _): - mocked_methods = [ - 'check_env_config_attrs', - 'validate_file_by_schema' - ] - self.mock_methods(self.validator, mocked_methods) - self.validator.check_schemas() - - self.assertEqual( - [mock.call(self.schema_class().metadata_schema, - self.validator.meta_path), - mock.call(self.schema_class().tasks_schema, - self.validator.tasks_path)], - self.validator.validate_file_by_schema.call_args_list) - - self.validator.check_env_config_attrs.assert_called_once_with() - - def test_check_releases_paths(self, utils_mock): - utils_mock.parse_yaml.return_value = { - 'releases': [{ - 'deployment_scripts_path': '/tmp/deployment_scripts_path', - 'repository_path': '/tmp/repository_path'}]} - - utils_mock.exists.return_value = True - self.validator.check_releases_paths() - self.assertEqual( - utils_mock.exists.call_args_list, - [mock.call('/tmp/deployment_scripts_path'), - mock.call('/tmp/repository_path')]) - - def test_check_releases_paths_error(self, utils_mock): - utils_mock.parse_yaml.return_value = { - 'releases': [{ - 'deployment_scripts_path': '/tmp/deployment_scripts_path', - 'repository_path': '/tmp/repository_path'}]} - - utils_mock.exists.return_value = False - with self.assertRaisesRegexp( - errors.ReleasesDirectoriesError, - 'Cannot find directories /tmp/deployment_scripts_path' - ', /tmp/repository_path for release '): - self.validator.check_releases_paths() - - def test_check_env_config_attrs_do_not_fail_if_empty(self, utils_mock): - utils_mock.parse_yaml.return_value = None - self.validator.check_env_config_attrs() - - def test_check_env_config_attrs_fail_if_none(self, utils_mock): - utils_mock.parse_yaml.return_value = {'attributes': None} - with self.assertRaisesRegexp( - errors.ValidationError, - "File '/tmp/plugin_path/environment_config.yaml', None " - "is not of type 'object', value path 'attributes'"): - self.validator.check_env_config_attrs() - - def test_check_env_config_attrs_checks_metadata(self, utils_mock): - utils_mock.parse_yaml.return_value = { - 'attributes': {'metadata': []}} - - with self.assertRaisesRegexp( - errors.ValidationError, - "File '/tmp/plugin_path/environment_config.yaml', \[\] is " - "not of type 'object', value path 'attributes -> metadata'"): - self.validator.check_env_config_attrs() - - def test_check_env_config_attrs_checks_attrs(self, utils_mock): - utils_mock.parse_yaml.return_value = { - 'attributes': { - 'key1': { - 'type': True, - 'label': 'text', - 'value': 'text', - 'weight': 1}}} - - with self.assertRaisesRegexp( - errors.ValidationError, - "File '/tmp/plugin_path/environment_config.yaml', True is not " - "of type 'string', value path 'attributes -> key1 -> type'"): - self.validator.check_env_config_attrs() - - def test_check_env_config_attrs_generator_value(self, utils_mock): - utils_mock.parse_yaml.return_value = { - 'attributes': { - 'key1': { - 'type': 'hidden', - 'label': '', - 'value': {'generator': 'password'}, - 'weight': 1}}} - - self.validator.check_env_config_attrs() - - def test_check_env_config_attrs_restriction_fails(self, utils_mock): - utils_mock.parse_yaml.return_value = { - 'attributes': { - 'key1': { - 'type': 'text', - 'label': 'test', - 'value': 'test', - 'weight': 1, - 'restrictions': [ - { - 'condition': 'false', - 'action': 'disable' - }, - { - 'condition': True, - 'action': 'hide' - } - ] - } - } - } - - with self.assertRaisesRegexp( - errors.ValidationError, - "File '/tmp/plugin_path/environment_config.yaml', True is not " - "of type 'string', value path " - "'attributes -> key1 -> restrictions -> 1 -> condition"): - self.validator.check_env_config_attrs() - - def check_raised_exception(self, utils_mock, mock_data, - err_msg, executed_method, - err_type=errors.ValidationError): - """Check if the given error with given type was raised. - - :param obj utils_mock: fuel_plugin_builder.utils mock - :param List[dict] mock_data: mock data - :param str err_msg: what error message is expected - :param function executed_method: what method should be executed - :param Exception err_type: what error type is expected - """ - utils_mock.parse_yaml.return_value = mock_data - - with self.assertRaisesRegexp(err_type, err_msg): - executed_method() - - def check_validate(self, mocked_methods=[]): - self.mock_methods(self.validator, mocked_methods) - self.validator.validate() - - for method in mocked_methods: - getattr(self.validator, method).assert_called_once_with() diff --git a/fuel_plugin_builder/tests/test_base_validator.py b/fuel_plugin_builder/tests/test_base_validator.py deleted file mode 100644 index a2a1faa..0000000 --- a/fuel_plugin_builder/tests/test_base_validator.py +++ /dev/null @@ -1,183 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2014 Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file 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. -import jsonschema -import mock - -from fuel_plugin_builder import errors -from fuel_plugin_builder.tests.base import BaseTestCase -from fuel_plugin_builder.validators import LegacyBaseValidator - - -class LegacyBaseValidatorTestCase(BaseTestCase): - - def setUp(self): - class NewValidator(LegacyBaseValidator): - - @property - def basic_version(self): - return None - - def validate(self): - pass - - self.plugin_path = '/tmp/plugin_path' - self.validator = NewValidator(self.plugin_path) - self.data = {'data': 'data1'} - self.schema = self.make_schema(['data'], {'data': {'type': 'string'}}) - self.format_checker = jsonschema.FormatChecker - - @classmethod - def make_schema(cls, required, properties): - return { - '$schema': 'http://json-schema.org/draft-04/schema#', - 'type': 'object', - 'required': required, - 'properties': properties} - - @mock.patch('fuel_plugin_builder.validators.base.jsonschema') - def test_validate_schema(self, schema_mock): - self.validator.validate_schema( - self.data, - self.schema, - 'file_path') - schema_mock.validate.assert_called_once_with( - self.data, - self.schema, format_checker=self.format_checker) - - def test_validate_schema_raises_error(self): - schema = self.make_schema(['key'], {'key': {'type': 'string'}}) - data = {} - - with self.assertRaisesRegexp( - errors.ValidationError, - "File 'file_path', 'key' is a required property"): - self.validator.validate_schema(data, schema, 'file_path') - - def test_validate_schema_raises_error_path_in_message(self): - schema = self.make_schema( - ['key'], - {'key': {'type': 'array', 'items': {'type': 'string'}}}) - data = {'key': ['str', 'str', 0]} - - expected_error = ("File 'file_path', 0 is not of type " - "'string', value path 'key -> 2'") - with self.assertRaisesRegexp( - errors.ValidationError, - expected_error): - self.validator.validate_schema(data, schema, 'file_path') - - def test_validate_schema_raises_error_custom_value_path(self): - schema = self.make_schema(['key'], {'key': {'type': 'string'}}) - data = {} - - with self.assertRaisesRegexp( - errors.ValidationError, - "File 'file_path', 'key' is a required property, " - "value path '0 -> path2'"): - self.validator.validate_schema( - data, schema, 'file_path', value_path=[0, 'path2']) - - @mock.patch( - 'fuel_plugin_builder.validators.base' - '.LegacyBaseValidator.validate_schema') - def test_validate_file_by_schema_failed(self, utils_mock): - utils_mock.parse_yaml.return_value = self.data - with self.assertRaisesRegexp( - errors.FileDoesNotExist, - "File '/tmp/plugin_path' does not exist"): - self.validator.validate_file_by_schema( - self.schema, self.plugin_path) - - @mock.patch('fuel_plugin_builder.validators.base.utils') - @mock.patch( - 'fuel_plugin_builder.validators.base' - '.LegacyBaseValidator.validate_schema') - def test_validate_file_by_schema(self, validate_mock, utils_mock): - utils_mock.parse_yaml.return_value = self.data - self.validator.validate_file_by_schema(self.schema, self.plugin_path) - utils_mock.parse_yaml.assert_called_once_with(self.plugin_path) - validate_mock(self.data, self.schema, self.plugin_path) - - @mock.patch('fuel_plugin_builder.validators.base.utils') - @mock.patch( - 'fuel_plugin_builder.validators.base' - '.LegacyBaseValidator.validate_schema') - def test_validate_file_by_schema_empty_file_passes( - self, validate_mock, utils_mock): - utils_mock.parse_yaml.return_value = None - self.validator.validate_file_by_schema( - self.schema, - self.plugin_path, - allow_empty=True) - utils_mock.parse_yaml.assert_called_once_with(self.plugin_path) - - @mock.patch('fuel_plugin_builder.validators.base.utils') - @mock.patch( - 'fuel_plugin_builder.validators.base' - '.LegacyBaseValidator.validate_schema') - def test_validate_file_by_schema_empty_file_fails( - self, validate_mock, utils_mock): - utils_mock.parse_yaml.return_value = None - with self.assertRaises(errors.FileIsEmpty): - self.validator.validate_file_by_schema( - self.schema, - self.plugin_path, - allow_empty=False) - - def test_validate_schema_with_subschemas(self): - schema_object = { - 'key': { - 'type': 'array', - 'items': { - 'anyOf': [ - { - 'type': 'string' - }, - { - 'type': 'object', - 'required': ['inner_key'], - 'properties': { - 'inner_key_1': {'type': 'string'}, - 'inner_key_2': {'type': 'string'}, - } - }, - { - 'type': 'object', - 'minProperties': 1, - 'maxProperties': 1 - } - ] - } - } - } - - schema = self.make_schema(['key'], schema_object) - - with self.assertRaisesRegexp( - errors.ValidationError, - "File 'file_path', True is not of type 'string', " - "value path '0 -> path1 -> key -> 0'"): - data = {'key': [True]} - self.validator.validate_schema( - data, schema, 'file_path', value_path=[0, 'path1']) - - with self.assertRaisesRegexp( - errors.ValidationError, - "File 'file_path', True is not of type 'string', " - "value path '0 -> path1 -> key -> 0 -> inner_key_1'"): - data = {'key': [{'inner_key_1': True, 'inner_key_2': 'str'}]} - self.validator.validate_schema( - data, schema, 'file_path', value_path=[0, 'path1']) diff --git a/fuel_plugin_builder/tests/test_build.py b/fuel_plugin_builder/tests/test_build.py deleted file mode 100644 index 57ec7fa..0000000 --- a/fuel_plugin_builder/tests/test_build.py +++ /dev/null @@ -1,401 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2014 Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file 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. - -from __future__ import unicode_literals - -import mock -import os - -from os.path import join as join_path - -from fuel_plugin_builder.actions.build import BaseBuildPlugin -from fuel_plugin_builder.actions.build import BuildPluginV1 -from fuel_plugin_builder.actions.build import BuildPluginV2 -from fuel_plugin_builder.actions.build import BuildPluginV3 -from fuel_plugin_builder import errors -from fuel_plugin_builder.tests.base import BaseTestCase - - -class BaseBuild(BaseTestCase): - - # Prevent test runner to run tests in base - __test__ = False - # Redefine class - builder_class = None - - releases = [ - {'os': 'ubuntu', - 'deployment_scripts_path': 'deployment_scripts_path', - 'repository_path': 'repository_path'}] - - def setUp(self): - self.plugins_name = 'fuel_plugin' - self.plugin_path = '/tmp/{0}'.format(self.plugins_name) - self.builder = self.create_builder(self.plugin_path) - - def create_builder(self, plugin_path, meta=None): - meta = meta or self.meta - with mock.patch( - 'fuel_plugin_builder.actions.build.utils.parse_yaml', - return_value=meta): - return self.builder_class(plugin_path) - - def test_run(self): - mocked_methods = [ - 'clean', - 'run_pre_build_hook', - 'check', - 'build_repos', - 'add_checksums_file', - 'make_package'] - - self.mock_methods(self.builder, mocked_methods) - self.builder.run() - - self.builder.clean.assert_called_once_with() - self.builder.run_pre_build_hook.assert_called_once_with() - self.builder.check.assert_called_once_with() - self.builder.add_checksums_file() - self.builder.build_repos.assert_called_once_with() - self.builder.make_package() - - @mock.patch('fuel_plugin_builder.actions.build.utils.which') - @mock.patch('fuel_plugin_builder.actions.build.utils.exec_cmd', - return_value=True) - def test_run_pre_build_hook(self, exec_cmd_mock, which_mock): - self.builder.run_pre_build_hook() - exec_cmd_mock.assert_called_once_with(self.builder.pre_build_hook_cmd, - self.builder.plugin_path) - which_mock.assert_called_once_with( - join_path(self.builder.plugin_path, - self.builder.pre_build_hook_cmd)) - - @mock.patch('fuel_plugin_builder.actions.build.utils') - def test_build_repos(self, utils_mock): - with mock.patch.object( - self.builder_class, 'build_ubuntu_repos') as build_ubuntu_mock: - with mock.patch.object( - self.builder_class, - 'build_centos_repos') as build_centos_mock: - self.builder.build_repos() - - utils_mock.create_dir.assert_called_once_with( - self.builder.build_src_dir) - utils_mock.copy_files_in_dir.assert_called_once_with( - '/tmp/fuel_plugin/*', - self.builder.build_src_dir) - build_centos_mock.assert_called_once_with([]) - build_ubuntu_mock.assert_called_once_with([ - '/tmp/fuel_plugin/.build/src/repository_path']) - - @mock.patch('fuel_plugin_builder.actions.build.utils') - def test_build_ubuntu_repos(self, utils_mock): - path = '/repo/path' - self.builder.build_ubuntu_repos([path]) - utils_mock.exec_piped_cmds.assert_called_once_with( - ['dpkg-scanpackages -m .', 'gzip -c9 > Packages.gz'], - cwd=path) - - @mock.patch('fuel_plugin_builder.actions.build.utils') - def test_build_centos_repos(self, utils_mock): - path = '/repo/path' - self.builder.build_centos_repos([path]) - utils_mock.create_dir.assert_called_once_with( - '/repo/path/Packages') - utils_mock.move_files_in_dir.assert_called_once_with( - '/repo/path/*.rpm', '/repo/path/Packages') - utils_mock.exec_cmd.assert_called_once_with( - 'createrepo -o /repo/path /repo/path') - - @mock.patch.object(BaseBuildPlugin, '_check_requirements') - @mock.patch.object(BaseBuildPlugin, '_check_structure') - def test_check(self, check_structure_mock, check_requirements_mock): - self.builder.check() - check_structure_mock.assert_called_once_with() - check_requirements_mock.assert_called_once_with() - - @mock.patch('fuel_plugin_builder.actions.build.utils.which', - return_value=True) - def test_check_requirements(self, _): - self.builder._check_requirements() - - @mock.patch('fuel_plugin_builder.actions.build.ValidatorManager') - def test_check_structure(self, manager_class_mock): - validator_manager_obj = mock.MagicMock() - manager_class_mock.return_value = validator_manager_obj - validator_mock = mock.MagicMock() - validator_manager_obj.get_validator.return_value = validator_mock - - self.builder._check_structure() - - manager_class_mock.assert_called_once_with(self.plugin_path) - validator_manager_obj.get_validator.assert_called_once_with() - validator_mock.validate.assert_called_once_with() - - @mock.patch( - 'fuel_plugin_builder.actions.build.utils.create_checksums_file') - def test_add_checksums_file(self, create_checksums_file_mock): - self.builder.add_checksums_file() - create_checksums_file_mock.assert_called_once_with( - self.builder.build_src_dir, self.builder.checksums_path) - - @mock.patch('fuel_plugin_builder.actions.build.utils') - def test_clean(self, utils_mock): - self.builder.clean() - utils_mock.assert_has_calls([ - mock.call.remove(self.builder.build_dir), - mock.call.create_dir(self.builder.build_dir), - mock.call.remove_by_mask(self.builder.result_package_mask)]) - - -class TestBaseBuildV1(BaseBuild): - - __test__ = True - builder_class = BuildPluginV1 - - meta = { - 'releases': BaseBuild.releases, - 'version': '1.2.3', - 'name': 'plugin_name' - } - - @mock.patch('fuel_plugin_builder.actions.build.utils') - def test_make_package(self, utils_mock): - self.builder.make_package() - tar_path = '/tmp/fuel_plugin/plugin_name-1.2.3.fp' - - utils_mock.make_tar_gz.assert_called_once_with( - self.builder.build_src_dir, - tar_path, - 'plugin_name-1.2.3') - - @mock.patch('fuel_plugin_builder.actions.build.utils.which', - return_value=False) - def test_check_requirements_raises_error(self, _): - self.assertRaisesRegexp( - errors.FuelCannotFindCommandError, - 'Cannot find commands "rpm, createrepo, dpkg-scanpackages", ' - 'install required commands and try again', - self.builder._check_requirements) - - -class TestBaseBuildV2(BaseBuild): - - __test__ = True - builder_class = BuildPluginV2 - meta = { - 'releases': BaseBuild.releases, - 'version': '1.2.3', - 'name': 'plugin_name', - 'title': 'Plugin title', - 'description': 'Description', - 'licenses': ['Apache', 'BSD'], - 'authors': ['author1', 'author2'], - 'homepage': 'url' - } - - def path_from_plugin(self, plugin_path, path): - return join_path(plugin_path, path) - - @mock.patch('fuel_plugin_builder.actions.build.utils') - def check_make_package(self, builder, plugin_path, utils_mock): - plugin_path = plugin_path - - utils_mock.get_current_year.return_value = '2014' - builder.make_package() - rpm_src_path = self.path_from_plugin(plugin_path, - '.build/rpm/SOURCES') - utils_mock.create_dir.assert_called_once_with(rpm_src_path) - - fp_dst = self.path_from_plugin( - plugin_path, '.build/rpm/SOURCES/plugin_name-1.2.fp') - - utils_mock.make_tar_gz.assert_called_once_with( - self.path_from_plugin(plugin_path, '.build/src'), - fp_dst, - 'plugin_name-1.2') - - spec_src = os.path.abspath(join_path( - os.path.dirname(__file__), '..', - self.builder.rpm_spec_src_path)) - utils_mock.render_to_file.assert_called_once_with( - spec_src, - join_path(plugin_path, '.build/rpm/plugin_rpm.spec'), - {'vendor': 'author1, author2', - 'description': 'Description', - 'license': 'Apache and BSD', - 'summary': 'Plugin title', - 'version': '1.2.3', - 'homepage': 'url', - 'name': 'plugin_name-1.2', - 'year': '2014'}) - - utils_mock.exec_cmd.assert_called_once_with( - 'rpmbuild -vv --nodeps --define "_topdir {0}" -bb ' - '{1}'.format( - self.path_from_plugin(plugin_path, '.build/rpm'), - self.path_from_plugin(plugin_path, - '.build/rpm/plugin_rpm.spec'))) - - utils_mock.copy_files_in_dir.assert_called_once_with( - self.path_from_plugin(plugin_path, - '.build/rpm/RPMS/noarch/*.rpm'), - plugin_path - ) - - def test_make_package(self): - self.check_make_package(self.builder, self.plugin_path) - - def test_make_package_with_non_ascii_chars_in_path(self): - plugin_path = '/tmp/тест/' + self.plugins_name - - builder = self.create_builder(plugin_path) - - self.check_make_package(builder, plugin_path) - - @mock.patch('fuel_plugin_builder.actions.build.utils.which', - return_value=False) - def test_check_requirements_raises_error(self, _): - self.assertRaisesRegexp( - errors.FuelCannotFindCommandError, - 'Cannot find commands "rpmbuild, rpm, createrepo, ' - 'dpkg-scanpackages", install required commands and try again', - self.builder._check_requirements) - - @mock.patch('fuel_plugin_builder.actions.build.utils') - def test_build_ubuntu_repos(self, utils_mock): - path = '/repo/path' - self.builder.build_ubuntu_repos([path]) - utils_mock.exec_piped_cmds.assert_called_once_with( - ['dpkg-scanpackages -m .', 'gzip -c9 > Packages.gz'], - cwd=path) - release_src = os.path.abspath(join_path( - os.path.dirname(__file__), '..', - self.builder.release_tmpl_src_path)) - utils_mock.render_to_file.assert_called_once_with( - release_src, - '/repo/path/Release', - {'major_version': '1.2', - 'plugin_name': 'plugin_name'}) - - -class TestBaseBuildV3(BaseBuild): - - __test__ = True - builder_class = BuildPluginV3 - meta = { - 'releases': BaseBuild.releases, - 'version': '1.2.3', - 'name': 'plugin_name', - 'title': 'Plugin title', - 'description': 'Description', - 'licenses': ['Apache', 'BSD'], - 'authors': ['author1', 'author2'], - 'homepage': 'url' - } - - def path_from_plugin(self, path): - return join_path(self.plugin_path, path) - - @mock.patch('fuel_plugin_builder.actions.build.utils') - def _test_make_package(self, utils_mock): - utils_mock.get_current_year.return_value = '2014' - utils_mock.read_if_exist.side_effect = ['echo uninst', 'echo preinst', - 'echo postinst'] - self.builder.make_package() - rpm_src_path = self.path_from_plugin('.build/rpm/SOURCES') - utils_mock.create_dir.assert_called_once_with(rpm_src_path) - - fp_dst = self.path_from_plugin('.build/rpm/SOURCES/plugin_name-1.2.fp') - utils_mock.make_tar_gz.assert_called_once_with( - self.path_from_plugin('.build/src'), - fp_dst, - 'plugin_name-1.2') - - utils_mock.exec_cmd.assert_called_once_with( - 'rpmbuild -vv --nodeps --define "_topdir {0}" -bb ' - '{1}'.format( - self.path_from_plugin('.build/rpm'), - self.path_from_plugin('.build/rpm/plugin_rpm.spec'))) - - utils_mock.copy_files_in_dir.assert_called_once_with( - self.path_from_plugin('.build/rpm/RPMS/noarch/*.rpm'), - self.plugin_path) - - utils_mock.read_if_exist.assert_has_calls([ - mock.call(self.path_from_plugin('uninstall.sh')), - mock.call(self.path_from_plugin('pre_install.sh')), - mock.call(self.path_from_plugin('post_install.sh'))]) - return utils_mock - - def test_make_package(self): - utils_mock = self._test_make_package() - spec_src = os.path.abspath(join_path( - os.path.dirname(__file__), '..', - self.builder.rpm_spec_src_path)) - - utils_mock.render_to_file.assert_called_once_with( - spec_src, - join_path(self.plugin_path, '.build/rpm/plugin_rpm.spec'), - {'vendor': 'author1, author2', - 'description': 'Description', - 'license': 'Apache and BSD', - 'summary': 'Plugin title', - 'version': '1.2.3', - 'homepage': 'url', - 'name': 'plugin_name-1.2', - 'year': '2014', - 'preinstall_hook': 'echo preinst', - 'postinstall_hook': 'echo postinst', - 'uninstall_hook': 'echo uninst', - 'build_version': '1'}) - - def test_make_package_with_build_version(self): - - meta = { - 'releases': BaseBuild.releases, - 'version': '1.2.3', - 'name': 'plugin_name', - 'title': 'Plugin title', - 'description': 'Description', - 'licenses': ['Apache', 'BSD'], - 'authors': ['author1', 'author2'], - 'homepage': 'url', - 'build_version': '34' - } - - self.builder = self.create_builder(self.plugin_path, meta=meta) - utils_mock = self._test_make_package() - - spec_src = os.path.abspath(join_path( - os.path.dirname(__file__), '..', - self.builder.rpm_spec_src_path)) - - utils_mock.render_to_file.assert_called_once_with( - spec_src, - join_path(self.plugin_path, '.build/rpm/plugin_rpm.spec'), - {'vendor': 'author1, author2', - 'description': 'Description', - 'license': 'Apache and BSD', - 'summary': 'Plugin title', - 'version': '1.2.3', - 'homepage': 'url', - 'name': 'plugin_name-1.2', - 'year': '2014', - 'preinstall_hook': 'echo preinst', - 'postinstall_hook': 'echo postinst', - 'uninstall_hook': 'echo uninst', - 'build_version': '34'}) diff --git a/fuel_plugin_builder/tests/test_cli.py b/fuel_plugin_builder/tests/test_cli.py deleted file mode 100644 index 3294ee5..0000000 --- a/fuel_plugin_builder/tests/test_cli.py +++ /dev/null @@ -1,149 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2014 Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file 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. - -import mock - -from fuel_plugin_builder.cli import package_version_check -from fuel_plugin_builder.cli import perform_action -from fuel_plugin_builder.tests.base import BaseTestCase - - -class TestCli(BaseTestCase): - - @mock.patch('fuel_plugin_builder.cli.actions') - def test_perform_action_create_with_package_version(self, actions_mock): - args = mock.MagicMock(create='plugin_path', package_version='2.0.0') - creatre_obj = mock.MagicMock() - actions_mock.CreatePlugin.return_value = creatre_obj - - perform_action(args) - - actions_mock.CreatePlugin.assert_called_once_with( - 'plugin_path', - '2.0.0') - creatre_obj.run.assert_called_once_with() - - @mock.patch('fuel_plugin_builder.cli.actions') - def test_perform_action_create_without_package_version(self, actions_mock): - args = mock.MagicMock(create='plugin_path', package_version=None) - creatre_obj = mock.MagicMock() - actions_mock.CreatePlugin.return_value = creatre_obj - - perform_action(args) - - actions_mock.CreatePlugin.assert_called_once_with('plugin_path', None) - creatre_obj.run.assert_called_once_with() - - @mock.patch('fuel_plugin_builder.cli.actions.make_builder') - def test_perform_action_build(self, builder_mock): - args = mock.MagicMock( - create=None, - build='plugin_path') - build_obj = mock.MagicMock() - builder_mock.return_value = build_obj - - perform_action(args) - - builder_mock.assert_called_once_with('plugin_path') - build_obj.run.assert_called_once_with() - - @mock.patch('fuel_plugin_builder.cli.ValidatorManager') - def test_perform_check(self, validator_mock): - args = mock.MagicMock( - create=None, - build=None, - check='plugin_path') - build_obj = mock.MagicMock() - validator_mock.BuildPlugin.return_value = build_obj - - perform_action(args) - - validator_mock.assert_called_once_with('plugin_path') - - def test_package_version_check_with_create_and_version(self): - args = mock.MagicMock( - create='plugin_path', - package_version='2.0.0', - build=None, - check=None) - - parser = mock.MagicMock() - - package_version_check(args, parser) - self.method_was_not_called(parser.error) - - def test_package_version_check_with_create_and_without_version(self): - args = mock.MagicMock( - create='plugin_path', - package_version=None, - build=None, - check=None) - - parser = mock.MagicMock() - - package_version_check(args, parser) - self.method_was_not_called(parser.error) - - def test_package_version_check_with_build_and_version(self): - args = mock.MagicMock( - create=None, - package_version='2.0.0', - build='plugin_path', - check=None) - - parser = mock.MagicMock() - - package_version_check(args, parser) - parser.error.assert_called_with( - '--package-version works only with --create') - - def test_package_version_check_with_build_and_without_version(self): - args = mock.MagicMock( - create=None, - package_version=None, - build='plugin_path', - check=None) - - parser = mock.MagicMock() - - package_version_check(args, parser) - self.method_was_not_called(parser.error) - - def test_package_version_check_with_check_and_version(self): - args = mock.MagicMock( - create=None, - package_version='2.0.0', - build=None, - check='plugin_path') - - parser = mock.MagicMock() - - package_version_check(args, parser) - - parser.error.assert_called_with( - '--package-version works only with --create') - - def test_package_version_check_with_check_and_without_version(self): - args = mock.MagicMock( - create=None, - package_version=None, - build=None, - check='plugin_path') - - parser = mock.MagicMock() - - package_version_check(args, parser) - self.method_was_not_called(parser.error) diff --git a/fuel_plugin_builder/tests/test_create.py b/fuel_plugin_builder/tests/test_create.py deleted file mode 100644 index a907d14..0000000 --- a/fuel_plugin_builder/tests/test_create.py +++ /dev/null @@ -1,66 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2014 Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file 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. - -import mock - -from fuel_plugin_builder.actions import CreatePlugin -from fuel_plugin_builder import errors -from fuel_plugin_builder import messages -from fuel_plugin_builder.tests.base import BaseTestCase - - -class TestCreate(BaseTestCase): - - def setUp(self): - self.plugins_name = 'fuel_plugin' - self.plugin_path = '/tmp/{0}'.format(self.plugins_name) - self.template_dir = '/temp_dir' - self.creator = CreatePlugin(self.plugin_path) - self.creator.template_dir = self.template_dir - - @mock.patch('fuel_plugin_builder.actions.create.utils.exists', - return_value=False) - def test_check(self, exists_mock): - self.creator.check() - exists_mock.assert_called_once_with(self.plugin_path) - - @mock.patch('fuel_plugin_builder.actions.create.utils.exists', - return_value=True) - def test_check_when_plugin_exists_with_same_name(self, exists_mock): - self.assertRaisesRegexp( - errors.PluginDirectoryExistsError, - 'Plugins directory {0} already exists, ' - 'choose another name'.format(self.plugin_path), - self.creator.check) - exists_mock.assert_called_once_with(self.plugin_path) - - @mock.patch('fuel_plugin_builder.actions.create.utils.exists', - return_value=False) - def test_check_with_invalid_name(self, exists_mock): - self.creator.plugin_name = 'Test_plugin' - self.assertRaisesRegexp( - errors.ValidationError, - messages.PLUGIN_WRONG_NAME_EXCEPTION_MESSAGE, - self.creator.check) - exists_mock.assert_called_once_with(self.plugin_path) - - @mock.patch.object(CreatePlugin, 'check') - @mock.patch('fuel_plugin_builder.actions.create.utils') - def test_run(self, utils_mock, _): - self.creator.run() - utils_mock.render_files_in_dir( - self.template_dir, - self.creator.render_ctx) diff --git a/fuel_plugin_builder/tests/test_utils.py b/fuel_plugin_builder/tests/test_utils.py deleted file mode 100644 index 8f46830..0000000 --- a/fuel_plugin_builder/tests/test_utils.py +++ /dev/null @@ -1,374 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2014 Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file 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. - -import os -import shutil -import subprocess -import tempfile - -import mock -from mock import patch - -from fuel_plugin_builder import errors -from fuel_plugin_builder.tests.base import BaseTestCase -from fuel_plugin_builder.tests.base import FakeFile -from fuel_plugin_builder import utils - - -class TestUtils(BaseTestCase): - - @mock.patch('fuel_plugin_builder.utils.os.path.isfile', return_value=True) - @mock.patch('fuel_plugin_builder.utils.os.access', return_value=True) - def test_is_executable_returns_true(self, access_mock, isfile_mock): - file_name = 'file_name' - self.assertTrue(utils.is_executable(file_name)) - isfile_mock.assert_called_once_with(file_name) - access_mock.assert_called_once_with(file_name, os.X_OK) - - @mock.patch('fuel_plugin_builder.utils.os.path.isfile', return_value=True) - @mock.patch('fuel_plugin_builder.utils.os.access', return_value=False) - def test_is_executable_returns_false(self, access_mock, isfile_mock): - file_name = 'file_name' - self.assertFalse(utils.is_executable(file_name)) - isfile_mock.assert_called_once_with(file_name) - access_mock.assert_called_once_with(file_name, os.X_OK) - - @mock.patch('fuel_plugin_builder.utils.os') - @mock.patch('fuel_plugin_builder.utils.is_executable', return_value=True) - def test_which_returns_for_absolute_path_exec(self, _, os_mock): - path = '/usr/bin/some_exec' - os_mock.path.split.return_value = ('/usr/bin/', 'some_exec') - self.assertEqual(utils.which(path), path) - - @mock.patch('fuel_plugin_builder.utils.is_executable', - side_effect=[False, True]) - def test_which_returns_if_exec_in_env_path(self, _): - # some_exec is in /bin directory - path = 'some_exec' - with patch.dict('os.environ', {'PATH': '/usr/bin:/bin'}): - self.assertEqual(utils.which(path), '/bin/some_exec') - - @mock.patch('fuel_plugin_builder.utils.is_executable', return_value=False) - def test_which_returns_none(self, _): - with patch.dict('os.environ', {'PATH': '/usr/bin:/bin'}): - self.assertIsNone(utils.which('some_exec')) - - def make_process_mock(self, return_code=0): - process_mock = mock.Mock( - communicate=mock.Mock(return_value=('stdout', 'stderr'))) - process_mock.stdout = ['Stdout line 1', 'Stdout line 2'] - process_mock.returncode = return_code - - return process_mock - - def test_exec_cmd_raises_error_in_case_of_non_zero_exit_code(self): - cmd = 'some command' - return_code = 1 - - process_mock = self.make_process_mock(return_code=return_code) - with patch.object(subprocess, 'Popen', return_value=process_mock): - self.assertRaisesRegexp( - errors.ExecutedErrorNonZeroExitCode, - 'Shell command executed with "{0}" ' - 'exit code: {1} '.format(return_code, cmd), - utils.exec_cmd, cmd) - - def test_exec_piped_cmds_raises_error_in_case_of_non_zero_exit_code(self): - cmds = ['some command', 'some other command'] - return_code = 1 - - process_mock = self.make_process_mock(return_code=return_code) - with patch.object(subprocess, 'Popen', return_value=process_mock): - self.assertRaisesRegexp( - errors.ExecutedErrorNonZeroExitCode, - 'Shell command executed with "{0}" ' - 'exit code: {1} '.format(return_code, " | ".join(cmds)), - utils.exec_piped_cmds, cmds) - - def test_exec_cmd(self): - process_mock = self.make_process_mock(return_code=0) - with patch.object(subprocess, 'Popen', return_value=process_mock): - utils.exec_cmd('some command') - process_mock.wait.assert_called_once_with() - - def test_exec_piped_cmds(self): - process_mock = self.make_process_mock(return_code=0) - with patch.object(subprocess, 'Popen', return_value=process_mock): - utils.exec_piped_cmds(['some command', 'some other command']) - process_mock.communicate.assert_called_with(input='stdout') - - @mock.patch('fuel_plugin_builder.utils.os') - def test_create_dir(self, os_mock): - path = '/dir/path' - os_mock.path.isdir.return_value = False - utils.create_dir(path) - os_mock.path.isdir.assert_called_once_with(path) - os_mock.makedirs.assert_called_once_with(path) - - @mock.patch('fuel_plugin_builder.utils.os') - def test_create_dir_dont_create_if_created(self, os_mock): - path = '/dir/path' - os_mock.path.isdir.return_value = True - utils.create_dir(path) - os_mock.path.isdir.assert_called_once_with(path) - self.method_was_not_called(os_mock.makedirs) - - @mock.patch('fuel_plugin_builder.utils.os.path.lexists', return_value=True) - def test_exists(self, os_exists): - file_path = '/dir/path' - self.assertTrue(utils.exists(file_path)) - os_exists.assert_called_once_with(file_path) - - @mock.patch('fuel_plugin_builder.utils.os.path.lexists', - return_value=False) - def test_exists_returns_false(self, os_exists): - file_path = '/dir/path' - self.assertFalse(utils.exists(file_path)) - os_exists.assert_called_once_with(file_path) - - @mock.patch('fuel_plugin_builder.utils.os.path.basename') - def test_basename(self, base_mock): - path = 'some_path' - base_mock.return_value = path - self.assertEqual(utils.basename(path), path) - base_mock.assert_called_once_with(path) - - @mock.patch('fuel_plugin_builder.utils.shutil') - def test_copy_file_permissions(self, shutil_mock): - utils.copy_file_permissions('src', 'dst') - shutil_mock.copymode.assert_called_once_with('src', 'dst') - - @mock.patch('fuel_plugin_builder.utils.shutil') - @mock.patch('fuel_plugin_builder.utils.os') - def test_remove_file(self, os_mock, shutil_mock): - path = 'file_for_removing' - os_mock.path.isdir.return_value = False - utils.remove(path) - os_mock.remove.assert_called_once_with(path) - self.method_was_not_called(shutil_mock.rmtree) - - @mock.patch('fuel_plugin_builder.utils.shutil') - @mock.patch('fuel_plugin_builder.utils.os') - def test_remove_dir(self, os_mock, shutil_mock): - path = 'dir_for_removing' - os_mock.path.isdir.return_value = True - os_mock.path.islink.return_value = False - utils.remove(path) - shutil_mock.rmtree.assert_called_once_with(path) - self.method_was_not_called(os_mock.remove) - - @mock.patch('fuel_plugin_builder.utils.dir_util') - @mock.patch('fuel_plugin_builder.utils.shutil') - @mock.patch('fuel_plugin_builder.utils.os') - def test_copy_file(self, os_mock, shutil_mock, dir_util_mock): - src = '/tmp/soruce_file' - dst = '/tmp/destination_file' - os_mock.path.isdir.return_value = False - utils.copy(src, dst) - shutil_mock.copy.assert_called_once_with(src, dst) - self.method_was_not_called(dir_util_mock.copy_tree) - - @mock.patch('fuel_plugin_builder.utils.dir_util') - @mock.patch('fuel_plugin_builder.utils.shutil') - @mock.patch('fuel_plugin_builder.utils.os') - def test_copy_dir(self, os_mock, shutil_mock, dir_util_mock): - src = '/tmp/soruce_file' - dst = '/tmp/destination_file' - os_mock.path.isdir.return_value = True - utils.copy(src, dst) - dir_util_mock.copy_tree.assert_called_once_with( - src, - dst, - preserve_symlinks=True) - self.method_was_not_called(shutil_mock.copy) - - @mock.patch('fuel_plugin_builder.utils.copy') - @mock.patch('fuel_plugin_builder.utils.glob', - return_value=['file1', 'file2']) - def test_copy_files_in_dir(self, glob_mock, copy_mock): - mask = 'file*' - dst_dir = '/tmp' - utils.copy_files_in_dir(mask, dst_dir) - glob_mock.assert_called_once_with(mask) - self.assertEqual( - copy_mock.call_args_list, - [mock.call('file1', '/tmp/file1'), - mock.call('file2', '/tmp/file2')]) - - @mock.patch('fuel_plugin_builder.utils.tarfile') - def test_make_tar_gz(self, tarfile_mock): - src = 'dir' - dst = '/tmp/file.fp' - prefix = 'prefix_dir' - tar_mock = mock.MagicMock() - tarfile_mock.open.return_value = tar_mock - utils.make_tar_gz(src, dst, prefix) - tarfile_mock.open.assert_called_once_with(dst, 'w:gz') - tar_mock.add.assert_called_once_with(src, arcname=prefix) - tar_mock.close.assert_called_once_with() - - @mock.patch('fuel_plugin_builder.utils.shutil.move') - @mock.patch('fuel_plugin_builder.utils.glob', - return_value=['file1', 'file2']) - def test_move_files_in_dir(self, glob_mock, move_mock): - mask = 'file*' - dst_dir = '/tmp' - utils.move_files_in_dir(mask, dst_dir) - glob_mock.assert_called_once_with(mask) - self.assertEqual( - move_mock.call_args_list, - [mock.call('file1', '/tmp/file1'), - mock.call('file2', '/tmp/file2')]) - - @mock.patch('__builtin__.open') - @mock.patch('fuel_plugin_builder.utils.yaml') - def test_parse_yaml(self, yaml_mock, open_mock): - path = '/tmp/path' - file_mock = mock.MagicMock() - open_mock.return_value = file_mock - utils.parse_yaml(path) - open_mock.assert_called_once_with(path) - yaml_mock.load.assert_called_once_with(file_mock) - - def test_render_to_file_unicode_handling(self): - expected = u'тест' - params = {'vendors': expected} - template_content = "${vendors}" - - temp_dir = tempfile.mkdtemp() - self.addCleanup(shutil.rmtree, temp_dir) - - src_file = os.path.join(temp_dir, 'test_template') - dst_file = os.path.join(temp_dir, 'test_rendered') - - with open(src_file, 'w') as f: - f.write(template_content) - - utils.render_to_file(src=src_file, dst=dst_file, params=params) - - with open(dst_file, 'rb') as f: - actual = f.read() - self.assertEqual(expected, actual.decode('utf-8')) - - @mock.patch('fuel_plugin_builder.utils.copy_file_permissions') - @mock.patch('fuel_plugin_builder.utils.render_to_file') - @mock.patch('fuel_plugin_builder.utils.remove') - @mock.patch('fuel_plugin_builder.utils.os.walk') - def test_render_files_in_dir( - self, walk_mock, remove_mock, render_mock, copy_permissions_mock): - dir_path = '/tmp/some_plugin' - walk_mock.return_value = [ - [dir_path, '', ['file1.txt.mako', 'file2.txt']], - [dir_path, '', ['file3', 'file4.mako']]] - params = {'param1': 'value1', 'param2': 'value2'} - - utils.render_files_in_dir(dir_path, params) - - self.assertEqual( - [mock.call('/tmp/some_plugin/file1.txt.mako', - '/tmp/some_plugin/file1.txt', - params), - mock.call('/tmp/some_plugin/file4.mako', - '/tmp/some_plugin/file4', - params)], - render_mock.call_args_list) - - self.assertEqual( - [mock.call('/tmp/some_plugin/file1.txt.mako'), - mock.call('/tmp/some_plugin/file4.mako')], - remove_mock.call_args_list) - - self.assertEqual( - [mock.call('/tmp/some_plugin/file1.txt.mako', - '/tmp/some_plugin/file1.txt'), - mock.call('/tmp/some_plugin/file4.mako', - '/tmp/some_plugin/file4')], - copy_permissions_mock.call_args_list) - - def test_calculate_sha(self): - file_path = '/tmp/file' - - with mock.patch('__builtin__.open', - self.mock_open('fake file content')): - - self.assertEqual( - utils.calculate_sha(file_path), - '5083c27641e7e4ae287d690cb3fafb4dd6e8f6ab') - - @mock.patch('fuel_plugin_builder.utils.calculate_sha') - @mock.patch('fuel_plugin_builder.utils.os.walk') - def test_calculate_checksums(self, walk_mock, sha_mock): - dir_path = '/tmp/dir_path' - walk_mock.return_value = [ - [dir_path, '', ['file1.txt', 'file2.txt']], - [dir_path, '', ['file3.txt']]] - - sha_mock.side_effect = ['sha_1', 'sha_2', 'sha_3'] - - self.assertEqual( - utils.calculate_checksums(dir_path), - [{'file_path': 'file1.txt', 'checksum': 'sha_1'}, - {'file_path': 'file2.txt', 'checksum': 'sha_2'}, - {'file_path': 'file3.txt', 'checksum': 'sha_3'}]) - - self.assertEqual( - [mock.call('/tmp/dir_path/file1.txt'), - mock.call('/tmp/dir_path/file2.txt'), - mock.call('/tmp/dir_path/file3.txt')], - sha_mock.call_args_list) - - @mock.patch('fuel_plugin_builder.utils.calculate_checksums') - def test_create_checksums_file(self, calculate_mock): - calculate_mock.return_value = [ - {'checksum': 'checksum2', 'file_path': 'file2.txt'}, - {'checksum': 'checksum', 'file_path': 'file1.txt'}] - - fileobj = FakeFile('') - open_mock = mock.MagicMock(return_value=fileobj) - - with mock.patch('__builtin__.open', open_mock): - utils.create_checksums_file('/tmp/dir', '/tmp/checksums') - - self.assertEqual( - fileobj.getvalue(), - 'checksum file1.txt\nchecksum2 file2.txt\n') - - @mock.patch('fuel_plugin_builder.utils.remove') - @mock.patch('fuel_plugin_builder.utils.glob', - return_value=['file1', 'file2']) - def test_remove_by_mask(self, glob_mock, remove_mock): - mask = '/tmp/test/*.yaml' - utils.remove_by_mask(mask) - glob_mock.assert_called_once_with(mask) - self.assertEqual( - remove_mock.call_args_list, - [mock.call('file1'), mock.call('file2')]) - - @mock.patch('fuel_plugin_builder.utils.exists', - return_value=True) - def test_read_if_exist(self, utils_exists): - file_path = '/tmp/file' - with mock.patch('__builtin__.open', self.mock_open("foo")): - self.assertEqual(utils.read_if_exist(file_path), "foo") - utils_exists.assert_called_once_with(file_path) - - @mock.patch('fuel_plugin_builder.utils.exists', - return_value=False) - def test_read_if_exist_returns_empty(self, utils_exists): - file_path = '/tmp/file' - with mock.patch('__builtin__.open', self.mock_open("foo")): - self.assertEqual(utils.read_if_exist(file_path), "") - utils_exists.assert_called_once_with(file_path) diff --git a/fuel_plugin_builder/tests/test_validator_manager.py b/fuel_plugin_builder/tests/test_validator_manager.py deleted file mode 100644 index 6e19a98..0000000 --- a/fuel_plugin_builder/tests/test_validator_manager.py +++ /dev/null @@ -1,39 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2014 Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file 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. - -import mock - -from fuel_plugin_builder.tests.base import BaseTestCase -from fuel_plugin_builder.validators import ValidatorManager - - -class TestValidatorManager(BaseTestCase): - - def setUp(self): - self.plugin_path = '/tmp/plugin_path' - - def test_get_validator(self): - validator = mock.MagicMock(return_value='test') - - with mock.patch( - 'fuel_plugin_builder.validators.manager.' - 'version_mapping.get_version_mapping_from_plugin', - return_value={'validator': validator}): - self.assertEqual( - ValidatorManager(self.plugin_path).get_validator(), - 'test') - - validator.assert_called_once_with(self.plugin_path) diff --git a/fuel_plugin_builder/tests/test_validator_v1.py b/fuel_plugin_builder/tests/test_validator_v1.py deleted file mode 100644 index 5e40b95..0000000 --- a/fuel_plugin_builder/tests/test_validator_v1.py +++ /dev/null @@ -1,82 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2015 Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file 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. - -import mock - -from fuel_plugin_builder import errors -from fuel_plugin_builder.tests.base import LegacyBaseValidatorTestCase -from fuel_plugin_builder.validators.schemas.v1 import SchemaV1 -from fuel_plugin_builder.validators.validator_v1 import ValidatorV1 - - -class TestValidatorV1(LegacyBaseValidatorTestCase): - - __test__ = True - validator_class = ValidatorV1 - schema_class = SchemaV1 - - @mock.patch('fuel_plugin_builder.validators.validator_v1.utils') - def test_check_tasks(self, utils_mock): - mocked_methods = [ - 'validate_schema' - ] - self.mock_methods(self.validator, mocked_methods) - utils_mock.parse_yaml.return_value = [ - {'type': 'puppet', 'parameters': 'param1'}, - {'type': 'shell', 'parameters': 'param2'}] - - self.validator.check_tasks() - - self.assertEqual( - [mock.call('param1', self.schema_class().puppet_parameters, - self.validator.tasks_path, - value_path=[0, 'parameters']), - mock.call('param2', self.schema_class().shell_parameters, - self.validator.tasks_path, - value_path=[1, 'parameters'])], - self.validator.validate_schema.call_args_list) - - @mock.patch('fuel_plugin_builder.validators.validator_v1.utils') - def test_check_tasks_no_parameters_not_failed(self, utils_mock): - mocked_methods = [ - 'validate_schema' - ] - self.mock_methods(self.validator, mocked_methods) - utils_mock.parse_yaml.return_value = [ - {'type': 'puppet'}, - ] - - self.validator.check_tasks() - - self.assertEqual( - [mock.call(None, self.schema_class().puppet_parameters, - self.validator.tasks_path, - value_path=[0, 'parameters'])], - self.validator.validate_schema.call_args_list) - - @mock.patch('fuel_plugin_builder.validators.base.utils') - def test_check_compatibility(self, utils_mock): - utils_mock.parse_yaml.return_value = { - 'fuel_version': ['5.1', '6.0', '6.1'], - 'package_version': '1.0.0'} - - with self.assertRaisesRegexp( - errors.ValidationError, - 'Current plugin format 1.0.0 is not compatible with 5.1 Fuel' - ' release. Fuel version must be 6.0 or higher.' - ' Please remove 5.1 version from metadata.yaml file or' - ' downgrade package_version.'): - self.validator.check_compatibility() diff --git a/fuel_plugin_builder/tests/test_validator_v2.py b/fuel_plugin_builder/tests/test_validator_v2.py deleted file mode 100644 index 4843ad2..0000000 --- a/fuel_plugin_builder/tests/test_validator_v2.py +++ /dev/null @@ -1,86 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2015 Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file 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. - -import mock - -from fuel_plugin_builder import errors -from fuel_plugin_builder.tests.base import LegacyBaseValidatorTestCase -from fuel_plugin_builder.validators.schemas.v2 import SchemaV2 -from fuel_plugin_builder.validators.validator_v2 import ValidatorV2 - - -class TestValidatorV2(LegacyBaseValidatorTestCase): - - __test__ = True - validator_class = ValidatorV2 - schema_class = SchemaV2 - - @mock.patch('fuel_plugin_builder.validators.validator_v2.utils') - def test_check_tasks(self, utils_mock): - mocked_methods = [ - 'validate_schema' - ] - self.mock_methods(self.validator, mocked_methods) - utils_mock.parse_yaml.return_value = [ - {'type': 'puppet', 'parameters': 'param1'}, - {'type': 'shell', 'parameters': 'param2'}, - {'type': 'reboot', 'parameters': 'param3'}] - - self.validator.check_tasks() - - self.assertEqual( - [mock.call('param1', self.schema_class().puppet_parameters, - self.validator.tasks_path, - value_path=[0, 'parameters']), - mock.call('param2', self.schema_class().shell_parameters, - self.validator.tasks_path, - value_path=[1, 'parameters']), - mock.call('param3', self.schema_class().reboot_parameters, - self.validator.tasks_path, - value_path=[2, 'parameters'])], - self.validator.validate_schema.call_args_list) - - @mock.patch('fuel_plugin_builder.validators.base.utils') - def test_check_compatibility(self, utils_mock): - utils_mock.parse_yaml.return_value = { - 'fuel_version': ['6.0', '6.1'], - 'package_version': '2.0.0'} - - with self.assertRaisesRegexp( - errors.ValidationError, - 'Current plugin format 2.0.0 is not compatible with 6.0 Fuel' - ' release. Fuel version must be 6.1 or higher.' - ' Please remove 6.0 version from metadata.yaml file or' - ' downgrade package_version.'): - self.validator.check_compatibility() - - @mock.patch('fuel_plugin_builder.validators.validator_v2.utils') - def test_check_tasks_no_parameters_not_failed(self, utils_mock): - mocked_methods = [ - 'validate_schema' - ] - self.mock_methods(self.validator, mocked_methods) - utils_mock.parse_yaml.return_value = [ - {'type': 'puppet'}, - ] - - self.validator.check_tasks() - - self.assertEqual( - [mock.call(None, self.schema_class().puppet_parameters, - self.validator.tasks_path, - value_path=[0, 'parameters'])], - self.validator.validate_schema.call_args_list) diff --git a/fuel_plugin_builder/tests/test_validator_v3.py b/fuel_plugin_builder/tests/test_validator_v3.py deleted file mode 100644 index f765edf..0000000 --- a/fuel_plugin_builder/tests/test_validator_v3.py +++ /dev/null @@ -1,637 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2015 Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file 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. - -import mock - -from fuel_plugin_builder import errors -from fuel_plugin_builder.tests.base import LegacyBaseValidatorTestCase -from fuel_plugin_builder.validators.schemas import SchemaV3 -from fuel_plugin_builder.validators.validator_v3 import ValidatorV3 - - -class TestValidatorV3(LegacyBaseValidatorTestCase): - - __test__ = True - validator_class = ValidatorV3 - schema_class = SchemaV3 - - def test_validate(self): - mocked_methods = [ - 'check_schemas', - 'check_tasks', - 'check_releases_paths', - 'check_compatibility', - 'check_deployment_tasks' - ] - self.check_validate(mocked_methods) - - @mock.patch('fuel_plugin_builder.validators.validator_v3.utils') - def test_check_tasks_schema_validation_failed(self, utils_mock, *args): - data_sets = [ - { - 'type': 'shell', - 'parameters': { - 'timeout': 3 - }, - 'stage': 'post_deployment', - 'role': '*' - }, - { - 'type': 'puppet', - 'parameters': { - 'timeout': 3 - }, - 'stage': 'post_deployment', - 'role': '*' - }, - { - 'type': 'puppet', - 'parameters': { - 'timeout': 3, - 'cmd': 'xx' - }, - 'stage': 'post_deployment', - 'role': '*' - }, - { - 'type': 'shell', - 'parameters': { - 'timeout': 3, - 'puppet_manifest': 'xx', - 'puppet_modules': 'yy', - }, - 'stage': 'post_deployment', - 'role': '*' - }, - { - 'type': 'puppet', - 'parameters': { - 'timeout': 3, - 'puppet_manifest': 'xx', - 'puppet_modules': 'yy', - 'retries': 'asd', - }, - 'stage': 'post_deployment', - 'role': '*' - }, - { - 'type': 'puppet', - 'parameters': { - 'timeout': 3, - 'puppet_manifest': 'xx', - 'puppet_modules': '', - 'retries': 1, - }, - 'stage': 'pre_deployment', - 'role': '*' - }, - { - 'type': 'puppet', - 'parameters': { - 'timeout': 3, - 'puppet_manifest': '', - 'puppet_modules': 'yy', - 'retries': 1, - }, - 'stage': 'pre_deployment', - 'role': '*' - } - ] - - for data in data_sets: - utils_mock.parse_yaml.return_value = [data] - self.assertRaises(errors.ValidationError, - self.validator.check_deployment_tasks) - - @mock.patch('fuel_plugin_builder.validators.validator_v3.utils') - def test_check_tasks_schema_validation_passed(self, utils_mock, *args): - data_sets = [ - [ - { - 'type': 'shell', - 'parameters': { - 'timeout': 3, - 'cmd': 'xx' - }, - 'stage': 'post_deployment', - 'role': '*' - }, - ], - [ - { - 'type': 'shell', - 'parameters': { - 'timeout': 3, - 'cmd': 'xx' - }, - 'stage': 'post_deployment', - 'role': '*' - }, - { - 'type': 'puppet', - 'parameters': { - 'timeout': 3, - 'puppet_manifest': 'xx', - 'puppet_modules': 'xxx' - }, - 'stage': 'post_deployment', - 'role': '*' - }, - ], - [ - { - 'type': 'shell', - 'parameters': { - 'timeout': 3, - 'cmd': 'reboot' - }, - 'stage': 'post_deployment', - 'role': '*' - }, - { - 'type': 'shell', - 'parameters': { - 'timeout': 3, - 'cmd': 'xx' - }, - 'stage': 'post_deployment', - 'role': '*' - }, - { - 'type': 'puppet', - 'parameters': { - 'timeout': 3, - 'puppet_manifest': 'xx', - 'puppet_modules': 'xxx' - }, - 'stage': 'post_deployment', - 'role': '*' - } - ], - [ - { - 'type': 'shell', - 'parameters': { - 'timeout': 3, - 'cmd': 'reboot' - }, - 'stage': 'post_deployment', - 'role': '*' - }, - { - 'type': 'shell', - 'parameters': { - 'timeout': 3, - 'puppet_manifest': 'xx', - 'puppet_modules': 'yy', - 'cmd': 'reboot' - }, - 'stage': 'post_deployment', - 'role': '*' - }, - { - 'type': 'puppet', - 'parameters': { - 'timeout': 3, - 'retries': 10, - 'puppet_manifest': 'xx', - 'puppet_modules': 'xxx' - }, - 'stage': 'post_deployment', - 'role': '*' - }, - { - 'type': 'puppet', - 'parameters': { - 'timeout': 3, - 'retries': 10, - 'puppet_manifest': 'xx', - 'puppet_modules': 'xxx' - }, - 'stage': 'post_deployment', - 'role': 'master' - }, - ] - ] - - for data in data_sets: - utils_mock.parse_yaml.return_value = data - self.validator.check_deployment_tasks() - - @mock.patch('fuel_plugin_builder.validators.validator_v3.utils') - @mock.patch('fuel_plugin_builder.validators.base.utils.exists') - def test_check_tasks_no_file(self, exists_mock, utils_mock, *args): - mocked_methods = ['validate_schema'] - self.mock_methods(self.validator, mocked_methods) - exists_mock.return_value = False - self.validator.check_deployment_tasks() - self.assertFalse(self.validator.validate_schema.called) - - def test_check_schemas(self): - mocked_methods = [ - 'check_env_config_attrs', - 'check_deployment_tasks_schema', - 'check_network_roles_schema', - 'check_node_roles_schema', - 'check_volumes_schema' - ] - self.mock_methods(self.validator, mocked_methods) - self.mock_methods(self.validator, ['validate_file_by_schema']) - self.validator.check_schemas() - - self.assertEqual( - [mock.call(self.schema_class().metadata_schema, - self.validator.meta_path), - mock.call(self.schema_class().tasks_schema, - self.validator.tasks_path, allow_not_exists=True)], - self.validator.validate_file_by_schema.call_args_list) - - for method in mocked_methods: - getattr(self.validator, method).assert_called_once_with() - - @mock.patch('fuel_plugin_builder.validators.base.utils') - def test_check_compatibility_failed(self, utils_mock): - fuel_version_checks = ( - (['6.0', '6.1', '7.0']), - (['6.1', '7.0']), - ) - - for fuel_version in fuel_version_checks: - mock_data = { - 'fuel_version': fuel_version, - 'package_version': '3.0.0'} - err_msg = 'Current plugin format 3.0.0 is not compatible with ' \ - '{0} Fuel release. Fuel version must be 7.0 or higher.' \ - ' Please remove {0} version from metadata.yaml file or' \ - ' downgrade package_version.'.format(fuel_version[0]) - - self.check_raised_exception( - utils_mock, mock_data, - err_msg, self.validator.check_compatibility) - - @mock.patch('fuel_plugin_builder.validators.base.utils') - def test_check_compatibility_passed(self, utils_mock): - utils_mock.parse_yaml.return_value = { - 'fuel_version': ['7.0'], - 'package_version': '3.0.0'} - self.validator.check_compatibility() - - @mock.patch('fuel_plugin_builder.validators.validator_v3.utils') - def test_role_attribute_is_required_for_deployment_task_types( - self, utils_mock, *args): - deployment_task_types = [ - 'group', 'shell', 'copy_files', 'sync', 'upload_file'] - - for task_type in deployment_task_types: - mock_data = [{ - 'id': 'plugin_name', - 'type': task_type}] - err_msg = "File '/tmp/plugin_path/deployment_tasks.yaml', " \ - "'role' is a required property, value path '0'" - self.check_raised_exception( - utils_mock, mock_data, - err_msg, self.validator.check_deployment_tasks) - - @mock.patch('fuel_plugin_builder.validators.validator_v3.utils') - def test_parameters_attribute_is_required_for_deployment_task_types( - self, utils_mock, *args): - deployment_task_types = ['copy_files', 'sync', 'upload_file'] - - for task_type in deployment_task_types: - mock_data = [{ - 'id': 'plugin_name', - 'type': task_type, - 'role': '*'}] - err_msg = "File '/tmp/plugin_path/deployment_tasks.yaml', " \ - "'parameters' is a required property, value path '0'" - self.check_raised_exception( - utils_mock, mock_data, - err_msg, self.validator.check_deployment_tasks) - - @mock.patch('fuel_plugin_builder.validators.validator_v3.utils') - def test_files_attribute_is_required_for_copy_files_task_type( - self, utils_mock, *args): - mock_data = [{ - 'id': 'plugin_name', - 'type': 'copy_files', - 'role': '*', - 'parameters': {}}] - err_msg = "File '/tmp/plugin_path/deployment_tasks.yaml', " \ - "'files' is a required property, value path '0 " \ - "-> parameters'" - self.check_raised_exception( - utils_mock, mock_data, - err_msg, self.validator.check_deployment_tasks) - - @mock.patch('fuel_plugin_builder.validators.validator_v3.utils') - def test_files_should_contain_at_least_one_item_for_copy_files_task_type( - self, utils_mock, *args): - mock_data = [{ - 'id': 'plugin_name', - 'type': 'copy_files', - 'role': '*', - 'parameters': {'files': []}}] - err_msg = "File '/tmp/plugin_path/deployment_tasks.yaml', " \ - "\[\] is too short, value path '0 -> parameters -> files'" - self.check_raised_exception( - utils_mock, mock_data, - err_msg, self.validator.check_deployment_tasks) - - @mock.patch('fuel_plugin_builder.validators.validator_v3.utils') - def test_src_and_dst_attributes_are_required_for_copy_files_task_type( - self, utils_mock, *args): - data_to_check = [ - ([{ - 'id': 'plugin_name', - 'type': 'copy_files', - 'role': '*', - 'parameters': { - 'files': [{}]} - }], 'src'), - ([{ - 'id': 'plugin_name', - 'type': 'copy_files', - 'role': '*', - 'parameters': { - 'files': [{'src': 'some_source'}]} - }], 'dst')] - - for mock_data, key in data_to_check: - err_msg = "File '/tmp/plugin_path/deployment_tasks.yaml', " \ - "'{0}' is a required property, value path '0 " \ - "-> parameters -> files -> 0'".format(key) - self.check_raised_exception( - utils_mock, mock_data, - err_msg, self.validator.check_deployment_tasks) - - @mock.patch('fuel_plugin_builder.validators.validator_v3.utils') - def test_src_and_dst_attributes_are_required_for_sync_task_type( - self, utils_mock, *args): - data_to_check = [ - ([{ - 'id': 'plugin_name', - 'type': 'sync', - 'role': '*', - 'parameters': {} - }], 'src'), - ([{ - 'id': 'plugin_name', - 'type': 'sync', - 'role': '*', - 'parameters': {'src': 'some_source'} - }], 'dst')] - - for mock_data, key in data_to_check: - err_msg = "File '/tmp/plugin_path/deployment_tasks.yaml', " \ - "'{0}' is a required property, value path '0 " \ - "-> parameters'".format(key) - self.check_raised_exception( - utils_mock, mock_data, - err_msg, self.validator.check_deployment_tasks) - - @mock.patch('fuel_plugin_builder.validators.validator_v3.utils') - def test_path_and_data_attributes_are_required_for_upload_file_task_type( - self, utils_mock, *args): - data_to_check = [ - ([{ - 'id': 'plugin_name', - 'type': 'upload_file', - 'role': '*', - 'parameters': {} - }], 'path'), - ([{ - 'id': 'plugin_name', - 'type': 'upload_file', - 'role': '*', - 'parameters': {'path': 'some_path'} - }], 'data')] - - for mock_data, key in data_to_check: - err_msg = "File '/tmp/plugin_path/deployment_tasks.yaml', " \ - "'{0}' is a required property, value path '0 " \ - "-> parameters'".format(key) - self.check_raised_exception( - utils_mock, mock_data, - err_msg, self.validator.check_deployment_tasks) - - @mock.patch('fuel_plugin_builder.validators.validator_v3.utils') - def test_check_group_type_deployment_task_does_not_contain_manifests( - self, utils_mock, *args): - utils_mock.parse_yaml.return_value = [{ - 'id': 'plugin_name', - 'type': 'group', - 'role': ['plugin_name'], - 'parameters': {}}] - - self.validator.check_deployment_tasks() - - @mock.patch('fuel_plugin_builder.validators.validator_v3.utils') - def test_check_deployment_task_role_failed(self, utils_mock, *args): - mock_data = [{ - 'id': 'plugin_name', - 'type': 'group', - 'role': ['plugin_n@me']}] - err_msg = "File '/tmp/plugin_path/deployment_tasks.yaml'," \ - " 'plugin_n@me' does not match" - self.check_raised_exception( - utils_mock, mock_data, - err_msg, self.validator.check_deployment_tasks) - - @mock.patch('fuel_plugin_builder.validators.validator_v3.utils') - def test_check_deployment_task_role(self, utils_mock, *args): - utils_mock.parse_yaml.return_value = [ - {'id': 'plugin_name', 'type': 'group', 'role': []}, - {'id': 'plugin_name', 'type': 'group', 'role': ['a', 'b']}, - {'id': 'plugin_name', 'type': 'group', 'role': '*'}, - {'id': 'plugin_name', 'type': 'puppet', 'role': []}, - {'id': 'plugin_name', 'type': 'puppet', 'role': ['a', 'b']}, - {'id': 'plugin_name', 'type': 'puppet', 'role': '*'}, - {'id': 'plugin_name', 'type': 'shell', 'role': []}, - {'id': 'plugin_name', 'type': 'shell', 'role': ['a', 'b']}, - {'id': 'plugin_name', 'type': 'shell', 'role': '*'}, - {'id': 'plugin_name', 'type': 'skipped'}, - {'id': 'plugin_name', 'type': 'stage'}, - {'id': 'plugin_name', 'type': 'reboot'}, - { - 'id': 'plugin_name', - 'type': 'copy_files', - 'role': '*', - 'parameters': { - 'files': [ - {'src': 'some_source', 'dst': 'some_destination'}]} - }, - { - 'id': 'plugin_name', - 'type': 'sync', - 'role': '*', - 'parameters': { - 'src': 'some_source', 'dst': 'some_destination'} - }, - { - 'id': 'plugin_name', - 'type': 'upload_file', - 'role': '*', - 'parameters': { - 'path': 'some_path', 'data': 'some_data'} - }, - ] - - self.validator.check_deployment_tasks() - - @mock.patch('fuel_plugin_builder.validators.base.utils') - def test_check_deployment_task_id(self, utils_mock): - mock_data = [{ - 'id': 'plugin_n@me', - 'type': 'group', - 'role': ['plugin_name']}] - err_msg = "File '/tmp/plugin_path/deployment_tasks.yaml'," \ - " 'plugin_n@me' does not match" - self.check_raised_exception( - utils_mock, mock_data, - err_msg, self.validator.check_deployment_tasks_schema) - - @mock.patch('fuel_plugin_builder.validators.base.utils') - def test_check_deployment_task_valid_dependencies(self, utils_mock): - utils_mock.parse_yaml.return_value = [{ - 'id': 'plugin_name', - 'type': 'group', - 'role': ['plugin_name'], - 'requires': ['dependency_1', 'dependency_2']}] - - self.validator.check_deployment_tasks_schema() - - @mock.patch('fuel_plugin_builder.validators.base.utils') - def test_check_deployment_task_invalid_dependencies(self, utils_mock): - mock_data = [{ - 'id': 'plugin_name', - 'type': 'group', - 'role': ['plugin_name'], - 'requires': ['dependency_1', 'dependency_#']}] - err_msg = "File '/tmp/plugin_path/deployment_tasks.yaml'," \ - " 'dependency_#' does not match" - self.check_raised_exception( - utils_mock, mock_data, - err_msg, self.validator.check_deployment_tasks_schema) - - @mock.patch('fuel_plugin_builder.validators.base.utils') - def test_check_node_roles_have_correct_name(self, utils_mock): - mock_data = { - 'plug$n_n@me': { - 'name': 'test_plugin', - 'description': 'test plugin'}} - err_msg = "File '/tmp/plugin_path/node_roles.yaml', Additional" \ - " properties are not allowed" - self.check_raised_exception( - utils_mock, mock_data, - err_msg, self.validator.check_node_roles_schema) - - @mock.patch('fuel_plugin_builder.validators.base.utils') - def test_check_node_role_should_has_name(self, utils_mock): - mock_data = { - 'plugin_name': { - 'description': 'test plugin'}} - err_msg = "File '/tmp/plugin_path/node_roles.yaml', 'name' is" \ - " a required property, value path 'plugin_name'" - self.check_raised_exception( - utils_mock, mock_data, - err_msg, self.validator.check_node_roles_schema) - - @mock.patch('fuel_plugin_builder.validators.base.utils') - def test_check_node_role_conflicts(self, utils_mock): - utils_mock.parse_yaml.return_value = { - 'plugin_name': { - 'name': 'test_plugin', - 'description': 'test plugin', - 'conflicts': '*'}} - - self.validator.check_node_roles_schema() - - utils_mock.parse_yaml.return_value = { - 'plugin_name': { - 'name': 'test_plugin', - 'description': 'test plugin', - 'conflicts': ['some_role']}} - - self.validator.check_node_roles_schema() - - @mock.patch('fuel_plugin_builder.validators.base.utils') - def test_check_valid_volumes_roles_mapping_name(self, utils_mock): - utils_mock.parse_yaml.return_value = { - 'volumes_roles_mapping': { - 'mapping_name': [{'allocate_size': 'min', 'id': 'test'}]}, - 'volumes': []} - - self.validator.check_volumes_schema() - - @mock.patch('fuel_plugin_builder.validators.base.utils') - def test_check_invalid_volumes_roles_mapping_name(self, utils_mock): - mock_data = { - 'volumes_roles_mapping': { - 'm@pping_name': [{'allocate_size': 'min', 'id': 'test'}]}, - 'volumes': []} - err_msg = "File '/tmp/plugin_path/volumes.yaml', Additional" \ - " properties are not allowed" - self.check_raised_exception( - utils_mock, mock_data, - err_msg, self.validator.check_volumes_schema) - - @mock.patch('fuel_plugin_builder.validators.base.utils') - def test_check_valid_network_roles(self, utils_mock): - utils_mock.parse_yaml.return_value = [{ - "id": "example_net_role", - "default_mapping": "public", - "properties": { - "subnet": True, - "gateway": False, - "vip": [{ - "name": "vip_name", - "namespace": "haproxy"}]}}] - - self.validator.check_network_roles_schema() - - @mock.patch('fuel_plugin_builder.validators.base.utils') - def test_check_network_roles_vip_have_invalid_name(self, utils_mock): - mock_data = [{ - "id": "example_net_role", - "default_mapping": "public", - "properties": { - "subnet": True, - "gateway": False, - "vip": [{ - "name": "vip@name", - "namespace": "haproxy"}]}}] - err_msg = "File '/tmp/plugin_path/network_roles.yaml'," \ - " 'vip@name' does not match" - self.check_raised_exception( - utils_mock, mock_data, - err_msg, self.validator.check_network_roles_schema) - - @mock.patch('fuel_plugin_builder.validators.base.utils') - def test_check_network_roles_vip_have_invalid_namespace(self, utils_mock): - mock_data = [{ - "id": "example_net_role", - "default_mapping": "public", - "properties": { - "subnet": True, - "gateway": False, - "vip": [{ - "name": "vip_name", - "namespace": "hap roxy"}]}}] - err_msg = "File '/tmp/plugin_path/network_roles.yaml'," \ - " 'hap roxy' does not match" - self.check_raised_exception( - utils_mock, mock_data, - err_msg, self.validator.check_network_roles_schema) diff --git a/fuel_plugin_builder/tests/test_validator_v4.py b/fuel_plugin_builder/tests/test_validator_v4.py deleted file mode 100644 index 3e0d095..0000000 --- a/fuel_plugin_builder/tests/test_validator_v4.py +++ /dev/null @@ -1,923 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2015 Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file 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. - -import mock - -from fuel_plugin_builder import errors -from fuel_plugin_builder.tests.test_validator_v3 import TestValidatorV3 -from fuel_plugin_builder.validators.schemas import SchemaV4 -from fuel_plugin_builder.validators.validator_v4 import ValidatorV4 - - -class TestValidatorV4(TestValidatorV3): - - __test__ = True - validator_class = ValidatorV4 - schema_class = SchemaV4 - package_version = '4.0.0' - - def setUp(self): - super(TestValidatorV4, self).setUp() - self.metadata = { - 'name': 'plugin_name-12', - 'title': 'plugin_name-12', - 'version': '1.2.3', - 'package_version': self.package_version, - 'description': 'Description', - 'fuel_version': ['8.0.0'], - 'licenses': ['Apache', 'BSD'], - 'authors': ['Author1', 'Author2'], - 'homepage': 'http://test.com', - 'releases': [ - { - "os": "ubuntu", - "version": "liberty-8.0", - "mode": ['ha'], - "deployment_scripts_path": "deployment_scripts/", - "repository_path": "repositories/ubuntu" - } - ], - 'groups': [], - 'is_hotpluggable': False - } - - def test_check_schemas(self): - mocked_methods = [ - 'check_metadata_schema', - 'check_env_config_attrs', - 'check_tasks_schema', - 'check_deployment_tasks_schema', - 'check_network_roles_schema', - 'check_node_roles_schema', - 'check_volumes_schema', - 'check_components_schema' - ] - self.mock_methods(self.validator, mocked_methods) - self.mock_methods(self.validator, ['validate_file_by_schema']) - self.validator.check_schemas() - - for method in mocked_methods: - getattr(self.validator, method).assert_called_once_with() - - @mock.patch('fuel_plugin_builder.validators.base.utils') - def test_check_compatibility_failed(self, utils_mock): - fuel_version_checks = ( - (['6.0', '6.1', '7.0', '8.0']), - (['6.1', '7.0', '8.0']), - (['6.0', '6.1', '7.0']), - (['6.1', '7.0']), - ) - - for fuel_version in fuel_version_checks: - mock_data = { - 'fuel_version': fuel_version, - 'package_version': '4.0.0'} - err_msg = 'Current plugin format 4.0.0 is not compatible with ' \ - '{0} Fuel release. Fuel version must be 8.0 or higher.' \ - ' Please remove {0} version from metadata.yaml file or' \ - ' downgrade package_version.'.format(fuel_version[0]) - - self.check_raised_exception( - utils_mock, mock_data, - err_msg, self.validator.check_compatibility) - - @mock.patch('fuel_plugin_builder.validators.base.utils') - def test_check_compatibility_passed(self, utils_mock): - utils_mock.parse_yaml.return_value = { - 'fuel_version': ['8.0'], - 'package_version': '4.0.0'} - self.validator.check_compatibility() - - @mock.patch('fuel_plugin_builder.validators.base.utils') - def test_is_hotpluggable_flag(self, utils_mock): - mock_data = { - 'name': 'plugin_name-12', - 'title': 'plugin_name-12', - 'version': '1.2.3', - 'package_version': self.package_version, - 'description': 'Description', - 'fuel_version': ['8.0.0'], - 'licenses': ['Apache', 'BSD'], - 'authors': ['Author1', 'Author2'], - 'homepage': 'http://test.com', - 'releases': [ - { - "os": "ubuntu", - "version": "liberty-8.0", - "mode": ['ha'], - "deployment_scripts_path": "deployment_scripts/", - "repository_path": "repositories/ubuntu" - } - ], - 'groups': ['network'], - 'is_hotpluggable': True - } - utils_mock.parse_yaml.return_value = mock_data - self.assertEqual(None, self.validator.check_metadata_schema()) - - @mock.patch('fuel_plugin_builder.validators.base.utils') - def test_environment_config_settings_groups(self, utils_mock): - mock_data = {'attributes': {}} - utils_mock.parse_yaml.return_value = mock_data - self.assertEqual(None, self.validator.check_env_config_attrs()) - - mock_data = {'attributes': {'metadata': {}}} - utils_mock.parse_yaml.return_value = mock_data - self.assertEqual(None, self.validator.check_env_config_attrs()) - - mock_data = {'attributes': {'metadata': {'group': 'network'}}} - utils_mock.parse_yaml.return_value = mock_data - self.assertEqual(None, self.validator.check_env_config_attrs()) - - mock_data = {'attributes': {'metadata': {'group': 'unknown'}}} - utils_mock.parse_yaml.return_value = mock_data - self.assertRaises( - errors.ValidationError, - self.validator.check_env_config_attrs - ) - - @mock.patch('fuel_plugin_builder.validators.base.utils') - def test_environment_config_type_attrs(self, utils_mock): - mock_data = { - 'attributes': { - 'server-name': { - 'value': [], - 'label': 'test', - 'weight': 1, - 'type': 'text_list', - } - } - } - utils_mock.parse_yaml.return_value = mock_data - self.assertEqual(None, self.validator.check_env_config_attrs()) - - @mock.patch('fuel_plugin_builder.validators.base.utils') - def test_check_components_schema_validation_failed(self, utils_mock): - data_sets = [ - { - 'name': 'test_additional_item', - 'type': 'network', - 'label': 'test label', - 'compatible': [] - }, - { - 'name': 'test_wrong_label_type', - 'label': 1 - }, - { - 'name': 'test_wrong_description_type', - 'description': [] - }, - { - 'compatible': [], - 'incompatible': [] - }, - { - 'name': 'wrong::type_name:*', - 'compatible': [], - 'incompatible': [] - }, - { - 'name': 'storage::NameWithUpperCase', - 'label': 'Component Label' - }, - { - 'name': 'storage::wrong_compatible_types', - 'compatible': {}, - 'requires': 3, - 'incompatible': "" - }, - { - 'name': 'storage:no_name_compatible_items', - 'incompatible': [{ - 'message': 'Component incompatible with XXX' - }], - }, - { - 'name': 'storage:wrong_message_compatible_items', - 'incompatible': [{ - 'name': 'storage:*', - 'message': 1234 - }] - }, - { - 'name': 'network:new_net:wrong_compatible', - 'compatible': [ - {'name': ''}, - {'name': 'wrong::component'}, - {'name': 'storage:UpperCaseWrongName'}, - {'name': 'Another_wrong**'} - ] - } - ] - - for data in data_sets: - utils_mock.parse_yaml.return_value = [data] - self.assertRaises(errors.ValidationError, - self.validator.check_components_schema) - - @mock.patch('fuel_plugin_builder.validators.base.utils') - def test_check_components_schema_validation_passed(self, utils_mock): - data_sets = [ - { - 'name': 'network:test_name', - 'label': 'Test Name network' - }, - { - 'name': 'storage:sub-type:test_name', - 'label': 'Test Storage', - 'description': 'New Test Storage Description', - 'compatible': [ - {'name': 'hypervisor:libvirt:*'}, - {'name': 'hypervisor:wmvare_new_1'}, - {'name': 'network:neutron:ml2:*'}, - {'name': 'additional_service:murano'}, - ], - 'requires': [{ - 'name': 'hypervisor:libvirt:kvm', - 'message': 'Requires message' - }], - 'incompatible': [ - { - 'name': 'storage:*', - 'message': 'New storage is incompatible with other' - }, - { - 'name': 'additional_service:sahara', - 'message': 'New storage is incompatible with Sahara' - } - ] - }, - { - 'name': 'hypervisor:new', - 'label': 'New Hypervisor', - 'compatible': [] - }, - { - 'name': 'additional_service:ironic-new', - 'label': 'Ironic New', - 'bind': [('some_key', 'some_val')], - 'incompatible': [{ - 'name': 'additional_service:*', - 'message': 'Alert message' - }], - 'requires': [{ - 'name': 'storage:test' - }] - } - ] - - for data in data_sets: - utils_mock.parse_yaml.return_value = [data] - self.validator.check_components_schema() - - @mock.patch('fuel_plugin_builder.validators.base.utils') - def test_groups(self, utils_mock): - groups_data = [ - ["network"], - ["storage"], - ["storage::cinder"], - ["storage::glance"], - ["hypervisor"], - ["equipment"], - ["storage::cinder", "equipment"], - [] - ] - for gd in groups_data: - self.metadata['groups'] = gd - utils_mock.parse_yaml.return_value = self.metadata - self.assertEqual(None, self.validator.check_metadata_schema()) - - @mock.patch('fuel_plugin_builder.validators.base.utils') - def test_check_deployment_task_reexecute_on(self, utils_mock): - mock_data = [{ - 'id': 'plugin_task', - 'type': 'puppet', - 'groups': ['controller'], - 'reexecute_on': ['bla']}] - err_msg = "File '/tmp/plugin_path/deployment_tasks.yaml', " \ - "'bla' is not one of" - self.check_raised_exception( - utils_mock, mock_data, - err_msg, self.validator.check_deployment_tasks_schema) - - @mock.patch('fuel_plugin_builder.validators.validator_v4.utils') - @mock.patch('fuel_plugin_builder.validators.validator_v4.logger') - def test_role_attribute_is_required_for_deployment_task_types( - self, logger_mock, utils_mock, *args): - deployment_tasks_data = [ - { - 'id': 'plugin_name', - 'type': 'group' - }, - { - 'id': 'plugin_name', - 'type': 'shell' - }, - { - 'id': 'plugin_name', - 'type': 'copy_files', - 'parameters': { - 'files': [{'src': '/dev/null', 'dst': '/dev/null'}] - } - }, - { - 'id': 'plugin_name', - 'type': 'sync', - 'parameters': {'src': '/dev/null', 'dst': '/dev/null'} - }, - { - 'id': 'plugin_name', - 'type': 'upload_file', - 'parameters': { - 'path': 'http://test.com', - 'data': 'VGVzdERhdGE=' - } - } - ] - - for task in deployment_tasks_data: - utils_mock.parse_yaml.return_value = [task] - logger_mock.warn.reset_mock() - self.validator.check_deployment_tasks() - self.assertEqual(logger_mock.warn.call_count, 1) - - # This is the section of tests inherited from the v3 validator - # where decorators is re-defined for module v4 - - @mock.patch('fuel_plugin_builder.validators.validator_v4.utils') - @mock.patch('fuel_plugin_builder.validators.base.utils.exists') - def test_check_tasks_no_file(self, exists_mock, utils_mock, *args): - super(TestValidatorV4, self).test_check_deployment_task_role( - exists_mock, utils_mock) - - @mock.patch('fuel_plugin_builder.validators.validator_v4.utils') - def test_check_deployment_task_role(self, utils_mock, *args): - utils_mock.parse_yaml.return_value = [ - {'id': 'plugin_name', 'type': 'group', 'groups': ['a', 'b']}, - {'id': 'plugin_name', 'type': 'group', 'groups': '*'}, - {'id': 'plugin_name', 'type': 'puppet', 'role': ['a', 'b']}, - {'id': 'plugin_name', 'type': 'puppet', 'role': '*'}, - {'id': 'plugin_name', 'type': 'shell', 'roles': ['a', 'b']}, - {'id': 'plugin_name', 'type': 'shell', 'roles': '*'}, - {'id': 'plugin_name', 'type': 'skipped', 'role': '/test/'}, - {'id': 'plugin_name', 'type': 'stage'}, - {'id': 'plugin_name', 'type': 'reboot', 'groups': 'contrail'}, - { - 'id': 'plugin_name', - 'type': 'copy_files', - 'role': '*', - 'parameters': { - 'files': [ - {'src': 'some_source', 'dst': 'some_destination'}]} - }, - { - 'id': 'plugin_name', - 'type': 'sync', - 'role': 'plugin_name', - 'parameters': { - 'src': 'some_source', 'dst': 'some_destination'} - }, - { - 'id': 'plugin_name', - 'type': 'upload_file', - 'role': '/^.*plugin\w+name$/', - 'parameters': { - 'path': 'some_path', 'data': 'some_data'} - }, - ] - - self.validator.check_deployment_tasks() - - @mock.patch('fuel_plugin_builder.validators.validator_v4.utils') - def test_check_deployment_task_role_failed(self, utils_mock, *args): - mock_data = [{ - 'id': 'plugin_name', - 'type': 'group', - 'role': ['plugin_n@me']}] - err_msg = "field should" - self.check_raised_exception( - utils_mock, mock_data, - err_msg, self.validator.check_deployment_tasks) - - @mock.patch('fuel_plugin_builder.validators.validator_v4.utils') - def test_check_deployment_task_required_missing(self, utils_mock, *args): - mock_data = [{ - 'groups': 'plugin_name', - 'type': 'puppet'}] - err_msg = 'required' - self.check_raised_exception( - utils_mock, mock_data, - err_msg, self.validator.check_deployment_tasks) - - @mock.patch('fuel_plugin_builder.validators.validator_v4.utils') - def test_check_deployment_task_required_roles_missing_is_ok( - self, utils_mock, *args): - utils_mock.parse_yaml.return_value = [{ - 'id': 'plugin_name', - 'type': 'stage'}] - self.validator.check_deployment_tasks() - - @mock.patch('fuel_plugin_builder.validators.validator_v4.utils') - def test_check_deployment_task_role_regexp_failed(self, utils_mock, *args): - mock_data = [{ - 'id': 'plugin_name', - 'type': 'group', - 'role': '/[0-9]++/'}] - err_msg = "field should.*multiple repeat" - self.check_raised_exception( - utils_mock, mock_data, - err_msg, self.validator.check_deployment_tasks) - - @mock.patch('fuel_plugin_builder.validators.validator_v4.utils') - def test_check_group_type_deployment_task_does_not_contain_manifests( - self, utils_mock, *args): - super( - TestValidatorV4, self - ).test_check_group_type_deployment_task_does_not_contain_manifests( - utils_mock) - - @mock.patch('fuel_plugin_builder.validators.validator_v4.utils') - def test_files_attribute_is_required_for_copy_files_task_type( - self, utils_mock, *args): - super( - TestValidatorV4, self - ).test_files_attribute_is_required_for_copy_files_task_type( - utils_mock) - - @mock.patch('fuel_plugin_builder.validators.validator_v4.utils') - def test_files_should_contain_at_least_one_item_for_copy_files_task_type( - self, utils_mock, *args): - super( - TestValidatorV4, self - ).test_files_should_contain_at_least_one_item_for_copy_files_task_type( - utils_mock) - - @mock.patch('fuel_plugin_builder.validators.validator_v4.utils') - def test_parameters_attribute_is_required_for_deployment_task_types( - self, utils_mock, *args): - super( - TestValidatorV4, self - ).test_parameters_attribute_is_required_for_deployment_task_types( - utils_mock) - - @mock.patch('fuel_plugin_builder.validators.validator_v4.utils') - def test_path_and_data_attributes_are_required_for_upload_file_task_type( - self, utils_mock, *args): - super( - TestValidatorV4, self - ).test_path_and_data_attributes_are_required_for_upload_file_task_type( - utils_mock) - - @mock.patch('fuel_plugin_builder.validators.validator_v4.utils') - def test_src_and_dst_attributes_are_required_for_copy_files_task_type( - self, utils_mock, *args): - super( - TestValidatorV4, self - ).test_src_and_dst_attributes_are_required_for_copy_files_task_type( - utils_mock) - - @mock.patch('fuel_plugin_builder.validators.validator_v4.utils') - def test_src_and_dst_attributes_are_required_for_sync_task_type( - self, utils_mock, *args): - super( - TestValidatorV4, self - ).test_src_and_dst_attributes_are_required_for_sync_task_type( - utils_mock) - - # todo(ikutukov): validation for old-style tasks.yaml without - # id and normal dependencies. Have to find out what to do with them. - - @mock.patch('fuel_plugin_builder.validators.validator_v4.utils') - def test_check_tasks_schema_validation_failed(self, utils_mock, *args): - pass - - @mock.patch('fuel_plugin_builder.validators.validator_v4.utils') - def test_check_tasks_schema_validation_passed(self, utils_mock, *args): - pass - - @mock.patch('fuel_plugin_builder.validators.validator_v4.utils') - def test_check_tasks_schema_1_0_validation_failed(self, utils_mock, *args): - checks = [ - { - 'data': { - 'id': 'task-id', - 'type': 'shell', - 'parameters': { - 'timeout': 3 - }, - 'stage': 'post_deployment', - 'role': '*' - }, - 'errorTextContains': "'cmd' is a required property, " - "value path '0 -> parameters'" - }, - { - 'data': { - 'id': 'task-id', - 'type': 'puppet', - 'parameters': { - 'timeout': 3 - }, - 'stage': 'post_deployment', - 'role': '*' - }, - 'errorTextContains': "'puppet_manifest' is a required property" - ", value path '0 -> parameters'" - }, - { - 'data': { - 'id': 'task-id', - 'type': 'puppet', - 'parameters': { - 'timeout': 3, - 'cmd': 'xx' - }, - 'stage': 'post_deployment', - 'role': '*' - }, - 'errorTextContains': "'puppet_manifest' is a required property" - ", value path '0 -> parameters'" - }, - { - 'data': { - 'id': 'task-id', - 'type': 'shell', - 'parameters': { - 'timeout': 3, - 'puppet_manifest': 'xx', - 'puppet_modules': 'yy', - }, - 'stage': 'post_deployment', - 'role': '*' - }, - 'errorTextContains': "'cmd' is a required property, value path" - " '0 -> parameters'" - }, - { - 'data': { - 'id': 'task-id', - 'type': 'puppet', - 'parameters': { - 'timeout': 3, - 'puppet_manifest': 'xx', - 'puppet_modules': 'yy', - 'retries': 'asd', - }, - 'stage': 'post_deployment', - 'role': '*' - }, - 'errorTextContains': "'asd' is not of type 'integer', value " - "path '0 -> parameters -> retries'" - }, - { - 'data': { - 'id': 'task-id', - 'type': 'puppet', - 'parameters': { - 'timeout': 3, - 'puppet_manifest': 'xx', - 'puppet_modules': '', - 'retries': 1, - }, - 'stage': 'pre_deployment', - 'role': '*' - }, - 'errorTextContains': "'' is too short, value path '0 -> " - "parameters -> puppet_modules'" - }, - { - 'data': { - 'id': 'task-id', - 'type': 'puppet', - 'parameters': { - 'timeout': 3, - 'puppet_manifest': '', - 'puppet_modules': 'yy', - 'retries': 1, - }, - 'stage': 'pre_deployment', - 'role': '*' - }, - 'errorTextContains': "'' is too short, value path '0 -> " - "parameters -> puppet_manifest'" - } - ] - - for check in checks: - utils_mock.parse_yaml.return_value = [check['data']] - self.assertRaisesRegexp( - errors.ValidationError, - check['errorTextContains'], - self.validator.check_deployment_tasks) - - @mock.patch('fuel_plugin_builder.validators.validator_v4.utils') - def test_check_tasks_schema_1_0_validation_passed(self, utils_mock, *args): - data_sets = [ - [ - { - 'id': 'task_id', - 'type': 'shell', - 'parameters': { - 'timeout': 3, - 'cmd': 'xx' - }, - 'stage': 'post_deployment', - 'role': '*' - }, - ], - [ - { - 'id': 'task_id', - 'type': 'shell', - 'parameters': { - 'timeout': 3, - 'cmd': 'xx' - }, - 'stage': 'post_deployment', - 'role': '*' - }, - { - 'id': 'task_id', - 'type': 'puppet', - 'parameters': { - 'timeout': 3, - 'puppet_manifest': 'xx', - 'puppet_modules': 'xxx' - }, - 'stage': 'post_deployment', - 'role': '*' - }, - ], - [ - { - 'id': 'task_id', - 'type': 'shell', - 'parameters': { - 'timeout': 3, - 'cmd': 'reboot' - }, - 'stage': 'post_deployment', - 'role': '*' - }, - { - 'id': 'task_id', - 'type': 'shell', - 'parameters': { - 'timeout': 3, - 'cmd': 'xx' - }, - 'stage': 'post_deployment', - 'role': '*' - }, - { - 'id': 'task_id', - 'type': 'puppet', - 'parameters': { - 'timeout': 3, - 'puppet_manifest': 'xx', - 'puppet_modules': 'xxx' - }, - 'stage': 'post_deployment', - 'role': '*' - } - ], - [ - { - 'id': 'task_id', - 'type': 'shell', - 'parameters': { - 'timeout': 3, - 'cmd': 'reboot' - }, - 'stage': 'post_deployment', - 'role': '*' - }, - { - 'id': 'task_id', - 'type': 'shell', - 'parameters': { - 'timeout': 3, - 'puppet_manifest': 'xx', - 'puppet_modules': 'yy', - 'cmd': 'reboot' - }, - 'stage': 'post_deployment', - 'role': '*' - }, - { - 'id': 'task_id', - 'type': 'puppet', - 'parameters': { - 'timeout': 3, - 'retries': 10, - 'puppet_manifest': 'xx', - 'puppet_modules': 'xxx' - }, - 'stage': 'post_deployment', - 'role': '*' - }, - { - 'id': 'task_id', - 'type': 'puppet', - 'parameters': { - 'timeout': 3, - 'retries': 10, - 'puppet_manifest': 'xx', - 'puppet_modules': 'xxx' - }, - 'stage': 'post_deployment', - 'role': 'master' - }, - ] - ] - - for data in data_sets: - utils_mock.parse_yaml.return_value = data - self.validator.check_deployment_tasks() - - @mock.patch('fuel_plugin_builder.validators.validator_v4.utils') - def test_check_tasks_schema_2_0_validation_failed(self, utils_mock, *args): - tasks_data = [ - { - 'id': 'test', - 'type': 'shell', - 'version': '2' - }, - { - 'id': 'test', - 'type': 'shell', - 'cross-depends': [ - { - 'role': 'role_without_name' - } - ] - }, - { - 'id': 'test', - 'type': 'shell', - 'parameters': { - 'strategy': 'NOSUCHSTRATEGY' - } - }, - { - 'id': 'test', - 'type': 'shell', - 'parameters': { - 'strategy': { - 'type': 'NOSUCHSTRATEGY' - } - } - } - ] - - utils_mock.parse_yaml.return_value = tasks_data - self.assertRaises(errors.ValidationError, - self.validator.check_deployment_tasks) - - @mock.patch('fuel_plugin_builder.validators.validator_v4.utils') - def test_check_tasks_schema_2_0_validation_passed(self, utils_mock, *args): - tasks_data = [ - { - 'id': 'task_id', - 'type': 'puppet', - 'version': '2.0.0', - 'parameters': { - 'timeout': 3, - 'retries': 10, - 'puppet_manifest': 'xx', - 'puppet_modules': 'xxx' - }, - 'stage': 'post_deployment', - 'roles': ['test_role'], - 'cross-depends': [ - { - 'name': 'task_id2', - }, - { - 'name': 'task_id2', - 'role': ['some_role'] - }, - { - 'name': 'task_id2', - 'role': 'some_role' - }, - { - 'name': 'task_id2', - 'policy': 'all' - }, - { - 'name': 'task_id2', - 'policy': 'any' - } - ], - 'cross-depended-by': [ - { - 'name': 'task_id2', - }, - { - 'name': 'task_id2', - 'role': ['some_role'] - }, - { - 'name': 'task_id2', - 'role': 'some_role' - }, - { - 'name': 'task_id2', - 'policy': 'all' - }, - { - 'name': 'task_id2', - 'policy': 'any' - } - ], - 'strategy': { - 'type': 'parallel', - 'amount': 10 - } - } - ] - - utils_mock.parse_yaml.return_value = tasks_data - self.validator.check_deployment_tasks() - - @mock.patch('fuel_plugin_builder.validators.validator_v4.utils') - def test_check_tasks_schema_2_1_validation_passed(self, utils_mock, *args): - # this is a slightly modified task from netconfig.yaml - tasks_data = [ - { - "id": "netconfig", - "type": "puppet", - "version": "2.1.0", - "groups": [ - "primary-controller", - "controller", - ], - "required_for": [ - "deploy_end" - ], - "requires": [ - "tools" - ], - "condition": { - "yaql_exp": "changedAny($.network_scheme, $.dpdk, $.get('" - "use_ovs'), $.get('set_rps'), $.get('set_rps')" - ", $.get('run_ping_checker'), $.network_scheme" - ".endpoints.values().where(\n $.get('gateway'" - ") != null).gateway)\n" - }, - "parameters": { - "puppet_manifest": "/etc/puppet/modules/osnailyfacter/" - "modular/netconfig/netconfig.pp", - "puppet_modules": "/etc/puppet/modules", - "timeout": 300, - "strategy": { - "type": "parallel", - "amount": { - "yaql_exp": "switch($.get('deployed_before', {})." - "get('value') => 1, true => 3)\n" - } - } - }, - "test_pre": { - "cmd": "ruby /etc/puppet/modules/osnailyfacter/modular/" - "netconfig/netconfig_pre.rb" - }, - "test_post": { - "cmd": "ruby /etc/puppet/modules/osnailyfacter/modular/" - "netconfig/netconfig_post.rb" - }, - "cross-depends": { - "yaql_exp": "switch( (\n $.roles.any($.matches('(" - "primary-)?(controller|mongo)'))\n " - "or ($.network_metadata.get('vips',{}).get" - "('management') = null)\n ) => [],\n " - "true => [{name =>'virtual_ips'}]\n)\n" - } - } - ] - - utils_mock.parse_yaml.return_value = tasks_data - self.validator.check_deployment_tasks() - - @mock.patch('fuel_plugin_builder.validators.base.utils.exists') - def test_check_tasks_schema_validation_no_file(self, exists_mock, *args): - mocked_methods = ['validate_schema'] - self.mock_methods(self.validator, mocked_methods) - exists_mock.return_value = False - self.validator.check_tasks_schema() - self.assertFalse(self.validator.validate_schema.called) diff --git a/fuel_plugin_builder/tests/test_validator_v5.py b/fuel_plugin_builder/tests/test_validator_v5.py deleted file mode 100644 index 8aabfde..0000000 --- a/fuel_plugin_builder/tests/test_validator_v5.py +++ /dev/null @@ -1,452 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2016 Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file 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. - -import mock - -from fuel_plugin_builder import errors -from fuel_plugin_builder.tests.test_validator_v4 import TestValidatorV4 -from fuel_plugin_builder.validators.schemas import SchemaV5 -from fuel_plugin_builder.validators.validator_v5 import ValidatorV5 - - -class TestValidatorV5(TestValidatorV4): - - __test__ = True - validator_class = ValidatorV5 - schema_class = SchemaV5 - package_version = '5.0.0' - - def setUp(self): - super(TestValidatorV5, self).setUp() - - def test_check_schemas(self): - mocked_methods = [ - 'check_metadata_schema', - 'check_env_config_attrs', - 'check_tasks_schema', - 'check_deployment_tasks_schema', - 'check_network_roles_schema', - 'check_node_roles_schema', - 'check_volumes_schema', - 'check_components_schema', - 'check_node_attributes_schema' - ] - self.mock_methods(self.validator, mocked_methods) - self.mock_methods( - self.validator, - ['validate_file_by_schema', 'check_interface_attributes_schema'] - ) - self.validator.check_schemas() - - self.assertEqual( - [mock.call(self.validator.bond_config_path), - mock.call(self.validator.nic_config_path)], - self.validator.check_interface_attributes_schema.call_args_list) - for method in mocked_methods: - getattr(self.validator, method).assert_called_once_with() - - @mock.patch('fuel_plugin_builder.validators.base.utils') - def test_check_compatibility_failed(self, utils_mock): - fuel_version_checks = ( - (['8.0', '9.0', '10.0']), - (['6.1', '7.0', '8.0']), - (['6.0', '6.1', '7.0']), - (['6.1', '7.0']), - ) - - for fuel_version in fuel_version_checks: - mock_data = { - 'fuel_version': fuel_version, - 'package_version': '5.0.0'} - err_msg = 'Current plugin format 5.0.0 is not compatible with ' \ - '{0} Fuel release. Fuel version must be 9.0 or higher.' \ - ' Please remove {0} version from metadata.yaml file or' \ - ' downgrade package_version.'.format(fuel_version[0]) - - self.check_raised_exception( - utils_mock, mock_data, - err_msg, self.validator.check_compatibility) - - @mock.patch('fuel_plugin_builder.validators.base.utils') - def test_check_compatibility_passed(self, utils_mock): - utils_mock.parse_yaml.return_value = { - 'fuel_version': ['9.0', '9.1', '9.2', '10.0'], - 'package_version': '5.0.0'} - self.validator.check_compatibility() - - @mock.patch('fuel_plugin_builder.validators.base.utils.exists') - def test_check_interface_attributes_schema_validation_no_file(self, - exists_mock): - mocked_methods = ['validate_schema'] - self.mock_methods(self.validator, mocked_methods) - exists_mock.return_value = False - self.validator.check_interface_attributes_schema(mock.ANY) - self.assertFalse(self.validator.validate_schema.called) - - @mock.patch('fuel_plugin_builder.validators.base.utils') - def test_check_interface_attributes_schema_validation_failed(self, - utils_mock): - data_sets = [ - { - '123': { - 'label': 'Attribute without type', - 'description': 'Attribute without type', - 'value': '' - } - }, - { - 'attribute_without_label': { - 'description': 'Attribute without label', - 'type': 'text', - 'value': 'attribute_value' - } - }, { - 'attribute_without_value': { - 'label': 'Attribute without value', - 'description': 'Attribute without value', - 'type': 'text', - } - }, - { - 'attribute-1': { - 'description': 'Attribute with wrong label type', - 'label': 123, - 'type': 'checkbox', - } - }, - { - 'attribute-2': { - 'label': 'Attribute with wrong type type', - 'type': [], - } - }, - { - 'attribute-3': { - 'label': 'Attribute with wrong description type', - 'type': 'text', - 'description': False - } - }, - { - 'attribute-4': { - 'label': 'Attribute with wrong restrictions type', - 'type': 'text', - 'restrictions': {} - } - }, - { - 'label': 'Missed attribute name. Wrong level nesting.', - 'type': 'text', - 'value': '' - }, - { - 'extra_level': { - 'attribute_name': { - 'label': 'Attribute with extra nesting level', - 'type': 'text', - 'value': '' - } - } - }, - { - 'uns@pported_letters=!n_attr_name*': { - 'label': 'Attribute with wrong name', - 'type': 'text', - 'value': '' - } - }, - ['wrong interface attributes object type'] - ] - - for data in data_sets: - utils_mock.parse_yaml.return_value = data - self.assertRaises(errors.ValidationError, - self.validator.check_interface_attributes_schema, - mock.ANY) - - @mock.patch('fuel_plugin_builder.validators.base.utils') - def test_check_interface_attributes_schema_validation_passed(self, - utils_mock): - data_sets = [ - { - '123': { - 'label': 'Attribute with min required fields', - 'type': 'text', - 'value': '' - } - }, - { - 'Attribute_1': { - 'label': 'Attribute with restrictions & complex value', - 'description': 'Some attribute description', - 'type': 'text', - 'value': {'key1': ['val_1', 'val_2']}, - 'restrictions': [ - { - 'condition': 'false', - 'action': 'disable' - } - ] - }, - 'attribute-2': { - 'label': 'Attribute with additional fields', - 'type': 'number', - 'description': 'Some attribute description', - 'value': 10, - 'min': 0 - }, - 'metadata': { - 'label': 'Some metadata' - } - } - ] - - for data in data_sets: - utils_mock.parse_yaml.return_value = data - self.validator.check_interface_attributes_schema('nic_config_path') - - @mock.patch('fuel_plugin_builder.validators.base.utils.exists') - def test_check_node_attributes_schema_validation_no_file(self, - exists_mock): - mocked_methods = ['validate_schema'] - self.mock_methods(self.validator, mocked_methods) - exists_mock.return_value = False - self.validator.check_node_attributes_schema() - self.assertFalse(self.validator.validate_schema.called) - - @mock.patch('fuel_plugin_builder.validators.base.utils') - def test_check_node_attributes_schema_validation_failed(self, utils_mock): - data_sets = [ - { - 'plugin_section': { - 'metadata': { - 'label': 'Some label' - }, - '123': { - 'label': 'Attribute without type', - 'description': 'Attribute without type', - 'value': '' - } - } - }, { - 'plugin_section': { - 'metadata': { - 'label': 'Some label' - }, - 'attribute_without_label': { - 'description': 'Attribute without label', - 'type': 'text', - 'value': 'attribute_value' - } - } - }, { - 'plugin_section': { - 'metadata': { - 'label': 'Some label' - }, - 'attribute_without_value': { - 'label': 'Attribute without value', - 'description': 'Attribute without value', - 'type': 'text', - } - } - }, { - 'plugin_section': { - 'metadata': { - 'label': 'Some label' - }, - 'attribute-1': { - 'description': 'Attribute with wrong label type', - 'label': 123, - 'type': 'checkbox', - 'value': '' - } - } - }, { - 'plugin_section': { - 'metadata': { - 'label': 'Some label' - }, - 'attribute-2': { - 'label': 'Attribute with wrong type type', - 'type': [], - 'value': '' - } - } - }, { - 'plugin_section': { - 'metadata': { - 'label': 'Some label' - }, - 'attribute-3': { - 'label': 'Attribute with wrong description type', - 'type': 'text', - 'value': '', - 'description': False - } - } - }, { - 'plugin_section': { - 'metadata': { - 'label': 'Some label' - }, - 'attribute-4': { - 'label': 'Attribute with wrong restrictions type', - 'type': 'text', - 'value': '', - 'restrictions': {} - } - } - }, { - 'plugin_section': { - 'metadata': { - 'group': 'Metadata without label' - }, - 'attribute_a': { - 'label': 'Some label', - 'type': 'text', - 'value': '', - } - } - }, { - 'plugin_section': { - 'metadata': { - 'label': None, - 'group': 'Metadata with wrong label type' - }, - 'attribute_a': { - 'label': 'Some label', - 'type': 'text', - 'value': '', - } - } - }, { - 'plugin_section': { - 'metadata': { - 'label': None, - 'group': 'Metadata with wrong restriction type', - 'restrictions': 'restrictions' - }, - 'attribute_a': { - 'label': 'Some label', - 'type': 'text', - 'value': '', - } - } - }, { - 'metadata': { - 'label': 'Some label' - }, - 'attribute': { - 'label': 'Missed plugin section. Wrong level nesting.', - 'type': 'text', - 'value': '' - } - }, { - 'extra_level': { - 'plugin_section': { - 'metadata': { - 'label': 'Some label' - }, - 'attribute-4': { - 'label': 'Attribute with extra nesting level', - 'type': 'text', - 'value': '' - } - } - } - }, { - 'plugin_section': { - 'metadata': { - 'label': 'Some label' - }, - 'uns@pported_letters=!n_attr_name*': { - 'label': 'Attribute with wrong name', - 'type': 'text', - 'value': '' - } - } - }, { - 'uns@pported_letters=!n_section_name': { - 'metadata': { - 'label': 'Some label' - }, - 'attribute': { - 'label': 'Attribute with wrong name', - 'type': 'text', - 'value': '' - } - } - }, - ['wrong interface attributes object type'] - ] - - for data in data_sets: - utils_mock.parse_yaml.return_value = data - self.assertRaises(errors.ValidationError, - self.validator.check_node_attributes_schema) - - @mock.patch('fuel_plugin_builder.validators.base.utils') - def test_check_node_attributes_schema_validation_passed(self, utils_mock): - data_sets = [ - { - 'plugin_section': { - 'metadata': { - 'label': 'Some label' - }, - '123': { - 'label': 'Attribute with min required fields', - 'type': 'text', - 'value': '' - } - }, - 'plugin_section123': { - 'Attribute_1': { - 'label': 'Attribute with restrictions & complex value', - 'description': 'Some attribute description', - 'type': 'text', - 'value': {'key1': ['val_1', 'val_2']}, - 'restrictions': [ - { - 'condition': 'false', - 'action': 'disable' - } - ] - }, - 'attribute-2': { - 'label': 'Attribute with additional fields', - 'type': 'number', - 'description': 'Some attribute description', - 'value': 10, - 'min': 0 - }, - 'metadata': { - 'label': 'Metadata with extra field & restrictions', - 'restrictions': [ - { - 'condition': 'false', - 'action': 'disable' - } - ], - 'group': 'group A' - } - } - } - ] - - for data in data_sets: - utils_mock.parse_yaml.return_value = data - self.validator.check_node_attributes_schema() diff --git a/fuel_plugin_builder/tests/test_version_mapping.py b/fuel_plugin_builder/tests/test_version_mapping.py deleted file mode 100644 index ccbf453..0000000 --- a/fuel_plugin_builder/tests/test_version_mapping.py +++ /dev/null @@ -1,79 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2014 Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file 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. - -from fuel_plugin_builder import errors -from fuel_plugin_builder.tests.base import BaseTestCase -from fuel_plugin_builder.validators import ValidatorV1 -from fuel_plugin_builder.validators import ValidatorV2 -from fuel_plugin_builder.validators import ValidatorV3 -from fuel_plugin_builder.validators import ValidatorV4 -from fuel_plugin_builder.validators import ValidatorV5 -from fuel_plugin_builder.version_mapping import get_plugin_for_version - - -class TestVersionMapping(BaseTestCase): - - def test_get_plugin_for_version_1(self): - result = get_plugin_for_version('1.0.0') - self.assertEqual(result['version'], '1.0.0') - self.assertEqual( - result['templates'], - ['templates/base/plugin_data', 'templates/v1/plugin_data/']) - self.assertEqual(result['validator'], ValidatorV1) - - def test_get_plugin_for_version_2(self): - result = get_plugin_for_version('2.0.0') - self.assertEqual(result['version'], '2.0.0') - self.assertEqual( - result['templates'], - ['templates/base/plugin_data', 'templates/v2/plugin_data/']) - self.assertEqual(result['validator'], ValidatorV2) - - def test_get_plugin_for_version_3(self): - result = get_plugin_for_version('3.0.0') - self.assertEqual(result['version'], '3.0.0') - self.assertEqual( - result['templates'], - ['templates/base/plugin_data', 'templates/v3/plugin_data/']) - self.assertEqual(result['validator'], ValidatorV3) - - def test_get_plugin_for_version_4(self): - result = get_plugin_for_version('4.0.0') - self.assertEqual(result['version'], '4.0.0') - self.assertEqual( - result['templates'], - [ - 'templates/base/plugin_data', - 'templates/v3/plugin_data/', - 'templates/v4/plugin_data/']) - self.assertEqual(result['validator'], ValidatorV4) - - def test_get_plugin_for_version_5(self): - result = get_plugin_for_version('5.0.0') - self.assertEqual(result['version'], '5.0.0') - self.assertEqual( - result['templates'], - [ - 'templates/base/plugin_data', - 'templates/v3/plugin_data/', - 'templates/v4/plugin_data/', - 'templates/v5/plugin_data/']) - self.assertEqual(result['validator'], ValidatorV5) - - def test_get_plugin_for_version_raises_error(self): - with self.assertRaisesRegexp(errors.WrongPackageVersionError, - 'Wrong package version "2999"'): - get_plugin_for_version('2999') diff --git a/fuel_plugin_builder/utils.py b/fuel_plugin_builder/utils.py deleted file mode 100644 index 8ff327e..0000000 --- a/fuel_plugin_builder/utils.py +++ /dev/null @@ -1,387 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2014 Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file 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. - -import datetime -import hashlib -import io -import logging -import os -import shutil -import subprocess -import tarfile -import yaml - -from distutils import dir_util -from distutils.version import StrictVersion -from glob import glob - -from mako.template import Template - -from fuel_plugin_builder import errors - -logger = logging.getLogger(__name__) - - -def is_executable(file_path): - """Checks if file executable - - :param str file_path: path to the file - :returns: True if file is executable, False if is not - """ - return os.path.isfile(file_path) and os.access(file_path, os.X_OK) - - -def which(cmd): - """Checks if file executable - - :param str cmd: the name of the command or path - - :returns: None if there is no such command, - if there is such command returns - the path to the command - """ - - fpath, fname = os.path.split(cmd) - if fpath: - if is_executable(cmd): - return cmd - - for path in os.environ['PATH'].split(os.pathsep): - exe_file = os.path.join(path, cmd) - if is_executable(exe_file): - return exe_file - - return None - - -def exec_cmd(cmd, cwd=None): - """Execute command with logging. - Ouput of stdout and stderr will be written - in log. - - :param cmd: shell command - :param cwd: string or None - """ - logger.debug(u'Execute command "{0}"'.format(cmd)) - child = subprocess.Popen( - cmd, stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, - shell=True, - cwd=cwd) - - logger.debug(u'Stdout and stderr of command "{0}":'.format(cmd)) - for line in child.stdout: - logger.debug(line.rstrip()) - - child.wait() - exit_code = child.returncode - - if exit_code != 0: - raise errors.ExecutedErrorNonZeroExitCode( - u'Shell command executed with "{0}" ' - 'exit code: {1} '.format(exit_code, cmd)) - - logger.debug(u'Command "{0}" successfully executed'.format(cmd)) - - -def exec_piped_cmds(cmds, cwd=None): - """Execute pipe of commands with logging. - - :param cmds: list of shell commands - :type cmds: list - :param cwd: current working directory - :type cwd: string or None - """ - logger.debug(u'Executing commands "{0}"'.format(" | ".join(cmds))) - - std_out = None - for cmd in cmds: - child = subprocess.Popen( - cmd, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - stdin=subprocess.PIPE, - shell=True, - cwd=cwd) - - std_out, std_err = child.communicate(input=std_out) - exit_code = child.returncode - - if exit_code != 0: - logger.debug(u'Stderr of command "{0}":'.format(cmd)) - logger.debug(std_err) - - raise errors.ExecutedErrorNonZeroExitCode( - u'Shell command executed with "{0}" ' - 'exit code: {1} '.format(exit_code, cmd)) - - logger.debug(u'Stdout of command "{0}":'.format(" | ".join(cmds))) - logger.debug(std_out) - logger.debug( - u'Command "{0}" successfully executed'.format(" | ".join(cmds)) - ) - - -def create_dir(dir_path): - """Creates directory - - :param dir_path: directory path - :raises: errors.DirectoryExistsError - """ - logger.debug(u'Creating directory %s', dir_path) - if not os.path.isdir(dir_path): - os.makedirs(dir_path) - - -def exists(path): - """Checks if filel is exist - - :param str path: path to the file - :returns: True if file is exist, Flase if is not - """ - return os.path.lexists(path) - - -def basename(path): - """Basename for path - - :param str path: path to the file - :returns: str with filename - """ - return os.path.basename(path) - - -def render_to_file(src, dst, params): - """Render mako template and write it to specified file - - :param src: path to template - :param dst: path where rendered template will be saved - """ - logger.debug(u'Render template from {0} to {1} with params: {2}'.format( - src, dst, params)) - - # NOTE(aroma): we use io.open because sometimes we ended up with - # non-ascii chars in rendered template so must explicitly - # converse content to 'utf-8' encoding before writing - - with io.open(src, 'r', encoding='utf-8') as f: - template_file = f.read() - - with io.open(dst, 'w', encoding='utf-8') as f: - # NOTE(aroma): 'render' in such configuration always - # return unicode object as the result - rendered_file = Template(template_file).render(**params) - f.write(rendered_file) - - -def render_files_in_dir(dir_path, params): - """Renders all *.mako files and removes templates - - :param str dir_path: path to the directory - :param dict params: parameters for rendering - """ - for root, _, files in os.walk(dir_path): - for file_path in files: - name, extension = os.path.splitext(file_path) - if not extension == '.mako': - continue - - src_path = os.path.join(root, file_path) - dst_path = os.path.join(root, name) - render_to_file(src_path, dst_path, params) - copy_file_permissions(src_path, dst_path) - remove(src_path) - - -def copy_file_permissions(src, dst): - """Copies file permissions - - :param str src: source file - :param str dst: destination - """ - shutil.copymode(src, dst) - - -def remove(path): - """Remove file or directory - - :param path: a file or directory to remove - """ - logger.debug(u'Removing "%s"', path) - - if not os.path.lexists(path): - return - - if os.path.isdir(path) and not os.path.islink(path): - shutil.rmtree(path) - else: - os.remove(path) - - -def copy(src, dst): - """Copy a given file or directory from one place to another. - Rewrite already exists files. - - :param src: copy from - :param dst: copy to - """ - logger.debug(u'Copy from %s to %s', src, dst) - - if os.path.isdir(src): - # dir_util.copy_tree use here instead of shutil.copytree because - # it can overwrite existing folder and files. This is necessary - # for our template combinations, e.g.: base and v1 - dir_util.copy_tree(src, dst, preserve_symlinks=True) - else: - shutil.copy(src, dst) - - -def copy_files_in_dir(src, dst): - """Copies file in directory - - :param str src: source files - :param str dst: destination directory - """ - logger.debug(u'Copy files in directory %s %s', src, dst) - for f in glob(src): - dst_path = os.path.join(dst, os.path.basename(f)) - copy(f, dst_path) - - -def move_files_in_dir(src, dst): - """Move files or directories - - :param str src: source files or directories - :param str dst: destination directory - """ - logger.debug(u'Move files to directory %s %s', src, dst) - for f in glob(src): - dst_path = os.path.join(dst, os.path.basename(f)) - shutil.move(f, dst_path) - - -def make_tar_gz(dir_path, tar_path, files_prefix): - """Compress the file in tar.gz archive - - :param str dir_path: directory for archiving - :param str tar_path: the name and path to the file - :param str files_prefix: the directory in the tar files where all - of the files are allocated - """ - logger.debug(u'Archive directory %s to file %s', dir_path, tar_path) - tar = tarfile.open(tar_path, 'w:gz') - tar.add(dir_path, arcname=files_prefix) - tar.close() - - -def parse_yaml(path): - """Parses yaml file - - :param str path: path to the file - :returns: dict or list - """ - return yaml.load(open(path)) - - -def calculate_sha(file_path, chunk_size=2 ** 20): - """Calculate file's checksum - - :param str file_path: file path - :param int chunk_size: optional parameter, size of chunk - :returns: SHA1 string - """ - sha = hashlib.sha1() - - with open(file_path, 'rb') as f: - for chunk in iter(lambda: f.read(chunk_size), b''): - sha.update(chunk) - - return sha.hexdigest() - - -def calculate_checksums(dir_path): - """Calculates checksums of files in the directory - - :param str dir_path: path to the directory - :returns: list of dicts, where 'checksum' is SHA1, - 'file_path' is a relative path to the file - """ - checksums = [] - for root, _, files in os.walk(dir_path): - for file_path in files: - full_path = os.path.join(root, file_path) - rel_path = os.path.relpath(full_path, dir_path) - - checksums.append({ - 'checksum': calculate_sha(full_path), - 'file_path': rel_path}) - - return checksums - - -def create_checksums_file(dir_path, checksums_file): - """Creates file with checksums - - :param str dir_path: path to the directory for checksums calculation - :param str checksums_file: path to the file where checksums are saved - """ - checksums = calculate_checksums(dir_path) - checksums_sorted = sorted(checksums, key=lambda c: c['file_path']) - checksum_lines = [ - '{checksum} {file_path}\n'.format(**checksum) - for checksum in checksums_sorted] - - with open(checksums_file, 'w') as f: - f.writelines(checksum_lines) - - -def version_split_name_rpm(version): - version_tuple = StrictVersion(version).version - major = '.'.join(map(str, version_tuple[0:2])) - minor = version - - return (major, minor) - - -def get_current_year(): - """Returns current year - """ - return str(datetime.date.today().year) - - -def remove_by_mask(mask): - """Deletes files by mask - - :param str mask: files mask - """ - logger.debug(u'Remove files by mask %s', mask) - for f in glob(mask): - remove(f) - - -def read_if_exist(filename): - """Read contents from filename - - :param str filename: path to the file - :retruns: str with contents of filename or empty string - """ - - if not exists(filename): - logger.debug('File not found. Skipping {0}'.format(filename)) - return "" - with open(filename) as f: - logger.debug('Reading file {0}'.format(filename)) - return f.read() diff --git a/fuel_plugin_builder/validators/__init__.py b/fuel_plugin_builder/validators/__init__.py deleted file mode 100644 index 653ffb1..0000000 --- a/fuel_plugin_builder/validators/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2014 Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file 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. - -from fuel_plugin_builder.validators.manager import ValidatorManager -from fuel_plugin_builder.validators.validator_v1 import ValidatorV1 -from fuel_plugin_builder.validators.validator_v2 import ValidatorV2 -from fuel_plugin_builder.validators.validator_v3 import ValidatorV3 -from fuel_plugin_builder.validators.validator_v4 import ValidatorV4 -from fuel_plugin_builder.validators.validator_v5 import ValidatorV5 -from fuel_plugin_builder.validators.base import LegacyBaseValidator diff --git a/fuel_plugin_builder/validators/base.py b/fuel_plugin_builder/validators/base.py deleted file mode 100644 index a487ac0..0000000 --- a/fuel_plugin_builder/validators/base.py +++ /dev/null @@ -1,190 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2014 Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file 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. - -import abc -import logging - -import jsonschema -import six - -from distutils.version import StrictVersion -from fuel_plugin_builder import errors -from fuel_plugin_builder import utils -from os.path import join as join_path - -logger = logging.getLogger(__name__) - - -@six.add_metaclass(abc.ABCMeta) -class LegacyBaseValidator(object): - - @abc.abstractproperty - def basic_version(self): - pass - - def __init__(self, plugin_path, format_checker=jsonschema.FormatChecker): - self.plugin_path = plugin_path - self.format_checker = format_checker - - def validate_schema(self, data, schema, file_path, value_path=None): - logger.debug( - 'Start schema validation for %s file, %s', file_path, schema) - try: - jsonschema.validate(data, schema, - format_checker=self.format_checker) - except jsonschema.exceptions.ValidationError as exc: - raise errors.ValidationError( - self._make_error_message(exc, file_path, value_path)) - - def _make_error_message(self, exc, file_path, value_path): - if value_path is None: - value_path = [] - - if exc.absolute_path: - value_path.extend(exc.absolute_path) - - if exc.context: - sub_exceptions = sorted( - exc.context, key=lambda e: len(e.schema_path), reverse=True) - sub_message = sub_exceptions[0] - value_path.extend(list(sub_message.absolute_path)[2:]) - message = sub_message.message - else: - message = exc.message - - error_msg = "File '{0}', {1}".format(file_path, message) - - if value_path: - value_path = ' -> '.join(map(six.text_type, value_path)) - error_msg = '{0}, {1}'.format( - error_msg, "value path '{0}'".format(value_path)) - - return error_msg - - def validate_file_by_schema(self, schema, file_path, - allow_not_exists=False, allow_empty=False): - """Validate file with given JSON schema. - - :param schema: object dict - :type schema: object - :param file_path: path to the file - :type file_path: basestring - :param allow_not_exists: if true don't raise error on missing file - :type allow_not_exists: bool - :param allow_empty: allow file to contain no json - :type allow_empty: bool - :return: - """ - if not utils.exists(file_path): - if allow_not_exists: - logger.debug('No file "%s". Skipping check.', file_path) - return - else: - raise errors.FileDoesNotExist(file_path) - - data = utils.parse_yaml(file_path) - if data is not None: - self.validate_schema(data, schema, file_path) - else: - if not allow_empty: - raise errors.FileIsEmpty(file_path) - - @abc.abstractmethod - def validate(self): - """Performs validation - - """ - - def check_schemas(self): - logger.debug('Start schema checking "%s"', self.plugin_path) - self.validate_file_by_schema( - self.schema.metadata_schema, - self.meta_path) - self.validate_file_by_schema( - self.schema.tasks_schema, - self.tasks_path) - self.check_env_config_attrs() - - def check_env_config_attrs(self): - """Check attributes in environment config file. - - 'attributes' is not required field, but if it's - present it should contain UI elements OR metadata - structure. - """ - config = utils.parse_yaml(self.env_conf_path) - if not config: - return - - self.validate_schema( - config, - self.schema.attr_root_schema, - self.env_conf_path) - - attrs = config.get('attributes', {}) - for attr_id, attr in six.iteritems(attrs): - schema = self.schema.attr_element_schema - # Metadata object is totally different - # from the others, we have to set different - # validator for it - if attr_id == 'metadata': - schema = self.schema.attr_meta_schema - - self.validate_schema( - attr, - schema, - self.env_conf_path, - value_path=['attributes', attr_id]) - - def check_releases_paths(self): - meta = utils.parse_yaml(self.meta_path) - for release in meta['releases']: - scripts_path = join_path( - self.plugin_path, - release['deployment_scripts_path']) - repo_path = join_path( - self.plugin_path, - release['repository_path']) - - wrong_paths = [] - for path in [scripts_path, repo_path]: - if not utils.exists(path): - wrong_paths.append(path) - - if wrong_paths: - raise errors.ReleasesDirectoriesError( - 'Cannot find directories {0} for release "{1}"'.format( - ', '.join(wrong_paths), release)) - - def check_compatibility(self): - """Json schema doesn't have any conditions, so we have - - to make sure here, that this validation schema can be used - for described fuel releases - """ - - meta = utils.parse_yaml(self.meta_path) - for fuel_release in meta['fuel_version']: - if StrictVersion(fuel_release) < StrictVersion(self.basic_version): - raise errors.ValidationError( - 'Current plugin format {0} is not compatible with {2} Fuel' - ' release. Fuel version must be {1} or higher.' - ' Please remove {2} version from metadata.yaml file or' - ' downgrade package_version.' - .format( - meta['package_version'], - self.basic_version, - fuel_release)) diff --git a/fuel_plugin_builder/validators/formatchecker.py b/fuel_plugin_builder/validators/formatchecker.py deleted file mode 100644 index 7d8d76e..0000000 --- a/fuel_plugin_builder/validators/formatchecker.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2016 Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file 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. - -import re -from sre_constants import error as sre_error - -import jsonschema -import six - -from fuel_plugin_builder import errors - - -class FormatChecker(jsonschema.FormatChecker): - - def __init__(self, role_patterns=(), *args, **kwargs): - super(FormatChecker, self).__init__() - - @self.checks('fuel_task_role_format') - def _validate_role(instance): - sre_msg = None - if isinstance(instance, six.string_types): - if instance.startswith('/') and instance.endswith('/'): - try: - re.compile(instance[1:-1]) - return True - except sre_error as e: - sre_msg = str(e) - else: - for role_pattern in role_patterns: - if re.match(role_pattern, instance): - return True - err_msg = "Role field should be either a valid " \ - "regexp enclosed by " \ - "slashes or a string of '{0}' or an " \ - "array of those. " \ - "Got '{1}' instead.".format(", ".join(role_patterns), - instance) - if sre_msg: - err_msg += "SRE error: \"{0}\"".format(sre_msg) - raise errors.TaskFieldError(err_msg) diff --git a/fuel_plugin_builder/validators/manager.py b/fuel_plugin_builder/validators/manager.py deleted file mode 100644 index 00c3404..0000000 --- a/fuel_plugin_builder/validators/manager.py +++ /dev/null @@ -1,28 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2014 Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file 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. - -from fuel_plugin_builder import version_mapping - - -class ValidatorManager(object): - - def __init__(self, plugin_path): - self.plugin_path = plugin_path - - def get_validator(self): - validator = version_mapping.get_version_mapping_from_plugin( - self.plugin_path)['validator'] - return validator(self.plugin_path) diff --git a/fuel_plugin_builder/validators/schemas/__init__.py b/fuel_plugin_builder/validators/schemas/__init__.py deleted file mode 100644 index fd077d0..0000000 --- a/fuel_plugin_builder/validators/schemas/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2015 Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file 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. - - -from fuel_plugin_builder.validators.schemas.base import BaseSchema -from fuel_plugin_builder.validators.schemas.v1 import SchemaV1 -from fuel_plugin_builder.validators.schemas.v2 import SchemaV2 -from fuel_plugin_builder.validators.schemas.v3 import SchemaV3 -from fuel_plugin_builder.validators.schemas.v4 import SchemaV4 -from fuel_plugin_builder.validators.schemas.v5 import SchemaV5 diff --git a/fuel_plugin_builder/validators/schemas/base.py b/fuel_plugin_builder/validators/schemas/base.py deleted file mode 100644 index ee8a835..0000000 --- a/fuel_plugin_builder/validators/schemas/base.py +++ /dev/null @@ -1,211 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2015 Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file 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. - -from fuel_plugin_builder import consts - - -class BaseSchema(object): - - @property - def plugin_release_schema(self): - return { - 'type': 'object', - 'required': ['version', 'os', 'mode'], - 'properties': { - 'version': {'type': 'string'}, - 'os': {'enum': ['ubuntu', 'centos']}, - 'deployment_scripts_path': {'type': 'string'}, - 'repository_path': {'type': 'string'}, - 'mode': {'type': 'array', - 'items': {'enum': ['ha', 'multinode']}}} - } - - @property - def condition(self): - return {'type': 'string'} - - @property - def full_restriction(self): - return { - 'type': 'object', - 'required': ['condition'], - 'properties': { - 'condition': self.condition, - 'message': {'type': 'string'}, - 'action': {'type': 'string'}}} - - @property - def short_restriction(self): - return { - 'type': 'object', - 'minProperties': 1, - 'maxProperties': 1} - - @property - def restrictions(self): - return { - 'type': 'array', - 'minItems': 1, - 'items': { - 'anyOf': [ - self.condition, - self.full_restriction, - self.short_restriction]}} - - @property - def metadata_schema(self): - return { - '$schema': 'http://json-schema.org/draft-04/schema#', - 'title': 'plugin', - 'type': 'object', - 'required': [ - 'name', - 'title', - 'version', - 'package_version', - 'description', - 'fuel_version', - 'releases', - ], - 'properties': { - 'name': { - 'type': 'string', - 'pattern': consts.PLUGIN_NAME_PATTERN}, - 'title': {'type': 'string'}, - 'version': {'type': 'string'}, - 'package_version': {'enum': ['1.0.0']}, - 'description': {'type': 'string'}, - 'fuel_version': self.list_of_strings, - 'releases': { - 'type': 'array', - 'items': self.plugin_release_schema}} - } - - @property - def list_of_strings(self): - return {'type': 'array', - 'items': {'type': 'string'}} - - @property - def positive_integer(self): - return {'type': 'integer', 'minimum': 0} - - @property - def puppet_parameters(self): - return { - '$schema': 'http://json-schema.org/draft-04/schema#', - 'type': 'object', - 'required': ['timeout', 'puppet_modules', 'puppet_manifest'], - 'properties': { - 'timeout': self.positive_integer, - 'puppet_modules': {'type': 'string'}, - 'puppet_manifest': {'type': 'string'}} - } - - @property - def shell_parameters(self): - return { - '$schema': 'http://json-schema.org/draft-04/schema#', - 'type': 'object', - 'required': ['timeout', 'cmd'], - 'properties': { - 'timeout': self.positive_integer, - 'cmd': {'type': 'string'}} - } - - @property - def task_base_parameters(self): - return { - '$schema': 'http://json-schema.org/draft-04/schema#', - 'type': 'object', - 'required': ['timeout'], - 'properties': { - 'timeout': self.positive_integer} - } - - @property - def task_schema(self): - return { - '$schema': 'http://json-schema.org/draft-04/schema#', - 'type': 'object', - 'required': ['parameters', 'type', 'stage', 'role'], - 'properties': { - 'type': {'enum': ['puppet', 'shell']}, - 'parameters': self.task_base_parameters, - 'stage': {'enum': ['post_deployment', 'pre_deployment']}, - 'role': { - 'oneOf': [ - self.list_of_strings, - {'enum': ['*', 'master']}]}} - } - - @property - def tasks_schema(self): - return { - '$schema': 'http://json-schema.org/draft-04/schema#', - 'type': 'array', - 'items': self.task_schema - } - - @property - def attr_element_schema(self): - return { - '$schema': 'http://json-schema.org/draft-04/schema#', - 'type': 'object', - 'required': ['type', 'label', 'weight', 'value'], - 'properties': { - 'type': {'type': 'string'}, - 'weight': {'type': 'integer'}, - 'value': {'anyOf': [ - {'type': 'string'}, - {'type': 'boolean'}, - {'type': 'object', - 'properties': {'generator': {'type': 'string'}}}, - {'type': 'array', - 'items': {'anyOf': [{'type': 'string'}, - {'type': 'boolean'}]}}, - ]}, - 'label': {'type': 'string'}, - 'restrictions': self.restrictions, - 'values': {'type': 'array', 'items': - {'type': 'object', - 'required': ['data', 'label'], - 'properties': { - 'data': {'type': 'string'}, - 'label': {'type': 'string'}}}}} - } - - @property - def attr_meta_schema(self): - return { - '$schema': 'http://json-schema.org/draft-04/schema#', - 'type': 'object', - 'properties': { - 'label': {'type': 'string'}, - 'weight': {'type': 'integer'}, - 'toggleable': {'type': 'boolean'}, - 'enabled': {'type': 'boolean'}, - 'restrictions': self.restrictions} - } - - @property - def attr_root_schema(self): - return { - '$schema': 'http://json-schema.org/draft-04/schema#', - 'type': 'object', - 'properties': { - 'attributes': {'type': 'object'}} - } diff --git a/fuel_plugin_builder/validators/schemas/v1.py b/fuel_plugin_builder/validators/schemas/v1.py deleted file mode 100644 index 0689ccb..0000000 --- a/fuel_plugin_builder/validators/schemas/v1.py +++ /dev/null @@ -1,21 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2014 Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file 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. - -from fuel_plugin_builder.validators.schemas import BaseSchema - - -class SchemaV1(BaseSchema): - pass diff --git a/fuel_plugin_builder/validators/schemas/v2.py b/fuel_plugin_builder/validators/schemas/v2.py deleted file mode 100644 index d222077..0000000 --- a/fuel_plugin_builder/validators/schemas/v2.py +++ /dev/null @@ -1,96 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2014 Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file 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. - -from fuel_plugin_builder import consts -from fuel_plugin_builder.validators.schemas import BaseSchema - - -class SchemaV2(BaseSchema): - - @property - def package_version(self): - return {'enum': ['2.0.0']} - - @property - def metadata_schema(self): - return { - '$schema': 'http://json-schema.org/draft-04/schema#', - 'title': 'plugin', - 'type': 'object', - 'required': [ - 'name', - 'title', - 'version', - 'package_version', - 'description', - 'fuel_version', - 'licenses', - 'authors', - 'homepage', - 'releases', - 'groups'], - 'properties': { - 'name': { - 'type': 'string', - 'pattern': consts.PLUGIN_NAME_PATTERN}, - 'title': {'type': 'string'}, - 'version': {'type': 'string'}, - 'package_version': self.package_version, - 'description': {'type': 'string'}, - 'fuel_version': self.list_of_strings, - 'licenses': self.list_of_strings, - 'authors': self.list_of_strings, - 'groups': {'type': 'array', 'uniqueItems': True, 'items': - {'enum': - ['network', - 'storage', - 'storage::cinder', - 'storage::glance', - 'hypervisor', - 'monitoring']}}, - 'homepage': {'type': 'string'}, - 'releases': { - 'type': 'array', - 'items': self.plugin_release_schema}} - } - - @property - def task_schema(self): - return { - '$schema': 'http://json-schema.org/draft-04/schema#', - 'type': 'object', - 'required': ['parameters', 'type', 'stage', 'role'], - 'properties': { - 'type': {'enum': ['puppet', 'shell', 'reboot']}, - 'parameters': self.task_base_parameters, - 'stage': {'type': 'string', - 'pattern': - '^(post_deployment|pre_deployment)' - '(/[-+]?([0-9]*\.[0-9]+|[0-9]+))?$'}, - 'role': { - 'oneOf': [ - self.list_of_strings, - {'enum': ['*', 'master']}]}} - } - - @property - def reboot_parameters(self): - return { - '$schema': 'http://json-schema.org/draft-04/schema#', - 'type': 'object', - 'required': ['timeout'], - 'properties': {'timeout': self.positive_integer} - } diff --git a/fuel_plugin_builder/validators/schemas/v3.py b/fuel_plugin_builder/validators/schemas/v3.py deleted file mode 100644 index d79411d..0000000 --- a/fuel_plugin_builder/validators/schemas/v3.py +++ /dev/null @@ -1,393 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2015 Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file 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. - -from fuel_plugin_builder.validators.schemas import SchemaV2 - - -TASK_NAME_PATTERN = '^[0-9a-zA-Z_-]+$' -NETWORK_ROLE_PATTERN = '^[0-9a-z_-]+$' -FILE_PERMISSIONS_PATTERN = '^[0-7]{4}$' - - -class SchemaV3(SchemaV2): - - @property - def task_role(self): - return { - 'oneOf': [ - self.task_group, - {'enum': ['*', 'master']} - ] - } - - @property - def task_group(self): - return { - 'type': 'array', - 'items': { - 'type': 'string', - 'pattern': TASK_NAME_PATTERN - } - } - - @property - def rule(self): - return { - 'type': ['string', 'integer'] - } - - @property - def override(self): - return { - 'type': 'object', - 'description': 'Property which can change limit recommended|min' - '|max properties due to some additional condition', - 'required': ['condition'], - 'properties': { - 'condition': {'type': 'string'}, - 'max': self.rule, - 'recommended': self.rule, - 'min': self.rule, - 'message': {'type': 'string'} - } - } - - @property - def overrides(self): - return { - 'type': 'array', - 'description': 'Array of limit override properties', - 'minItems': 1, - 'items': self.override - } - - @property - def limits(self): - return { - 'type': 'object', - 'description': 'Limits for count of nodes for node role', - 'properties': { - 'condition': self.condition, - 'max': self.rule, - 'recommended': self.rule, - 'min': self.rule, - 'overrides': self.overrides - } - } - - @property - def package_version(self): - return {'enum': ['3.0.0']} - - @property - def puppet_task(self): - return { - 'type': 'object', - 'properties': { - 'type': {'enum': ['puppet']}, - 'groups': self.task_group, - 'role': self.task_role, - 'parameters': { - 'type': 'object', - 'required': [ - 'puppet_manifest', 'puppet_modules', 'timeout'], - 'properties': { - 'puppet_manifest': { - 'type': 'string', - 'minLength': 1}, - 'puppet_modules': { - 'type': 'string', - 'minLength': 1}, - 'timeout': { - 'type': 'integer'}, - 'retries': { - 'type': 'integer'}, - } - } - } - } - - @property - def shell_task(self): - return { - 'type': 'object', - 'required': ['role'], - 'properties': { - 'type': {'enum': ['shell']}, - 'role': self.task_role, - 'parameters': { - 'type': 'object', - 'required': ['cmd'], - 'properties': { - 'cmd': { - 'type': 'string'}, - 'retries': { - 'type': 'integer'}, - 'interval': { - 'type': 'integer'}, - 'timeout': { - 'type': 'integer'}}}} - } - - @property - def group_task(self): - return { - 'type': 'object', - 'required': ['role'], - 'properties': { - 'type': {'enum': ['group']}, - 'role': self.task_role, - 'parameters': { - 'type': 'object', - 'properties': { - 'strategy': { - 'type': 'object', - 'properties': { - 'type': { - 'enum': ['parallel', 'one_by_one']}}}}}} - } - - @property - def skipped_task(self): - return { - 'type': 'object', - 'properties': { - 'type': {'enum': ['skipped']}} - } - - @property - def copy_files(self): - return { - 'type': 'object', - 'required': ['role', 'parameters'], - 'properties': { - 'type': {'enum': ['copy_files']}, - 'role': self.task_role, - 'parameters': { - 'type': 'object', - 'required': ['files'], - 'properties': { - 'files': { - 'type': 'array', - 'minItems': 1, - 'items': { - 'type': 'object', - 'required': ['src', 'dst'], - 'properties': { - 'src': {'type': 'string'}, - 'dst': {'type': 'string'}}}}, - 'permissions': { - 'type': 'string', - 'pattern': FILE_PERMISSIONS_PATTERN}, - 'dir_permissions': { - 'type': 'string', - 'pattern': FILE_PERMISSIONS_PATTERN}}}} - } - - @property - def sync(self): - return { - 'type': 'object', - 'required': ['role', 'parameters'], - 'properties': { - 'type': {'enum': ['sync']}, - 'role': self.task_role, - 'parameters': { - 'type': 'object', - 'required': ['src', 'dst'], - 'properties': { - 'src': {'type': 'string'}, - 'dst': {'type': 'string'}, - 'timeout': {'type': 'integer'}}}} - } - - @property - def upload_file(self): - return { - 'type': 'object', - 'required': ['role', 'parameters'], - 'properties': { - 'type': {'enum': ['upload_file']}, - 'role': self.task_role, - 'parameters': { - 'type': 'object', - 'required': ['path', 'data'], - 'properties': { - 'path': {'type': 'string'}, - 'data': {'type': 'string'}}}} - } - - @property - def stage(self): - return { - 'type': 'object', - 'properties': { - 'type': {'enum': ['stage']}} - } - - @property - def reboot(self): - return { - 'type': 'object', - 'properties': { - 'type': {'enum': ['reboot']}, - 'parameters': { - 'type': 'object', - 'properties': { - 'timeout': {'type': 'integer'}}}} - } - - @property - def deployment_task_schema(self): - return { - '$schema': 'http://json-schema.org/draft-04/schema#', - 'type': 'array', - 'items': { - 'type': 'object', - 'required': ['id', 'type'], - 'properties': { - 'id': { - 'type': 'string', - 'pattern': TASK_NAME_PATTERN}, - 'type': { - 'enum': [ - 'puppet', - 'shell', - 'group', - 'skipped', - 'copy_files', - 'sync', - 'upload_file', - 'stage', - 'reboot']}, - 'required_for': self.task_group, - 'requires': self.task_group}} - } - - @property - def network_roles_schema(self): - return { - '$schema': 'http://json-schema.org/draft-04/schema#', - 'type': 'array', - 'items': { - 'type': 'object', - 'required': ['id', 'default_mapping', 'properties'], - 'properties': { - 'id': {'type': 'string'}, - 'default_mapping': {'type': 'string'}, - 'properties': { - 'type': 'object', - 'required': ['subnet', 'gateway', 'vip'], - 'properties': { - 'subnet': {'type': 'boolean'}, - 'gateway': {'type': 'boolean'}, - 'vip': { - 'type': 'array', - 'items': { - 'type': 'object', - 'required': ['name'], - 'properties': { - 'name': { - 'type': 'string', - 'pattern': NETWORK_ROLE_PATTERN}, - 'namespace': { - 'type': 'string', - 'pattern': NETWORK_ROLE_PATTERN} - }}}}}}} - } - - @property - def node_roles_schema(self): - return { - '$schema': 'http://json-schema.org/draft-04/schema#', - 'type': 'object', - 'patternProperties': { - '^[0-9a-zA-Z_-]+$': { - 'type': 'object', - 'required': ['name', 'description'], - 'properties': { - 'name': { - 'type': 'string', - 'description': 'Name that will be shown on UI'}, - 'description': { - 'type': 'string', - 'description': ('Short description of role' - ' functionality')}, - 'conflicts': { - 'oneOf': [ - self.list_of_strings, - {'type': 'string', 'enum': ['*']}]}, - 'has_primary': { - 'type': 'boolean', - 'description': ('During orchestration this role' - ' will be splitted into' - ' primary-role and role.')}, - 'public_ip_required': { - 'type': 'boolean', - 'description': ('Specify if role needs public' - ' IP address.')}, - 'update_required': self.list_of_strings, - 'update_once': self.list_of_strings, - 'weight': { - 'type': 'integer', - 'description': ('Specify weight that will be' - ' used to sort out the roles' - ' on the Fuel web UI')}, - 'limits': self.limits, - 'restrictions': self.restrictions}}}, - 'additionalProperties': False - } - - @property - def volume_schema(self): - return { - '$schema': 'http://json-schema.org/draft-04/schema#', - 'type': 'object', - 'required': ['volumes_roles_mapping', 'volumes'], - 'properties': { - 'volumes_roles_mapping': { - 'type': 'object', - 'patternProperties': { - TASK_NAME_PATTERN: { - 'type': 'array', - 'minItems': 1, - 'items': { - 'type': 'object', - 'description': 'Volume allocations for role', - 'required': ['allocate_size', 'id'], - 'properties': { - 'allocate_size': { - 'type': 'string', - 'enum': ['all', 'min', 'full-disk']}, - 'id': {'type': 'string'}}}}}, - 'additionalProperties': False}, - 'volumes': { - 'type': 'array', - 'items': { - 'type': 'object', - 'required': ['id', 'type'], - 'properties': { - 'id': { - 'type': 'string'}, - 'type': { - 'type': 'string'}}}}} - } - - @property - def task_base_parameters(self): - schema = super(SchemaV3, self).task_base_parameters - schema['properties']['retries'] = self.positive_integer - return schema diff --git a/fuel_plugin_builder/validators/schemas/v4.py b/fuel_plugin_builder/validators/schemas/v4.py deleted file mode 100644 index f6781d3..0000000 --- a/fuel_plugin_builder/validators/schemas/v4.py +++ /dev/null @@ -1,423 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2015 Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file 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. - -import six - -from fuel_plugin_builder.validators.schemas import SchemaV3 - - -COMPONENTS_TYPES_STR = '|'.join( - ['hypervisor', 'network', 'storage', 'additional_service']) -COMPONENT_NAME_PATTERN = \ - '^({0}):([0-9a-z_-]+:)*[0-9a-z_-]+$'.format(COMPONENTS_TYPES_STR) -COMPATIBLE_COMPONENT_NAME_PATTERN = \ - '^({0}):([0-9a-z_-]+:)*([0-9a-z_-]+|(\*)?)$'.format(COMPONENTS_TYPES_STR) - - -TASK_NAME_PATTERN = TASK_ROLE_PATTERN = '^[0-9a-zA-Z_-]+$|^\*$' -NETWORK_ROLE_PATTERN = '^[0-9a-z_-]+$' -FILE_PERMISSIONS_PATTERN = '^[0-7]{4}$' -TASK_VERSION_PATTERN = '^\d+.\d+.\d+$' -STAGE_PATTERN = '^(post_deployment|pre_deployment)' \ - '(/[-+]?([0-9]*\.[0-9]+|[0-9]+))?$' - -ROLE_ALIASES = ('roles', 'groups', 'role') -TASK_OBLIGATORY_FIELDS = ['id', 'type'] -ROLELESS_TASKS = ('stage') - - -class SchemaV4(SchemaV3): - - def __init__(self): - super(SchemaV4, self).__init__() - self.role_pattern = TASK_ROLE_PATTERN - self.roleless_tasks = ROLELESS_TASKS - self.role_aliases = ROLE_ALIASES - - @property - def _node_resolve_policy(self): - return { - 'type': 'string', - 'enum': ['all', 'any'] - } - - @property - def _yaql_expression(self): - return { - '$schema': 'http://json-schema.org/draft-04/schema#', - 'type': 'object', - 'required': ['yaql_exp'], - 'properties': { - 'yaql_exp': {'type': 'string'}, - } - } - - @property - def _task_relation(self): - return { - '$schema': 'http://json-schema.org/draft-04/schema#', - 'type': 'object', - 'required': ['name'], - 'properties': { - 'name': { - 'oneOf': [ - {'type': 'string'}, - self._yaql_expression], - }, - 'role': { - 'oneOf': [ - {'type': 'string'}, - {'type': 'array'}, - self._yaql_expression] - }, - 'policy': self._node_resolve_policy, - } - } - - @property - def _task_role(self): - return { - 'oneOf': [ - { - 'type': 'string', - 'format': 'fuel_task_role_format' - }, - { - 'type': 'array', - 'items': { - 'type': 'string', - 'format': 'fuel_task_role_format' - } - } - ] - } - - @property - def _task_strategy(self): - return { - '$schema': 'http://json-schema.org/draft-04/schema#', - 'type': 'object', - 'required': ['type'], - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['parallel', 'one_by_one']}, - 'amount': { - 'oneOf': [ - {'type': 'integer'}, - self._yaql_expression - ] - } - } - } - - @property - def _task_stage(self): - return {'type': 'string', 'pattern': STAGE_PATTERN} - - @property - def _task_reexecute(self): - return { - 'type': 'array', - 'items': { - 'type': 'string', - 'enum': ['deploy_changes'] - } - } - - def _gen_task_schema(self, task_types, required=None, - parameters=None): - """Generate deployment task schema using prototype. - - :param task_types: task types - :type task_types: str|list - :param required: new required fields - :type required: list - :param parameters: new properties dict - :type parameters: dict - :return: - :rtype: dict - """ - if not task_types: - raise ValueError('Task type should not be empty') - - if isinstance(task_types, six.string_types): - task_types = [task_types] - - # patch strategy parameter - parameters = parameters or { - "type": "object", - } - parameters.setdefault("properties", {}) - parameters["properties"].setdefault("strategy", self._task_strategy) - task_specific_req_fields = list(set(TASK_OBLIGATORY_FIELDS + - (required or []))) - return { - '$schema': 'http://json-schema.org/draft-04/schema#', - 'type': 'object', - 'required': task_specific_req_fields, - 'properties': { - 'type': {'enum': task_types}, - 'id': { - 'type': 'string', - 'pattern': TASK_NAME_PATTERN}, - 'version': { - 'type': 'string', "pattern": TASK_VERSION_PATTERN}, - 'role': self._task_role, - 'groups': self._task_role, - 'roles': self._task_role, - 'required_for': self.task_group, - 'requires': self.task_group, - 'cross-depends': { - 'oneOf': [ - {'type': 'array', 'items': self._task_relation}, - self._yaql_expression] - }, - 'cross-depended-by': { - 'oneOf': [ - {'type': 'array', 'items': self._task_relation}, - self._yaql_expression] - }, - 'stage': self._task_stage, - 'tasks': { # used only for 'group' tasks - 'type': 'array', - 'items': { - 'type': 'string', - 'pattern': TASK_ROLE_PATTERN}}, - 'reexecute_on': self._task_reexecute, - 'parameters': parameters, - }, - } - - @property - def deployment_task_schema(self): - return { - '$schema': 'http://json-schema.org/draft-04/schema#', - 'type': 'array', - 'items': { - "$ref": "#/definitions/anyTask" - }, - "definitions": { - "anyTask": self._gen_task_schema( - [ - 'copy_files', - 'group', - 'reboot', - 'shell', - 'skipped', - 'stage', - 'sync', - 'puppet', - 'upload_file', - ] - ) - } - } - - @property - def copy_files_task(self): - return self._gen_task_schema( - "copy_files", - ['parameters'], - { - 'type': 'object', - 'required': ['files'], - 'properties': { - 'files': { - 'type': 'array', - 'minItems': 1, - 'items': { - 'type': 'object', - 'required': ['src', 'dst'], - 'properties': { - 'src': {'type': 'string'}, - 'dst': {'type': 'string'}}}}, - 'permissions': { - 'type': 'string', - 'pattern': FILE_PERMISSIONS_PATTERN}, - 'dir_permissions': { - 'type': 'string', - 'pattern': FILE_PERMISSIONS_PATTERN}}}) - - @property - def group_task(self): - return self._gen_task_schema("group", []) - - @property - def puppet_task(self): - return self._gen_task_schema( - "puppet", - [], - { - 'type': 'object', - 'required': [ - 'puppet_manifest', 'puppet_modules', 'timeout'], - 'properties': { - 'puppet_manifest': { - 'type': 'string', 'minLength': 1}, - 'puppet_modules': { - 'type': 'string', 'minLength': 1}, - 'timeout': {'type': 'integer'}, - 'retries': {'type': 'integer'} - } - } - ) - - @property - def reboot_task(self): - return self._gen_task_schema( - "reboot", - [], - { - 'type': 'object', - 'properties': { - 'timeout': {'type': 'integer'} - } - } - ) - - @property - def shell_task(self): - return self._gen_task_schema( - "shell", - [], - { - 'type': 'object', - 'required': ['cmd'], - 'properties': { - 'cmd': { - 'type': 'string'}, - 'retries': { - 'type': 'integer'}, - 'interval': { - 'type': 'integer'}, - 'timeout': { - 'type': 'integer'} - } - } - ) - - @property - def skipped_task(self): - return self._gen_task_schema("skipped") - - @property - def stage_task(self): - return self._gen_task_schema("stage") - - @property - def sync_task(self): - return self._gen_task_schema( - "sync", - ['parameters'], - { - 'type': 'object', - 'required': ['src', 'dst'], - 'properties': { - 'src': {'type': 'string'}, - 'dst': {'type': 'string'}, - 'timeout': {'type': 'integer'} - } - } - ) - - @property - def upload_file_task(self): - return self._gen_task_schema( - "upload_file", - ['parameters'], - { - 'type': 'object', - 'required': ['path', 'data'], - 'properties': { - 'path': {'type': 'string'}, - 'data': {'type': 'string'} - } - } - ) - - @property - def package_version(self): - return {'enum': ['4.0.0']} - - @property - def metadata_schema(self): - schema = super(SchemaV4, self).metadata_schema - schema['required'].append('is_hotpluggable') - schema['properties']['is_hotpluggable'] = {'type': 'boolean'} - schema['properties']['groups']['items']['enum'].append('equipment') - return schema - - @property - def attr_root_schema(self): - schema = super(SchemaV4, self).attr_root_schema - schema['properties']['attributes']['properties'] = { - 'metadata': { - 'type': 'object', - 'properties': { - 'group': { - 'enum': [ - 'general', 'security', - 'compute', 'network', - 'storage', 'logging', - 'openstack_services', 'other' - ] - } - } - } - } - return schema - - @property - def components_items(self): - return { - 'type': 'array', - 'items': { - 'type': 'object', - 'required': ['name'], - 'properties': { - 'name': { - 'type': 'string', - 'pattern': COMPATIBLE_COMPONENT_NAME_PATTERN - }, - 'message': {'type': 'string'} - } - } - } - - @property - def components_schema(self): - return { - '$schema': 'http://json-schema.org/draft-04/schema#', - 'type': 'array', - 'items': { - 'required': ['name', 'label'], - 'type': 'object', - 'additionalProperties': False, - 'properties': { - 'name': { - 'type': 'string', - 'pattern': COMPONENT_NAME_PATTERN - }, - 'label': {'type': 'string'}, - 'description': {'type': 'string'}, - 'compatible': self.components_items, - 'requires': self.components_items, - 'incompatible': self.components_items, - 'bind': {'type': 'array'} - } - } - } diff --git a/fuel_plugin_builder/validators/schemas/v5.py b/fuel_plugin_builder/validators/schemas/v5.py deleted file mode 100644 index 2d5a00a..0000000 --- a/fuel_plugin_builder/validators/schemas/v5.py +++ /dev/null @@ -1,77 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2016 Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file 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. - -from fuel_plugin_builder.validators.schemas import SchemaV4 - - -class SchemaV5(SchemaV4): - - @property - def package_version(self): - return {'enum': ['5.0.0']} - - @property - def node_attributes_schema(self): - return { - '$schema': 'http://json-schema.org/draft-04/schema#', - 'type': 'object', - 'patternProperties': { - '^[0-9a-zA-Z_-]+$': {"$ref": "#/definitions/attrItem"} - }, - "definitions": { - "attrItem": self.node_nic_attributes_schema - }, - "additionalProperties": False - } - - @property - def node_nic_attributes_schema(self): - return { - '$schema': 'http://json-schema.org/draft-04/schema#', - 'type': 'object', - 'properties': { - 'metadata': self.node_nic_metadata_items - }, - 'patternProperties': { - '^(?!metadata)[0-9a-zA-Z_-]+$': self.node_nic_attribute_items - }, - "additionalProperties": False - } - - @property - def node_nic_attribute_items(self): - return { - 'type': 'object', - 'required': ['type', 'label', 'value'], - 'properties': { - 'label': {'type': 'string'}, - 'description': {'type': 'string'}, - 'type': {'type': 'string'}, - 'value': {}, - 'restrictions': self.restrictions - } - } - - @property - def node_nic_metadata_items(self): - return { - 'type': 'object', - 'required': ['label'], - 'properties': { - 'label': {'type': 'string'}, - 'restrictions': self.restrictions - } - } diff --git a/fuel_plugin_builder/validators/validator_v1.py b/fuel_plugin_builder/validators/validator_v1.py deleted file mode 100644 index aabce30..0000000 --- a/fuel_plugin_builder/validators/validator_v1.py +++ /dev/null @@ -1,66 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2014 Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file 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. - -import logging -from os.path import join as join_path - -from fuel_plugin_builder import utils -from fuel_plugin_builder.validators.base import LegacyBaseValidator -from fuel_plugin_builder.validators.schemas import SchemaV1 - - -logger = logging.getLogger(__name__) - - -class ValidatorV1(LegacyBaseValidator): - - schema = SchemaV1() - - @property - def basic_version(self): - return '6.0' - - def __init__(self, *args, **kwargs): - super(ValidatorV1, self).__init__(*args, **kwargs) - self.meta_path = join_path(self.plugin_path, 'metadata.yaml') - self.tasks_path = join_path(self.plugin_path, 'tasks.yaml') - self.env_conf_path = join_path( - self.plugin_path, 'environment_config.yaml') - - def validate(self): - self.check_schemas() - self.check_tasks() - self.check_releases_paths() - self.check_compatibility() - - def check_tasks(self): - """Json schema doesn't have any conditions, so we have - to make sure here, that puppet task is really puppet - and shell task is correct too - """ - logger.debug('Start tasks checking "%s"', self.tasks_path) - tasks = utils.parse_yaml(self.tasks_path) - - schemas = { - 'puppet': self.schema.puppet_parameters, - 'shell': self.schema.shell_parameters} - - for idx, task in enumerate(tasks): - self.validate_schema( - task.get('parameters'), - schemas[task['type']], - self.tasks_path, - value_path=[idx, 'parameters']) diff --git a/fuel_plugin_builder/validators/validator_v2.py b/fuel_plugin_builder/validators/validator_v2.py deleted file mode 100644 index 43de703..0000000 --- a/fuel_plugin_builder/validators/validator_v2.py +++ /dev/null @@ -1,72 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2014 Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file 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. - -import logging -from os.path import join as join_path - -from fuel_plugin_builder import utils -from fuel_plugin_builder.validators.base import LegacyBaseValidator -from fuel_plugin_builder.validators.schemas import SchemaV2 - - -logger = logging.getLogger(__name__) - - -class ValidatorV2(LegacyBaseValidator): - - schema = SchemaV2() - - @property - def basic_version(self): - return '6.1' - - def __init__(self, *args, **kwargs): - super(ValidatorV2, self).__init__(*args, **kwargs) - self.meta_path = join_path(self.plugin_path, 'metadata.yaml') - self.tasks_path = join_path(self.plugin_path, 'tasks.yaml') - self.env_conf_path = join_path( - self.plugin_path, 'environment_config.yaml') - - def validate(self): - self.check_schemas() - self.check_tasks() - self.check_releases_paths() - self.check_compatibility() - - def _parse_tasks(self): - return utils.parse_yaml(self.tasks_path) - - def check_tasks(self): - """Json schema doesn't have any conditions, so we have - to make sure here, that puppet task is really puppet, - shell or reboot tasks are correct too - """ - logger.debug('Start tasks checking "%s"', self.tasks_path) - tasks = self._parse_tasks() - if tasks is None: - return - - schemas = { - 'puppet': self.schema.puppet_parameters, - 'shell': self.schema.shell_parameters, - 'reboot': self.schema.reboot_parameters} - - for idx, task in enumerate(tasks): - self.validate_schema( - task.get('parameters'), - schemas[task['type']], - self.tasks_path, - value_path=[idx, 'parameters']) diff --git a/fuel_plugin_builder/validators/validator_v3.py b/fuel_plugin_builder/validators/validator_v3.py deleted file mode 100644 index 3439655..0000000 --- a/fuel_plugin_builder/validators/validator_v3.py +++ /dev/null @@ -1,125 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2015 Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file 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. - -import logging -from os.path import join as join_path - -from fuel_plugin_builder import errors -from fuel_plugin_builder import utils -from fuel_plugin_builder.validators.schemas import SchemaV3 -from fuel_plugin_builder.validators import ValidatorV2 - -logger = logging.getLogger(__name__) - - -class ValidatorV3(ValidatorV2): - - schema = SchemaV3() - - def __init__(self, *args, **kwargs): - super(ValidatorV3, self).__init__(*args, **kwargs) - self.deployment_tasks_path = join_path( - self.plugin_path, 'deployment_tasks.yaml') - self.network_roles_path = join_path( - self.plugin_path, 'network_roles.yaml') - self.node_roles_path = join_path( - self.plugin_path, 'node_roles.yaml') - self.volumes_path = join_path( - self.plugin_path, 'volumes.yaml') - - @property - def basic_version(self): - return '7.0' - - def validate(self): - super(ValidatorV3, self).validate() - self.check_deployment_tasks() - - def check_schemas(self): - logger.debug('Start schema checking "%s"', self.plugin_path) - self.validate_file_by_schema( - self.schema.metadata_schema, - self.meta_path) - self.validate_file_by_schema( - self.schema.tasks_schema, - self.tasks_path, - allow_not_exists=True - ) - self.check_env_config_attrs() - self.check_deployment_tasks_schema() - self.check_network_roles_schema() - self.check_node_roles_schema() - self.check_volumes_schema() - - def check_deployment_tasks_schema(self): - self.validate_file_by_schema( - self.schema.deployment_task_schema, - self.deployment_tasks_path) - - def check_network_roles_schema(self): - self.validate_file_by_schema( - self.schema.network_roles_schema, - self.network_roles_path, - allow_not_exists=True) - - def check_node_roles_schema(self): - self.validate_file_by_schema( - self.schema.node_roles_schema, - self.node_roles_path, - allow_not_exists=True) - - def check_volumes_schema(self): - self.validate_file_by_schema( - self.schema.volume_schema, - self.volumes_path, - allow_not_exists=True) - - def check_deployment_tasks(self): - logger.debug( - 'Start deployment tasks checking "%s"', - self.deployment_tasks_path) - - deployment_tasks = utils.parse_yaml(self.deployment_tasks_path) - schemas = { - 'puppet': self.schema.puppet_task, - 'shell': self.schema.shell_task, - 'group': self.schema.group_task, - 'skipped': self.schema.skipped_task, - 'copy_files': self.schema.copy_files, - 'sync': self.schema.sync, - 'upload_file': self.schema.upload_file, - 'stage': self.schema.stage, - 'reboot': self.schema.reboot} - - for idx, deployment_task in enumerate(deployment_tasks): - if deployment_task['type'] not in schemas: - error_msg = 'There is no such task type:' \ - '{0}'.format(deployment_task['type']) - raise errors.ValidationError(error_msg) - self.validate_schema( - deployment_task, - schemas[deployment_task['type']], - self.deployment_tasks_path, - value_path=[idx]) - - def _parse_tasks(self): - if utils.exists(self.tasks_path): - tasks = utils.parse_yaml(self.tasks_path) - # Tasks schema is not checked in check_schemas, thus - # we perform manual check on parsing tasks file - if tasks is None: - raise errors.FileIsEmpty(self.tasks_path) - return None diff --git a/fuel_plugin_builder/validators/validator_v4.py b/fuel_plugin_builder/validators/validator_v4.py deleted file mode 100644 index 45839e6..0000000 --- a/fuel_plugin_builder/validators/validator_v4.py +++ /dev/null @@ -1,134 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2015 Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file 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. - -import logging -from os.path import join as join_path - -from fuel_plugin_builder import errors -from fuel_plugin_builder import utils -from fuel_plugin_builder.validators.formatchecker import FormatChecker -from fuel_plugin_builder.validators.schemas import SchemaV4 -from fuel_plugin_builder.validators import ValidatorV3 - - -logger = logging.getLogger(__name__) - - -class ValidatorV4(ValidatorV3): - - schema = SchemaV4() - - def __init__(self, *args, **kwargs): - super(ValidatorV4, self).__init__(format_checker=FormatChecker( - role_patterns=[self.schema.role_pattern]), *args, **kwargs) - self.components_path = join_path(self.plugin_path, 'components.yaml') - - @property - def basic_version(self): - return '8.0' - - def check_metadata_schema(self): - self.validate_file_by_schema( - self.schema.metadata_schema, - self.meta_path, - allow_not_exists=True) - - def check_tasks_schema(self): - self.validate_file_by_schema( - self.schema.tasks_schema, - self.tasks_path, - allow_not_exists=True, - allow_empty=True - ) - - def check_schemas(self): - logger.debug('Start schema checking "%s"', self.plugin_path) - self.check_metadata_schema() - self.check_tasks_schema() - self.check_env_config_attrs() - self.check_deployment_tasks_schema() - self.check_network_roles_schema() - self.check_node_roles_schema() - self.check_volumes_schema() - self.check_components_schema() - - def check_components_schema(self): - self.validate_file_by_schema(self.schema.components_schema, - self.components_path, - allow_not_exists=True) - - def check_deployment_tasks(self): - logger.debug( - 'Start deployment tasks checking "%s"', - self.deployment_tasks_path) - - deployment_tasks = utils.parse_yaml(self.deployment_tasks_path) - schemas = { - 'puppet': self.schema.puppet_task, - 'shell': self.schema.shell_task, - 'group': self.schema.group_task, - 'skipped': self.schema.skipped_task, - 'copy_files': self.schema.copy_files_task, - 'sync': self.schema.sync_task, - 'upload_file': self.schema.upload_file_task, - 'stage': self.schema.stage_task, - 'reboot': self.schema.reboot_task} - - for idx, deployment_task in enumerate(deployment_tasks): - if deployment_task['type'] not in schemas: - error_msg = 'There is no such task type:' \ - '{0}'.format(deployment_task['type']) - raise errors.ValidationError(error_msg) - if deployment_task['type'] not in self.schema.roleless_tasks: - for role_alias in self.schema.role_aliases: - deployment_role = deployment_task.get(role_alias) - if deployment_role: - break - else: - logger.warn( - 'Task {0} does not contain {1} fields. That ' - 'may lead to tasks being unassigned to nodes.'. - format(deployment_task['id'], '/'. - join(self.schema.role_aliases))) - - self.validate_schema( - deployment_task, - schemas[deployment_task['type']], - self.deployment_tasks_path, - value_path=[idx]) - - def check_tasks(self): - """Check legacy tasks.yaml.""" - logger.debug('Start tasks checking "%s"', self.tasks_path) - if utils.exists(self.tasks_path): - # todo(ikutukov): remove self._check_tasks - tasks = utils.parse_yaml(self.tasks_path) - if tasks is None: - return - - schemas = { - 'puppet': self.schema.puppet_parameters, - 'shell': self.schema.shell_parameters, - 'reboot': self.schema.reboot_parameters} - - for idx, task in enumerate(tasks): - self.validate_schema( - task.get('parameters'), - schemas[task['type']], - self.tasks_path, - value_path=[idx, 'parameters']) - else: - logger.debug('File "%s" doesn\'t exist', self.tasks_path) diff --git a/fuel_plugin_builder/validators/validator_v5.py b/fuel_plugin_builder/validators/validator_v5.py deleted file mode 100644 index 8f2a642..0000000 --- a/fuel_plugin_builder/validators/validator_v5.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2016 Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file 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. - -from os.path import join as join_path - -from fuel_plugin_builder.validators.schemas import SchemaV5 -from fuel_plugin_builder.validators import ValidatorV4 - - -class ValidatorV5(ValidatorV4): - - schema = SchemaV5() - - def __init__(self, *args, **kwargs): - super(ValidatorV5, self).__init__(*args, **kwargs) - self.bond_config_path = join_path(self.plugin_path, 'bond_config.yaml') - self.nic_config_path = join_path(self.plugin_path, 'nic_config.yaml') - self.node_config_path = join_path(self.plugin_path, 'node_config.yaml') - - @property - def basic_version(self): - return '9.0' - - def check_schemas(self): - super(ValidatorV5, self).check_schemas() - self.check_node_attributes_schema() - self.check_interface_attributes_schema(self.bond_config_path) - self.check_interface_attributes_schema(self.nic_config_path) - - def check_node_attributes_schema(self): - self.validate_file_by_schema(self.schema.node_attributes_schema, - self.node_config_path, - allow_not_exists=True) - - def check_interface_attributes_schema(self, file_path): - self.validate_file_by_schema(self.schema.node_nic_attributes_schema, - file_path, - allow_not_exists=True) diff --git a/fuel_plugin_builder/version_mapping.py b/fuel_plugin_builder/version_mapping.py deleted file mode 100644 index 61533ba..0000000 --- a/fuel_plugin_builder/version_mapping.py +++ /dev/null @@ -1,101 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2014 Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file 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. - -from os.path import join as join_path - -from fuel_plugin_builder import errors -from fuel_plugin_builder import utils - - -latest_version = '5.0.0' - - -def get_mapping(): - # NOTE(eli): It's required not to have circular dependencies error - from fuel_plugin_builder.actions import build - from fuel_plugin_builder import validators - - return [ - {'version': '1.0.0', - 'templates': ['templates/base/plugin_data', - 'templates/v1/plugin_data/'], - 'validator': validators.ValidatorV1, - 'builder': build.BuildPluginV1}, - {'version': '2.0.0', - 'templates': ['templates/base/plugin_data', - 'templates/v2/plugin_data/'], - 'validator': validators.ValidatorV2, - 'builder': build.BuildPluginV2}, - {'version': '3.0.0', - 'templates': ['templates/base/plugin_data', - 'templates/v3/plugin_data/'], - 'validator': validators.ValidatorV3, - 'builder': build.BuildPluginV3}, - {'version': '4.0.0', - 'templates': [ - 'templates/base/plugin_data', - 'templates/v3/plugin_data/', - 'templates/v4/plugin_data/'], - 'validator': validators.ValidatorV4, - 'builder': build.BuildPluginV4}, - {'version': '5.0.0', - 'templates': [ - 'templates/base/plugin_data', - 'templates/v3/plugin_data/', - 'templates/v4/plugin_data/', - 'templates/v5/plugin_data/'], - 'validator': validators.ValidatorV5, - 'builder': build.BuildPluginV5}] - - -def get_plugin_for_version(version): - """Retrieves data which are required for specific version of plugin - - :param str version: version of package - :returns: dict which contains - 'version' - package version - 'templates' - array of paths to templates - 'validator' - validator class - 'builder' - builder class - """ - data = filter(lambda p: p['version'] == version, get_mapping()) - - if not data: - raise errors.WrongPackageVersionError( - 'Wrong package version "{0}"'.format(version)) - - return data[0] - - -def get_version_mapping_from_plugin(plugin_path): - """Returns mapping for specific version of the plugin - - :param str plugin_path: path to the directory with metadata.yaml file - :returns: dict which contains - 'version' - package version - 'validator' - validator class - 'templates' - path to templates - 'builder' - builder class - """ - meta_path = join_path(plugin_path, 'metadata.yaml') - if not utils.exists(meta_path): - errors.WrongPluginDirectoryError( - 'Wrong path to the plugin, cannot find "%s" file', meta_path) - - meta = utils.parse_yaml(meta_path) - package_version = meta.get('package_version') - - return get_plugin_for_version(package_version) diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 2a977bb..0000000 --- a/requirements.txt +++ /dev/null @@ -1,9 +0,0 @@ -# The order of packages is significant, because pip processes them in the order -# of appearance. Changing the order has an impact on the overall integration -# process, which may cause wedges in the gate later. - -pbr>=1.6 -six>=1.5.2 -Mako==0.9.1 -PyYAML==3.10 -jsonschema==2.4.0 diff --git a/run_tests.sh b/run_tests.sh deleted file mode 100755 index cf6bf73..0000000 --- a/run_tests.sh +++ /dev/null @@ -1,151 +0,0 @@ -#!/bin/bash - -# Copyright 2014 Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file 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. - -set -eu - - -function usage { - echo "Usage: $0 [OPTION]..." - echo "Run fuel plugin building" - echo "" - echo " -b, --build Builds all of the plugins" - echo " -B, --no-build Don't run plugins build" - echo " -f, --fpb Run tests for fpb" - echo " -F, --no-fpb Don't run tests for fpb" - echo " -h, --help Print this usage message" - echo "" - echo "Note: with no options specified, the script will try to run " - echo " all available tests with all available checks." - exit -} - - -function process_options { - for arg in $@; do - case "$arg" in - -h|--help) usage;; - -b|--build) plugins_build=1;; - -B|--no-build) no_plugins_build=1;; - -f|--fpb) fpb_tests=1;; - -F|--no-fpb) no_fpb_tests=1;; - -*) testropts="$testropts $arg";; - *) testrargs="$testrargs $arg" - esac - done -} - -# Settings -ROOT=$(dirname `readlink -f $0`) -FPB_VENV_PATH=${FPB_VENV_PATH:-"${ROOT}/fpb_venv"} -BUILT_PLUGINS_PATH=${BUILT_PLUGINS_PATH:-"${ROOT}/built_plugins"} - -# Initialize global variables -plugins_build=0 -no_plugins_build=0 -fpb_tests=0 -no_fpb_tests=0 - - -function run_tests { - run_cleanup - - # This variable collects all failed tests. It'll be printed in - # the end of this function as a small statistic for user. - local errors="" - - # Enable all tests if none was specified skipping all explicitly - # disabled tests. - if [[ $plugins_build -eq 0 && \ - $fpb_tests -eq 0 ]]; then - - if [ $no_plugins_build -ne 1 ]; then plugins_build=1; fi - if [ $no_fpb_tests -ne 1 ]; then fpb_tests=1; fi - - fi - - # Run all enabled tests - if [ $plugins_build -eq 1 ]; then - echo "Starting plugins build..." - run_build || errors+=" plugins_build" - fi - - if [ $fpb_tests -eq 1 ]; then - echo "Starting fpb testing..." - run_fpb || errors+=" fpb_tests" - fi - - if [ -n "$errors" ]; then - echo Failed tests: $errors - exit 1 - fi - - exit -} - - -function run_cleanup { - find ${ROOT} -type f -name *.pyc -delete -} - - -function run_fpb { - local result=0 - - pushd "${ROOT}" >> /dev/null - tox || result=1 - popd >> /dev/null - - return $result -} - - -# Build all of the plugins with current version of plugins builder -function run_build { - virtualenv $FPB_VENV_PATH - - # virtualenv has unbound variables - # disable it during virtualenv usage - set +u - - source $FPB_VENV_PATH/bin/activate || return 1 - fpb_path="${ROOT}" - pushd $fpb_path - pip install . - popd - - mkdir -p $BUILT_PLUGINS_PATH - rm -f $BUILT_PLUGINS_PATH/*.fp - rm -f $BUILT_PLUGINS_PATH/*.rpm - - # Find plugins - for dir in $ROOT/examples/*/metadata.yaml; - do - plugin_dir=$(dirname "${dir}"); - pushd "${plugin_dir}" - fpb --build "${plugin_dir}" --debug || return 1 - cp *.fp $BUILT_PLUGINS_PATH/ - cp *.rpm $BUILT_PLUGINS_PATH/ - popd - done - - deactivate - set -u - return 0 -} - -# Parse command line arguments and run the tests -process_options $@ -run_tests diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index dbd6c14..0000000 --- a/setup.cfg +++ /dev/null @@ -1,32 +0,0 @@ -[metadata] -name = fuel-plugin-builder -description-file = README.rst -description = Helps to create and build fuel plugins -author = OpenStack -author-email = openstack-dev@lists.openstack.org -home-page = https://wiki.openstack.org/wiki/Fuel/Plugins -classifier = - Environment :: OpenStack - Intended Audience :: Information Technology - Intended Audience :: Developers - License :: OSI Approved :: Apache Software License - Operating System :: POSIX :: Linux - Programming Language :: Python - Programming Language :: Python :: 2 - Programming Language :: Python :: 2.7 - Topic :: System :: Software Distribution - -[files] -packages = fuel_plugin_builder - -[entry_points] -console_scripts = - fpb = fuel_plugin_builder.cli:main - fuel-plugin-builder = fuel_plugin_builder.cli:main - -[global] -setup-hooks = - pbr.hooks.setup_hook - -[wheel] -python-tag = py2 diff --git a/setup.py b/setup.py deleted file mode 100644 index 782bb21..0000000 --- a/setup.py +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright (c) 2013 Hewlett-Packard Development Company, L.P. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file 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. - -# THIS FILE IS MANAGED BY THE GLOBAL REQUIREMENTS REPO - DO NOT EDIT -import setuptools - -# In python < 2.7.4, a lazy loading of package `pbr` will break -# setuptools if some other modules registered functions in `atexit`. -# solution from: http://bugs.python.org/issue15881#msg170215 -try: - import multiprocessing # noqa -except ImportError: - pass - -setuptools.setup( - setup_requires=['pbr>=1.8'], - pbr=True) diff --git a/test-requirements.txt b/test-requirements.txt deleted file mode 100644 index d791da9..0000000 --- a/test-requirements.txt +++ /dev/null @@ -1,5 +0,0 @@ -hacking==0.7 -mock==1.0 -nose==1.1.2 -nose2==0.4.1 -nose-timer==0.2.0 diff --git a/tox.ini b/tox.ini deleted file mode 100644 index 6b9f0b8..0000000 --- a/tox.ini +++ /dev/null @@ -1,36 +0,0 @@ -[tox] -minversion = 1.6 -skipsdist = True -envlist = py27,pep8 - -[testenv] -usedevelop = True -install_command = pip install {packages} -setenv = VIRTUAL_ENV={envdir} -passenv = http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY -deps = -r{toxinidir}/test-requirements.txt -commands = - nosetests {posargs:fuel_plugin_builder} - -[testenv:pep8] -deps = hacking==0.7 -usedevelop = False -commands = - flake8 {posargs:.} - -[testenv:venv] -commands = {posargs:} - -[testenv:devenv] -envdir = devenv -usedevelop = True - -[flake8] -ignore = H302,H802 -exclude = .venv,.git,.tox,dist,doc,*lib/python*,*egg,build,tools,__init__.py,docs,examples,fpb_venv -show-pep8 = True -show-source = True -count = True - -[hacking] -import_exceptions = testtools.matchers