diff --git a/nscharm_ns/charms/ns/README.md b/nscharm_ns/charms/layers/ns/README.md similarity index 100% rename from nscharm_ns/charms/ns/README.md rename to nscharm_ns/charms/layers/ns/README.md diff --git a/nscharm_ns/charms/ns/actions.yaml b/nscharm_ns/charms/layers/ns/actions.yaml similarity index 63% rename from nscharm_ns/charms/ns/actions.yaml rename to nscharm_ns/charms/layers/ns/actions.yaml index 74a4fdfe0628413272e9ac2d42ec600b39b0f60f..59063a412eec30dd9b03fff6dedfb1daa40a35c0 100644 --- a/nscharm_ns/charms/ns/actions.yaml +++ b/nscharm_ns/charms/layers/ns/actions.yaml @@ -15,28 +15,28 @@ # under the License. ## -"add-user": - "description": "Add a user" - "params": - "username": - "description": "The username to add" - "type": "string" - "default": "" - "bw": - "description": "" - "type": "integer" - "default": !!int "0" - "qos": - "description": "" - "type": "integer" - "default": !!int "0" - "tariff": - "description": "" - "type": "integer" - "default": !!int "0" +add-user: + description: "Add a user" + params: + username: + description: "The username to add" + type: string + default: "" + bw: + description: "" + type: integer + default: 0 + qos: + description: "" + type: integer + default: 0 + tariff: + description: "" + type: integer + default: 0 - "required": + required: # We're only requiring username here, and will use the default values # for the remaining parameters. This can be changed by adding the # required parameter names below. - - "username" + - username diff --git a/nscharm_ns/charms/ns/actions/add-user b/nscharm_ns/charms/layers/ns/actions/add-user similarity index 100% rename from nscharm_ns/charms/ns/actions/add-user rename to nscharm_ns/charms/layers/ns/actions/add-user diff --git a/nscharm_ns/charms/layers/ns/config.yaml b/nscharm_ns/charms/layers/ns/config.yaml new file mode 100644 index 0000000000000000000000000000000000000000..446fb46768315e8f1f5922d86755a1bae91435aa --- /dev/null +++ b/nscharm_ns/charms/layers/ns/config.yaml @@ -0,0 +1,18 @@ +options: + user-member-index: + default: + description: The vnf-member-index of the user VNF. + type: string + user-vdu-id: + default: + description: The id of the VDU containing the charm. + type: string + + policy-member-index: + default: + description: The vnf-member-index of the policy VNF. + type: string + policy-vdu-id: + default: + description: The id of the VDU containing the charm. + type: string diff --git a/nscharm_ns/charms/ns/icon.svg b/nscharm_ns/charms/layers/ns/icon.svg similarity index 100% rename from nscharm_ns/charms/ns/icon.svg rename to nscharm_ns/charms/layers/ns/icon.svg diff --git a/nscharm_ns/charms/layers/ns/layer.yaml b/nscharm_ns/charms/layers/ns/layer.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ca5c75eb483ff9efbd2a34556397cfd92605f895 --- /dev/null +++ b/nscharm_ns/charms/layers/ns/layer.yaml @@ -0,0 +1,6 @@ +includes: + - 'layer:basic' + - 'layer:osm-ns' +options: + basic: + use_venv: false diff --git a/nscharm_ns/charms/layers/ns/metadata.yaml b/nscharm_ns/charms/layers/ns/metadata.yaml new file mode 100644 index 0000000000000000000000000000000000000000..3880a8e3f9637a4bb90654011b00868c20cfa824 --- /dev/null +++ b/nscharm_ns/charms/layers/ns/metadata.yaml @@ -0,0 +1,13 @@ +name: ns +summary: +maintainer: Adam Israel +description: | + +tags: + # Replace "misc" with one or more whitelisted tags from this list: + # https://jujucharms.com/docs/stable/authors-charm-metadata + - misc +series: + - xenial + - bionic +subordinate: false diff --git a/nscharm_ns/charms/ns/reactive/ns.py b/nscharm_ns/charms/layers/ns/reactive/ns.py similarity index 100% rename from nscharm_ns/charms/ns/reactive/ns.py rename to nscharm_ns/charms/layers/ns/reactive/ns.py diff --git a/nscharm_ns/charms/ns/tests/00-setup b/nscharm_ns/charms/layers/ns/tests/00-setup similarity index 100% rename from nscharm_ns/charms/ns/tests/00-setup rename to nscharm_ns/charms/layers/ns/tests/00-setup diff --git a/nscharm_ns/charms/ns/tests/10-deploy b/nscharm_ns/charms/layers/ns/tests/10-deploy similarity index 100% rename from nscharm_ns/charms/ns/tests/10-deploy rename to nscharm_ns/charms/layers/ns/tests/10-deploy diff --git a/nscharm_ns/charms/ns/.build.manifest b/nscharm_ns/charms/ns/.build.manifest deleted file mode 100644 index 427002c443216031e86c90618381b1aeef07dd4d..0000000000000000000000000000000000000000 --- a/nscharm_ns/charms/ns/.build.manifest +++ /dev/null @@ -1,292 +0,0 @@ -{ - "layers": [ - { - "rev": "fcdcea4e5de3e1556c24e6704607862d0ba00a56", - "url": "layer:options" - }, - { - "rev": "623e69c7b432456fd4364f6e1835424fd6b5425e", - "url": "layer:basic" - }, - { - "rev": "d59fe211bb4c2834352dc8bf62b6d6891e81834c", - "url": "layer:osm-ns" - }, - { - "rev": "b189ed8df5e652bdd886431f3c0220f7f5af87b4", - "url": "ns" - } - ], - "signatures": { - ".build.manifest": [ - "build", - "dynamic", - "unchecked" - ], - ".gitignore": [ - "layer:basic", - "static", - "0da5c4dcda27cd6406e5bb81cbf68ddccaf728ac764ec15053a165c1449d87d9" - ], - ".travis/profile-update.yaml": [ - "layer:basic", - "static", - "731e20aa59bf61c024d317ad630e478301a9386ccc0afe56e6c1c09db07ac83b" - ], - "LICENSE": [ - "layer:basic", - "static", - "cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30" - ], - "Makefile": [ - "layer:basic", - "static", - "b7ab3a34e5faf79b96a8632039a0ad0aa87f2a9b5f0ba604e007cafb22190301" - ], - "README.md": [ - "ns", - "static", - "2d66b85187cdce4854d3a5a39f7458faf882b919b47a83a675654cdcaa520742" - ], - "actions.yaml": [ - "ns", - "dynamic", - "d3eeb0c4a2386661202166c19774b6ae9e04ae71dda52a027bffdf67075a1448" - ], - "actions/add-user": [ - "ns", - "static", - "46bf4be02078a0f5ac60ab81609372a8f9943885b7a4999ce5332ea2f4857036" - ], - "bin/charm-env": [ - "layer:basic", - "static", - "fb6a20fac4102a6a4b6ffe903fcf666998f9a95a3647e6f9af7a1eeb44e58fd5" - ], - "bin/layer_option": [ - "layer:options", - "static", - "e959bf29da4c5edff28b2602c24113c4df9e25cdc9f2aa3b5d46c8577b2a40cc" - ], - "config.yaml": [ - "ns", - "dynamic", - "ae697230ea4c0e9ac8ec8fa039dbb11304cad42011adcaa40a8412c47159324b" - ], - "copyright": [ - "layer:basic", - "static", - "f6740d66fd60b60f2533d9fcb53907078d1e20920a0219afce7182e2a1c97629" - ], - "copyright.layer-options": [ - "layer:options", - "static", - "f6740d66fd60b60f2533d9fcb53907078d1e20920a0219afce7182e2a1c97629" - ], - "hooks/config-changed": [ - "layer:basic", - "dynamic", - "2b693cb2a11594a80cc91235c2dc219a0a6303ae62bee8aa87eb35781f7158f7" - ], - "hooks/hook.template": [ - "layer:basic", - "static", - "2b693cb2a11594a80cc91235c2dc219a0a6303ae62bee8aa87eb35781f7158f7" - ], - "hooks/install": [ - "layer:basic", - "dynamic", - "2b693cb2a11594a80cc91235c2dc219a0a6303ae62bee8aa87eb35781f7158f7" - ], - "hooks/leader-elected": [ - "layer:basic", - "dynamic", - "2b693cb2a11594a80cc91235c2dc219a0a6303ae62bee8aa87eb35781f7158f7" - ], - "hooks/leader-settings-changed": [ - "layer:basic", - "dynamic", - "2b693cb2a11594a80cc91235c2dc219a0a6303ae62bee8aa87eb35781f7158f7" - ], - "hooks/post-series-upgrade": [ - "layer:basic", - "dynamic", - "2b693cb2a11594a80cc91235c2dc219a0a6303ae62bee8aa87eb35781f7158f7" - ], - "hooks/pre-series-upgrade": [ - "layer:basic", - "dynamic", - "2b693cb2a11594a80cc91235c2dc219a0a6303ae62bee8aa87eb35781f7158f7" - ], - "hooks/start": [ - "layer:basic", - "dynamic", - "2b693cb2a11594a80cc91235c2dc219a0a6303ae62bee8aa87eb35781f7158f7" - ], - "hooks/stop": [ - "layer:basic", - "dynamic", - "2b693cb2a11594a80cc91235c2dc219a0a6303ae62bee8aa87eb35781f7158f7" - ], - "hooks/update-status": [ - "layer:basic", - "dynamic", - "2b693cb2a11594a80cc91235c2dc219a0a6303ae62bee8aa87eb35781f7158f7" - ], - "hooks/upgrade-charm": [ - "layer:basic", - "dynamic", - "2b693cb2a11594a80cc91235c2dc219a0a6303ae62bee8aa87eb35781f7158f7" - ], - "icon.svg": [ - "ns", - "static", - "d20624e9389af6506a8d8a69ac9bba4d41709601b624c0875fd7d6717b395088" - ], - "layer.yaml": [ - "ns", - "dynamic", - "431a730b6fb7851377a021b85ba3ebdfca416448af0bb0618d953928089b1df0" - ], - "lib/charms/layer/__init__.py": [ - "layer:basic", - "static", - "dfe0d26c6bf409767de6e2546bc648f150e1b396243619bad3aa0553ab7e0e6f" - ], - "lib/charms/layer/basic.py": [ - "layer:basic", - "static", - "3126b5754ad39402ee27e64527044ddd231ed1cd137fcedaffb51e63a635f108" - ], - "lib/charms/layer/execd.py": [ - "layer:basic", - "static", - "fda8bd491032db1db8ddaf4e99e7cc878c6fb5432efe1f91cadb5b34765d076d" - ], - "lib/charms/layer/options.py": [ - "layer:options", - "static", - "8ae7a07d22542fc964f2d2bee8219d1c78a68dace70a1b38d36d4aea47b1c3b2" - ], - "lib/charms/osm/ns.py": [ - "layer:osm-ns", - "static", - "743c4d49f0bd5a143057a0370fc47a837e0ee43d8eceff8e90b7f05e4db7b1e9" - ], - "metadata.yaml": [ - "ns", - "dynamic", - "19db902355c43e4f6c41291e48c7a1d1c789a13774a49b524d1d052dbbacc32f" - ], - "reactive/__init__.py": [ - "layer:basic", - "static", - "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" - ], - "reactive/ns.py": [ - "ns", - "static", - "eea5f82e9332f2129f63c8ff528abf3f556c1c68e25fb08fb9cc2255e0ebdcae" - ], - "reactive/osm_ns.py": [ - "layer:osm-ns", - "static", - "d29161a94d60dc8666ede44e4bfe7f51fe052f919eb9c03db03b2111a8f2b68c" - ], - "requirements.txt": [ - "layer:basic", - "static", - "a00f75d80849e5b4fc5ad2e7536f947c25b1a4044b341caa8ee87a92d3a4c804" - ], - "tests/00-setup": [ - "ns", - "static", - "111c079b81d260bbcd716dcf41672372a4cf4aaa14154b6c3055deeedae37a06" - ], - "tests/10-deploy": [ - "ns", - "static", - "1750031833a1d3e3dfa1e7f5ee97f75cb84ac2e483b1470b2b41e17f0b39c173" - ], - "version": [ - "ns", - "dynamic", - "a6dd063a3024e9bf54901a897cd7926d5bceab359e6cb0eb9deb34d2eab29367" - ], - "wheelhouse.txt": [ - "layer:basic", - "dynamic", - "7cf3f983dc8f85b0c0ca6d69accdb4f4af842a911625286df09005ed1897d797" - ], - "wheelhouse/Jinja2-2.10.1.tar.gz": [ - "layer:basic", - "dynamic", - "065c4f02ebe7f7cf559e49ee5a95fb800a9e4528727aec6f24402a5374c65013" - ], - "wheelhouse/MarkupSafe-1.1.1.tar.gz": [ - "__pip__", - "dynamic", - "29872e92839765e546828bb7754a68c418d927cd064fd4708fab9fe9c8bb116b" - ], - "wheelhouse/PyYAML-5.2.tar.gz": [ - "layer:basic", - "dynamic", - "c0ee8eca2c582d29c3c2ec6e2c4f703d1b7f1fb10bc72317355a746057e7346c" - ], - "wheelhouse/Tempita-0.5.2.tar.gz": [ - "__pip__", - "dynamic", - "cacecf0baa674d356641f1d406b8bff1d756d739c46b869a54de515d08e6fc9c" - ], - "wheelhouse/charmhelpers-0.20.19.tar.gz": [ - "layer:basic", - "dynamic", - "74b2d95ec305e5799f0f7d068b0c6e010612ec877feadf32fc51e6bed1f68234" - ], - "wheelhouse/charms.reactive-1.3.2.tar.gz": [ - "layer:basic", - "dynamic", - "f4633eb37143bf9cc2c0e760a67314954c31fa68ec36d5399d386839cb5d54d5" - ], - "wheelhouse/netaddr-0.7.19.tar.gz": [ - "layer:basic", - "dynamic", - "38aeec7cdd035081d3a4c306394b19d677623bf76fa0913f6695127c7753aefd" - ], - "wheelhouse/pbr-5.5.1.tar.gz": [ - "__pip__", - "dynamic", - "5fad80b613c402d5b7df7bd84812548b2a61e9977387a80a5fc5c396492b13c9" - ], - "wheelhouse/pip-18.1.tar.gz": [ - "layer:basic", - "dynamic", - "c0a292bd977ef590379a3f05d7b7f65135487b67470f6281289a94e015650ea1" - ], - "wheelhouse/pyaml-20.4.0.tar.gz": [ - "__pip__", - "dynamic", - "29a5c2a68660a799103d6949167bd6c7953d031449d08802386372de1db6ad71" - ], - "wheelhouse/setuptools-41.6.0.zip": [ - "layer:basic", - "dynamic", - "6afa61b391dcd16cb8890ec9f66cc4015a8a31a6e1c2b4e0c464514be1a3d722" - ], - "wheelhouse/setuptools_scm-1.17.0.tar.gz": [ - "layer:basic", - "dynamic", - "70a4cf5584e966ae92f54a764e6437af992ba42ac4bca7eb37cc5d02b98ec40a" - ], - "wheelhouse/six-1.15.0.tar.gz": [ - "__pip__", - "dynamic", - "30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259" - ], - "wheelhouse/wheel-0.33.6.tar.gz": [ - "layer:basic", - "dynamic", - "10c9da68765315ed98850f8e048347c3eb06dd81822dc2ab1d4fde9dc9702646" - ] - } -} \ No newline at end of file diff --git a/nscharm_ns/charms/ns/.gitignore b/nscharm_ns/charms/ns/.gitignore deleted file mode 100644 index 56e95aac517af399ce55d6b518634be955772bd4..0000000000000000000000000000000000000000 --- a/nscharm_ns/charms/ns/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -*.pyc -*~ -.ropeproject -.settings -.tox diff --git a/nscharm_ns/charms/ns/.travis/profile-update.yaml b/nscharm_ns/charms/ns/.travis/profile-update.yaml deleted file mode 100644 index 57f96eb6f9fa6f13158e59df78f2a9cab4c51949..0000000000000000000000000000000000000000 --- a/nscharm_ns/charms/ns/.travis/profile-update.yaml +++ /dev/null @@ -1,12 +0,0 @@ -config: {} -description: Default LXD profile - updated -devices: - eth0: - name: eth0 - parent: lxdbr0 - nictype: bridged - type: nic - root: - path: / - pool: default - type: disk diff --git a/nscharm_ns/charms/ns/LICENSE b/nscharm_ns/charms/ns/LICENSE deleted file mode 100644 index d645695673349e3947e8e5ae42332d0ac3164cd7..0000000000000000000000000000000000000000 --- a/nscharm_ns/charms/ns/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/nscharm_ns/charms/ns/Makefile b/nscharm_ns/charms/ns/Makefile deleted file mode 100644 index a1ad3a5cd27751144f6bd1a0a7db50f1e11b18eb..0000000000000000000000000000000000000000 --- a/nscharm_ns/charms/ns/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/make - -all: lint unit_test - - -.PHONY: clean -clean: - @rm -rf .tox - -.PHONY: apt_prereqs -apt_prereqs: - @# Need tox, but don't install the apt version unless we have to (don't want to conflict with pip) - @which tox >/dev/null || (sudo apt-get install -y python-pip && sudo pip install tox) - -.PHONY: lint -lint: apt_prereqs - @tox --notest - @PATH=.tox/py34/bin:.tox/py35/bin flake8 $(wildcard hooks reactive lib unit_tests tests) - @charm proof - -.PHONY: unit_test -unit_test: apt_prereqs - @echo Starting tests... - tox diff --git a/nscharm_ns/charms/ns/bin/charm-env b/nscharm_ns/charms/ns/bin/charm-env deleted file mode 100755 index d211ce9b2912dd072aa7e1ce0399783fd075efc4..0000000000000000000000000000000000000000 --- a/nscharm_ns/charms/ns/bin/charm-env +++ /dev/null @@ -1,107 +0,0 @@ -#!/bin/bash - -VERSION="1.0.0" - - -find_charm_dirs() { - # Hopefully, $JUJU_CHARM_DIR is set so which venv to use in unambiguous. - if [[ -n "$JUJU_CHARM_DIR" || -n "$CHARM_DIR" ]]; then - if [[ -z "$JUJU_CHARM_DIR" ]]; then - # accept $CHARM_DIR to be more forgiving - export JUJU_CHARM_DIR="$CHARM_DIR" - fi - if [[ -z "$CHARM_DIR" ]]; then - # set CHARM_DIR as well to help with backwards compatibility - export CHARM_DIR="$JUJU_CHARM_DIR" - fi - return - fi - # Try to guess the value for JUJU_CHARM_DIR by looking for a non-subordinate - # (because there's got to be at least one principle) charm directory; - # if there are several, pick the first by alpha order. - agents_dir="/var/lib/juju/agents" - if [[ -d "$agents_dir" ]]; then - desired_charm="$1" - found_charm_dir="" - if [[ -n "$desired_charm" ]]; then - for charm_dir in $(/bin/ls -d "$agents_dir"/unit-*/charm); do - charm_name="$(grep -o '^['\''"]\?name['\''"]\?:.*' $charm_dir/metadata.yaml 2> /dev/null | sed -e 's/.*: *//' -e 's/['\''"]//g')" - if [[ "$charm_name" == "$desired_charm" ]]; then - if [[ -n "$found_charm_dir" ]]; then - >&2 echo "Ambiguous possibilities for JUJU_CHARM_DIR matching '$desired_charm'; please run within a Juju hook context" - exit 1 - fi - found_charm_dir="$charm_dir" - fi - done - if [[ -z "$found_charm_dir" ]]; then - >&2 echo "Unable to determine JUJU_CHARM_DIR matching '$desired_charm'; please run within a Juju hook context" - exit 1 - fi - export JUJU_CHARM_DIR="$found_charm_dir" - export CHARM_DIR="$found_charm_dir" - return - fi - # shellcheck disable=SC2126 - non_subordinates="$(grep -L 'subordinate"\?:.*true' "$agents_dir"/unit-*/charm/metadata.yaml | wc -l)" - if [[ "$non_subordinates" -gt 1 ]]; then - >&2 echo 'Ambiguous possibilities for JUJU_CHARM_DIR; please use --charm or run within a Juju hook context' - exit 1 - elif [[ "$non_subordinates" -eq 1 ]]; then - for charm_dir in $(/bin/ls -d "$agents_dir"/unit-*/charm); do - if grep -q 'subordinate"\?:.*true' "$charm_dir/metadata.yaml"; then - continue - fi - export JUJU_CHARM_DIR="$charm_dir" - export CHARM_DIR="$charm_dir" - return - done - fi - fi - >&2 echo 'Unable to determine JUJU_CHARM_DIR; please run within a Juju hook context' - exit 1 -} - -try_activate_venv() { - if [[ -d "$JUJU_CHARM_DIR/../.venv" ]]; then - . "$JUJU_CHARM_DIR/../.venv/bin/activate" - fi -} - -find_wrapped() { - PATH="${PATH/\/usr\/local\/sbin:}" which "$(basename "$0")" -} - - -if [[ "$1" == "--version" || "$1" == "-v" ]]; then - echo "$VERSION" - exit 0 -fi - - -# allow --charm option to hint which JUJU_CHARM_DIR to choose when ambiguous -# NB: --charm option must come first -# NB: option must be processed outside find_charm_dirs to modify $@ -charm_name="" -if [[ "$1" == "--charm" ]]; then - charm_name="$2" - shift; shift -fi - -find_charm_dirs "$charm_name" -try_activate_venv -export PYTHONPATH="$JUJU_CHARM_DIR/lib:$PYTHONPATH" - -if [[ "$(basename "$0")" == "charm-env" ]]; then - # being used as a shebang - exec "$@" -elif [[ "$0" == "$BASH_SOURCE" ]]; then - # being invoked as a symlink wrapping something to find in the venv - exec "$(find_wrapped)" "$@" -elif [[ "$(basename "$BASH_SOURCE")" == "charm-env" ]]; then - # being sourced directly; do nothing - /bin/true -else - # being sourced for wrapped bash helpers - . "$(find_wrapped)" -fi diff --git a/nscharm_ns/charms/ns/bin/layer_option b/nscharm_ns/charms/ns/bin/layer_option deleted file mode 100755 index 3253ef8aadb95807f26e5ebd8486adde67e5cbc2..0000000000000000000000000000000000000000 --- a/nscharm_ns/charms/ns/bin/layer_option +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 - -import sys -import argparse -from charms import layer - - -parser = argparse.ArgumentParser(description='Access layer options.') -parser.add_argument('section', - help='the section, or layer, the option is from') -parser.add_argument('option', - help='the option to access') - -args = parser.parse_args() -value = layer.options.get(args.section, args.option) -if isinstance(value, bool): - sys.exit(0 if value else 1) -elif isinstance(value, list): - for val in value: - print(val) -else: - print(value) diff --git a/nscharm_ns/charms/ns/config.yaml b/nscharm_ns/charms/ns/config.yaml deleted file mode 100644 index 1dcfabea1e8861891afa3bccedf6f55bc587fdb1..0000000000000000000000000000000000000000 --- a/nscharm_ns/charms/ns/config.yaml +++ /dev/null @@ -1,31 +0,0 @@ -"options": - "juju-username": - "type": "string" - "default": "" - "description": "The Juju username to authenticate with." - "juju-password": - "type": "string" - "default": "" - "description": "The Juju password to authenticate with." - "ns_config_info": - "type": "string" - "default": "" - "description": "The NS_CONFIG_INFO containing the mapping of NS object to application\ - \ names" - "user-member-index": - "default": !!null "" - "description": "The vnf-member-index of the user VNF." - "type": "string" - "user-vdu-id": - "default": !!null "" - "description": "The id of the VDU containing the charm." - "type": "string" - - "policy-member-index": - "default": !!null "" - "description": "The vnf-member-index of the policy VNF." - "type": "string" - "policy-vdu-id": - "default": !!null "" - "description": "The id of the VDU containing the charm." - "type": "string" diff --git a/nscharm_ns/charms/ns/copyright b/nscharm_ns/charms/ns/copyright deleted file mode 100644 index d4fdd18281c632d030a301d26d45b4dabdb308ef..0000000000000000000000000000000000000000 --- a/nscharm_ns/charms/ns/copyright +++ /dev/null @@ -1,16 +0,0 @@ -Format: http://dep.debian.net/deps/dep5/ - -Files: * -Copyright: Copyright 2015-2017, Canonical Ltd., All Rights Reserved. -License: Apache License 2.0 - 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/nscharm_ns/charms/ns/copyright.layer-options b/nscharm_ns/charms/ns/copyright.layer-options deleted file mode 100644 index d4fdd18281c632d030a301d26d45b4dabdb308ef..0000000000000000000000000000000000000000 --- a/nscharm_ns/charms/ns/copyright.layer-options +++ /dev/null @@ -1,16 +0,0 @@ -Format: http://dep.debian.net/deps/dep5/ - -Files: * -Copyright: Copyright 2015-2017, Canonical Ltd., All Rights Reserved. -License: Apache License 2.0 - 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/nscharm_ns/charms/ns/hooks/config-changed b/nscharm_ns/charms/ns/hooks/config-changed deleted file mode 100755 index 9858c6be15b8a682778ab4727835151e1b693801..0000000000000000000000000000000000000000 --- a/nscharm_ns/charms/ns/hooks/config-changed +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 - -# Load modules from $JUJU_CHARM_DIR/lib -import sys -sys.path.append('lib') - -from charms.layer import basic # noqa -basic.bootstrap_charm_deps() - -from charmhelpers.core import hookenv # noqa -hookenv.atstart(basic.init_config_states) -hookenv.atexit(basic.clear_config_states) - - -# This will load and run the appropriate @hook and other decorated -# handlers from $JUJU_CHARM_DIR/reactive, $JUJU_CHARM_DIR/hooks/reactive, -# and $JUJU_CHARM_DIR/hooks/relations. -# -# See https://jujucharms.com/docs/stable/authors-charm-building -# for more information on this pattern. -from charms.reactive import main # noqa -main() diff --git a/nscharm_ns/charms/ns/hooks/hook.template b/nscharm_ns/charms/ns/hooks/hook.template deleted file mode 100644 index 9858c6be15b8a682778ab4727835151e1b693801..0000000000000000000000000000000000000000 --- a/nscharm_ns/charms/ns/hooks/hook.template +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 - -# Load modules from $JUJU_CHARM_DIR/lib -import sys -sys.path.append('lib') - -from charms.layer import basic # noqa -basic.bootstrap_charm_deps() - -from charmhelpers.core import hookenv # noqa -hookenv.atstart(basic.init_config_states) -hookenv.atexit(basic.clear_config_states) - - -# This will load and run the appropriate @hook and other decorated -# handlers from $JUJU_CHARM_DIR/reactive, $JUJU_CHARM_DIR/hooks/reactive, -# and $JUJU_CHARM_DIR/hooks/relations. -# -# See https://jujucharms.com/docs/stable/authors-charm-building -# for more information on this pattern. -from charms.reactive import main # noqa -main() diff --git a/nscharm_ns/charms/ns/hooks/install b/nscharm_ns/charms/ns/hooks/install deleted file mode 100755 index 9858c6be15b8a682778ab4727835151e1b693801..0000000000000000000000000000000000000000 --- a/nscharm_ns/charms/ns/hooks/install +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 - -# Load modules from $JUJU_CHARM_DIR/lib -import sys -sys.path.append('lib') - -from charms.layer import basic # noqa -basic.bootstrap_charm_deps() - -from charmhelpers.core import hookenv # noqa -hookenv.atstart(basic.init_config_states) -hookenv.atexit(basic.clear_config_states) - - -# This will load and run the appropriate @hook and other decorated -# handlers from $JUJU_CHARM_DIR/reactive, $JUJU_CHARM_DIR/hooks/reactive, -# and $JUJU_CHARM_DIR/hooks/relations. -# -# See https://jujucharms.com/docs/stable/authors-charm-building -# for more information on this pattern. -from charms.reactive import main # noqa -main() diff --git a/nscharm_ns/charms/ns/hooks/leader-elected b/nscharm_ns/charms/ns/hooks/leader-elected deleted file mode 100755 index 9858c6be15b8a682778ab4727835151e1b693801..0000000000000000000000000000000000000000 --- a/nscharm_ns/charms/ns/hooks/leader-elected +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 - -# Load modules from $JUJU_CHARM_DIR/lib -import sys -sys.path.append('lib') - -from charms.layer import basic # noqa -basic.bootstrap_charm_deps() - -from charmhelpers.core import hookenv # noqa -hookenv.atstart(basic.init_config_states) -hookenv.atexit(basic.clear_config_states) - - -# This will load and run the appropriate @hook and other decorated -# handlers from $JUJU_CHARM_DIR/reactive, $JUJU_CHARM_DIR/hooks/reactive, -# and $JUJU_CHARM_DIR/hooks/relations. -# -# See https://jujucharms.com/docs/stable/authors-charm-building -# for more information on this pattern. -from charms.reactive import main # noqa -main() diff --git a/nscharm_ns/charms/ns/hooks/leader-settings-changed b/nscharm_ns/charms/ns/hooks/leader-settings-changed deleted file mode 100755 index 9858c6be15b8a682778ab4727835151e1b693801..0000000000000000000000000000000000000000 --- a/nscharm_ns/charms/ns/hooks/leader-settings-changed +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 - -# Load modules from $JUJU_CHARM_DIR/lib -import sys -sys.path.append('lib') - -from charms.layer import basic # noqa -basic.bootstrap_charm_deps() - -from charmhelpers.core import hookenv # noqa -hookenv.atstart(basic.init_config_states) -hookenv.atexit(basic.clear_config_states) - - -# This will load and run the appropriate @hook and other decorated -# handlers from $JUJU_CHARM_DIR/reactive, $JUJU_CHARM_DIR/hooks/reactive, -# and $JUJU_CHARM_DIR/hooks/relations. -# -# See https://jujucharms.com/docs/stable/authors-charm-building -# for more information on this pattern. -from charms.reactive import main # noqa -main() diff --git a/nscharm_ns/charms/ns/hooks/post-series-upgrade b/nscharm_ns/charms/ns/hooks/post-series-upgrade deleted file mode 100755 index 9858c6be15b8a682778ab4727835151e1b693801..0000000000000000000000000000000000000000 --- a/nscharm_ns/charms/ns/hooks/post-series-upgrade +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 - -# Load modules from $JUJU_CHARM_DIR/lib -import sys -sys.path.append('lib') - -from charms.layer import basic # noqa -basic.bootstrap_charm_deps() - -from charmhelpers.core import hookenv # noqa -hookenv.atstart(basic.init_config_states) -hookenv.atexit(basic.clear_config_states) - - -# This will load and run the appropriate @hook and other decorated -# handlers from $JUJU_CHARM_DIR/reactive, $JUJU_CHARM_DIR/hooks/reactive, -# and $JUJU_CHARM_DIR/hooks/relations. -# -# See https://jujucharms.com/docs/stable/authors-charm-building -# for more information on this pattern. -from charms.reactive import main # noqa -main() diff --git a/nscharm_ns/charms/ns/hooks/pre-series-upgrade b/nscharm_ns/charms/ns/hooks/pre-series-upgrade deleted file mode 100755 index 9858c6be15b8a682778ab4727835151e1b693801..0000000000000000000000000000000000000000 --- a/nscharm_ns/charms/ns/hooks/pre-series-upgrade +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 - -# Load modules from $JUJU_CHARM_DIR/lib -import sys -sys.path.append('lib') - -from charms.layer import basic # noqa -basic.bootstrap_charm_deps() - -from charmhelpers.core import hookenv # noqa -hookenv.atstart(basic.init_config_states) -hookenv.atexit(basic.clear_config_states) - - -# This will load and run the appropriate @hook and other decorated -# handlers from $JUJU_CHARM_DIR/reactive, $JUJU_CHARM_DIR/hooks/reactive, -# and $JUJU_CHARM_DIR/hooks/relations. -# -# See https://jujucharms.com/docs/stable/authors-charm-building -# for more information on this pattern. -from charms.reactive import main # noqa -main() diff --git a/nscharm_ns/charms/ns/hooks/start b/nscharm_ns/charms/ns/hooks/start deleted file mode 100755 index 9858c6be15b8a682778ab4727835151e1b693801..0000000000000000000000000000000000000000 --- a/nscharm_ns/charms/ns/hooks/start +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 - -# Load modules from $JUJU_CHARM_DIR/lib -import sys -sys.path.append('lib') - -from charms.layer import basic # noqa -basic.bootstrap_charm_deps() - -from charmhelpers.core import hookenv # noqa -hookenv.atstart(basic.init_config_states) -hookenv.atexit(basic.clear_config_states) - - -# This will load and run the appropriate @hook and other decorated -# handlers from $JUJU_CHARM_DIR/reactive, $JUJU_CHARM_DIR/hooks/reactive, -# and $JUJU_CHARM_DIR/hooks/relations. -# -# See https://jujucharms.com/docs/stable/authors-charm-building -# for more information on this pattern. -from charms.reactive import main # noqa -main() diff --git a/nscharm_ns/charms/ns/hooks/stop b/nscharm_ns/charms/ns/hooks/stop deleted file mode 100755 index 9858c6be15b8a682778ab4727835151e1b693801..0000000000000000000000000000000000000000 --- a/nscharm_ns/charms/ns/hooks/stop +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 - -# Load modules from $JUJU_CHARM_DIR/lib -import sys -sys.path.append('lib') - -from charms.layer import basic # noqa -basic.bootstrap_charm_deps() - -from charmhelpers.core import hookenv # noqa -hookenv.atstart(basic.init_config_states) -hookenv.atexit(basic.clear_config_states) - - -# This will load and run the appropriate @hook and other decorated -# handlers from $JUJU_CHARM_DIR/reactive, $JUJU_CHARM_DIR/hooks/reactive, -# and $JUJU_CHARM_DIR/hooks/relations. -# -# See https://jujucharms.com/docs/stable/authors-charm-building -# for more information on this pattern. -from charms.reactive import main # noqa -main() diff --git a/nscharm_ns/charms/ns/hooks/update-status b/nscharm_ns/charms/ns/hooks/update-status deleted file mode 100755 index 9858c6be15b8a682778ab4727835151e1b693801..0000000000000000000000000000000000000000 --- a/nscharm_ns/charms/ns/hooks/update-status +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 - -# Load modules from $JUJU_CHARM_DIR/lib -import sys -sys.path.append('lib') - -from charms.layer import basic # noqa -basic.bootstrap_charm_deps() - -from charmhelpers.core import hookenv # noqa -hookenv.atstart(basic.init_config_states) -hookenv.atexit(basic.clear_config_states) - - -# This will load and run the appropriate @hook and other decorated -# handlers from $JUJU_CHARM_DIR/reactive, $JUJU_CHARM_DIR/hooks/reactive, -# and $JUJU_CHARM_DIR/hooks/relations. -# -# See https://jujucharms.com/docs/stable/authors-charm-building -# for more information on this pattern. -from charms.reactive import main # noqa -main() diff --git a/nscharm_ns/charms/ns/hooks/upgrade-charm b/nscharm_ns/charms/ns/hooks/upgrade-charm deleted file mode 100755 index 9858c6be15b8a682778ab4727835151e1b693801..0000000000000000000000000000000000000000 --- a/nscharm_ns/charms/ns/hooks/upgrade-charm +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 - -# Load modules from $JUJU_CHARM_DIR/lib -import sys -sys.path.append('lib') - -from charms.layer import basic # noqa -basic.bootstrap_charm_deps() - -from charmhelpers.core import hookenv # noqa -hookenv.atstart(basic.init_config_states) -hookenv.atexit(basic.clear_config_states) - - -# This will load and run the appropriate @hook and other decorated -# handlers from $JUJU_CHARM_DIR/reactive, $JUJU_CHARM_DIR/hooks/reactive, -# and $JUJU_CHARM_DIR/hooks/relations. -# -# See https://jujucharms.com/docs/stable/authors-charm-building -# for more information on this pattern. -from charms.reactive import main # noqa -main() diff --git a/nscharm_ns/charms/ns/layer.yaml b/nscharm_ns/charms/ns/layer.yaml deleted file mode 100644 index 8c27bd4db54139870a342ba0f86b60bb6ed08318..0000000000000000000000000000000000000000 --- a/nscharm_ns/charms/ns/layer.yaml +++ /dev/null @@ -1,14 +0,0 @@ -"includes": -- "layer:options" -- "layer:basic" -- "layer:osm-ns" -"exclude": [".travis.yml", "tests", "tox.ini", "test-requirements.txt", "unit_tests"] -"options": - "basic": - "use_venv": !!bool "false" - "packages": ["libssl-dev"] - "python_packages": [] - "include_system_packages": !!bool "false" - "osm-ns": {} - "ns": {} -"is": "ns" diff --git a/nscharm_ns/charms/ns/lib/charms/layer/__init__.py b/nscharm_ns/charms/ns/lib/charms/layer/__init__.py deleted file mode 100644 index a8e0c640642f44cac85df60f3d9b7f73b0bb18bb..0000000000000000000000000000000000000000 --- a/nscharm_ns/charms/ns/lib/charms/layer/__init__.py +++ /dev/null @@ -1,60 +0,0 @@ -import sys -from importlib import import_module -from pathlib import Path - - -def import_layer_libs(): - """ - Ensure that all layer libraries are imported. - - This makes it possible to do the following: - - from charms import layer - - layer.foo.do_foo_thing() - - Note: This function must be called after bootstrap. - """ - for module_file in Path('lib/charms/layer').glob('*'): - module_name = module_file.stem - if module_name in ('__init__', 'basic', 'execd') or not ( - module_file.suffix == '.py' or module_file.is_dir() - ): - continue - import_module('charms.layer.{}'.format(module_name)) - - -# Terrible hack to support the old terrible interface. -# Try to get people to call layer.options.get() instead so -# that we can remove this garbage. -# Cribbed from https://stackoverfLow.com/a/48100440/4941864 -class OptionsBackwardsCompatibilityHack(sys.modules[__name__].__class__): - def __call__(self, section=None, layer_file=None): - if layer_file is None: - return self.get(section=section) - else: - return self.get(section=section, - layer_file=Path(layer_file)) - - -def patch_options_interface(): - from charms.layer import options - if sys.version_info.minor >= 5: - options.__class__ = OptionsBackwardsCompatibilityHack - else: - # Py 3.4 doesn't support changing the __class__, so we have to do it - # another way. The last line is needed because we already have a - # reference that doesn't get updated with sys.modules. - name = options.__name__ - hack = OptionsBackwardsCompatibilityHack(name) - hack.get = options.get - sys.modules[name] = hack - sys.modules[__name__].options = hack - - -try: - patch_options_interface() -except ImportError: - # This may fail if pyyaml hasn't been installed yet. But in that - # case, the bootstrap logic will try it again once it has. - pass diff --git a/nscharm_ns/charms/ns/lib/charms/layer/basic.py b/nscharm_ns/charms/ns/lib/charms/layer/basic.py deleted file mode 100644 index 75072039adab3e35ae268c4e31c6c03cd4a1bdef..0000000000000000000000000000000000000000 --- a/nscharm_ns/charms/ns/lib/charms/layer/basic.py +++ /dev/null @@ -1,446 +0,0 @@ -import os -import sys -import re -import shutil -from distutils.version import LooseVersion -from pkg_resources import Requirement -from glob import glob -from subprocess import check_call, check_output, CalledProcessError -from time import sleep - -from charms import layer -from charms.layer.execd import execd_preinstall - - -def _get_subprocess_env(): - env = os.environ.copy() - env['LANG'] = env.get('LANG', 'C.UTF-8') - return env - - -def get_series(): - """ - Return series for a few known OS:es. - Tested as of 2019 november: - * centos6, centos7, rhel6. - * bionic - """ - series = "" - - # Looking for content in /etc/os-release - # works for ubuntu + some centos - if os.path.isfile('/etc/os-release'): - d = {} - with open('/etc/os-release', 'r') as rel: - for l in rel: - if not re.match(r'^\s*$', l): - k, v = l.split('=') - d[k.strip()] = v.strip().replace('"', '') - series = "{ID}{VERSION_ID}".format(**d) - - # Looking for content in /etc/redhat-release - # works for redhat enterprise systems - elif os.path.isfile('/etc/redhat-release'): - with open('/etc/redhat-release', 'r') as redhatlsb: - # CentOS Linux release 7.7.1908 (Core) - line = redhatlsb.readline() - release = int(line.split("release")[1].split()[0][0]) - series = "centos" + str(release) - - # Looking for content in /etc/lsb-release - # works for ubuntu - elif os.path.isfile('/etc/lsb-release'): - d = {} - with open('/etc/lsb-release', 'r') as lsb: - for l in lsb: - k, v = l.split('=') - d[k.strip()] = v.strip() - series = d['DISTRIB_CODENAME'] - - # This is what happens if we cant figure out the OS. - else: - series = "unknown" - return series - - -def bootstrap_charm_deps(): - """ - Set up the base charm dependencies so that the reactive system can run. - """ - # execd must happen first, before any attempt to install packages or - # access the network, because sites use this hook to do bespoke - # configuration and install secrets so the rest of this bootstrap - # and the charm itself can actually succeed. This call does nothing - # unless the operator has created and populated $JUJU_CHARM_DIR/exec.d. - execd_preinstall() - # ensure that $JUJU_CHARM_DIR/bin is on the path, for helper scripts - - series = get_series() - - # OMG?! is build-essentials needed? - ubuntu_packages = ['python3-pip', - 'python3-setuptools', - 'python3-yaml', - 'python3-dev', - 'python3-wheel', - 'build-essential'] - - # I'm not going to "yum group info "Development Tools" - # omitting above madness - centos_packages = ['python3-pip', - 'python3-setuptools', - 'python3-devel', - 'python3-wheel'] - - packages_needed = [] - if 'centos' in series: - packages_needed = centos_packages - else: - packages_needed = ubuntu_packages - - charm_dir = os.environ['JUJU_CHARM_DIR'] - os.environ['PATH'] += ':%s' % os.path.join(charm_dir, 'bin') - venv = os.path.abspath('../.venv') - vbin = os.path.join(venv, 'bin') - vpip = os.path.join(vbin, 'pip') - vpy = os.path.join(vbin, 'python') - hook_name = os.path.basename(sys.argv[0]) - is_bootstrapped = os.path.exists('wheelhouse/.bootstrapped') - is_charm_upgrade = hook_name == 'upgrade-charm' - is_series_upgrade = hook_name == 'post-series-upgrade' - is_post_upgrade = os.path.exists('wheelhouse/.upgraded') - is_upgrade = (not is_post_upgrade and - (is_charm_upgrade or is_series_upgrade)) - if is_bootstrapped and not is_upgrade: - # older subordinates might have downgraded charm-env, so we should - # restore it if necessary - install_or_update_charm_env() - activate_venv() - # the .upgrade file prevents us from getting stuck in a loop - # when re-execing to activate the venv; at this point, we've - # activated the venv, so it's safe to clear it - if is_post_upgrade: - os.unlink('wheelhouse/.upgraded') - return - if os.path.exists(venv): - try: - # focal installs or upgrades prior to PR 160 could leave the venv - # in a broken state which would prevent subsequent charm upgrades - _load_installed_versions(vpip) - except CalledProcessError: - is_broken_venv = True - else: - is_broken_venv = False - if is_upgrade or is_broken_venv: - # All upgrades should do a full clear of the venv, rather than - # just updating it, to bring in updates to Python itself - shutil.rmtree(venv) - if is_upgrade: - if os.path.exists('wheelhouse/.bootstrapped'): - os.unlink('wheelhouse/.bootstrapped') - # bootstrap wheelhouse - if os.path.exists('wheelhouse'): - pre_eoan = series in ('ubuntu12.04', 'precise', - 'ubuntu14.04', 'trusty', - 'ubuntu16.04', 'xenial', - 'ubuntu18.04', 'bionic') - pydistutils_lines = [ - "[easy_install]\n", - "find_links = file://{}/wheelhouse/\n".format(charm_dir), - "no_index=True\n", - "index_url=\n", # deliberately nothing here; disables it. - ] - if pre_eoan: - pydistutils_lines.append("allow_hosts = ''\n") - with open('/root/.pydistutils.cfg', 'w') as fp: - # make sure that easy_install also only uses the wheelhouse - # (see https://github.com/pypa/pip/issues/410) - fp.writelines(pydistutils_lines) - if 'centos' in series: - yum_install(packages_needed) - else: - apt_install(packages_needed) - from charms.layer import options - cfg = options.get('basic') - # include packages defined in layer.yaml - if 'centos' in series: - yum_install(cfg.get('packages', [])) - else: - apt_install(cfg.get('packages', [])) - # if we're using a venv, set it up - if cfg.get('use_venv'): - if not os.path.exists(venv): - series = get_series() - if series in ('ubuntu12.04', 'precise', - 'ubuntu14.04', 'trusty'): - apt_install(['python-virtualenv']) - elif 'centos' in series: - yum_install(['python-virtualenv']) - else: - apt_install(['virtualenv']) - cmd = ['virtualenv', '-ppython3', '--never-download', venv] - if cfg.get('include_system_packages'): - cmd.append('--system-site-packages') - check_call(cmd, env=_get_subprocess_env()) - os.environ['PATH'] = ':'.join([vbin, os.environ['PATH']]) - pip = vpip - else: - pip = 'pip3' - # save a copy of system pip to prevent `pip3 install -U pip` - # from changing it - if os.path.exists('/usr/bin/pip'): - shutil.copy2('/usr/bin/pip', '/usr/bin/pip.save') - pre_install_pkgs = ['pip', 'setuptools', 'setuptools-scm'] - # we bundle these packages to work around bugs in older versions (such - # as https://github.com/pypa/pip/issues/56), but if the system already - # provided a newer version, downgrading it can cause other problems - _update_if_newer(pip, pre_install_pkgs) - # install the rest of the wheelhouse deps (extract the pkg names into - # a set so that we can ignore the pre-install packages and let pip - # choose the best version in case there are multiple from layer - # conflicts) - pkgs = _load_wheelhouse_versions().keys() - set(pre_install_pkgs) - reinstall_flag = '--force-reinstall' - if not cfg.get('use_venv', True) and pre_eoan: - reinstall_flag = '--ignore-installed' - check_call([pip, 'install', '-U', reinstall_flag, '--no-index', - '--no-cache-dir', '-f', 'wheelhouse'] + list(pkgs), - env=_get_subprocess_env()) - # re-enable installation from pypi - os.remove('/root/.pydistutils.cfg') - - # install pyyaml for centos7, since, unlike the ubuntu image, the - # default image for centos doesn't include pyyaml; see the discussion: - # https://discourse.jujucharms.com/t/charms-for-centos-lets-begin - if 'centos' in series: - check_call([pip, 'install', '-U', 'pyyaml'], - env=_get_subprocess_env()) - - # install python packages from layer options - if cfg.get('python_packages'): - check_call([pip, 'install', '-U'] + cfg.get('python_packages'), - env=_get_subprocess_env()) - if not cfg.get('use_venv'): - # restore system pip to prevent `pip3 install -U pip` - # from changing it - if os.path.exists('/usr/bin/pip.save'): - shutil.copy2('/usr/bin/pip.save', '/usr/bin/pip') - os.remove('/usr/bin/pip.save') - # setup wrappers to ensure envs are used for scripts - install_or_update_charm_env() - for wrapper in ('charms.reactive', 'charms.reactive.sh', - 'chlp', 'layer_option'): - src = os.path.join('/usr/local/sbin', 'charm-env') - dst = os.path.join('/usr/local/sbin', wrapper) - if not os.path.exists(dst): - os.symlink(src, dst) - if cfg.get('use_venv'): - shutil.copy2('bin/layer_option', vbin) - else: - shutil.copy2('bin/layer_option', '/usr/local/bin/') - # re-link the charm copy to the wrapper in case charms - # call bin/layer_option directly (as was the old pattern) - os.remove('bin/layer_option') - os.symlink('/usr/local/sbin/layer_option', 'bin/layer_option') - # flag us as having already bootstrapped so we don't do it again - open('wheelhouse/.bootstrapped', 'w').close() - if is_upgrade: - # flag us as having already upgraded so we don't do it again - open('wheelhouse/.upgraded', 'w').close() - # Ensure that the newly bootstrapped libs are available. - # Note: this only seems to be an issue with namespace packages. - # Non-namespace-package libs (e.g., charmhelpers) are available - # without having to reload the interpreter. :/ - reload_interpreter(vpy if cfg.get('use_venv') else sys.argv[0]) - - -def _load_installed_versions(pip): - pip_freeze = check_output([pip, 'freeze']).decode('utf8') - versions = {} - for pkg_ver in pip_freeze.splitlines(): - try: - req = Requirement.parse(pkg_ver) - except ValueError: - continue - versions.update({ - req.project_name: LooseVersion(ver) - for op, ver in req.specs if op == '==' - }) - return versions - - -def _load_wheelhouse_versions(): - versions = {} - for wheel in glob('wheelhouse/*'): - pkg, ver = os.path.basename(wheel).rsplit('-', 1) - # nb: LooseVersion ignores the file extension - versions[pkg.replace('_', '-')] = LooseVersion(ver) - return versions - - -def _update_if_newer(pip, pkgs): - installed = _load_installed_versions(pip) - wheelhouse = _load_wheelhouse_versions() - for pkg in pkgs: - if pkg not in installed or wheelhouse[pkg] > installed[pkg]: - check_call([pip, 'install', '-U', '--no-index', '-f', 'wheelhouse', - pkg], env=_get_subprocess_env()) - - -def install_or_update_charm_env(): - # On Trusty python3-pkg-resources is not installed - try: - from pkg_resources import parse_version - except ImportError: - apt_install(['python3-pkg-resources']) - from pkg_resources import parse_version - - try: - installed_version = parse_version( - check_output(['/usr/local/sbin/charm-env', - '--version']).decode('utf8')) - except (CalledProcessError, FileNotFoundError): - installed_version = parse_version('0.0.0') - try: - bundled_version = parse_version( - check_output(['bin/charm-env', - '--version']).decode('utf8')) - except (CalledProcessError, FileNotFoundError): - bundled_version = parse_version('0.0.0') - if installed_version < bundled_version: - shutil.copy2('bin/charm-env', '/usr/local/sbin/') - - -def activate_venv(): - """ - Activate the venv if enabled in ``layer.yaml``. - - This is handled automatically for normal hooks, but actions might - need to invoke this manually, using something like: - - # Load modules from $JUJU_CHARM_DIR/lib - import sys - sys.path.append('lib') - - from charms.layer.basic import activate_venv - activate_venv() - - This will ensure that modules installed in the charm's - virtual environment are available to the action. - """ - from charms.layer import options - venv = os.path.abspath('../.venv') - vbin = os.path.join(venv, 'bin') - vpy = os.path.join(vbin, 'python') - use_venv = options.get('basic', 'use_venv') - if use_venv and '.venv' not in sys.executable: - # activate the venv - os.environ['PATH'] = ':'.join([vbin, os.environ['PATH']]) - reload_interpreter(vpy) - layer.patch_options_interface() - layer.import_layer_libs() - - -def reload_interpreter(python): - """ - Reload the python interpreter to ensure that all deps are available. - - Newly installed modules in namespace packages sometimes seemt to - not be picked up by Python 3. - """ - os.execve(python, [python] + list(sys.argv), os.environ) - - -def apt_install(packages): - """ - Install apt packages. - - This ensures a consistent set of options that are often missed but - should really be set. - """ - if isinstance(packages, (str, bytes)): - packages = [packages] - - env = _get_subprocess_env() - - if 'DEBIAN_FRONTEND' not in env: - env['DEBIAN_FRONTEND'] = 'noninteractive' - - cmd = ['apt-get', - '--option=Dpkg::Options::=--force-confold', - '--assume-yes', - 'install'] - for attempt in range(3): - try: - check_call(cmd + packages, env=env) - except CalledProcessError: - if attempt == 2: # third attempt - raise - try: - # sometimes apt-get update needs to be run - check_call(['apt-get', 'update'], env=env) - except CalledProcessError: - # sometimes it's a dpkg lock issue - pass - sleep(5) - else: - break - - -def yum_install(packages): - """ Installs packages with yum. - This function largely mimics the apt_install function for consistency. - """ - if packages: - env = os.environ.copy() - cmd = ['yum', '-y', 'install'] - for attempt in range(3): - try: - check_call(cmd + packages, env=env) - except CalledProcessError: - if attempt == 2: - raise - try: - check_call(['yum', 'update'], env=env) - except CalledProcessError: - pass - sleep(5) - else: - break - else: - pass - - -def init_config_states(): - import yaml - from charmhelpers.core import hookenv - from charms.reactive import set_state - from charms.reactive import toggle_state - config = hookenv.config() - config_defaults = {} - config_defs = {} - config_yaml = os.path.join(hookenv.charm_dir(), 'config.yaml') - if os.path.exists(config_yaml): - with open(config_yaml) as fp: - config_defs = yaml.safe_load(fp).get('options', {}) - config_defaults = {key: value.get('default') - for key, value in config_defs.items()} - for opt in config_defs.keys(): - if config.changed(opt): - set_state('config.changed') - set_state('config.changed.{}'.format(opt)) - toggle_state('config.set.{}'.format(opt), config.get(opt)) - toggle_state('config.default.{}'.format(opt), - config.get(opt) == config_defaults[opt]) - - -def clear_config_states(): - from charmhelpers.core import hookenv, unitdata - from charms.reactive import remove_state - config = hookenv.config() - remove_state('config.changed') - for opt in config.keys(): - remove_state('config.changed.{}'.format(opt)) - remove_state('config.set.{}'.format(opt)) - remove_state('config.default.{}'.format(opt)) - unitdata.kv().flush() diff --git a/nscharm_ns/charms/ns/lib/charms/layer/execd.py b/nscharm_ns/charms/ns/lib/charms/layer/execd.py deleted file mode 100644 index 438d9a1bc90042fd8b20517d5ecf358dfbf08afc..0000000000000000000000000000000000000000 --- a/nscharm_ns/charms/ns/lib/charms/layer/execd.py +++ /dev/null @@ -1,114 +0,0 @@ -# Copyright 2014-2016 Canonical Limited. -# -# This file is part of layer-basic, the reactive base layer for Juju. -# -# charm-helpers is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 as -# published by the Free Software Foundation. -# -# charm-helpers is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with charm-helpers. If not, see . - -# This module may only import from the Python standard library. -import os -import sys -import subprocess -import time - -''' -execd/preinstall - -Read the layer-basic docs for more info on how to use this feature. -https://charmsreactive.readthedocs.io/en/latest/layer-basic.html#exec-d-support -''' - - -def default_execd_dir(): - return os.path.join(os.environ['JUJU_CHARM_DIR'], 'exec.d') - - -def execd_module_paths(execd_dir=None): - """Generate a list of full paths to modules within execd_dir.""" - if not execd_dir: - execd_dir = default_execd_dir() - - if not os.path.exists(execd_dir): - return - - for subpath in os.listdir(execd_dir): - module = os.path.join(execd_dir, subpath) - if os.path.isdir(module): - yield module - - -def execd_submodule_paths(command, execd_dir=None): - """Generate a list of full paths to the specified command within exec_dir. - """ - for module_path in execd_module_paths(execd_dir): - path = os.path.join(module_path, command) - if os.access(path, os.X_OK) and os.path.isfile(path): - yield path - - -def execd_sentinel_path(submodule_path): - module_path = os.path.dirname(submodule_path) - execd_path = os.path.dirname(module_path) - module_name = os.path.basename(module_path) - submodule_name = os.path.basename(submodule_path) - return os.path.join(execd_path, - '.{}_{}.done'.format(module_name, submodule_name)) - - -def execd_run(command, execd_dir=None, stop_on_error=True, stderr=None): - """Run command for each module within execd_dir which defines it.""" - if stderr is None: - stderr = sys.stdout - for submodule_path in execd_submodule_paths(command, execd_dir): - # Only run each execd once. We cannot simply run them in the - # install hook, as potentially storage hooks are run before that. - # We cannot rely on them being idempotent. - sentinel = execd_sentinel_path(submodule_path) - if os.path.exists(sentinel): - continue - - try: - subprocess.check_call([submodule_path], stderr=stderr, - universal_newlines=True) - with open(sentinel, 'w') as f: - f.write('{} ran successfully {}\n'.format(submodule_path, - time.ctime())) - f.write('Removing this file will cause it to be run again\n') - except subprocess.CalledProcessError as e: - # Logs get the details. We can't use juju-log, as the - # output may be substantial and exceed command line - # length limits. - print("ERROR ({}) running {}".format(e.returncode, e.cmd), - file=stderr) - print("STDOUT<" -"maintainer": "Adam Israel " -"description": | - -"tags": - # Replace "misc" with one or more whitelisted tags from this list: - # https://jujucharms.com/docs/stable/authors-charm-metadata -- "misc" -"series": -- "xenial" -- "bionic" -"subordinate": !!bool "false" diff --git a/nscharm_ns/charms/ns/reactive/__init__.py b/nscharm_ns/charms/ns/reactive/__init__.py deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/nscharm_ns/charms/ns/reactive/osm_ns.py b/nscharm_ns/charms/ns/reactive/osm_ns.py deleted file mode 100644 index aacdeb5366fdf950f09236196f3ecfa34caf91cf..0000000000000000000000000000000000000000 --- a/nscharm_ns/charms/ns/reactive/osm_ns.py +++ /dev/null @@ -1,7 +0,0 @@ -from charms.reactive import when, when_not, set_flag - - -@when_not('osm-stack.installed') -def install_osm_stack(): - - set_flag('osm-stack.installed') diff --git a/nscharm_ns/charms/ns/requirements.txt b/nscharm_ns/charms/ns/requirements.txt deleted file mode 100644 index 55543d9b632ff05cf7e6ee20dfec3160d2c554c2..0000000000000000000000000000000000000000 --- a/nscharm_ns/charms/ns/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -mock -flake8 -pytest diff --git a/nscharm_ns/charms/ns/version b/nscharm_ns/charms/ns/version deleted file mode 100644 index 890fe8c2f228c2359735691da2fa962ee2cb83f4..0000000000000000000000000000000000000000 --- a/nscharm_ns/charms/ns/version +++ /dev/null @@ -1 +0,0 @@ -b189ed8 \ No newline at end of file diff --git a/nscharm_ns/charms/ns/wheelhouse.txt b/nscharm_ns/charms/ns/wheelhouse.txt deleted file mode 100644 index c2337ba80c7080f7be01b59f8853fc854bd37ccb..0000000000000000000000000000000000000000 --- a/nscharm_ns/charms/ns/wheelhouse.txt +++ /dev/null @@ -1,16 +0,0 @@ -# layer:basic -# pip is pinned to <19.0 to avoid https://github.com/pypa/pip/issues/6164 -# even with installing setuptools before upgrading pip ends up with pip seeing -# the older setuptools at the system level if include_system_packages is true -pip>=18.1,<19.0 -# pin Jinja2 and PyYAML to the last versions supporting python 3.4 for trusty -Jinja2<=2.10.1 -PyYAML<=5.2 -setuptools<42 -setuptools-scm<=1.17.0 -charmhelpers>=0.4.0,<1.0.0 -charms.reactive>=0.1.0,<2.0.0 -wheel<0.34 -# pin netaddr to avoid pulling importlib-resources -netaddr<=0.7.19 - diff --git a/nscharm_ns/charms/ns/wheelhouse/setuptools-41.6.0.zip b/nscharm_ns/charms/ns/wheelhouse/setuptools-41.6.0.zip deleted file mode 100644 index 3345759c1ca861c181742e84fc5285e3284a2886..0000000000000000000000000000000000000000 Binary files a/nscharm_ns/charms/ns/wheelhouse/setuptools-41.6.0.zip and /dev/null differ diff --git a/nscharm_ns/nscharm_nsd.yaml b/nscharm_ns/nscharm_nsd.yaml index c8ccb2d1a28b073a5d4efa930e5f3a0b01a0671c..5aaaeecaf6b1d1e393cbaa783b0fe1bf4084fe1f 100644 --- a/nscharm_ns/nscharm_nsd.yaml +++ b/nscharm_ns/nscharm_nsd.yaml @@ -39,7 +39,7 @@ nsd: - name: juju-username value: 'admin' - name: juju-password - value: 'a6ffabed913f9d33e1d3201f6f9561b4' + value: 'a5611fc6452349cc6e45705d34c501d4' - seq: '2' name: add-user parameter: diff --git a/nscharm_policy_vnf/charms/vnf-policy/README.md b/nscharm_policy_vnf/charms/layers/vnf-policy/README.md similarity index 100% rename from nscharm_policy_vnf/charms/vnf-policy/README.md rename to nscharm_policy_vnf/charms/layers/vnf-policy/README.md diff --git a/nscharm_policy_vnf/charms/layers/vnf-policy/actions.yaml b/nscharm_policy_vnf/charms/layers/vnf-policy/actions.yaml new file mode 100644 index 0000000000000000000000000000000000000000..995a197ac33b2078a3d344442b777e23145d102f --- /dev/null +++ b/nscharm_policy_vnf/charms/layers/vnf-policy/actions.yaml @@ -0,0 +1,19 @@ +set-policy: + description: "Set a user policy" + params: + user_id: + description: "The user_id to modify the policy of" + type: integer + default: 0 + bw: + description: "" + type: integer + default: 0 + qos: + description: "" + type: integer + default: 0 + required: + - user_id + - bw + - qos diff --git a/nscharm_policy_vnf/charms/vnf-policy/actions/set-policy b/nscharm_policy_vnf/charms/layers/vnf-policy/actions/set-policy similarity index 100% rename from nscharm_policy_vnf/charms/vnf-policy/actions/set-policy rename to nscharm_policy_vnf/charms/layers/vnf-policy/actions/set-policy diff --git a/nscharm_policy_vnf/charms/vnf-policy/icon.svg b/nscharm_policy_vnf/charms/layers/vnf-policy/icon.svg similarity index 100% rename from nscharm_policy_vnf/charms/vnf-policy/icon.svg rename to nscharm_policy_vnf/charms/layers/vnf-policy/icon.svg diff --git a/nscharm_policy_vnf/charms/layers/vnf-policy/layer.yaml b/nscharm_policy_vnf/charms/layers/vnf-policy/layer.yaml new file mode 100644 index 0000000000000000000000000000000000000000..a0649a97718a7882882222ca5aa845298bdd73b0 --- /dev/null +++ b/nscharm_policy_vnf/charms/layers/vnf-policy/layer.yaml @@ -0,0 +1,8 @@ +includes: + - 'layer:basic' + - 'layer:vnfproxy' + - 'layer:sshproxy' +options: + basic: + use_venv: false + diff --git a/nscharm_policy_vnf/charms/layers/vnf-policy/metadata.yaml b/nscharm_policy_vnf/charms/layers/vnf-policy/metadata.yaml new file mode 100644 index 0000000000000000000000000000000000000000..1f79bfdf93f9bf02cdc0bd50943924c5330df41a --- /dev/null +++ b/nscharm_policy_vnf/charms/layers/vnf-policy/metadata.yaml @@ -0,0 +1,13 @@ +name: vnf-policy +summary: +maintainer: Adam Israel +description: | + +tags: + # Replace "misc" with one or more whitelisted tags from this list: + # https://jujucharms.com/docs/stable/authors-charm-metadata + - misc +series: + - xenial + - bionic +subordinate: false diff --git a/nscharm_policy_vnf/charms/vnf-policy/reactive/vnf_policy.py b/nscharm_policy_vnf/charms/layers/vnf-policy/reactive/vnf_policy.py similarity index 100% rename from nscharm_policy_vnf/charms/vnf-policy/reactive/vnf_policy.py rename to nscharm_policy_vnf/charms/layers/vnf-policy/reactive/vnf_policy.py diff --git a/nscharm_policy_vnf/charms/vnf-policy/tests/00-setup b/nscharm_policy_vnf/charms/layers/vnf-policy/tests/00-setup similarity index 100% rename from nscharm_policy_vnf/charms/vnf-policy/tests/00-setup rename to nscharm_policy_vnf/charms/layers/vnf-policy/tests/00-setup diff --git a/nscharm_policy_vnf/charms/vnf-policy/tests/10-deploy b/nscharm_policy_vnf/charms/layers/vnf-policy/tests/10-deploy similarity index 100% rename from nscharm_policy_vnf/charms/vnf-policy/tests/10-deploy rename to nscharm_policy_vnf/charms/layers/vnf-policy/tests/10-deploy diff --git a/nscharm_policy_vnf/charms/vnf-policy/.build.manifest b/nscharm_policy_vnf/charms/vnf-policy/.build.manifest deleted file mode 100644 index eb419db2a0fb23dde005d634ce239e930f166ced..0000000000000000000000000000000000000000 --- a/nscharm_policy_vnf/charms/vnf-policy/.build.manifest +++ /dev/null @@ -1,366 +0,0 @@ -{ - "layers": [ - { - "rev": "fcdcea4e5de3e1556c24e6704607862d0ba00a56", - "url": "layer:options" - }, - { - "rev": "623e69c7b432456fd4364f6e1835424fd6b5425e", - "url": "layer:basic" - }, - { - "rev": "009e8631e4d173a71ac53032bbad465a89c6c365", - "url": "layer:sshproxy" - }, - { - "rev": "e6a495fab012f06484ed419fd5c2453e6a92eef1", - "url": "layer:vnfproxy" - }, - { - "rev": "83c13bd97764feab1b162d0ac2303f874ea2856f", - "url": "vnf-policy" - } - ], - "signatures": { - ".build.manifest": [ - "build", - "dynamic", - "unchecked" - ], - ".gitignore": [ - "layer:sshproxy", - "static", - "17526a7f7312e7eefb932d1c514b7bc8425fab5bd1ade149e106ecf8bff67358" - ], - ".travis/profile-update.yaml": [ - "layer:basic", - "static", - "731e20aa59bf61c024d317ad630e478301a9386ccc0afe56e6c1c09db07ac83b" - ], - "LICENSE": [ - "layer:basic", - "static", - "cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30" - ], - "Makefile": [ - "layer:basic", - "static", - "b7ab3a34e5faf79b96a8632039a0ad0aa87f2a9b5f0ba604e007cafb22190301" - ], - "README.md": [ - "vnf-policy", - "static", - "6380429bf8915e9bfbd26c06d330c083ed2ad65d52a465e1214428e43beabb88" - ], - "actions.yaml": [ - "vnf-policy", - "dynamic", - "e1ace1900b6520fa5b4f0bc99b3a6cfca4072e72dd49be5d423499ec0515450a" - ], - "actions/generate-ssh-key": [ - "layer:sshproxy", - "static", - "46bf4be02078a0f5ac60ab81609372a8f9943885b7a4999ce5332ea2f4857036" - ], - "actions/get-ssh-public-key": [ - "layer:sshproxy", - "static", - "46bf4be02078a0f5ac60ab81609372a8f9943885b7a4999ce5332ea2f4857036" - ], - "actions/reboot": [ - "layer:vnfproxy", - "static", - "afc0df4409fb6eb7b7e6595490913c1efe329b393d4860ae226d8aaccc01fcf2" - ], - "actions/restart": [ - "layer:vnfproxy", - "static", - "afc0df4409fb6eb7b7e6595490913c1efe329b393d4860ae226d8aaccc01fcf2" - ], - "actions/run": [ - "layer:sshproxy", - "static", - "46bf4be02078a0f5ac60ab81609372a8f9943885b7a4999ce5332ea2f4857036" - ], - "actions/set-policy": [ - "vnf-policy", - "static", - "46bf4be02078a0f5ac60ab81609372a8f9943885b7a4999ce5332ea2f4857036" - ], - "actions/start": [ - "layer:vnfproxy", - "static", - "afc0df4409fb6eb7b7e6595490913c1efe329b393d4860ae226d8aaccc01fcf2" - ], - "actions/stop": [ - "layer:vnfproxy", - "static", - "afc0df4409fb6eb7b7e6595490913c1efe329b393d4860ae226d8aaccc01fcf2" - ], - "actions/upgrade": [ - "layer:vnfproxy", - "static", - "afc0df4409fb6eb7b7e6595490913c1efe329b393d4860ae226d8aaccc01fcf2" - ], - "actions/verify-ssh-credentials": [ - "layer:sshproxy", - "static", - "46bf4be02078a0f5ac60ab81609372a8f9943885b7a4999ce5332ea2f4857036" - ], - "bin/charm-env": [ - "layer:basic", - "static", - "fb6a20fac4102a6a4b6ffe903fcf666998f9a95a3647e6f9af7a1eeb44e58fd5" - ], - "bin/layer_option": [ - "layer:options", - "static", - "e959bf29da4c5edff28b2602c24113c4df9e25cdc9f2aa3b5d46c8577b2a40cc" - ], - "config.yaml": [ - "layer:vnfproxy", - "dynamic", - "c5bd79d6699ffdf49cc71ab18a6e8f0e7b0ca71fae2f1416a2138154fe6c1a34" - ], - "copyright": [ - "layer:basic", - "static", - "f6740d66fd60b60f2533d9fcb53907078d1e20920a0219afce7182e2a1c97629" - ], - "copyright.layer-options": [ - "layer:options", - "static", - "f6740d66fd60b60f2533d9fcb53907078d1e20920a0219afce7182e2a1c97629" - ], - "hooks/collect-metrics": [ - "layer:vnfproxy", - "static", - "f2a6360cf21993f7dc07785ad702f141679a5a9b03c3db5d50dd06ffbe26bbb2" - ], - "hooks/config-changed": [ - "layer:basic", - "dynamic", - "2b693cb2a11594a80cc91235c2dc219a0a6303ae62bee8aa87eb35781f7158f7" - ], - "hooks/hook.template": [ - "layer:basic", - "static", - "2b693cb2a11594a80cc91235c2dc219a0a6303ae62bee8aa87eb35781f7158f7" - ], - "hooks/install": [ - "layer:basic", - "dynamic", - "2b693cb2a11594a80cc91235c2dc219a0a6303ae62bee8aa87eb35781f7158f7" - ], - "hooks/leader-elected": [ - "layer:basic", - "dynamic", - "2b693cb2a11594a80cc91235c2dc219a0a6303ae62bee8aa87eb35781f7158f7" - ], - "hooks/leader-settings-changed": [ - "layer:basic", - "dynamic", - "2b693cb2a11594a80cc91235c2dc219a0a6303ae62bee8aa87eb35781f7158f7" - ], - "hooks/post-series-upgrade": [ - "layer:basic", - "dynamic", - "2b693cb2a11594a80cc91235c2dc219a0a6303ae62bee8aa87eb35781f7158f7" - ], - "hooks/pre-series-upgrade": [ - "layer:basic", - "dynamic", - "2b693cb2a11594a80cc91235c2dc219a0a6303ae62bee8aa87eb35781f7158f7" - ], - "hooks/start": [ - "layer:basic", - "dynamic", - "2b693cb2a11594a80cc91235c2dc219a0a6303ae62bee8aa87eb35781f7158f7" - ], - "hooks/stop": [ - "layer:basic", - "dynamic", - "2b693cb2a11594a80cc91235c2dc219a0a6303ae62bee8aa87eb35781f7158f7" - ], - "hooks/update-status": [ - "layer:basic", - "dynamic", - "2b693cb2a11594a80cc91235c2dc219a0a6303ae62bee8aa87eb35781f7158f7" - ], - "hooks/upgrade-charm": [ - "layer:basic", - "dynamic", - "2b693cb2a11594a80cc91235c2dc219a0a6303ae62bee8aa87eb35781f7158f7" - ], - "icon.svg": [ - "vnf-policy", - "static", - "d20624e9389af6506a8d8a69ac9bba4d41709601b624c0875fd7d6717b395088" - ], - "layer.yaml": [ - "vnf-policy", - "dynamic", - "309a53cb906038c4732b442265d7f1f3ca662a38660763721f2a0a1f11fc455a" - ], - "lib/charms/layer/__init__.py": [ - "layer:basic", - "static", - "dfe0d26c6bf409767de6e2546bc648f150e1b396243619bad3aa0553ab7e0e6f" - ], - "lib/charms/layer/basic.py": [ - "layer:basic", - "static", - "3126b5754ad39402ee27e64527044ddd231ed1cd137fcedaffb51e63a635f108" - ], - "lib/charms/layer/execd.py": [ - "layer:basic", - "static", - "fda8bd491032db1db8ddaf4e99e7cc878c6fb5432efe1f91cadb5b34765d076d" - ], - "lib/charms/layer/options.py": [ - "layer:options", - "static", - "8ae7a07d22542fc964f2d2bee8219d1c78a68dace70a1b38d36d4aea47b1c3b2" - ], - "lib/charms/sshproxy.py": [ - "layer:sshproxy", - "static", - "fba0834f98f570b0b3d6b3e8a7f17b1d8909f50da9410ccda89b586f914b7ffd" - ], - "metadata.yaml": [ - "vnf-policy", - "dynamic", - "ea261c975b1ab509eda9cd654c0f5a1219664c5ff3359e9df7209711ad8cc4bb" - ], - "reactive/__init__.py": [ - "layer:basic", - "static", - "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" - ], - "reactive/sshproxy.py": [ - "layer:sshproxy", - "static", - "acfaedf414946f8d218e5ebd04177f87258286915ba83b9c42ff7385975da6ab" - ], - "reactive/vnf_policy.py": [ - "vnf-policy", - "static", - "95e056af5cf27cd850494d69bdc09ea707e70d6cb79fbd807466acd76ca270ab" - ], - "reactive/vnfproxy.py": [ - "layer:vnfproxy", - "static", - "8e4101a72f02832e5c233b731981ff483675be608321b8eb9743d605b3f7d77a" - ], - "requirements.txt": [ - "layer:basic", - "static", - "a00f75d80849e5b4fc5ad2e7536f947c25b1a4044b341caa8ee87a92d3a4c804" - ], - "tests/00-setup": [ - "vnf-policy", - "static", - "111c079b81d260bbcd716dcf41672372a4cf4aaa14154b6c3055deeedae37a06" - ], - "tests/10-deploy": [ - "vnf-policy", - "static", - "0d0154aad1f9694cddc25e318160dedfaa3c6c6471e732f5dcaa60f1df71ce75" - ], - "version": [ - "vnf-policy", - "dynamic", - "ddf4577d49e7c71e11e6dd4f85ad6e74551d5ba89f52b6370de9c141680f9c7f" - ], - "wheelhouse.txt": [ - "layer:sshproxy", - "dynamic", - "6ad4334a685c25c67bf07a9271a6d62afb85e3642fb5bc16e71852fba412ef8e" - ], - "wheelhouse/Jinja2-2.10.1.tar.gz": [ - "layer:basic", - "dynamic", - "065c4f02ebe7f7cf559e49ee5a95fb800a9e4528727aec6f24402a5374c65013" - ], - "wheelhouse/MarkupSafe-1.1.1.tar.gz": [ - "__pip__", - "dynamic", - "29872e92839765e546828bb7754a68c418d927cd064fd4708fab9fe9c8bb116b" - ], - "wheelhouse/PyYAML-5.2.tar.gz": [ - "layer:basic", - "dynamic", - "c0ee8eca2c582d29c3c2ec6e2c4f703d1b7f1fb10bc72317355a746057e7346c" - ], - "wheelhouse/Tempita-0.5.2.tar.gz": [ - "__pip__", - "dynamic", - "cacecf0baa674d356641f1d406b8bff1d756d739c46b869a54de515d08e6fc9c" - ], - "wheelhouse/charmhelpers-0.20.19.tar.gz": [ - "layer:basic", - "dynamic", - "74b2d95ec305e5799f0f7d068b0c6e010612ec877feadf32fc51e6bed1f68234" - ], - "wheelhouse/charms.reactive-1.3.2.tar.gz": [ - "layer:basic", - "dynamic", - "f4633eb37143bf9cc2c0e760a67314954c31fa68ec36d5399d386839cb5d54d5" - ], - "wheelhouse/ecdsa-0.16.1.tar.gz": [ - "__pip__", - "dynamic", - "cfc046a2ddd425adbd1a78b3c46f0d1325c657811c0f45ecc3a0a6236c1e50ff" - ], - "wheelhouse/netaddr-0.7.19.tar.gz": [ - "layer:basic", - "dynamic", - "38aeec7cdd035081d3a4c306394b19d677623bf76fa0913f6695127c7753aefd" - ], - "wheelhouse/paramiko-1.16.3.tar.gz": [ - "layer:sshproxy", - "dynamic", - "97d932fdb4fec9aadf6bea368123f3ee15b92199f92eb62666370c7fed62d072" - ], - "wheelhouse/pbr-5.5.1.tar.gz": [ - "__pip__", - "dynamic", - "5fad80b613c402d5b7df7bd84812548b2a61e9977387a80a5fc5c396492b13c9" - ], - "wheelhouse/pip-18.1.tar.gz": [ - "layer:basic", - "dynamic", - "c0a292bd977ef590379a3f05d7b7f65135487b67470f6281289a94e015650ea1" - ], - "wheelhouse/pyaml-20.4.0.tar.gz": [ - "__pip__", - "dynamic", - "29a5c2a68660a799103d6949167bd6c7953d031449d08802386372de1db6ad71" - ], - "wheelhouse/pycrypto-2.6.1.tar.gz": [ - "__pip__", - "dynamic", - "f2ce1e989b272cfcb677616763e0a2e7ec659effa67a88aa92b3a65528f60a3c" - ], - "wheelhouse/setuptools-41.6.0.zip": [ - "layer:basic", - "dynamic", - "6afa61b391dcd16cb8890ec9f66cc4015a8a31a6e1c2b4e0c464514be1a3d722" - ], - "wheelhouse/setuptools_scm-1.17.0.tar.gz": [ - "layer:basic", - "dynamic", - "70a4cf5584e966ae92f54a764e6437af992ba42ac4bca7eb37cc5d02b98ec40a" - ], - "wheelhouse/six-1.15.0.tar.gz": [ - "__pip__", - "dynamic", - "30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259" - ], - "wheelhouse/wheel-0.33.6.tar.gz": [ - "layer:basic", - "dynamic", - "10c9da68765315ed98850f8e048347c3eb06dd81822dc2ab1d4fde9dc9702646" - ] - } -} \ No newline at end of file diff --git a/nscharm_policy_vnf/charms/vnf-policy/.gitignore b/nscharm_policy_vnf/charms/vnf-policy/.gitignore deleted file mode 100644 index b8e7ba3a229bda75224369127d7454019fea641f..0000000000000000000000000000000000000000 --- a/nscharm_policy_vnf/charms/vnf-policy/.gitignore +++ /dev/null @@ -1 +0,0 @@ -trusty/ diff --git a/nscharm_policy_vnf/charms/vnf-policy/.travis/profile-update.yaml b/nscharm_policy_vnf/charms/vnf-policy/.travis/profile-update.yaml deleted file mode 100644 index 57f96eb6f9fa6f13158e59df78f2a9cab4c51949..0000000000000000000000000000000000000000 --- a/nscharm_policy_vnf/charms/vnf-policy/.travis/profile-update.yaml +++ /dev/null @@ -1,12 +0,0 @@ -config: {} -description: Default LXD profile - updated -devices: - eth0: - name: eth0 - parent: lxdbr0 - nictype: bridged - type: nic - root: - path: / - pool: default - type: disk diff --git a/nscharm_policy_vnf/charms/vnf-policy/LICENSE b/nscharm_policy_vnf/charms/vnf-policy/LICENSE deleted file mode 100644 index d645695673349e3947e8e5ae42332d0ac3164cd7..0000000000000000000000000000000000000000 --- a/nscharm_policy_vnf/charms/vnf-policy/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/nscharm_policy_vnf/charms/vnf-policy/Makefile b/nscharm_policy_vnf/charms/vnf-policy/Makefile deleted file mode 100644 index a1ad3a5cd27751144f6bd1a0a7db50f1e11b18eb..0000000000000000000000000000000000000000 --- a/nscharm_policy_vnf/charms/vnf-policy/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/make - -all: lint unit_test - - -.PHONY: clean -clean: - @rm -rf .tox - -.PHONY: apt_prereqs -apt_prereqs: - @# Need tox, but don't install the apt version unless we have to (don't want to conflict with pip) - @which tox >/dev/null || (sudo apt-get install -y python-pip && sudo pip install tox) - -.PHONY: lint -lint: apt_prereqs - @tox --notest - @PATH=.tox/py34/bin:.tox/py35/bin flake8 $(wildcard hooks reactive lib unit_tests tests) - @charm proof - -.PHONY: unit_test -unit_test: apt_prereqs - @echo Starting tests... - tox diff --git a/nscharm_policy_vnf/charms/vnf-policy/actions.yaml b/nscharm_policy_vnf/charms/vnf-policy/actions.yaml deleted file mode 100644 index 4e411b0143183aa6e9304bc90afc4b4873d53c5a..0000000000000000000000000000000000000000 --- a/nscharm_policy_vnf/charms/vnf-policy/actions.yaml +++ /dev/null @@ -1,63 +0,0 @@ -## -# Copyright 2016 Canonical Ltd. -# All rights reserved. -# -# 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. -## - -"run": - "description": "Run an arbitrary command" - "params": - "command": - "description": "The command to execute." - "type": "string" - "default": "" - "required": - - "command" -"generate-ssh-key": - "description": "Generate a new SSH keypair for this unit. This will replace any\ - \ existing previously generated keypair." -"verify-ssh-credentials": - "description": "Verify that this unit can authenticate with server specified by\ - \ ssh-hostname and ssh-username." -"get-ssh-public-key": - "description": "Get the public SSH key for this unit." -"start": - "description": "Stop the service on the VNF." -"stop": - "description": "Stop the service on the VNF." -"restart": - "description": "Stop the service on the VNF." -"reboot": - "description": "Reboot the VNF virtual machine." -"upgrade": - "description": "Upgrade the software on the VNF." -"set-policy": - "description": "Set a user policy" - "params": - "user_id": - "description": "The user_id to modify the policy of" - "type": "integer" - "default": !!int "0" - "bw": - "description": "" - "type": "integer" - "default": !!int "0" - "qos": - "description": "" - "type": "integer" - "default": !!int "0" - "required": - - "user_id" - - "bw" - - "qos" diff --git a/nscharm_policy_vnf/charms/vnf-policy/actions/generate-ssh-key b/nscharm_policy_vnf/charms/vnf-policy/actions/generate-ssh-key deleted file mode 100755 index 7e30af4cfa084120a9343bf71c421b69ec3f2967..0000000000000000000000000000000000000000 --- a/nscharm_policy_vnf/charms/vnf-policy/actions/generate-ssh-key +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env python3 -## -# Copyright 2016 Canonical Ltd. -# All rights reserved. -# -# 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 sys -sys.path.append('lib') - -from charms.reactive import main, set_flag -from charmhelpers.core.hookenv import action_fail, action_name - -""" -`set_state` only works here because it's flushed to disk inside the `main()` -loop. remove_state will need to be called inside the action method. -""" -set_flag('actions.{}'.format(action_name())) - -try: - main() -except Exception as e: - action_fail(repr(e)) diff --git a/nscharm_policy_vnf/charms/vnf-policy/actions/get-ssh-public-key b/nscharm_policy_vnf/charms/vnf-policy/actions/get-ssh-public-key deleted file mode 100755 index 7e30af4cfa084120a9343bf71c421b69ec3f2967..0000000000000000000000000000000000000000 --- a/nscharm_policy_vnf/charms/vnf-policy/actions/get-ssh-public-key +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env python3 -## -# Copyright 2016 Canonical Ltd. -# All rights reserved. -# -# 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 sys -sys.path.append('lib') - -from charms.reactive import main, set_flag -from charmhelpers.core.hookenv import action_fail, action_name - -""" -`set_state` only works here because it's flushed to disk inside the `main()` -loop. remove_state will need to be called inside the action method. -""" -set_flag('actions.{}'.format(action_name())) - -try: - main() -except Exception as e: - action_fail(repr(e)) diff --git a/nscharm_policy_vnf/charms/vnf-policy/actions/reboot b/nscharm_policy_vnf/charms/vnf-policy/actions/reboot deleted file mode 100755 index 9a2ba24b9efdfa3d21457469c503c050196fb170..0000000000000000000000000000000000000000 --- a/nscharm_policy_vnf/charms/vnf-policy/actions/reboot +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env python3 -import sys -sys.path.append('lib') -from charms.reactive import main, set_flag -from charmhelpers.core.hookenv import action_fail, action_name - -set_flag('actions.{}'.format(action_name())) - -try: - main() -except Exception as e: - action_fail(repr(e)) diff --git a/nscharm_policy_vnf/charms/vnf-policy/actions/restart b/nscharm_policy_vnf/charms/vnf-policy/actions/restart deleted file mode 100755 index 9a2ba24b9efdfa3d21457469c503c050196fb170..0000000000000000000000000000000000000000 --- a/nscharm_policy_vnf/charms/vnf-policy/actions/restart +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env python3 -import sys -sys.path.append('lib') -from charms.reactive import main, set_flag -from charmhelpers.core.hookenv import action_fail, action_name - -set_flag('actions.{}'.format(action_name())) - -try: - main() -except Exception as e: - action_fail(repr(e)) diff --git a/nscharm_policy_vnf/charms/vnf-policy/actions/run b/nscharm_policy_vnf/charms/vnf-policy/actions/run deleted file mode 100755 index 7e30af4cfa084120a9343bf71c421b69ec3f2967..0000000000000000000000000000000000000000 --- a/nscharm_policy_vnf/charms/vnf-policy/actions/run +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env python3 -## -# Copyright 2016 Canonical Ltd. -# All rights reserved. -# -# 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 sys -sys.path.append('lib') - -from charms.reactive import main, set_flag -from charmhelpers.core.hookenv import action_fail, action_name - -""" -`set_state` only works here because it's flushed to disk inside the `main()` -loop. remove_state will need to be called inside the action method. -""" -set_flag('actions.{}'.format(action_name())) - -try: - main() -except Exception as e: - action_fail(repr(e)) diff --git a/nscharm_policy_vnf/charms/vnf-policy/actions/start b/nscharm_policy_vnf/charms/vnf-policy/actions/start deleted file mode 100755 index 9a2ba24b9efdfa3d21457469c503c050196fb170..0000000000000000000000000000000000000000 --- a/nscharm_policy_vnf/charms/vnf-policy/actions/start +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env python3 -import sys -sys.path.append('lib') -from charms.reactive import main, set_flag -from charmhelpers.core.hookenv import action_fail, action_name - -set_flag('actions.{}'.format(action_name())) - -try: - main() -except Exception as e: - action_fail(repr(e)) diff --git a/nscharm_policy_vnf/charms/vnf-policy/actions/stop b/nscharm_policy_vnf/charms/vnf-policy/actions/stop deleted file mode 100755 index 9a2ba24b9efdfa3d21457469c503c050196fb170..0000000000000000000000000000000000000000 --- a/nscharm_policy_vnf/charms/vnf-policy/actions/stop +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env python3 -import sys -sys.path.append('lib') -from charms.reactive import main, set_flag -from charmhelpers.core.hookenv import action_fail, action_name - -set_flag('actions.{}'.format(action_name())) - -try: - main() -except Exception as e: - action_fail(repr(e)) diff --git a/nscharm_policy_vnf/charms/vnf-policy/actions/upgrade b/nscharm_policy_vnf/charms/vnf-policy/actions/upgrade deleted file mode 100755 index 9a2ba24b9efdfa3d21457469c503c050196fb170..0000000000000000000000000000000000000000 --- a/nscharm_policy_vnf/charms/vnf-policy/actions/upgrade +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env python3 -import sys -sys.path.append('lib') -from charms.reactive import main, set_flag -from charmhelpers.core.hookenv import action_fail, action_name - -set_flag('actions.{}'.format(action_name())) - -try: - main() -except Exception as e: - action_fail(repr(e)) diff --git a/nscharm_policy_vnf/charms/vnf-policy/actions/verify-ssh-credentials b/nscharm_policy_vnf/charms/vnf-policy/actions/verify-ssh-credentials deleted file mode 100755 index 7e30af4cfa084120a9343bf71c421b69ec3f2967..0000000000000000000000000000000000000000 --- a/nscharm_policy_vnf/charms/vnf-policy/actions/verify-ssh-credentials +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env python3 -## -# Copyright 2016 Canonical Ltd. -# All rights reserved. -# -# 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 sys -sys.path.append('lib') - -from charms.reactive import main, set_flag -from charmhelpers.core.hookenv import action_fail, action_name - -""" -`set_state` only works here because it's flushed to disk inside the `main()` -loop. remove_state will need to be called inside the action method. -""" -set_flag('actions.{}'.format(action_name())) - -try: - main() -except Exception as e: - action_fail(repr(e)) diff --git a/nscharm_policy_vnf/charms/vnf-policy/bin/charm-env b/nscharm_policy_vnf/charms/vnf-policy/bin/charm-env deleted file mode 100755 index d211ce9b2912dd072aa7e1ce0399783fd075efc4..0000000000000000000000000000000000000000 --- a/nscharm_policy_vnf/charms/vnf-policy/bin/charm-env +++ /dev/null @@ -1,107 +0,0 @@ -#!/bin/bash - -VERSION="1.0.0" - - -find_charm_dirs() { - # Hopefully, $JUJU_CHARM_DIR is set so which venv to use in unambiguous. - if [[ -n "$JUJU_CHARM_DIR" || -n "$CHARM_DIR" ]]; then - if [[ -z "$JUJU_CHARM_DIR" ]]; then - # accept $CHARM_DIR to be more forgiving - export JUJU_CHARM_DIR="$CHARM_DIR" - fi - if [[ -z "$CHARM_DIR" ]]; then - # set CHARM_DIR as well to help with backwards compatibility - export CHARM_DIR="$JUJU_CHARM_DIR" - fi - return - fi - # Try to guess the value for JUJU_CHARM_DIR by looking for a non-subordinate - # (because there's got to be at least one principle) charm directory; - # if there are several, pick the first by alpha order. - agents_dir="/var/lib/juju/agents" - if [[ -d "$agents_dir" ]]; then - desired_charm="$1" - found_charm_dir="" - if [[ -n "$desired_charm" ]]; then - for charm_dir in $(/bin/ls -d "$agents_dir"/unit-*/charm); do - charm_name="$(grep -o '^['\''"]\?name['\''"]\?:.*' $charm_dir/metadata.yaml 2> /dev/null | sed -e 's/.*: *//' -e 's/['\''"]//g')" - if [[ "$charm_name" == "$desired_charm" ]]; then - if [[ -n "$found_charm_dir" ]]; then - >&2 echo "Ambiguous possibilities for JUJU_CHARM_DIR matching '$desired_charm'; please run within a Juju hook context" - exit 1 - fi - found_charm_dir="$charm_dir" - fi - done - if [[ -z "$found_charm_dir" ]]; then - >&2 echo "Unable to determine JUJU_CHARM_DIR matching '$desired_charm'; please run within a Juju hook context" - exit 1 - fi - export JUJU_CHARM_DIR="$found_charm_dir" - export CHARM_DIR="$found_charm_dir" - return - fi - # shellcheck disable=SC2126 - non_subordinates="$(grep -L 'subordinate"\?:.*true' "$agents_dir"/unit-*/charm/metadata.yaml | wc -l)" - if [[ "$non_subordinates" -gt 1 ]]; then - >&2 echo 'Ambiguous possibilities for JUJU_CHARM_DIR; please use --charm or run within a Juju hook context' - exit 1 - elif [[ "$non_subordinates" -eq 1 ]]; then - for charm_dir in $(/bin/ls -d "$agents_dir"/unit-*/charm); do - if grep -q 'subordinate"\?:.*true' "$charm_dir/metadata.yaml"; then - continue - fi - export JUJU_CHARM_DIR="$charm_dir" - export CHARM_DIR="$charm_dir" - return - done - fi - fi - >&2 echo 'Unable to determine JUJU_CHARM_DIR; please run within a Juju hook context' - exit 1 -} - -try_activate_venv() { - if [[ -d "$JUJU_CHARM_DIR/../.venv" ]]; then - . "$JUJU_CHARM_DIR/../.venv/bin/activate" - fi -} - -find_wrapped() { - PATH="${PATH/\/usr\/local\/sbin:}" which "$(basename "$0")" -} - - -if [[ "$1" == "--version" || "$1" == "-v" ]]; then - echo "$VERSION" - exit 0 -fi - - -# allow --charm option to hint which JUJU_CHARM_DIR to choose when ambiguous -# NB: --charm option must come first -# NB: option must be processed outside find_charm_dirs to modify $@ -charm_name="" -if [[ "$1" == "--charm" ]]; then - charm_name="$2" - shift; shift -fi - -find_charm_dirs "$charm_name" -try_activate_venv -export PYTHONPATH="$JUJU_CHARM_DIR/lib:$PYTHONPATH" - -if [[ "$(basename "$0")" == "charm-env" ]]; then - # being used as a shebang - exec "$@" -elif [[ "$0" == "$BASH_SOURCE" ]]; then - # being invoked as a symlink wrapping something to find in the venv - exec "$(find_wrapped)" "$@" -elif [[ "$(basename "$BASH_SOURCE")" == "charm-env" ]]; then - # being sourced directly; do nothing - /bin/true -else - # being sourced for wrapped bash helpers - . "$(find_wrapped)" -fi diff --git a/nscharm_policy_vnf/charms/vnf-policy/bin/layer_option b/nscharm_policy_vnf/charms/vnf-policy/bin/layer_option deleted file mode 100755 index 3253ef8aadb95807f26e5ebd8486adde67e5cbc2..0000000000000000000000000000000000000000 --- a/nscharm_policy_vnf/charms/vnf-policy/bin/layer_option +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 - -import sys -import argparse -from charms import layer - - -parser = argparse.ArgumentParser(description='Access layer options.') -parser.add_argument('section', - help='the section, or layer, the option is from') -parser.add_argument('option', - help='the option to access') - -args = parser.parse_args() -value = layer.options.get(args.section, args.option) -if isinstance(value, bool): - sys.exit(0 if value else 1) -elif isinstance(value, list): - for val in value: - print(val) -else: - print(value) diff --git a/nscharm_policy_vnf/charms/vnf-policy/config.yaml b/nscharm_policy_vnf/charms/vnf-policy/config.yaml deleted file mode 100644 index a7d9291c137d1907b7ef2ba019123aa9201ef107..0000000000000000000000000000000000000000 --- a/nscharm_policy_vnf/charms/vnf-policy/config.yaml +++ /dev/null @@ -1,29 +0,0 @@ -"options": - "ssh-hostname": - "type": "string" - "default": "" - "description": "The hostname or IP address of the machine to" - "ssh-username": - "type": "string" - "default": "" - "description": "The username to login as." - "ssh-password": - "type": "string" - "default": "" - "description": "The password used to authenticate." - "ssh-private-key": - "type": "string" - "default": "" - "description": "DEPRECATED. The private ssh key to be used to authenticate." - "ssh-public-key": - "type": "string" - "default": "" - "description": "The public key of this unit." - "ssh-key-type": - "type": "string" - "default": "rsa" - "description": "The type of encryption to use for the SSH key." - "ssh-key-bits": - "type": "int" - "default": !!int "4096" - "description": "The number of bits to use for the SSH key." diff --git a/nscharm_policy_vnf/charms/vnf-policy/copyright b/nscharm_policy_vnf/charms/vnf-policy/copyright deleted file mode 100644 index d4fdd18281c632d030a301d26d45b4dabdb308ef..0000000000000000000000000000000000000000 --- a/nscharm_policy_vnf/charms/vnf-policy/copyright +++ /dev/null @@ -1,16 +0,0 @@ -Format: http://dep.debian.net/deps/dep5/ - -Files: * -Copyright: Copyright 2015-2017, Canonical Ltd., All Rights Reserved. -License: Apache License 2.0 - 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/nscharm_policy_vnf/charms/vnf-policy/copyright.layer-options b/nscharm_policy_vnf/charms/vnf-policy/copyright.layer-options deleted file mode 100644 index d4fdd18281c632d030a301d26d45b4dabdb308ef..0000000000000000000000000000000000000000 --- a/nscharm_policy_vnf/charms/vnf-policy/copyright.layer-options +++ /dev/null @@ -1,16 +0,0 @@ -Format: http://dep.debian.net/deps/dep5/ - -Files: * -Copyright: Copyright 2015-2017, Canonical Ltd., All Rights Reserved. -License: Apache License 2.0 - 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/nscharm_policy_vnf/charms/vnf-policy/hooks/collect-metrics b/nscharm_policy_vnf/charms/vnf-policy/hooks/collect-metrics deleted file mode 100755 index ecd7e62385689b00cc023b1057a0061b0f373134..0000000000000000000000000000000000000000 --- a/nscharm_policy_vnf/charms/vnf-policy/hooks/collect-metrics +++ /dev/null @@ -1,68 +0,0 @@ -#!/usr/bin/env python3 -"""Handle the collect-metrics hook via proxy. - -The normal metrics layer will only execute metrics collection against the local -machine. This hook implements the same approach, but runs the collection code -against the configured ssh proxy. - -Because the metrics hook runs in a restricted context, it can't be run as a -normal reactive event, nor can it access things like config. -""" - -import os -import shlex -from subprocess import check_call, CalledProcessError -import sys -import yaml - -# Load modules from $CHARM_DIR/lib -sys.path.append('lib') -import charms.sshproxy - - -def build_command(doc): - """Build the commands to report metrics. - - Build a list of `add-metric` commands to report the current metrics - back to the Juju controller. - """ - values = {} - metrics = doc.get("metrics", {}) - for metric, mdoc in metrics.items(): - cmd = mdoc.get("command") - if cmd: - try: - value, err = charms.sshproxy._run( - # The command may contain quotes that need to be preserved, - # i.e., `awk '{print $1}' /proc/uptime` - shlex.split(cmd, posix=False) - ) - except Exception as e: - # Ignore all errors - with open("metrics.log", "a") as f: - f.write("{}".format(e)) - continue - - if isinstance(value, bytes): - value = value.decode('utf-8') - - value = value.strip() - if value: - values[metric] = value - - if not values: - return None - command = ["add-metric"] - for metric, value in values.items(): - command.append("%s=%s" % (metric, value)) - return command - - -if __name__ == '__main__': - charm_dir = os.path.dirname(os.path.abspath(os.path.join(__file__, ".."))) - metrics_yaml = os.path.join(charm_dir, "metrics.yaml") - with open(metrics_yaml) as f: - doc = yaml.load(f) - command = build_command(doc) - if command: - check_call(command) diff --git a/nscharm_policy_vnf/charms/vnf-policy/hooks/config-changed b/nscharm_policy_vnf/charms/vnf-policy/hooks/config-changed deleted file mode 100755 index 9858c6be15b8a682778ab4727835151e1b693801..0000000000000000000000000000000000000000 --- a/nscharm_policy_vnf/charms/vnf-policy/hooks/config-changed +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 - -# Load modules from $JUJU_CHARM_DIR/lib -import sys -sys.path.append('lib') - -from charms.layer import basic # noqa -basic.bootstrap_charm_deps() - -from charmhelpers.core import hookenv # noqa -hookenv.atstart(basic.init_config_states) -hookenv.atexit(basic.clear_config_states) - - -# This will load and run the appropriate @hook and other decorated -# handlers from $JUJU_CHARM_DIR/reactive, $JUJU_CHARM_DIR/hooks/reactive, -# and $JUJU_CHARM_DIR/hooks/relations. -# -# See https://jujucharms.com/docs/stable/authors-charm-building -# for more information on this pattern. -from charms.reactive import main # noqa -main() diff --git a/nscharm_policy_vnf/charms/vnf-policy/hooks/hook.template b/nscharm_policy_vnf/charms/vnf-policy/hooks/hook.template deleted file mode 100644 index 9858c6be15b8a682778ab4727835151e1b693801..0000000000000000000000000000000000000000 --- a/nscharm_policy_vnf/charms/vnf-policy/hooks/hook.template +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 - -# Load modules from $JUJU_CHARM_DIR/lib -import sys -sys.path.append('lib') - -from charms.layer import basic # noqa -basic.bootstrap_charm_deps() - -from charmhelpers.core import hookenv # noqa -hookenv.atstart(basic.init_config_states) -hookenv.atexit(basic.clear_config_states) - - -# This will load and run the appropriate @hook and other decorated -# handlers from $JUJU_CHARM_DIR/reactive, $JUJU_CHARM_DIR/hooks/reactive, -# and $JUJU_CHARM_DIR/hooks/relations. -# -# See https://jujucharms.com/docs/stable/authors-charm-building -# for more information on this pattern. -from charms.reactive import main # noqa -main() diff --git a/nscharm_policy_vnf/charms/vnf-policy/hooks/install b/nscharm_policy_vnf/charms/vnf-policy/hooks/install deleted file mode 100755 index 9858c6be15b8a682778ab4727835151e1b693801..0000000000000000000000000000000000000000 --- a/nscharm_policy_vnf/charms/vnf-policy/hooks/install +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 - -# Load modules from $JUJU_CHARM_DIR/lib -import sys -sys.path.append('lib') - -from charms.layer import basic # noqa -basic.bootstrap_charm_deps() - -from charmhelpers.core import hookenv # noqa -hookenv.atstart(basic.init_config_states) -hookenv.atexit(basic.clear_config_states) - - -# This will load and run the appropriate @hook and other decorated -# handlers from $JUJU_CHARM_DIR/reactive, $JUJU_CHARM_DIR/hooks/reactive, -# and $JUJU_CHARM_DIR/hooks/relations. -# -# See https://jujucharms.com/docs/stable/authors-charm-building -# for more information on this pattern. -from charms.reactive import main # noqa -main() diff --git a/nscharm_policy_vnf/charms/vnf-policy/hooks/leader-elected b/nscharm_policy_vnf/charms/vnf-policy/hooks/leader-elected deleted file mode 100755 index 9858c6be15b8a682778ab4727835151e1b693801..0000000000000000000000000000000000000000 --- a/nscharm_policy_vnf/charms/vnf-policy/hooks/leader-elected +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 - -# Load modules from $JUJU_CHARM_DIR/lib -import sys -sys.path.append('lib') - -from charms.layer import basic # noqa -basic.bootstrap_charm_deps() - -from charmhelpers.core import hookenv # noqa -hookenv.atstart(basic.init_config_states) -hookenv.atexit(basic.clear_config_states) - - -# This will load and run the appropriate @hook and other decorated -# handlers from $JUJU_CHARM_DIR/reactive, $JUJU_CHARM_DIR/hooks/reactive, -# and $JUJU_CHARM_DIR/hooks/relations. -# -# See https://jujucharms.com/docs/stable/authors-charm-building -# for more information on this pattern. -from charms.reactive import main # noqa -main() diff --git a/nscharm_policy_vnf/charms/vnf-policy/hooks/leader-settings-changed b/nscharm_policy_vnf/charms/vnf-policy/hooks/leader-settings-changed deleted file mode 100755 index 9858c6be15b8a682778ab4727835151e1b693801..0000000000000000000000000000000000000000 --- a/nscharm_policy_vnf/charms/vnf-policy/hooks/leader-settings-changed +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 - -# Load modules from $JUJU_CHARM_DIR/lib -import sys -sys.path.append('lib') - -from charms.layer import basic # noqa -basic.bootstrap_charm_deps() - -from charmhelpers.core import hookenv # noqa -hookenv.atstart(basic.init_config_states) -hookenv.atexit(basic.clear_config_states) - - -# This will load and run the appropriate @hook and other decorated -# handlers from $JUJU_CHARM_DIR/reactive, $JUJU_CHARM_DIR/hooks/reactive, -# and $JUJU_CHARM_DIR/hooks/relations. -# -# See https://jujucharms.com/docs/stable/authors-charm-building -# for more information on this pattern. -from charms.reactive import main # noqa -main() diff --git a/nscharm_policy_vnf/charms/vnf-policy/hooks/post-series-upgrade b/nscharm_policy_vnf/charms/vnf-policy/hooks/post-series-upgrade deleted file mode 100755 index 9858c6be15b8a682778ab4727835151e1b693801..0000000000000000000000000000000000000000 --- a/nscharm_policy_vnf/charms/vnf-policy/hooks/post-series-upgrade +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 - -# Load modules from $JUJU_CHARM_DIR/lib -import sys -sys.path.append('lib') - -from charms.layer import basic # noqa -basic.bootstrap_charm_deps() - -from charmhelpers.core import hookenv # noqa -hookenv.atstart(basic.init_config_states) -hookenv.atexit(basic.clear_config_states) - - -# This will load and run the appropriate @hook and other decorated -# handlers from $JUJU_CHARM_DIR/reactive, $JUJU_CHARM_DIR/hooks/reactive, -# and $JUJU_CHARM_DIR/hooks/relations. -# -# See https://jujucharms.com/docs/stable/authors-charm-building -# for more information on this pattern. -from charms.reactive import main # noqa -main() diff --git a/nscharm_policy_vnf/charms/vnf-policy/hooks/pre-series-upgrade b/nscharm_policy_vnf/charms/vnf-policy/hooks/pre-series-upgrade deleted file mode 100755 index 9858c6be15b8a682778ab4727835151e1b693801..0000000000000000000000000000000000000000 --- a/nscharm_policy_vnf/charms/vnf-policy/hooks/pre-series-upgrade +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 - -# Load modules from $JUJU_CHARM_DIR/lib -import sys -sys.path.append('lib') - -from charms.layer import basic # noqa -basic.bootstrap_charm_deps() - -from charmhelpers.core import hookenv # noqa -hookenv.atstart(basic.init_config_states) -hookenv.atexit(basic.clear_config_states) - - -# This will load and run the appropriate @hook and other decorated -# handlers from $JUJU_CHARM_DIR/reactive, $JUJU_CHARM_DIR/hooks/reactive, -# and $JUJU_CHARM_DIR/hooks/relations. -# -# See https://jujucharms.com/docs/stable/authors-charm-building -# for more information on this pattern. -from charms.reactive import main # noqa -main() diff --git a/nscharm_policy_vnf/charms/vnf-policy/hooks/start b/nscharm_policy_vnf/charms/vnf-policy/hooks/start deleted file mode 100755 index 9858c6be15b8a682778ab4727835151e1b693801..0000000000000000000000000000000000000000 --- a/nscharm_policy_vnf/charms/vnf-policy/hooks/start +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 - -# Load modules from $JUJU_CHARM_DIR/lib -import sys -sys.path.append('lib') - -from charms.layer import basic # noqa -basic.bootstrap_charm_deps() - -from charmhelpers.core import hookenv # noqa -hookenv.atstart(basic.init_config_states) -hookenv.atexit(basic.clear_config_states) - - -# This will load and run the appropriate @hook and other decorated -# handlers from $JUJU_CHARM_DIR/reactive, $JUJU_CHARM_DIR/hooks/reactive, -# and $JUJU_CHARM_DIR/hooks/relations. -# -# See https://jujucharms.com/docs/stable/authors-charm-building -# for more information on this pattern. -from charms.reactive import main # noqa -main() diff --git a/nscharm_policy_vnf/charms/vnf-policy/hooks/stop b/nscharm_policy_vnf/charms/vnf-policy/hooks/stop deleted file mode 100755 index 9858c6be15b8a682778ab4727835151e1b693801..0000000000000000000000000000000000000000 --- a/nscharm_policy_vnf/charms/vnf-policy/hooks/stop +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 - -# Load modules from $JUJU_CHARM_DIR/lib -import sys -sys.path.append('lib') - -from charms.layer import basic # noqa -basic.bootstrap_charm_deps() - -from charmhelpers.core import hookenv # noqa -hookenv.atstart(basic.init_config_states) -hookenv.atexit(basic.clear_config_states) - - -# This will load and run the appropriate @hook and other decorated -# handlers from $JUJU_CHARM_DIR/reactive, $JUJU_CHARM_DIR/hooks/reactive, -# and $JUJU_CHARM_DIR/hooks/relations. -# -# See https://jujucharms.com/docs/stable/authors-charm-building -# for more information on this pattern. -from charms.reactive import main # noqa -main() diff --git a/nscharm_policy_vnf/charms/vnf-policy/hooks/update-status b/nscharm_policy_vnf/charms/vnf-policy/hooks/update-status deleted file mode 100755 index 9858c6be15b8a682778ab4727835151e1b693801..0000000000000000000000000000000000000000 --- a/nscharm_policy_vnf/charms/vnf-policy/hooks/update-status +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 - -# Load modules from $JUJU_CHARM_DIR/lib -import sys -sys.path.append('lib') - -from charms.layer import basic # noqa -basic.bootstrap_charm_deps() - -from charmhelpers.core import hookenv # noqa -hookenv.atstart(basic.init_config_states) -hookenv.atexit(basic.clear_config_states) - - -# This will load and run the appropriate @hook and other decorated -# handlers from $JUJU_CHARM_DIR/reactive, $JUJU_CHARM_DIR/hooks/reactive, -# and $JUJU_CHARM_DIR/hooks/relations. -# -# See https://jujucharms.com/docs/stable/authors-charm-building -# for more information on this pattern. -from charms.reactive import main # noqa -main() diff --git a/nscharm_policy_vnf/charms/vnf-policy/hooks/upgrade-charm b/nscharm_policy_vnf/charms/vnf-policy/hooks/upgrade-charm deleted file mode 100755 index 9858c6be15b8a682778ab4727835151e1b693801..0000000000000000000000000000000000000000 --- a/nscharm_policy_vnf/charms/vnf-policy/hooks/upgrade-charm +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 - -# Load modules from $JUJU_CHARM_DIR/lib -import sys -sys.path.append('lib') - -from charms.layer import basic # noqa -basic.bootstrap_charm_deps() - -from charmhelpers.core import hookenv # noqa -hookenv.atstart(basic.init_config_states) -hookenv.atexit(basic.clear_config_states) - - -# This will load and run the appropriate @hook and other decorated -# handlers from $JUJU_CHARM_DIR/reactive, $JUJU_CHARM_DIR/hooks/reactive, -# and $JUJU_CHARM_DIR/hooks/relations. -# -# See https://jujucharms.com/docs/stable/authors-charm-building -# for more information on this pattern. -from charms.reactive import main # noqa -main() diff --git a/nscharm_policy_vnf/charms/vnf-policy/layer.yaml b/nscharm_policy_vnf/charms/vnf-policy/layer.yaml deleted file mode 100644 index 98e6ce190f079f5cac984edcef7be28842870495..0000000000000000000000000000000000000000 --- a/nscharm_policy_vnf/charms/vnf-policy/layer.yaml +++ /dev/null @@ -1,16 +0,0 @@ -"includes": -- "layer:options" -- "layer:basic" -- "layer:sshproxy" -- "layer:vnfproxy" -"exclude": [".travis.yml", "tests", "tox.ini", "test-requirements.txt", "unit_tests"] -"options": - "basic": - "use_venv": !!bool "false" - "packages": [] - "python_packages": [] - "include_system_packages": !!bool "false" - "sshproxy": {} - "vnfproxy": {} - "vnf-policy": {} -"is": "vnf-policy" diff --git a/nscharm_policy_vnf/charms/vnf-policy/lib/charms/layer/__init__.py b/nscharm_policy_vnf/charms/vnf-policy/lib/charms/layer/__init__.py deleted file mode 100644 index a8e0c640642f44cac85df60f3d9b7f73b0bb18bb..0000000000000000000000000000000000000000 --- a/nscharm_policy_vnf/charms/vnf-policy/lib/charms/layer/__init__.py +++ /dev/null @@ -1,60 +0,0 @@ -import sys -from importlib import import_module -from pathlib import Path - - -def import_layer_libs(): - """ - Ensure that all layer libraries are imported. - - This makes it possible to do the following: - - from charms import layer - - layer.foo.do_foo_thing() - - Note: This function must be called after bootstrap. - """ - for module_file in Path('lib/charms/layer').glob('*'): - module_name = module_file.stem - if module_name in ('__init__', 'basic', 'execd') or not ( - module_file.suffix == '.py' or module_file.is_dir() - ): - continue - import_module('charms.layer.{}'.format(module_name)) - - -# Terrible hack to support the old terrible interface. -# Try to get people to call layer.options.get() instead so -# that we can remove this garbage. -# Cribbed from https://stackoverfLow.com/a/48100440/4941864 -class OptionsBackwardsCompatibilityHack(sys.modules[__name__].__class__): - def __call__(self, section=None, layer_file=None): - if layer_file is None: - return self.get(section=section) - else: - return self.get(section=section, - layer_file=Path(layer_file)) - - -def patch_options_interface(): - from charms.layer import options - if sys.version_info.minor >= 5: - options.__class__ = OptionsBackwardsCompatibilityHack - else: - # Py 3.4 doesn't support changing the __class__, so we have to do it - # another way. The last line is needed because we already have a - # reference that doesn't get updated with sys.modules. - name = options.__name__ - hack = OptionsBackwardsCompatibilityHack(name) - hack.get = options.get - sys.modules[name] = hack - sys.modules[__name__].options = hack - - -try: - patch_options_interface() -except ImportError: - # This may fail if pyyaml hasn't been installed yet. But in that - # case, the bootstrap logic will try it again once it has. - pass diff --git a/nscharm_policy_vnf/charms/vnf-policy/lib/charms/layer/basic.py b/nscharm_policy_vnf/charms/vnf-policy/lib/charms/layer/basic.py deleted file mode 100644 index 75072039adab3e35ae268c4e31c6c03cd4a1bdef..0000000000000000000000000000000000000000 --- a/nscharm_policy_vnf/charms/vnf-policy/lib/charms/layer/basic.py +++ /dev/null @@ -1,446 +0,0 @@ -import os -import sys -import re -import shutil -from distutils.version import LooseVersion -from pkg_resources import Requirement -from glob import glob -from subprocess import check_call, check_output, CalledProcessError -from time import sleep - -from charms import layer -from charms.layer.execd import execd_preinstall - - -def _get_subprocess_env(): - env = os.environ.copy() - env['LANG'] = env.get('LANG', 'C.UTF-8') - return env - - -def get_series(): - """ - Return series for a few known OS:es. - Tested as of 2019 november: - * centos6, centos7, rhel6. - * bionic - """ - series = "" - - # Looking for content in /etc/os-release - # works for ubuntu + some centos - if os.path.isfile('/etc/os-release'): - d = {} - with open('/etc/os-release', 'r') as rel: - for l in rel: - if not re.match(r'^\s*$', l): - k, v = l.split('=') - d[k.strip()] = v.strip().replace('"', '') - series = "{ID}{VERSION_ID}".format(**d) - - # Looking for content in /etc/redhat-release - # works for redhat enterprise systems - elif os.path.isfile('/etc/redhat-release'): - with open('/etc/redhat-release', 'r') as redhatlsb: - # CentOS Linux release 7.7.1908 (Core) - line = redhatlsb.readline() - release = int(line.split("release")[1].split()[0][0]) - series = "centos" + str(release) - - # Looking for content in /etc/lsb-release - # works for ubuntu - elif os.path.isfile('/etc/lsb-release'): - d = {} - with open('/etc/lsb-release', 'r') as lsb: - for l in lsb: - k, v = l.split('=') - d[k.strip()] = v.strip() - series = d['DISTRIB_CODENAME'] - - # This is what happens if we cant figure out the OS. - else: - series = "unknown" - return series - - -def bootstrap_charm_deps(): - """ - Set up the base charm dependencies so that the reactive system can run. - """ - # execd must happen first, before any attempt to install packages or - # access the network, because sites use this hook to do bespoke - # configuration and install secrets so the rest of this bootstrap - # and the charm itself can actually succeed. This call does nothing - # unless the operator has created and populated $JUJU_CHARM_DIR/exec.d. - execd_preinstall() - # ensure that $JUJU_CHARM_DIR/bin is on the path, for helper scripts - - series = get_series() - - # OMG?! is build-essentials needed? - ubuntu_packages = ['python3-pip', - 'python3-setuptools', - 'python3-yaml', - 'python3-dev', - 'python3-wheel', - 'build-essential'] - - # I'm not going to "yum group info "Development Tools" - # omitting above madness - centos_packages = ['python3-pip', - 'python3-setuptools', - 'python3-devel', - 'python3-wheel'] - - packages_needed = [] - if 'centos' in series: - packages_needed = centos_packages - else: - packages_needed = ubuntu_packages - - charm_dir = os.environ['JUJU_CHARM_DIR'] - os.environ['PATH'] += ':%s' % os.path.join(charm_dir, 'bin') - venv = os.path.abspath('../.venv') - vbin = os.path.join(venv, 'bin') - vpip = os.path.join(vbin, 'pip') - vpy = os.path.join(vbin, 'python') - hook_name = os.path.basename(sys.argv[0]) - is_bootstrapped = os.path.exists('wheelhouse/.bootstrapped') - is_charm_upgrade = hook_name == 'upgrade-charm' - is_series_upgrade = hook_name == 'post-series-upgrade' - is_post_upgrade = os.path.exists('wheelhouse/.upgraded') - is_upgrade = (not is_post_upgrade and - (is_charm_upgrade or is_series_upgrade)) - if is_bootstrapped and not is_upgrade: - # older subordinates might have downgraded charm-env, so we should - # restore it if necessary - install_or_update_charm_env() - activate_venv() - # the .upgrade file prevents us from getting stuck in a loop - # when re-execing to activate the venv; at this point, we've - # activated the venv, so it's safe to clear it - if is_post_upgrade: - os.unlink('wheelhouse/.upgraded') - return - if os.path.exists(venv): - try: - # focal installs or upgrades prior to PR 160 could leave the venv - # in a broken state which would prevent subsequent charm upgrades - _load_installed_versions(vpip) - except CalledProcessError: - is_broken_venv = True - else: - is_broken_venv = False - if is_upgrade or is_broken_venv: - # All upgrades should do a full clear of the venv, rather than - # just updating it, to bring in updates to Python itself - shutil.rmtree(venv) - if is_upgrade: - if os.path.exists('wheelhouse/.bootstrapped'): - os.unlink('wheelhouse/.bootstrapped') - # bootstrap wheelhouse - if os.path.exists('wheelhouse'): - pre_eoan = series in ('ubuntu12.04', 'precise', - 'ubuntu14.04', 'trusty', - 'ubuntu16.04', 'xenial', - 'ubuntu18.04', 'bionic') - pydistutils_lines = [ - "[easy_install]\n", - "find_links = file://{}/wheelhouse/\n".format(charm_dir), - "no_index=True\n", - "index_url=\n", # deliberately nothing here; disables it. - ] - if pre_eoan: - pydistutils_lines.append("allow_hosts = ''\n") - with open('/root/.pydistutils.cfg', 'w') as fp: - # make sure that easy_install also only uses the wheelhouse - # (see https://github.com/pypa/pip/issues/410) - fp.writelines(pydistutils_lines) - if 'centos' in series: - yum_install(packages_needed) - else: - apt_install(packages_needed) - from charms.layer import options - cfg = options.get('basic') - # include packages defined in layer.yaml - if 'centos' in series: - yum_install(cfg.get('packages', [])) - else: - apt_install(cfg.get('packages', [])) - # if we're using a venv, set it up - if cfg.get('use_venv'): - if not os.path.exists(venv): - series = get_series() - if series in ('ubuntu12.04', 'precise', - 'ubuntu14.04', 'trusty'): - apt_install(['python-virtualenv']) - elif 'centos' in series: - yum_install(['python-virtualenv']) - else: - apt_install(['virtualenv']) - cmd = ['virtualenv', '-ppython3', '--never-download', venv] - if cfg.get('include_system_packages'): - cmd.append('--system-site-packages') - check_call(cmd, env=_get_subprocess_env()) - os.environ['PATH'] = ':'.join([vbin, os.environ['PATH']]) - pip = vpip - else: - pip = 'pip3' - # save a copy of system pip to prevent `pip3 install -U pip` - # from changing it - if os.path.exists('/usr/bin/pip'): - shutil.copy2('/usr/bin/pip', '/usr/bin/pip.save') - pre_install_pkgs = ['pip', 'setuptools', 'setuptools-scm'] - # we bundle these packages to work around bugs in older versions (such - # as https://github.com/pypa/pip/issues/56), but if the system already - # provided a newer version, downgrading it can cause other problems - _update_if_newer(pip, pre_install_pkgs) - # install the rest of the wheelhouse deps (extract the pkg names into - # a set so that we can ignore the pre-install packages and let pip - # choose the best version in case there are multiple from layer - # conflicts) - pkgs = _load_wheelhouse_versions().keys() - set(pre_install_pkgs) - reinstall_flag = '--force-reinstall' - if not cfg.get('use_venv', True) and pre_eoan: - reinstall_flag = '--ignore-installed' - check_call([pip, 'install', '-U', reinstall_flag, '--no-index', - '--no-cache-dir', '-f', 'wheelhouse'] + list(pkgs), - env=_get_subprocess_env()) - # re-enable installation from pypi - os.remove('/root/.pydistutils.cfg') - - # install pyyaml for centos7, since, unlike the ubuntu image, the - # default image for centos doesn't include pyyaml; see the discussion: - # https://discourse.jujucharms.com/t/charms-for-centos-lets-begin - if 'centos' in series: - check_call([pip, 'install', '-U', 'pyyaml'], - env=_get_subprocess_env()) - - # install python packages from layer options - if cfg.get('python_packages'): - check_call([pip, 'install', '-U'] + cfg.get('python_packages'), - env=_get_subprocess_env()) - if not cfg.get('use_venv'): - # restore system pip to prevent `pip3 install -U pip` - # from changing it - if os.path.exists('/usr/bin/pip.save'): - shutil.copy2('/usr/bin/pip.save', '/usr/bin/pip') - os.remove('/usr/bin/pip.save') - # setup wrappers to ensure envs are used for scripts - install_or_update_charm_env() - for wrapper in ('charms.reactive', 'charms.reactive.sh', - 'chlp', 'layer_option'): - src = os.path.join('/usr/local/sbin', 'charm-env') - dst = os.path.join('/usr/local/sbin', wrapper) - if not os.path.exists(dst): - os.symlink(src, dst) - if cfg.get('use_venv'): - shutil.copy2('bin/layer_option', vbin) - else: - shutil.copy2('bin/layer_option', '/usr/local/bin/') - # re-link the charm copy to the wrapper in case charms - # call bin/layer_option directly (as was the old pattern) - os.remove('bin/layer_option') - os.symlink('/usr/local/sbin/layer_option', 'bin/layer_option') - # flag us as having already bootstrapped so we don't do it again - open('wheelhouse/.bootstrapped', 'w').close() - if is_upgrade: - # flag us as having already upgraded so we don't do it again - open('wheelhouse/.upgraded', 'w').close() - # Ensure that the newly bootstrapped libs are available. - # Note: this only seems to be an issue with namespace packages. - # Non-namespace-package libs (e.g., charmhelpers) are available - # without having to reload the interpreter. :/ - reload_interpreter(vpy if cfg.get('use_venv') else sys.argv[0]) - - -def _load_installed_versions(pip): - pip_freeze = check_output([pip, 'freeze']).decode('utf8') - versions = {} - for pkg_ver in pip_freeze.splitlines(): - try: - req = Requirement.parse(pkg_ver) - except ValueError: - continue - versions.update({ - req.project_name: LooseVersion(ver) - for op, ver in req.specs if op == '==' - }) - return versions - - -def _load_wheelhouse_versions(): - versions = {} - for wheel in glob('wheelhouse/*'): - pkg, ver = os.path.basename(wheel).rsplit('-', 1) - # nb: LooseVersion ignores the file extension - versions[pkg.replace('_', '-')] = LooseVersion(ver) - return versions - - -def _update_if_newer(pip, pkgs): - installed = _load_installed_versions(pip) - wheelhouse = _load_wheelhouse_versions() - for pkg in pkgs: - if pkg not in installed or wheelhouse[pkg] > installed[pkg]: - check_call([pip, 'install', '-U', '--no-index', '-f', 'wheelhouse', - pkg], env=_get_subprocess_env()) - - -def install_or_update_charm_env(): - # On Trusty python3-pkg-resources is not installed - try: - from pkg_resources import parse_version - except ImportError: - apt_install(['python3-pkg-resources']) - from pkg_resources import parse_version - - try: - installed_version = parse_version( - check_output(['/usr/local/sbin/charm-env', - '--version']).decode('utf8')) - except (CalledProcessError, FileNotFoundError): - installed_version = parse_version('0.0.0') - try: - bundled_version = parse_version( - check_output(['bin/charm-env', - '--version']).decode('utf8')) - except (CalledProcessError, FileNotFoundError): - bundled_version = parse_version('0.0.0') - if installed_version < bundled_version: - shutil.copy2('bin/charm-env', '/usr/local/sbin/') - - -def activate_venv(): - """ - Activate the venv if enabled in ``layer.yaml``. - - This is handled automatically for normal hooks, but actions might - need to invoke this manually, using something like: - - # Load modules from $JUJU_CHARM_DIR/lib - import sys - sys.path.append('lib') - - from charms.layer.basic import activate_venv - activate_venv() - - This will ensure that modules installed in the charm's - virtual environment are available to the action. - """ - from charms.layer import options - venv = os.path.abspath('../.venv') - vbin = os.path.join(venv, 'bin') - vpy = os.path.join(vbin, 'python') - use_venv = options.get('basic', 'use_venv') - if use_venv and '.venv' not in sys.executable: - # activate the venv - os.environ['PATH'] = ':'.join([vbin, os.environ['PATH']]) - reload_interpreter(vpy) - layer.patch_options_interface() - layer.import_layer_libs() - - -def reload_interpreter(python): - """ - Reload the python interpreter to ensure that all deps are available. - - Newly installed modules in namespace packages sometimes seemt to - not be picked up by Python 3. - """ - os.execve(python, [python] + list(sys.argv), os.environ) - - -def apt_install(packages): - """ - Install apt packages. - - This ensures a consistent set of options that are often missed but - should really be set. - """ - if isinstance(packages, (str, bytes)): - packages = [packages] - - env = _get_subprocess_env() - - if 'DEBIAN_FRONTEND' not in env: - env['DEBIAN_FRONTEND'] = 'noninteractive' - - cmd = ['apt-get', - '--option=Dpkg::Options::=--force-confold', - '--assume-yes', - 'install'] - for attempt in range(3): - try: - check_call(cmd + packages, env=env) - except CalledProcessError: - if attempt == 2: # third attempt - raise - try: - # sometimes apt-get update needs to be run - check_call(['apt-get', 'update'], env=env) - except CalledProcessError: - # sometimes it's a dpkg lock issue - pass - sleep(5) - else: - break - - -def yum_install(packages): - """ Installs packages with yum. - This function largely mimics the apt_install function for consistency. - """ - if packages: - env = os.environ.copy() - cmd = ['yum', '-y', 'install'] - for attempt in range(3): - try: - check_call(cmd + packages, env=env) - except CalledProcessError: - if attempt == 2: - raise - try: - check_call(['yum', 'update'], env=env) - except CalledProcessError: - pass - sleep(5) - else: - break - else: - pass - - -def init_config_states(): - import yaml - from charmhelpers.core import hookenv - from charms.reactive import set_state - from charms.reactive import toggle_state - config = hookenv.config() - config_defaults = {} - config_defs = {} - config_yaml = os.path.join(hookenv.charm_dir(), 'config.yaml') - if os.path.exists(config_yaml): - with open(config_yaml) as fp: - config_defs = yaml.safe_load(fp).get('options', {}) - config_defaults = {key: value.get('default') - for key, value in config_defs.items()} - for opt in config_defs.keys(): - if config.changed(opt): - set_state('config.changed') - set_state('config.changed.{}'.format(opt)) - toggle_state('config.set.{}'.format(opt), config.get(opt)) - toggle_state('config.default.{}'.format(opt), - config.get(opt) == config_defaults[opt]) - - -def clear_config_states(): - from charmhelpers.core import hookenv, unitdata - from charms.reactive import remove_state - config = hookenv.config() - remove_state('config.changed') - for opt in config.keys(): - remove_state('config.changed.{}'.format(opt)) - remove_state('config.set.{}'.format(opt)) - remove_state('config.default.{}'.format(opt)) - unitdata.kv().flush() diff --git a/nscharm_policy_vnf/charms/vnf-policy/lib/charms/layer/execd.py b/nscharm_policy_vnf/charms/vnf-policy/lib/charms/layer/execd.py deleted file mode 100644 index 438d9a1bc90042fd8b20517d5ecf358dfbf08afc..0000000000000000000000000000000000000000 --- a/nscharm_policy_vnf/charms/vnf-policy/lib/charms/layer/execd.py +++ /dev/null @@ -1,114 +0,0 @@ -# Copyright 2014-2016 Canonical Limited. -# -# This file is part of layer-basic, the reactive base layer for Juju. -# -# charm-helpers is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 as -# published by the Free Software Foundation. -# -# charm-helpers is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with charm-helpers. If not, see . - -# This module may only import from the Python standard library. -import os -import sys -import subprocess -import time - -''' -execd/preinstall - -Read the layer-basic docs for more info on how to use this feature. -https://charmsreactive.readthedocs.io/en/latest/layer-basic.html#exec-d-support -''' - - -def default_execd_dir(): - return os.path.join(os.environ['JUJU_CHARM_DIR'], 'exec.d') - - -def execd_module_paths(execd_dir=None): - """Generate a list of full paths to modules within execd_dir.""" - if not execd_dir: - execd_dir = default_execd_dir() - - if not os.path.exists(execd_dir): - return - - for subpath in os.listdir(execd_dir): - module = os.path.join(execd_dir, subpath) - if os.path.isdir(module): - yield module - - -def execd_submodule_paths(command, execd_dir=None): - """Generate a list of full paths to the specified command within exec_dir. - """ - for module_path in execd_module_paths(execd_dir): - path = os.path.join(module_path, command) - if os.access(path, os.X_OK) and os.path.isfile(path): - yield path - - -def execd_sentinel_path(submodule_path): - module_path = os.path.dirname(submodule_path) - execd_path = os.path.dirname(module_path) - module_name = os.path.basename(module_path) - submodule_name = os.path.basename(submodule_path) - return os.path.join(execd_path, - '.{}_{}.done'.format(module_name, submodule_name)) - - -def execd_run(command, execd_dir=None, stop_on_error=True, stderr=None): - """Run command for each module within execd_dir which defines it.""" - if stderr is None: - stderr = sys.stdout - for submodule_path in execd_submodule_paths(command, execd_dir): - # Only run each execd once. We cannot simply run them in the - # install hook, as potentially storage hooks are run before that. - # We cannot rely on them being idempotent. - sentinel = execd_sentinel_path(submodule_path) - if os.path.exists(sentinel): - continue - - try: - subprocess.check_call([submodule_path], stderr=stderr, - universal_newlines=True) - with open(sentinel, 'w') as f: - f.write('{} ran successfully {}\n'.format(submodule_path, - time.ctime())) - f.write('Removing this file will cause it to be run again\n') - except subprocess.CalledProcessError as e: - # Logs get the details. We can't use juju-log, as the - # output may be substantial and exceed command line - # length limits. - print("ERROR ({}) running {}".format(e.returncode, e.cmd), - file=stderr) - print("STDOUT< 0: - raise CalledProcessError(returncode=retcode, - cmd=cmd, - output=stderr.decode("utf-8").strip()) - return (stdout.decode('utf-8').strip(), stderr.decode('utf-8').strip()) - - -def _run(cmd, env=None): - """Run a command remotely via SSH. - - Note: The previous behavior was to run the command locally if SSH wasn't - configured, but that can lead to cases where execution succeeds when you'd - expect it not to. - """ - if isinstance(cmd, str): - cmd = shlex.split(cmd) - - if type(cmd) is not list: - cmd = [cmd] - - cfg = get_config() - - if cfg: - if all(k in cfg for k in ['ssh-hostname', 'ssh-username', - 'ssh-password', 'ssh-private-key']): - host = get_host_ip() - user = cfg['ssh-username'] - passwd = cfg['ssh-password'] - key = cfg['ssh-private-key'] # DEPRECATED - - if host and user: - return ssh(cmd, host, user, passwd, key) - - raise Exception("Invalid SSH credentials.") - - -def get_ssh_client(host, user, password=None, key=None): - """Return a connected Paramiko ssh object.""" - client = paramiko.SSHClient() - client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) - - pkey = None - - # Check for the DEPRECATED private-key - if key: - f = io.StringIO(key) - pkey = paramiko.RSAKey.from_private_key(f) - else: - # Otherwise, check for the auto-generated private key - if os.path.exists('/root/.ssh/id_juju_sshproxy'): - with open('/root/.ssh/id_juju_sshproxy', 'r') as f: - pkey = paramiko.RSAKey.from_private_key(f) - - ########################################################################### - # There is a bug in some versions of OpenSSH 4.3 (CentOS/RHEL 5) where # - # the server may not send the SSH_MSG_USERAUTH_BANNER message except when # - # responding to an auth_none request. For example, paramiko will attempt # - # to use password authentication when a password is set, but the server # - # could deny that, instead requesting keyboard-interactive. The hack to # - # workaround this is to attempt a reconnect, which will receive the right # - # banner, and authentication can proceed. See the following for more info # - # https://github.com/paramiko/paramiko/issues/432 # - # https://github.com/paramiko/paramiko/pull/438 # - ########################################################################### - - try: - client.connect(host, port=22, username=user, - password=password, pkey=pkey) - except paramiko.ssh_exception.SSHException as e: - if 'Error reading SSH protocol banner' == str(e): - # Once more, with feeling - client.connect(host, port=22, username=user, - password=password, pkey=pkey) - else: - # Reraise the original exception - raise e - - return client - - -def sftp(local_file, remote_file, host, user, password=None, key=None): - """Copy a local file to a remote host.""" - client = get_ssh_client(host, user, password, key) - - # Create an sftp connection from the underlying transport - sftp = paramiko.SFTPClient.from_transport(client.get_transport()) - sftp.put(local_file, remote_file) - client.close() - - -def ssh(cmd, host, user, password=None, key=None): - """Run an arbitrary command over SSH.""" - client = get_ssh_client(host, user, password, key) - - cmds = ' '.join(cmd) - stdin, stdout, stderr = client.exec_command(cmds, get_pty=True) - retcode = stdout.channel.recv_exit_status() - client.close() # @TODO re-use connections - if retcode > 0: - output = stderr.read().strip() - raise CalledProcessError(returncode=retcode, cmd=cmd, - output=output) - return ( - stdout.read().decode('utf-8').strip(), - stderr.read().decode('utf-8').strip() - ) diff --git a/nscharm_policy_vnf/charms/vnf-policy/metadata.yaml b/nscharm_policy_vnf/charms/vnf-policy/metadata.yaml deleted file mode 100644 index d1394f7a7e6311997d908965c464ea70570b5434..0000000000000000000000000000000000000000 --- a/nscharm_policy_vnf/charms/vnf-policy/metadata.yaml +++ /dev/null @@ -1,16 +0,0 @@ -"name": "vnf-policy" -"summary": "" -"maintainer": "Adam Israel " -"description": | - -"tags": - # Replace "misc" with one or more whitelisted tags from this list: - # https://jujucharms.com/docs/stable/authors-charm-metadata -- "misc" -- "osm" -- "vnf" -"series": -- "xenial" -- "bionic" -- "trusty" -"subordinate": !!bool "false" diff --git a/nscharm_policy_vnf/charms/vnf-policy/reactive/__init__.py b/nscharm_policy_vnf/charms/vnf-policy/reactive/__init__.py deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/nscharm_policy_vnf/charms/vnf-policy/reactive/sshproxy.py b/nscharm_policy_vnf/charms/vnf-policy/reactive/sshproxy.py deleted file mode 100644 index 5ef0f56f09612a9a775a1bc3037685cc1f27755e..0000000000000000000000000000000000000000 --- a/nscharm_policy_vnf/charms/vnf-policy/reactive/sshproxy.py +++ /dev/null @@ -1,210 +0,0 @@ -## -# Copyright 2016 Canonical Ltd. -# All rights reserved. -# -# 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 charmhelpers.core import unitdata -from charmhelpers.core.hookenv import ( - action_fail, - action_get, - action_set, - config, - log, - status_set, - DEBUG, -) - -from charms.reactive.flags import register_trigger - -from charms.reactive import ( - clear_flag, - set_flag, - when, - when_not, - when_any, -) -import charms.sshproxy -import os -import subprocess - -# Register a trigger so that we can respond to config.changed, even if -# it's being cleared by another handler -register_trigger(when='config.changed', - set_flag='sshproxy.reconfigure') - - -# @when_any('config.changed', 'sshproxy.reconfigure') -@when_any('config.set.ssh-hostname', 'config.set.ssh-username', 'config.set.ssh-password', 'sshproxy.reconfigure') -def ssh_configured(): - """Check if charm is properly configured. - - Check to see if the charm is configured with SSH credentials. If so, - set a state flag that can be used to execute ssh-only actions. - - For example: - - @when('sshproxy.configured') - def run_remote_command(cmd): - ... - - @when_not('sshproxy.configured') - def run_local_command(cmd): - ... - """ - log("Checking sshproxy configuration", DEBUG) - cfg = config() - ssh_keys = ['ssh-hostname', 'ssh-username', - 'ssh-password', 'ssh-private-key'] - - if all(k in cfg for k in ssh_keys): - - # Store config in unitdata so it's accessible to sshproxy - db = unitdata.kv() - db.set('config', cfg) - - # Explicitly flush the kv so it's immediately available - db.flush() - - log("Verifying ssh credentials...", DEBUG) - (verified, output) = charms.sshproxy.verify_ssh_credentials() - if verified: - log("SSH credentials verified.", DEBUG) - set_flag('sshproxy.configured') - status_set('active', 'Ready!') - else: - clear_flag('sshproxy.configured') - status_set('blocked', "Remote machine not ready yet: {}".format(output)) - else: - log("No ssh credentials configured", DEBUG) - clear_flag('sshproxy.configured') - status_set('blocked', 'Invalid SSH credentials.') - - -def generate_ssh_key(): - """Generate a new 4096-bit rsa keypair. - - If there is an existing keypair for this unit, it will be overwritten. - """ - cfg = config() - if all(k in cfg for k in ['ssh-key-type', 'ssh-key-bits']): - keytype = cfg['ssh-key-type'] - bits = str(cfg['ssh-key-bits']) - privatekey = '/root/.ssh/id_juju_sshproxy' - publickey = "{}.pub".format(privatekey) - - if os.path.exists(privatekey): - os.remove(privatekey) - if os.path.exists(publickey): - os.remove(publickey) - - cmd = "ssh-keygen -t {} -b {} -N '' -f {}".format( - keytype, - bits, - privatekey - ) - - output, err = charms.sshproxy.run_local([cmd]) - if len(err) == 0: - return True - return False - - -@when('actions.generate-ssh-key') -def action_generate_ssh_key(): - """Generate a new 4096-bit rsa keypair. - - If there is an existing keypair for this unit, it will be overwritten. - """ - try: - if not generate_ssh_key(): - action_fail('Unable to generate ssh key.') - except subprocess.CalledProcessError as e: - action_fail('Command failed: %s (%s)' % - (' '.join(e.cmd), str(e.output))) - finally: - clear_flag('actions.generate-ssh-key') - - -def get_ssh_public_key(): - """Get the public SSH key of this unit.""" - publickey_path = '/root/.ssh/id_juju_sshproxy.pub' - publickey = None - if os.path.exists(publickey_path): - with open(publickey_path, 'r') as f: - publickey = f.read() - - return publickey - - -@when('actions.get-ssh-public-key') -def action_get_ssh_public_key(): - """Get the public SSH key of this unit.""" - try: - action_set({'pubkey': get_ssh_public_key()}) - except subprocess.CalledProcessError as e: - action_fail('Command failed: %s (%s)' % - (' '.join(e.cmd), str(e.output))) - finally: - clear_flag('actions.get-ssh-public-key') - - -@when('actions.verify-ssh-credentials') -def action_verify_ssh_credentials(): - """Verify the ssh credentials have been installed to the VNF. - - Attempts to run a stock command - `hostname` on the remote host. - """ - try: - (verified, output) = charms.sshproxy.verify_ssh_credentials() - action_set({ - 'output': output, - 'verified': verified, - }) - if not verified: - action_fail("Verification failed: {}".format( - output, - )) - finally: - clear_flag('actions.verify-ssh-credentials') - - -@when('actions.run') -def run_command(): - """Run an arbitrary command. - - Run an arbitrary command, either locally or over SSH with the configured - credentials. - """ - try: - cmd = action_get('command') - output, err = charms.sshproxy._run(cmd) - if len(err): - action_fail("Command '{}' returned error code {}".format(cmd, err)) - else: - action_set({'output': output}) - except subprocess.CalledProcessError as e: - action_fail('Command failed: %s (%s)' % - (' '.join(e.cmd), str(e.output))) - finally: - clear_flag('actions.run') - - -@when_not('sshproxy.installed') -def install_vnf_ubuntu_proxy(): - """Install and Configure SSH Proxy.""" - - log("Generating SSH key...", DEBUG) - generate_ssh_key() - set_flag('sshproxy.installed') diff --git a/nscharm_policy_vnf/charms/vnf-policy/reactive/vnfproxy.py b/nscharm_policy_vnf/charms/vnf-policy/reactive/vnfproxy.py deleted file mode 100644 index 6616991df245a920116b9301b52602f15ba7a9bc..0000000000000000000000000000000000000000 --- a/nscharm_policy_vnf/charms/vnf-policy/reactive/vnfproxy.py +++ /dev/null @@ -1,89 +0,0 @@ -from charmhelpers.core.hookenv import ( - action_fail, - action_set, -) - -from charms.reactive import ( - when, - clear_flag, -) -import charms.sshproxy - - -@when('actions.reboot') -def reboot(): - err = '' - try: - result, err = charms.sshproxy._run("reboot") - except: - action_fail('command failed:' + err) - else: - action_set({'outout': result}) - finally: - clear_flag('actions.reboot') - - -############################################################################### -# Below is an example implementation of the start/stop/restart actions. # -# To use this, copy the below code into your layer and add the appropriate # -# command(s) necessary to perform the action. # -############################################################################### - -# @when('actions.start') -# def start(): -# err = '' -# try: -# cmd = "service myname start" -# result, err = charms.sshproxy._run(cmd) -# except: -# action_fail('command failed:' + err) -# else: -# action_set({'outout': result}) -# finally: -# clear_flag('actions.start') -# -# -# @when('actions.stop') -# def stop(): -# err = '' -# try: -# # Enter the command to stop your service(s) -# cmd = "service myname stop" -# result, err = charms.sshproxy._run(cmd) -# except: -# action_fail('command failed:' + err) -# else: -# action_set({'outout': result}) -# finally: -# clear_flag('actions.stop') -# -# -# @when('actions.restart') -# def restart(): -# err = '' -# try: -# # Enter the command to restart your service(s) -# cmd = "service myname restart" -# result, err = charms.sshproxy._run(cmd) -# except: -# action_fail('command failed:' + err) -# else: -# action_set({'outout': result}) -# finally: -# clear_flag('actions.restart') -# -# -# @when('actions.upgrade') -# def upgrade_vnf(): -# err = '' -# try: -# # Add the command(s) to perform a VNF software upgrade -# cmd = '' -# result, err = charms.sshproxy._run(cmd) -# except: -# action_fail('command failed:' + err) -# else: -# action_set({'outout': result}) -# finally: -# clear_flag('actions.upgrade') -# diff --git a/nscharm_policy_vnf/charms/vnf-policy/requirements.txt b/nscharm_policy_vnf/charms/vnf-policy/requirements.txt deleted file mode 100644 index 55543d9b632ff05cf7e6ee20dfec3160d2c554c2..0000000000000000000000000000000000000000 --- a/nscharm_policy_vnf/charms/vnf-policy/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -mock -flake8 -pytest diff --git a/nscharm_policy_vnf/charms/vnf-policy/version b/nscharm_policy_vnf/charms/vnf-policy/version deleted file mode 100644 index e412f8aaf4e137b95d10d1d6949d77de2922bcce..0000000000000000000000000000000000000000 --- a/nscharm_policy_vnf/charms/vnf-policy/version +++ /dev/null @@ -1 +0,0 @@ -83c13bd \ No newline at end of file diff --git a/nscharm_policy_vnf/charms/vnf-policy/wheelhouse.txt b/nscharm_policy_vnf/charms/vnf-policy/wheelhouse.txt deleted file mode 100644 index 1648a3618d1b0be88145a30665deecb2afd805ee..0000000000000000000000000000000000000000 --- a/nscharm_policy_vnf/charms/vnf-policy/wheelhouse.txt +++ /dev/null @@ -1,36 +0,0 @@ -# layer:basic -# pip is pinned to <19.0 to avoid https://github.com/pypa/pip/issues/6164 -# even with installing setuptools before upgrading pip ends up with pip seeing -# the older setuptools at the system level if include_system_packages is true -pip>=18.1,<19.0 -# pin Jinja2 and PyYAML to the last versions supporting python 3.4 for trusty -Jinja2<=2.10.1 -PyYAML<=5.2 -setuptools<42 -setuptools-scm<=1.17.0 -charmhelpers>=0.4.0,<1.0.0 -charms.reactive>=0.1.0,<2.0.0 -wheel<0.34 -# pin netaddr to avoid pulling importlib-resources -netaddr<=0.7.19 - -# layer:sshproxy -## -# Copyright 2016 Canonical Ltd. -# All rights reserved. -# -# 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. -## - -paramiko>=1.16.0,<1.17 - diff --git a/nscharm_policy_vnf/charms/vnf-policy/wheelhouse/setuptools-41.6.0.zip b/nscharm_policy_vnf/charms/vnf-policy/wheelhouse/setuptools-41.6.0.zip deleted file mode 100644 index 3345759c1ca861c181742e84fc5285e3284a2886..0000000000000000000000000000000000000000 Binary files a/nscharm_policy_vnf/charms/vnf-policy/wheelhouse/setuptools-41.6.0.zip and /dev/null differ diff --git a/nscharm_user_vnf/charms/vnf-user/README.md b/nscharm_user_vnf/charms/layers/vnf-user/README.md similarity index 100% rename from nscharm_user_vnf/charms/vnf-user/README.md rename to nscharm_user_vnf/charms/layers/vnf-user/README.md diff --git a/nscharm_user_vnf/charms/layers/vnf-user/actions.yaml b/nscharm_user_vnf/charms/layers/vnf-user/actions.yaml new file mode 100644 index 0000000000000000000000000000000000000000..1bd4c757facd6179cbd818ce2503ed7939d772e4 --- /dev/null +++ b/nscharm_user_vnf/charms/layers/vnf-user/actions.yaml @@ -0,0 +1,13 @@ +add-user: + description: "Add a new username to the database" + params: + username: + description: "The username to add" + type: string + default: "" + tariff: + description: "" + type: integer + default: 0 + required: + - username diff --git a/nscharm_user_vnf/charms/vnf-user/actions/add-user b/nscharm_user_vnf/charms/layers/vnf-user/actions/add-user similarity index 100% rename from nscharm_user_vnf/charms/vnf-user/actions/add-user rename to nscharm_user_vnf/charms/layers/vnf-user/actions/add-user diff --git a/nscharm_user_vnf/charms/vnf-user/icon.svg b/nscharm_user_vnf/charms/layers/vnf-user/icon.svg similarity index 100% rename from nscharm_user_vnf/charms/vnf-user/icon.svg rename to nscharm_user_vnf/charms/layers/vnf-user/icon.svg diff --git a/nscharm_user_vnf/charms/layers/vnf-user/layer.yaml b/nscharm_user_vnf/charms/layers/vnf-user/layer.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ba9c189068dd2cb000b68780692067d6467697ee --- /dev/null +++ b/nscharm_user_vnf/charms/layers/vnf-user/layer.yaml @@ -0,0 +1,8 @@ +includes: + - 'layer:basic' + - 'layer:vnfproxy' + - 'layer:sshproxy' +options: + basic: + use_venv: false + diff --git a/nscharm_user_vnf/charms/layers/vnf-user/metadata.yaml b/nscharm_user_vnf/charms/layers/vnf-user/metadata.yaml new file mode 100644 index 0000000000000000000000000000000000000000..7afdca211279614cbcdcf63d5e6830b039841266 --- /dev/null +++ b/nscharm_user_vnf/charms/layers/vnf-user/metadata.yaml @@ -0,0 +1,11 @@ +name: vnf-user +summary: +maintainer: Adam Israel +description: | + +tags: + - misc +series: + - xenial + - bionic +subordinate: false diff --git a/nscharm_user_vnf/charms/vnf-user/reactive/vnf_user.py b/nscharm_user_vnf/charms/layers/vnf-user/reactive/vnf_user.py similarity index 100% rename from nscharm_user_vnf/charms/vnf-user/reactive/vnf_user.py rename to nscharm_user_vnf/charms/layers/vnf-user/reactive/vnf_user.py diff --git a/nscharm_user_vnf/charms/vnf-user/tests/00-setup b/nscharm_user_vnf/charms/layers/vnf-user/tests/00-setup similarity index 100% rename from nscharm_user_vnf/charms/vnf-user/tests/00-setup rename to nscharm_user_vnf/charms/layers/vnf-user/tests/00-setup diff --git a/nscharm_user_vnf/charms/vnf-user/tests/10-deploy b/nscharm_user_vnf/charms/layers/vnf-user/tests/10-deploy similarity index 100% rename from nscharm_user_vnf/charms/vnf-user/tests/10-deploy rename to nscharm_user_vnf/charms/layers/vnf-user/tests/10-deploy diff --git a/nscharm_user_vnf/charms/vnf-user/.build.manifest b/nscharm_user_vnf/charms/vnf-user/.build.manifest deleted file mode 100644 index 708c096871b812d6cb34d9487f6c6190d87f66e9..0000000000000000000000000000000000000000 --- a/nscharm_user_vnf/charms/vnf-user/.build.manifest +++ /dev/null @@ -1,366 +0,0 @@ -{ - "layers": [ - { - "rev": "fcdcea4e5de3e1556c24e6704607862d0ba00a56", - "url": "layer:options" - }, - { - "rev": "623e69c7b432456fd4364f6e1835424fd6b5425e", - "url": "layer:basic" - }, - { - "rev": "009e8631e4d173a71ac53032bbad465a89c6c365", - "url": "layer:sshproxy" - }, - { - "rev": "e6a495fab012f06484ed419fd5c2453e6a92eef1", - "url": "layer:vnfproxy" - }, - { - "rev": "8c2332f258eebb94a1d74939d82919d7db6acf6f", - "url": "vnf-user" - } - ], - "signatures": { - ".build.manifest": [ - "build", - "dynamic", - "unchecked" - ], - ".gitignore": [ - "layer:sshproxy", - "static", - "17526a7f7312e7eefb932d1c514b7bc8425fab5bd1ade149e106ecf8bff67358" - ], - ".travis/profile-update.yaml": [ - "layer:basic", - "static", - "731e20aa59bf61c024d317ad630e478301a9386ccc0afe56e6c1c09db07ac83b" - ], - "LICENSE": [ - "layer:basic", - "static", - "cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30" - ], - "Makefile": [ - "layer:basic", - "static", - "b7ab3a34e5faf79b96a8632039a0ad0aa87f2a9b5f0ba604e007cafb22190301" - ], - "README.md": [ - "vnf-user", - "static", - "977a02e0bce81227970cca431a9abbf2df0c0eb7c1f8f39df522c01df5a8db7f" - ], - "actions.yaml": [ - "vnf-user", - "dynamic", - "0f81fbe14426ea342af768ad92d07db438db91a5b8714963e221892571815d37" - ], - "actions/add-user": [ - "vnf-user", - "static", - "46bf4be02078a0f5ac60ab81609372a8f9943885b7a4999ce5332ea2f4857036" - ], - "actions/generate-ssh-key": [ - "layer:sshproxy", - "static", - "46bf4be02078a0f5ac60ab81609372a8f9943885b7a4999ce5332ea2f4857036" - ], - "actions/get-ssh-public-key": [ - "layer:sshproxy", - "static", - "46bf4be02078a0f5ac60ab81609372a8f9943885b7a4999ce5332ea2f4857036" - ], - "actions/reboot": [ - "layer:vnfproxy", - "static", - "afc0df4409fb6eb7b7e6595490913c1efe329b393d4860ae226d8aaccc01fcf2" - ], - "actions/restart": [ - "layer:vnfproxy", - "static", - "afc0df4409fb6eb7b7e6595490913c1efe329b393d4860ae226d8aaccc01fcf2" - ], - "actions/run": [ - "layer:sshproxy", - "static", - "46bf4be02078a0f5ac60ab81609372a8f9943885b7a4999ce5332ea2f4857036" - ], - "actions/start": [ - "layer:vnfproxy", - "static", - "afc0df4409fb6eb7b7e6595490913c1efe329b393d4860ae226d8aaccc01fcf2" - ], - "actions/stop": [ - "layer:vnfproxy", - "static", - "afc0df4409fb6eb7b7e6595490913c1efe329b393d4860ae226d8aaccc01fcf2" - ], - "actions/upgrade": [ - "layer:vnfproxy", - "static", - "afc0df4409fb6eb7b7e6595490913c1efe329b393d4860ae226d8aaccc01fcf2" - ], - "actions/verify-ssh-credentials": [ - "layer:sshproxy", - "static", - "46bf4be02078a0f5ac60ab81609372a8f9943885b7a4999ce5332ea2f4857036" - ], - "bin/charm-env": [ - "layer:basic", - "static", - "fb6a20fac4102a6a4b6ffe903fcf666998f9a95a3647e6f9af7a1eeb44e58fd5" - ], - "bin/layer_option": [ - "layer:options", - "static", - "e959bf29da4c5edff28b2602c24113c4df9e25cdc9f2aa3b5d46c8577b2a40cc" - ], - "config.yaml": [ - "layer:vnfproxy", - "dynamic", - "c5bd79d6699ffdf49cc71ab18a6e8f0e7b0ca71fae2f1416a2138154fe6c1a34" - ], - "copyright": [ - "layer:basic", - "static", - "f6740d66fd60b60f2533d9fcb53907078d1e20920a0219afce7182e2a1c97629" - ], - "copyright.layer-options": [ - "layer:options", - "static", - "f6740d66fd60b60f2533d9fcb53907078d1e20920a0219afce7182e2a1c97629" - ], - "hooks/collect-metrics": [ - "layer:vnfproxy", - "static", - "f2a6360cf21993f7dc07785ad702f141679a5a9b03c3db5d50dd06ffbe26bbb2" - ], - "hooks/config-changed": [ - "layer:basic", - "dynamic", - "2b693cb2a11594a80cc91235c2dc219a0a6303ae62bee8aa87eb35781f7158f7" - ], - "hooks/hook.template": [ - "layer:basic", - "static", - "2b693cb2a11594a80cc91235c2dc219a0a6303ae62bee8aa87eb35781f7158f7" - ], - "hooks/install": [ - "layer:basic", - "dynamic", - "2b693cb2a11594a80cc91235c2dc219a0a6303ae62bee8aa87eb35781f7158f7" - ], - "hooks/leader-elected": [ - "layer:basic", - "dynamic", - "2b693cb2a11594a80cc91235c2dc219a0a6303ae62bee8aa87eb35781f7158f7" - ], - "hooks/leader-settings-changed": [ - "layer:basic", - "dynamic", - "2b693cb2a11594a80cc91235c2dc219a0a6303ae62bee8aa87eb35781f7158f7" - ], - "hooks/post-series-upgrade": [ - "layer:basic", - "dynamic", - "2b693cb2a11594a80cc91235c2dc219a0a6303ae62bee8aa87eb35781f7158f7" - ], - "hooks/pre-series-upgrade": [ - "layer:basic", - "dynamic", - "2b693cb2a11594a80cc91235c2dc219a0a6303ae62bee8aa87eb35781f7158f7" - ], - "hooks/start": [ - "layer:basic", - "dynamic", - "2b693cb2a11594a80cc91235c2dc219a0a6303ae62bee8aa87eb35781f7158f7" - ], - "hooks/stop": [ - "layer:basic", - "dynamic", - "2b693cb2a11594a80cc91235c2dc219a0a6303ae62bee8aa87eb35781f7158f7" - ], - "hooks/update-status": [ - "layer:basic", - "dynamic", - "2b693cb2a11594a80cc91235c2dc219a0a6303ae62bee8aa87eb35781f7158f7" - ], - "hooks/upgrade-charm": [ - "layer:basic", - "dynamic", - "2b693cb2a11594a80cc91235c2dc219a0a6303ae62bee8aa87eb35781f7158f7" - ], - "icon.svg": [ - "vnf-user", - "static", - "d20624e9389af6506a8d8a69ac9bba4d41709601b624c0875fd7d6717b395088" - ], - "layer.yaml": [ - "vnf-user", - "dynamic", - "05c0095f9c08579d4ad3d8a4c600fc296036eaa1b708998bbadb2f02449c5354" - ], - "lib/charms/layer/__init__.py": [ - "layer:basic", - "static", - "dfe0d26c6bf409767de6e2546bc648f150e1b396243619bad3aa0553ab7e0e6f" - ], - "lib/charms/layer/basic.py": [ - "layer:basic", - "static", - "3126b5754ad39402ee27e64527044ddd231ed1cd137fcedaffb51e63a635f108" - ], - "lib/charms/layer/execd.py": [ - "layer:basic", - "static", - "fda8bd491032db1db8ddaf4e99e7cc878c6fb5432efe1f91cadb5b34765d076d" - ], - "lib/charms/layer/options.py": [ - "layer:options", - "static", - "8ae7a07d22542fc964f2d2bee8219d1c78a68dace70a1b38d36d4aea47b1c3b2" - ], - "lib/charms/sshproxy.py": [ - "layer:sshproxy", - "static", - "fba0834f98f570b0b3d6b3e8a7f17b1d8909f50da9410ccda89b586f914b7ffd" - ], - "metadata.yaml": [ - "vnf-user", - "dynamic", - "230c0ac0564769b19ac10111235b95a2706737645bb4cd32cab9e052d9351afe" - ], - "reactive/__init__.py": [ - "layer:basic", - "static", - "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" - ], - "reactive/sshproxy.py": [ - "layer:sshproxy", - "static", - "acfaedf414946f8d218e5ebd04177f87258286915ba83b9c42ff7385975da6ab" - ], - "reactive/vnf_user.py": [ - "vnf-user", - "static", - "329c4fe24344bea55151fb8f840caeddce87fc1d97cb61b4f47cbd0690d99f05" - ], - "reactive/vnfproxy.py": [ - "layer:vnfproxy", - "static", - "8e4101a72f02832e5c233b731981ff483675be608321b8eb9743d605b3f7d77a" - ], - "requirements.txt": [ - "layer:basic", - "static", - "a00f75d80849e5b4fc5ad2e7536f947c25b1a4044b341caa8ee87a92d3a4c804" - ], - "tests/00-setup": [ - "vnf-user", - "static", - "111c079b81d260bbcd716dcf41672372a4cf4aaa14154b6c3055deeedae37a06" - ], - "tests/10-deploy": [ - "vnf-user", - "static", - "839d6a11ddd13334be05f37874bff464b7345aff7bff5fed2dcb7ad7eaaa9a05" - ], - "version": [ - "vnf-user", - "dynamic", - "02b6a61e71b793429e0391c6170475f2d35a07035a1f9db392271e8c44e76dd2" - ], - "wheelhouse.txt": [ - "layer:sshproxy", - "dynamic", - "6ad4334a685c25c67bf07a9271a6d62afb85e3642fb5bc16e71852fba412ef8e" - ], - "wheelhouse/Jinja2-2.10.1.tar.gz": [ - "layer:basic", - "dynamic", - "065c4f02ebe7f7cf559e49ee5a95fb800a9e4528727aec6f24402a5374c65013" - ], - "wheelhouse/MarkupSafe-1.1.1.tar.gz": [ - "__pip__", - "dynamic", - "29872e92839765e546828bb7754a68c418d927cd064fd4708fab9fe9c8bb116b" - ], - "wheelhouse/PyYAML-5.2.tar.gz": [ - "layer:basic", - "dynamic", - "c0ee8eca2c582d29c3c2ec6e2c4f703d1b7f1fb10bc72317355a746057e7346c" - ], - "wheelhouse/Tempita-0.5.2.tar.gz": [ - "__pip__", - "dynamic", - "cacecf0baa674d356641f1d406b8bff1d756d739c46b869a54de515d08e6fc9c" - ], - "wheelhouse/charmhelpers-0.20.19.tar.gz": [ - "layer:basic", - "dynamic", - "74b2d95ec305e5799f0f7d068b0c6e010612ec877feadf32fc51e6bed1f68234" - ], - "wheelhouse/charms.reactive-1.3.2.tar.gz": [ - "layer:basic", - "dynamic", - "f4633eb37143bf9cc2c0e760a67314954c31fa68ec36d5399d386839cb5d54d5" - ], - "wheelhouse/ecdsa-0.16.1.tar.gz": [ - "__pip__", - "dynamic", - "cfc046a2ddd425adbd1a78b3c46f0d1325c657811c0f45ecc3a0a6236c1e50ff" - ], - "wheelhouse/netaddr-0.7.19.tar.gz": [ - "layer:basic", - "dynamic", - "38aeec7cdd035081d3a4c306394b19d677623bf76fa0913f6695127c7753aefd" - ], - "wheelhouse/paramiko-1.16.3.tar.gz": [ - "layer:sshproxy", - "dynamic", - "97d932fdb4fec9aadf6bea368123f3ee15b92199f92eb62666370c7fed62d072" - ], - "wheelhouse/pbr-5.5.1.tar.gz": [ - "__pip__", - "dynamic", - "5fad80b613c402d5b7df7bd84812548b2a61e9977387a80a5fc5c396492b13c9" - ], - "wheelhouse/pip-18.1.tar.gz": [ - "layer:basic", - "dynamic", - "c0a292bd977ef590379a3f05d7b7f65135487b67470f6281289a94e015650ea1" - ], - "wheelhouse/pyaml-20.4.0.tar.gz": [ - "__pip__", - "dynamic", - "29a5c2a68660a799103d6949167bd6c7953d031449d08802386372de1db6ad71" - ], - "wheelhouse/pycrypto-2.6.1.tar.gz": [ - "__pip__", - "dynamic", - "f2ce1e989b272cfcb677616763e0a2e7ec659effa67a88aa92b3a65528f60a3c" - ], - "wheelhouse/setuptools-41.6.0.zip": [ - "layer:basic", - "dynamic", - "6afa61b391dcd16cb8890ec9f66cc4015a8a31a6e1c2b4e0c464514be1a3d722" - ], - "wheelhouse/setuptools_scm-1.17.0.tar.gz": [ - "layer:basic", - "dynamic", - "70a4cf5584e966ae92f54a764e6437af992ba42ac4bca7eb37cc5d02b98ec40a" - ], - "wheelhouse/six-1.15.0.tar.gz": [ - "__pip__", - "dynamic", - "30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259" - ], - "wheelhouse/wheel-0.33.6.tar.gz": [ - "layer:basic", - "dynamic", - "10c9da68765315ed98850f8e048347c3eb06dd81822dc2ab1d4fde9dc9702646" - ] - } -} \ No newline at end of file diff --git a/nscharm_user_vnf/charms/vnf-user/.gitignore b/nscharm_user_vnf/charms/vnf-user/.gitignore deleted file mode 100644 index b8e7ba3a229bda75224369127d7454019fea641f..0000000000000000000000000000000000000000 --- a/nscharm_user_vnf/charms/vnf-user/.gitignore +++ /dev/null @@ -1 +0,0 @@ -trusty/ diff --git a/nscharm_user_vnf/charms/vnf-user/.travis/profile-update.yaml b/nscharm_user_vnf/charms/vnf-user/.travis/profile-update.yaml deleted file mode 100644 index 57f96eb6f9fa6f13158e59df78f2a9cab4c51949..0000000000000000000000000000000000000000 --- a/nscharm_user_vnf/charms/vnf-user/.travis/profile-update.yaml +++ /dev/null @@ -1,12 +0,0 @@ -config: {} -description: Default LXD profile - updated -devices: - eth0: - name: eth0 - parent: lxdbr0 - nictype: bridged - type: nic - root: - path: / - pool: default - type: disk diff --git a/nscharm_user_vnf/charms/vnf-user/LICENSE b/nscharm_user_vnf/charms/vnf-user/LICENSE deleted file mode 100644 index d645695673349e3947e8e5ae42332d0ac3164cd7..0000000000000000000000000000000000000000 --- a/nscharm_user_vnf/charms/vnf-user/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/nscharm_user_vnf/charms/vnf-user/Makefile b/nscharm_user_vnf/charms/vnf-user/Makefile deleted file mode 100644 index a1ad3a5cd27751144f6bd1a0a7db50f1e11b18eb..0000000000000000000000000000000000000000 --- a/nscharm_user_vnf/charms/vnf-user/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/make - -all: lint unit_test - - -.PHONY: clean -clean: - @rm -rf .tox - -.PHONY: apt_prereqs -apt_prereqs: - @# Need tox, but don't install the apt version unless we have to (don't want to conflict with pip) - @which tox >/dev/null || (sudo apt-get install -y python-pip && sudo pip install tox) - -.PHONY: lint -lint: apt_prereqs - @tox --notest - @PATH=.tox/py34/bin:.tox/py35/bin flake8 $(wildcard hooks reactive lib unit_tests tests) - @charm proof - -.PHONY: unit_test -unit_test: apt_prereqs - @echo Starting tests... - tox diff --git a/nscharm_user_vnf/charms/vnf-user/actions.yaml b/nscharm_user_vnf/charms/vnf-user/actions.yaml deleted file mode 100644 index c6cdca61448e6173761254dac7b3427bd3bf18a9..0000000000000000000000000000000000000000 --- a/nscharm_user_vnf/charms/vnf-user/actions.yaml +++ /dev/null @@ -1,57 +0,0 @@ -## -# Copyright 2016 Canonical Ltd. -# All rights reserved. -# -# 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. -## - -"run": - "description": "Run an arbitrary command" - "params": - "command": - "description": "The command to execute." - "type": "string" - "default": "" - "required": - - "command" -"generate-ssh-key": - "description": "Generate a new SSH keypair for this unit. This will replace any\ - \ existing previously generated keypair." -"verify-ssh-credentials": - "description": "Verify that this unit can authenticate with server specified by\ - \ ssh-hostname and ssh-username." -"get-ssh-public-key": - "description": "Get the public SSH key for this unit." -"start": - "description": "Stop the service on the VNF." -"stop": - "description": "Stop the service on the VNF." -"restart": - "description": "Stop the service on the VNF." -"reboot": - "description": "Reboot the VNF virtual machine." -"upgrade": - "description": "Upgrade the software on the VNF." -"add-user": - "description": "Add a new username to the database" - "params": - "username": - "description": "The username to add" - "type": "string" - "default": "" - "tariff": - "description": "" - "type": "integer" - "default": !!int "0" - "required": - - "username" diff --git a/nscharm_user_vnf/charms/vnf-user/actions/generate-ssh-key b/nscharm_user_vnf/charms/vnf-user/actions/generate-ssh-key deleted file mode 100755 index 7e30af4cfa084120a9343bf71c421b69ec3f2967..0000000000000000000000000000000000000000 --- a/nscharm_user_vnf/charms/vnf-user/actions/generate-ssh-key +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env python3 -## -# Copyright 2016 Canonical Ltd. -# All rights reserved. -# -# 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 sys -sys.path.append('lib') - -from charms.reactive import main, set_flag -from charmhelpers.core.hookenv import action_fail, action_name - -""" -`set_state` only works here because it's flushed to disk inside the `main()` -loop. remove_state will need to be called inside the action method. -""" -set_flag('actions.{}'.format(action_name())) - -try: - main() -except Exception as e: - action_fail(repr(e)) diff --git a/nscharm_user_vnf/charms/vnf-user/actions/get-ssh-public-key b/nscharm_user_vnf/charms/vnf-user/actions/get-ssh-public-key deleted file mode 100755 index 7e30af4cfa084120a9343bf71c421b69ec3f2967..0000000000000000000000000000000000000000 --- a/nscharm_user_vnf/charms/vnf-user/actions/get-ssh-public-key +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env python3 -## -# Copyright 2016 Canonical Ltd. -# All rights reserved. -# -# 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 sys -sys.path.append('lib') - -from charms.reactive import main, set_flag -from charmhelpers.core.hookenv import action_fail, action_name - -""" -`set_state` only works here because it's flushed to disk inside the `main()` -loop. remove_state will need to be called inside the action method. -""" -set_flag('actions.{}'.format(action_name())) - -try: - main() -except Exception as e: - action_fail(repr(e)) diff --git a/nscharm_user_vnf/charms/vnf-user/actions/reboot b/nscharm_user_vnf/charms/vnf-user/actions/reboot deleted file mode 100755 index 9a2ba24b9efdfa3d21457469c503c050196fb170..0000000000000000000000000000000000000000 --- a/nscharm_user_vnf/charms/vnf-user/actions/reboot +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env python3 -import sys -sys.path.append('lib') -from charms.reactive import main, set_flag -from charmhelpers.core.hookenv import action_fail, action_name - -set_flag('actions.{}'.format(action_name())) - -try: - main() -except Exception as e: - action_fail(repr(e)) diff --git a/nscharm_user_vnf/charms/vnf-user/actions/restart b/nscharm_user_vnf/charms/vnf-user/actions/restart deleted file mode 100755 index 9a2ba24b9efdfa3d21457469c503c050196fb170..0000000000000000000000000000000000000000 --- a/nscharm_user_vnf/charms/vnf-user/actions/restart +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env python3 -import sys -sys.path.append('lib') -from charms.reactive import main, set_flag -from charmhelpers.core.hookenv import action_fail, action_name - -set_flag('actions.{}'.format(action_name())) - -try: - main() -except Exception as e: - action_fail(repr(e)) diff --git a/nscharm_user_vnf/charms/vnf-user/actions/run b/nscharm_user_vnf/charms/vnf-user/actions/run deleted file mode 100755 index 7e30af4cfa084120a9343bf71c421b69ec3f2967..0000000000000000000000000000000000000000 --- a/nscharm_user_vnf/charms/vnf-user/actions/run +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env python3 -## -# Copyright 2016 Canonical Ltd. -# All rights reserved. -# -# 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 sys -sys.path.append('lib') - -from charms.reactive import main, set_flag -from charmhelpers.core.hookenv import action_fail, action_name - -""" -`set_state` only works here because it's flushed to disk inside the `main()` -loop. remove_state will need to be called inside the action method. -""" -set_flag('actions.{}'.format(action_name())) - -try: - main() -except Exception as e: - action_fail(repr(e)) diff --git a/nscharm_user_vnf/charms/vnf-user/actions/start b/nscharm_user_vnf/charms/vnf-user/actions/start deleted file mode 100755 index 9a2ba24b9efdfa3d21457469c503c050196fb170..0000000000000000000000000000000000000000 --- a/nscharm_user_vnf/charms/vnf-user/actions/start +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env python3 -import sys -sys.path.append('lib') -from charms.reactive import main, set_flag -from charmhelpers.core.hookenv import action_fail, action_name - -set_flag('actions.{}'.format(action_name())) - -try: - main() -except Exception as e: - action_fail(repr(e)) diff --git a/nscharm_user_vnf/charms/vnf-user/actions/stop b/nscharm_user_vnf/charms/vnf-user/actions/stop deleted file mode 100755 index 9a2ba24b9efdfa3d21457469c503c050196fb170..0000000000000000000000000000000000000000 --- a/nscharm_user_vnf/charms/vnf-user/actions/stop +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env python3 -import sys -sys.path.append('lib') -from charms.reactive import main, set_flag -from charmhelpers.core.hookenv import action_fail, action_name - -set_flag('actions.{}'.format(action_name())) - -try: - main() -except Exception as e: - action_fail(repr(e)) diff --git a/nscharm_user_vnf/charms/vnf-user/actions/upgrade b/nscharm_user_vnf/charms/vnf-user/actions/upgrade deleted file mode 100755 index 9a2ba24b9efdfa3d21457469c503c050196fb170..0000000000000000000000000000000000000000 --- a/nscharm_user_vnf/charms/vnf-user/actions/upgrade +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env python3 -import sys -sys.path.append('lib') -from charms.reactive import main, set_flag -from charmhelpers.core.hookenv import action_fail, action_name - -set_flag('actions.{}'.format(action_name())) - -try: - main() -except Exception as e: - action_fail(repr(e)) diff --git a/nscharm_user_vnf/charms/vnf-user/actions/verify-ssh-credentials b/nscharm_user_vnf/charms/vnf-user/actions/verify-ssh-credentials deleted file mode 100755 index 7e30af4cfa084120a9343bf71c421b69ec3f2967..0000000000000000000000000000000000000000 --- a/nscharm_user_vnf/charms/vnf-user/actions/verify-ssh-credentials +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env python3 -## -# Copyright 2016 Canonical Ltd. -# All rights reserved. -# -# 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 sys -sys.path.append('lib') - -from charms.reactive import main, set_flag -from charmhelpers.core.hookenv import action_fail, action_name - -""" -`set_state` only works here because it's flushed to disk inside the `main()` -loop. remove_state will need to be called inside the action method. -""" -set_flag('actions.{}'.format(action_name())) - -try: - main() -except Exception as e: - action_fail(repr(e)) diff --git a/nscharm_user_vnf/charms/vnf-user/bin/charm-env b/nscharm_user_vnf/charms/vnf-user/bin/charm-env deleted file mode 100755 index d211ce9b2912dd072aa7e1ce0399783fd075efc4..0000000000000000000000000000000000000000 --- a/nscharm_user_vnf/charms/vnf-user/bin/charm-env +++ /dev/null @@ -1,107 +0,0 @@ -#!/bin/bash - -VERSION="1.0.0" - - -find_charm_dirs() { - # Hopefully, $JUJU_CHARM_DIR is set so which venv to use in unambiguous. - if [[ -n "$JUJU_CHARM_DIR" || -n "$CHARM_DIR" ]]; then - if [[ -z "$JUJU_CHARM_DIR" ]]; then - # accept $CHARM_DIR to be more forgiving - export JUJU_CHARM_DIR="$CHARM_DIR" - fi - if [[ -z "$CHARM_DIR" ]]; then - # set CHARM_DIR as well to help with backwards compatibility - export CHARM_DIR="$JUJU_CHARM_DIR" - fi - return - fi - # Try to guess the value for JUJU_CHARM_DIR by looking for a non-subordinate - # (because there's got to be at least one principle) charm directory; - # if there are several, pick the first by alpha order. - agents_dir="/var/lib/juju/agents" - if [[ -d "$agents_dir" ]]; then - desired_charm="$1" - found_charm_dir="" - if [[ -n "$desired_charm" ]]; then - for charm_dir in $(/bin/ls -d "$agents_dir"/unit-*/charm); do - charm_name="$(grep -o '^['\''"]\?name['\''"]\?:.*' $charm_dir/metadata.yaml 2> /dev/null | sed -e 's/.*: *//' -e 's/['\''"]//g')" - if [[ "$charm_name" == "$desired_charm" ]]; then - if [[ -n "$found_charm_dir" ]]; then - >&2 echo "Ambiguous possibilities for JUJU_CHARM_DIR matching '$desired_charm'; please run within a Juju hook context" - exit 1 - fi - found_charm_dir="$charm_dir" - fi - done - if [[ -z "$found_charm_dir" ]]; then - >&2 echo "Unable to determine JUJU_CHARM_DIR matching '$desired_charm'; please run within a Juju hook context" - exit 1 - fi - export JUJU_CHARM_DIR="$found_charm_dir" - export CHARM_DIR="$found_charm_dir" - return - fi - # shellcheck disable=SC2126 - non_subordinates="$(grep -L 'subordinate"\?:.*true' "$agents_dir"/unit-*/charm/metadata.yaml | wc -l)" - if [[ "$non_subordinates" -gt 1 ]]; then - >&2 echo 'Ambiguous possibilities for JUJU_CHARM_DIR; please use --charm or run within a Juju hook context' - exit 1 - elif [[ "$non_subordinates" -eq 1 ]]; then - for charm_dir in $(/bin/ls -d "$agents_dir"/unit-*/charm); do - if grep -q 'subordinate"\?:.*true' "$charm_dir/metadata.yaml"; then - continue - fi - export JUJU_CHARM_DIR="$charm_dir" - export CHARM_DIR="$charm_dir" - return - done - fi - fi - >&2 echo 'Unable to determine JUJU_CHARM_DIR; please run within a Juju hook context' - exit 1 -} - -try_activate_venv() { - if [[ -d "$JUJU_CHARM_DIR/../.venv" ]]; then - . "$JUJU_CHARM_DIR/../.venv/bin/activate" - fi -} - -find_wrapped() { - PATH="${PATH/\/usr\/local\/sbin:}" which "$(basename "$0")" -} - - -if [[ "$1" == "--version" || "$1" == "-v" ]]; then - echo "$VERSION" - exit 0 -fi - - -# allow --charm option to hint which JUJU_CHARM_DIR to choose when ambiguous -# NB: --charm option must come first -# NB: option must be processed outside find_charm_dirs to modify $@ -charm_name="" -if [[ "$1" == "--charm" ]]; then - charm_name="$2" - shift; shift -fi - -find_charm_dirs "$charm_name" -try_activate_venv -export PYTHONPATH="$JUJU_CHARM_DIR/lib:$PYTHONPATH" - -if [[ "$(basename "$0")" == "charm-env" ]]; then - # being used as a shebang - exec "$@" -elif [[ "$0" == "$BASH_SOURCE" ]]; then - # being invoked as a symlink wrapping something to find in the venv - exec "$(find_wrapped)" "$@" -elif [[ "$(basename "$BASH_SOURCE")" == "charm-env" ]]; then - # being sourced directly; do nothing - /bin/true -else - # being sourced for wrapped bash helpers - . "$(find_wrapped)" -fi diff --git a/nscharm_user_vnf/charms/vnf-user/bin/layer_option b/nscharm_user_vnf/charms/vnf-user/bin/layer_option deleted file mode 100755 index 3253ef8aadb95807f26e5ebd8486adde67e5cbc2..0000000000000000000000000000000000000000 --- a/nscharm_user_vnf/charms/vnf-user/bin/layer_option +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 - -import sys -import argparse -from charms import layer - - -parser = argparse.ArgumentParser(description='Access layer options.') -parser.add_argument('section', - help='the section, or layer, the option is from') -parser.add_argument('option', - help='the option to access') - -args = parser.parse_args() -value = layer.options.get(args.section, args.option) -if isinstance(value, bool): - sys.exit(0 if value else 1) -elif isinstance(value, list): - for val in value: - print(val) -else: - print(value) diff --git a/nscharm_user_vnf/charms/vnf-user/config.yaml b/nscharm_user_vnf/charms/vnf-user/config.yaml deleted file mode 100644 index a7d9291c137d1907b7ef2ba019123aa9201ef107..0000000000000000000000000000000000000000 --- a/nscharm_user_vnf/charms/vnf-user/config.yaml +++ /dev/null @@ -1,29 +0,0 @@ -"options": - "ssh-hostname": - "type": "string" - "default": "" - "description": "The hostname or IP address of the machine to" - "ssh-username": - "type": "string" - "default": "" - "description": "The username to login as." - "ssh-password": - "type": "string" - "default": "" - "description": "The password used to authenticate." - "ssh-private-key": - "type": "string" - "default": "" - "description": "DEPRECATED. The private ssh key to be used to authenticate." - "ssh-public-key": - "type": "string" - "default": "" - "description": "The public key of this unit." - "ssh-key-type": - "type": "string" - "default": "rsa" - "description": "The type of encryption to use for the SSH key." - "ssh-key-bits": - "type": "int" - "default": !!int "4096" - "description": "The number of bits to use for the SSH key." diff --git a/nscharm_user_vnf/charms/vnf-user/copyright b/nscharm_user_vnf/charms/vnf-user/copyright deleted file mode 100644 index d4fdd18281c632d030a301d26d45b4dabdb308ef..0000000000000000000000000000000000000000 --- a/nscharm_user_vnf/charms/vnf-user/copyright +++ /dev/null @@ -1,16 +0,0 @@ -Format: http://dep.debian.net/deps/dep5/ - -Files: * -Copyright: Copyright 2015-2017, Canonical Ltd., All Rights Reserved. -License: Apache License 2.0 - 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/nscharm_user_vnf/charms/vnf-user/copyright.layer-options b/nscharm_user_vnf/charms/vnf-user/copyright.layer-options deleted file mode 100644 index d4fdd18281c632d030a301d26d45b4dabdb308ef..0000000000000000000000000000000000000000 --- a/nscharm_user_vnf/charms/vnf-user/copyright.layer-options +++ /dev/null @@ -1,16 +0,0 @@ -Format: http://dep.debian.net/deps/dep5/ - -Files: * -Copyright: Copyright 2015-2017, Canonical Ltd., All Rights Reserved. -License: Apache License 2.0 - 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/nscharm_user_vnf/charms/vnf-user/hooks/collect-metrics b/nscharm_user_vnf/charms/vnf-user/hooks/collect-metrics deleted file mode 100755 index ecd7e62385689b00cc023b1057a0061b0f373134..0000000000000000000000000000000000000000 --- a/nscharm_user_vnf/charms/vnf-user/hooks/collect-metrics +++ /dev/null @@ -1,68 +0,0 @@ -#!/usr/bin/env python3 -"""Handle the collect-metrics hook via proxy. - -The normal metrics layer will only execute metrics collection against the local -machine. This hook implements the same approach, but runs the collection code -against the configured ssh proxy. - -Because the metrics hook runs in a restricted context, it can't be run as a -normal reactive event, nor can it access things like config. -""" - -import os -import shlex -from subprocess import check_call, CalledProcessError -import sys -import yaml - -# Load modules from $CHARM_DIR/lib -sys.path.append('lib') -import charms.sshproxy - - -def build_command(doc): - """Build the commands to report metrics. - - Build a list of `add-metric` commands to report the current metrics - back to the Juju controller. - """ - values = {} - metrics = doc.get("metrics", {}) - for metric, mdoc in metrics.items(): - cmd = mdoc.get("command") - if cmd: - try: - value, err = charms.sshproxy._run( - # The command may contain quotes that need to be preserved, - # i.e., `awk '{print $1}' /proc/uptime` - shlex.split(cmd, posix=False) - ) - except Exception as e: - # Ignore all errors - with open("metrics.log", "a") as f: - f.write("{}".format(e)) - continue - - if isinstance(value, bytes): - value = value.decode('utf-8') - - value = value.strip() - if value: - values[metric] = value - - if not values: - return None - command = ["add-metric"] - for metric, value in values.items(): - command.append("%s=%s" % (metric, value)) - return command - - -if __name__ == '__main__': - charm_dir = os.path.dirname(os.path.abspath(os.path.join(__file__, ".."))) - metrics_yaml = os.path.join(charm_dir, "metrics.yaml") - with open(metrics_yaml) as f: - doc = yaml.load(f) - command = build_command(doc) - if command: - check_call(command) diff --git a/nscharm_user_vnf/charms/vnf-user/hooks/config-changed b/nscharm_user_vnf/charms/vnf-user/hooks/config-changed deleted file mode 100755 index 9858c6be15b8a682778ab4727835151e1b693801..0000000000000000000000000000000000000000 --- a/nscharm_user_vnf/charms/vnf-user/hooks/config-changed +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 - -# Load modules from $JUJU_CHARM_DIR/lib -import sys -sys.path.append('lib') - -from charms.layer import basic # noqa -basic.bootstrap_charm_deps() - -from charmhelpers.core import hookenv # noqa -hookenv.atstart(basic.init_config_states) -hookenv.atexit(basic.clear_config_states) - - -# This will load and run the appropriate @hook and other decorated -# handlers from $JUJU_CHARM_DIR/reactive, $JUJU_CHARM_DIR/hooks/reactive, -# and $JUJU_CHARM_DIR/hooks/relations. -# -# See https://jujucharms.com/docs/stable/authors-charm-building -# for more information on this pattern. -from charms.reactive import main # noqa -main() diff --git a/nscharm_user_vnf/charms/vnf-user/hooks/hook.template b/nscharm_user_vnf/charms/vnf-user/hooks/hook.template deleted file mode 100644 index 9858c6be15b8a682778ab4727835151e1b693801..0000000000000000000000000000000000000000 --- a/nscharm_user_vnf/charms/vnf-user/hooks/hook.template +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 - -# Load modules from $JUJU_CHARM_DIR/lib -import sys -sys.path.append('lib') - -from charms.layer import basic # noqa -basic.bootstrap_charm_deps() - -from charmhelpers.core import hookenv # noqa -hookenv.atstart(basic.init_config_states) -hookenv.atexit(basic.clear_config_states) - - -# This will load and run the appropriate @hook and other decorated -# handlers from $JUJU_CHARM_DIR/reactive, $JUJU_CHARM_DIR/hooks/reactive, -# and $JUJU_CHARM_DIR/hooks/relations. -# -# See https://jujucharms.com/docs/stable/authors-charm-building -# for more information on this pattern. -from charms.reactive import main # noqa -main() diff --git a/nscharm_user_vnf/charms/vnf-user/hooks/install b/nscharm_user_vnf/charms/vnf-user/hooks/install deleted file mode 100755 index 9858c6be15b8a682778ab4727835151e1b693801..0000000000000000000000000000000000000000 --- a/nscharm_user_vnf/charms/vnf-user/hooks/install +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 - -# Load modules from $JUJU_CHARM_DIR/lib -import sys -sys.path.append('lib') - -from charms.layer import basic # noqa -basic.bootstrap_charm_deps() - -from charmhelpers.core import hookenv # noqa -hookenv.atstart(basic.init_config_states) -hookenv.atexit(basic.clear_config_states) - - -# This will load and run the appropriate @hook and other decorated -# handlers from $JUJU_CHARM_DIR/reactive, $JUJU_CHARM_DIR/hooks/reactive, -# and $JUJU_CHARM_DIR/hooks/relations. -# -# See https://jujucharms.com/docs/stable/authors-charm-building -# for more information on this pattern. -from charms.reactive import main # noqa -main() diff --git a/nscharm_user_vnf/charms/vnf-user/hooks/leader-elected b/nscharm_user_vnf/charms/vnf-user/hooks/leader-elected deleted file mode 100755 index 9858c6be15b8a682778ab4727835151e1b693801..0000000000000000000000000000000000000000 --- a/nscharm_user_vnf/charms/vnf-user/hooks/leader-elected +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 - -# Load modules from $JUJU_CHARM_DIR/lib -import sys -sys.path.append('lib') - -from charms.layer import basic # noqa -basic.bootstrap_charm_deps() - -from charmhelpers.core import hookenv # noqa -hookenv.atstart(basic.init_config_states) -hookenv.atexit(basic.clear_config_states) - - -# This will load and run the appropriate @hook and other decorated -# handlers from $JUJU_CHARM_DIR/reactive, $JUJU_CHARM_DIR/hooks/reactive, -# and $JUJU_CHARM_DIR/hooks/relations. -# -# See https://jujucharms.com/docs/stable/authors-charm-building -# for more information on this pattern. -from charms.reactive import main # noqa -main() diff --git a/nscharm_user_vnf/charms/vnf-user/hooks/leader-settings-changed b/nscharm_user_vnf/charms/vnf-user/hooks/leader-settings-changed deleted file mode 100755 index 9858c6be15b8a682778ab4727835151e1b693801..0000000000000000000000000000000000000000 --- a/nscharm_user_vnf/charms/vnf-user/hooks/leader-settings-changed +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 - -# Load modules from $JUJU_CHARM_DIR/lib -import sys -sys.path.append('lib') - -from charms.layer import basic # noqa -basic.bootstrap_charm_deps() - -from charmhelpers.core import hookenv # noqa -hookenv.atstart(basic.init_config_states) -hookenv.atexit(basic.clear_config_states) - - -# This will load and run the appropriate @hook and other decorated -# handlers from $JUJU_CHARM_DIR/reactive, $JUJU_CHARM_DIR/hooks/reactive, -# and $JUJU_CHARM_DIR/hooks/relations. -# -# See https://jujucharms.com/docs/stable/authors-charm-building -# for more information on this pattern. -from charms.reactive import main # noqa -main() diff --git a/nscharm_user_vnf/charms/vnf-user/hooks/post-series-upgrade b/nscharm_user_vnf/charms/vnf-user/hooks/post-series-upgrade deleted file mode 100755 index 9858c6be15b8a682778ab4727835151e1b693801..0000000000000000000000000000000000000000 --- a/nscharm_user_vnf/charms/vnf-user/hooks/post-series-upgrade +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 - -# Load modules from $JUJU_CHARM_DIR/lib -import sys -sys.path.append('lib') - -from charms.layer import basic # noqa -basic.bootstrap_charm_deps() - -from charmhelpers.core import hookenv # noqa -hookenv.atstart(basic.init_config_states) -hookenv.atexit(basic.clear_config_states) - - -# This will load and run the appropriate @hook and other decorated -# handlers from $JUJU_CHARM_DIR/reactive, $JUJU_CHARM_DIR/hooks/reactive, -# and $JUJU_CHARM_DIR/hooks/relations. -# -# See https://jujucharms.com/docs/stable/authors-charm-building -# for more information on this pattern. -from charms.reactive import main # noqa -main() diff --git a/nscharm_user_vnf/charms/vnf-user/hooks/pre-series-upgrade b/nscharm_user_vnf/charms/vnf-user/hooks/pre-series-upgrade deleted file mode 100755 index 9858c6be15b8a682778ab4727835151e1b693801..0000000000000000000000000000000000000000 --- a/nscharm_user_vnf/charms/vnf-user/hooks/pre-series-upgrade +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 - -# Load modules from $JUJU_CHARM_DIR/lib -import sys -sys.path.append('lib') - -from charms.layer import basic # noqa -basic.bootstrap_charm_deps() - -from charmhelpers.core import hookenv # noqa -hookenv.atstart(basic.init_config_states) -hookenv.atexit(basic.clear_config_states) - - -# This will load and run the appropriate @hook and other decorated -# handlers from $JUJU_CHARM_DIR/reactive, $JUJU_CHARM_DIR/hooks/reactive, -# and $JUJU_CHARM_DIR/hooks/relations. -# -# See https://jujucharms.com/docs/stable/authors-charm-building -# for more information on this pattern. -from charms.reactive import main # noqa -main() diff --git a/nscharm_user_vnf/charms/vnf-user/hooks/start b/nscharm_user_vnf/charms/vnf-user/hooks/start deleted file mode 100755 index 9858c6be15b8a682778ab4727835151e1b693801..0000000000000000000000000000000000000000 --- a/nscharm_user_vnf/charms/vnf-user/hooks/start +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 - -# Load modules from $JUJU_CHARM_DIR/lib -import sys -sys.path.append('lib') - -from charms.layer import basic # noqa -basic.bootstrap_charm_deps() - -from charmhelpers.core import hookenv # noqa -hookenv.atstart(basic.init_config_states) -hookenv.atexit(basic.clear_config_states) - - -# This will load and run the appropriate @hook and other decorated -# handlers from $JUJU_CHARM_DIR/reactive, $JUJU_CHARM_DIR/hooks/reactive, -# and $JUJU_CHARM_DIR/hooks/relations. -# -# See https://jujucharms.com/docs/stable/authors-charm-building -# for more information on this pattern. -from charms.reactive import main # noqa -main() diff --git a/nscharm_user_vnf/charms/vnf-user/hooks/stop b/nscharm_user_vnf/charms/vnf-user/hooks/stop deleted file mode 100755 index 9858c6be15b8a682778ab4727835151e1b693801..0000000000000000000000000000000000000000 --- a/nscharm_user_vnf/charms/vnf-user/hooks/stop +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 - -# Load modules from $JUJU_CHARM_DIR/lib -import sys -sys.path.append('lib') - -from charms.layer import basic # noqa -basic.bootstrap_charm_deps() - -from charmhelpers.core import hookenv # noqa -hookenv.atstart(basic.init_config_states) -hookenv.atexit(basic.clear_config_states) - - -# This will load and run the appropriate @hook and other decorated -# handlers from $JUJU_CHARM_DIR/reactive, $JUJU_CHARM_DIR/hooks/reactive, -# and $JUJU_CHARM_DIR/hooks/relations. -# -# See https://jujucharms.com/docs/stable/authors-charm-building -# for more information on this pattern. -from charms.reactive import main # noqa -main() diff --git a/nscharm_user_vnf/charms/vnf-user/hooks/update-status b/nscharm_user_vnf/charms/vnf-user/hooks/update-status deleted file mode 100755 index 9858c6be15b8a682778ab4727835151e1b693801..0000000000000000000000000000000000000000 --- a/nscharm_user_vnf/charms/vnf-user/hooks/update-status +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 - -# Load modules from $JUJU_CHARM_DIR/lib -import sys -sys.path.append('lib') - -from charms.layer import basic # noqa -basic.bootstrap_charm_deps() - -from charmhelpers.core import hookenv # noqa -hookenv.atstart(basic.init_config_states) -hookenv.atexit(basic.clear_config_states) - - -# This will load and run the appropriate @hook and other decorated -# handlers from $JUJU_CHARM_DIR/reactive, $JUJU_CHARM_DIR/hooks/reactive, -# and $JUJU_CHARM_DIR/hooks/relations. -# -# See https://jujucharms.com/docs/stable/authors-charm-building -# for more information on this pattern. -from charms.reactive import main # noqa -main() diff --git a/nscharm_user_vnf/charms/vnf-user/hooks/upgrade-charm b/nscharm_user_vnf/charms/vnf-user/hooks/upgrade-charm deleted file mode 100755 index 9858c6be15b8a682778ab4727835151e1b693801..0000000000000000000000000000000000000000 --- a/nscharm_user_vnf/charms/vnf-user/hooks/upgrade-charm +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 - -# Load modules from $JUJU_CHARM_DIR/lib -import sys -sys.path.append('lib') - -from charms.layer import basic # noqa -basic.bootstrap_charm_deps() - -from charmhelpers.core import hookenv # noqa -hookenv.atstart(basic.init_config_states) -hookenv.atexit(basic.clear_config_states) - - -# This will load and run the appropriate @hook and other decorated -# handlers from $JUJU_CHARM_DIR/reactive, $JUJU_CHARM_DIR/hooks/reactive, -# and $JUJU_CHARM_DIR/hooks/relations. -# -# See https://jujucharms.com/docs/stable/authors-charm-building -# for more information on this pattern. -from charms.reactive import main # noqa -main() diff --git a/nscharm_user_vnf/charms/vnf-user/layer.yaml b/nscharm_user_vnf/charms/vnf-user/layer.yaml deleted file mode 100644 index d8ab5ff8cc9465018a22882b13f77e4b61af524e..0000000000000000000000000000000000000000 --- a/nscharm_user_vnf/charms/vnf-user/layer.yaml +++ /dev/null @@ -1,16 +0,0 @@ -"includes": -- "layer:options" -- "layer:basic" -- "layer:sshproxy" -- "layer:vnfproxy" -"exclude": [".travis.yml", "tests", "tox.ini", "test-requirements.txt", "unit_tests"] -"options": - "basic": - "use_venv": !!bool "false" - "packages": [] - "python_packages": [] - "include_system_packages": !!bool "false" - "sshproxy": {} - "vnfproxy": {} - "vnf-user": {} -"is": "vnf-user" diff --git a/nscharm_user_vnf/charms/vnf-user/lib/charms/layer/__init__.py b/nscharm_user_vnf/charms/vnf-user/lib/charms/layer/__init__.py deleted file mode 100644 index a8e0c640642f44cac85df60f3d9b7f73b0bb18bb..0000000000000000000000000000000000000000 --- a/nscharm_user_vnf/charms/vnf-user/lib/charms/layer/__init__.py +++ /dev/null @@ -1,60 +0,0 @@ -import sys -from importlib import import_module -from pathlib import Path - - -def import_layer_libs(): - """ - Ensure that all layer libraries are imported. - - This makes it possible to do the following: - - from charms import layer - - layer.foo.do_foo_thing() - - Note: This function must be called after bootstrap. - """ - for module_file in Path('lib/charms/layer').glob('*'): - module_name = module_file.stem - if module_name in ('__init__', 'basic', 'execd') or not ( - module_file.suffix == '.py' or module_file.is_dir() - ): - continue - import_module('charms.layer.{}'.format(module_name)) - - -# Terrible hack to support the old terrible interface. -# Try to get people to call layer.options.get() instead so -# that we can remove this garbage. -# Cribbed from https://stackoverfLow.com/a/48100440/4941864 -class OptionsBackwardsCompatibilityHack(sys.modules[__name__].__class__): - def __call__(self, section=None, layer_file=None): - if layer_file is None: - return self.get(section=section) - else: - return self.get(section=section, - layer_file=Path(layer_file)) - - -def patch_options_interface(): - from charms.layer import options - if sys.version_info.minor >= 5: - options.__class__ = OptionsBackwardsCompatibilityHack - else: - # Py 3.4 doesn't support changing the __class__, so we have to do it - # another way. The last line is needed because we already have a - # reference that doesn't get updated with sys.modules. - name = options.__name__ - hack = OptionsBackwardsCompatibilityHack(name) - hack.get = options.get - sys.modules[name] = hack - sys.modules[__name__].options = hack - - -try: - patch_options_interface() -except ImportError: - # This may fail if pyyaml hasn't been installed yet. But in that - # case, the bootstrap logic will try it again once it has. - pass diff --git a/nscharm_user_vnf/charms/vnf-user/lib/charms/layer/basic.py b/nscharm_user_vnf/charms/vnf-user/lib/charms/layer/basic.py deleted file mode 100644 index 75072039adab3e35ae268c4e31c6c03cd4a1bdef..0000000000000000000000000000000000000000 --- a/nscharm_user_vnf/charms/vnf-user/lib/charms/layer/basic.py +++ /dev/null @@ -1,446 +0,0 @@ -import os -import sys -import re -import shutil -from distutils.version import LooseVersion -from pkg_resources import Requirement -from glob import glob -from subprocess import check_call, check_output, CalledProcessError -from time import sleep - -from charms import layer -from charms.layer.execd import execd_preinstall - - -def _get_subprocess_env(): - env = os.environ.copy() - env['LANG'] = env.get('LANG', 'C.UTF-8') - return env - - -def get_series(): - """ - Return series for a few known OS:es. - Tested as of 2019 november: - * centos6, centos7, rhel6. - * bionic - """ - series = "" - - # Looking for content in /etc/os-release - # works for ubuntu + some centos - if os.path.isfile('/etc/os-release'): - d = {} - with open('/etc/os-release', 'r') as rel: - for l in rel: - if not re.match(r'^\s*$', l): - k, v = l.split('=') - d[k.strip()] = v.strip().replace('"', '') - series = "{ID}{VERSION_ID}".format(**d) - - # Looking for content in /etc/redhat-release - # works for redhat enterprise systems - elif os.path.isfile('/etc/redhat-release'): - with open('/etc/redhat-release', 'r') as redhatlsb: - # CentOS Linux release 7.7.1908 (Core) - line = redhatlsb.readline() - release = int(line.split("release")[1].split()[0][0]) - series = "centos" + str(release) - - # Looking for content in /etc/lsb-release - # works for ubuntu - elif os.path.isfile('/etc/lsb-release'): - d = {} - with open('/etc/lsb-release', 'r') as lsb: - for l in lsb: - k, v = l.split('=') - d[k.strip()] = v.strip() - series = d['DISTRIB_CODENAME'] - - # This is what happens if we cant figure out the OS. - else: - series = "unknown" - return series - - -def bootstrap_charm_deps(): - """ - Set up the base charm dependencies so that the reactive system can run. - """ - # execd must happen first, before any attempt to install packages or - # access the network, because sites use this hook to do bespoke - # configuration and install secrets so the rest of this bootstrap - # and the charm itself can actually succeed. This call does nothing - # unless the operator has created and populated $JUJU_CHARM_DIR/exec.d. - execd_preinstall() - # ensure that $JUJU_CHARM_DIR/bin is on the path, for helper scripts - - series = get_series() - - # OMG?! is build-essentials needed? - ubuntu_packages = ['python3-pip', - 'python3-setuptools', - 'python3-yaml', - 'python3-dev', - 'python3-wheel', - 'build-essential'] - - # I'm not going to "yum group info "Development Tools" - # omitting above madness - centos_packages = ['python3-pip', - 'python3-setuptools', - 'python3-devel', - 'python3-wheel'] - - packages_needed = [] - if 'centos' in series: - packages_needed = centos_packages - else: - packages_needed = ubuntu_packages - - charm_dir = os.environ['JUJU_CHARM_DIR'] - os.environ['PATH'] += ':%s' % os.path.join(charm_dir, 'bin') - venv = os.path.abspath('../.venv') - vbin = os.path.join(venv, 'bin') - vpip = os.path.join(vbin, 'pip') - vpy = os.path.join(vbin, 'python') - hook_name = os.path.basename(sys.argv[0]) - is_bootstrapped = os.path.exists('wheelhouse/.bootstrapped') - is_charm_upgrade = hook_name == 'upgrade-charm' - is_series_upgrade = hook_name == 'post-series-upgrade' - is_post_upgrade = os.path.exists('wheelhouse/.upgraded') - is_upgrade = (not is_post_upgrade and - (is_charm_upgrade or is_series_upgrade)) - if is_bootstrapped and not is_upgrade: - # older subordinates might have downgraded charm-env, so we should - # restore it if necessary - install_or_update_charm_env() - activate_venv() - # the .upgrade file prevents us from getting stuck in a loop - # when re-execing to activate the venv; at this point, we've - # activated the venv, so it's safe to clear it - if is_post_upgrade: - os.unlink('wheelhouse/.upgraded') - return - if os.path.exists(venv): - try: - # focal installs or upgrades prior to PR 160 could leave the venv - # in a broken state which would prevent subsequent charm upgrades - _load_installed_versions(vpip) - except CalledProcessError: - is_broken_venv = True - else: - is_broken_venv = False - if is_upgrade or is_broken_venv: - # All upgrades should do a full clear of the venv, rather than - # just updating it, to bring in updates to Python itself - shutil.rmtree(venv) - if is_upgrade: - if os.path.exists('wheelhouse/.bootstrapped'): - os.unlink('wheelhouse/.bootstrapped') - # bootstrap wheelhouse - if os.path.exists('wheelhouse'): - pre_eoan = series in ('ubuntu12.04', 'precise', - 'ubuntu14.04', 'trusty', - 'ubuntu16.04', 'xenial', - 'ubuntu18.04', 'bionic') - pydistutils_lines = [ - "[easy_install]\n", - "find_links = file://{}/wheelhouse/\n".format(charm_dir), - "no_index=True\n", - "index_url=\n", # deliberately nothing here; disables it. - ] - if pre_eoan: - pydistutils_lines.append("allow_hosts = ''\n") - with open('/root/.pydistutils.cfg', 'w') as fp: - # make sure that easy_install also only uses the wheelhouse - # (see https://github.com/pypa/pip/issues/410) - fp.writelines(pydistutils_lines) - if 'centos' in series: - yum_install(packages_needed) - else: - apt_install(packages_needed) - from charms.layer import options - cfg = options.get('basic') - # include packages defined in layer.yaml - if 'centos' in series: - yum_install(cfg.get('packages', [])) - else: - apt_install(cfg.get('packages', [])) - # if we're using a venv, set it up - if cfg.get('use_venv'): - if not os.path.exists(venv): - series = get_series() - if series in ('ubuntu12.04', 'precise', - 'ubuntu14.04', 'trusty'): - apt_install(['python-virtualenv']) - elif 'centos' in series: - yum_install(['python-virtualenv']) - else: - apt_install(['virtualenv']) - cmd = ['virtualenv', '-ppython3', '--never-download', venv] - if cfg.get('include_system_packages'): - cmd.append('--system-site-packages') - check_call(cmd, env=_get_subprocess_env()) - os.environ['PATH'] = ':'.join([vbin, os.environ['PATH']]) - pip = vpip - else: - pip = 'pip3' - # save a copy of system pip to prevent `pip3 install -U pip` - # from changing it - if os.path.exists('/usr/bin/pip'): - shutil.copy2('/usr/bin/pip', '/usr/bin/pip.save') - pre_install_pkgs = ['pip', 'setuptools', 'setuptools-scm'] - # we bundle these packages to work around bugs in older versions (such - # as https://github.com/pypa/pip/issues/56), but if the system already - # provided a newer version, downgrading it can cause other problems - _update_if_newer(pip, pre_install_pkgs) - # install the rest of the wheelhouse deps (extract the pkg names into - # a set so that we can ignore the pre-install packages and let pip - # choose the best version in case there are multiple from layer - # conflicts) - pkgs = _load_wheelhouse_versions().keys() - set(pre_install_pkgs) - reinstall_flag = '--force-reinstall' - if not cfg.get('use_venv', True) and pre_eoan: - reinstall_flag = '--ignore-installed' - check_call([pip, 'install', '-U', reinstall_flag, '--no-index', - '--no-cache-dir', '-f', 'wheelhouse'] + list(pkgs), - env=_get_subprocess_env()) - # re-enable installation from pypi - os.remove('/root/.pydistutils.cfg') - - # install pyyaml for centos7, since, unlike the ubuntu image, the - # default image for centos doesn't include pyyaml; see the discussion: - # https://discourse.jujucharms.com/t/charms-for-centos-lets-begin - if 'centos' in series: - check_call([pip, 'install', '-U', 'pyyaml'], - env=_get_subprocess_env()) - - # install python packages from layer options - if cfg.get('python_packages'): - check_call([pip, 'install', '-U'] + cfg.get('python_packages'), - env=_get_subprocess_env()) - if not cfg.get('use_venv'): - # restore system pip to prevent `pip3 install -U pip` - # from changing it - if os.path.exists('/usr/bin/pip.save'): - shutil.copy2('/usr/bin/pip.save', '/usr/bin/pip') - os.remove('/usr/bin/pip.save') - # setup wrappers to ensure envs are used for scripts - install_or_update_charm_env() - for wrapper in ('charms.reactive', 'charms.reactive.sh', - 'chlp', 'layer_option'): - src = os.path.join('/usr/local/sbin', 'charm-env') - dst = os.path.join('/usr/local/sbin', wrapper) - if not os.path.exists(dst): - os.symlink(src, dst) - if cfg.get('use_venv'): - shutil.copy2('bin/layer_option', vbin) - else: - shutil.copy2('bin/layer_option', '/usr/local/bin/') - # re-link the charm copy to the wrapper in case charms - # call bin/layer_option directly (as was the old pattern) - os.remove('bin/layer_option') - os.symlink('/usr/local/sbin/layer_option', 'bin/layer_option') - # flag us as having already bootstrapped so we don't do it again - open('wheelhouse/.bootstrapped', 'w').close() - if is_upgrade: - # flag us as having already upgraded so we don't do it again - open('wheelhouse/.upgraded', 'w').close() - # Ensure that the newly bootstrapped libs are available. - # Note: this only seems to be an issue with namespace packages. - # Non-namespace-package libs (e.g., charmhelpers) are available - # without having to reload the interpreter. :/ - reload_interpreter(vpy if cfg.get('use_venv') else sys.argv[0]) - - -def _load_installed_versions(pip): - pip_freeze = check_output([pip, 'freeze']).decode('utf8') - versions = {} - for pkg_ver in pip_freeze.splitlines(): - try: - req = Requirement.parse(pkg_ver) - except ValueError: - continue - versions.update({ - req.project_name: LooseVersion(ver) - for op, ver in req.specs if op == '==' - }) - return versions - - -def _load_wheelhouse_versions(): - versions = {} - for wheel in glob('wheelhouse/*'): - pkg, ver = os.path.basename(wheel).rsplit('-', 1) - # nb: LooseVersion ignores the file extension - versions[pkg.replace('_', '-')] = LooseVersion(ver) - return versions - - -def _update_if_newer(pip, pkgs): - installed = _load_installed_versions(pip) - wheelhouse = _load_wheelhouse_versions() - for pkg in pkgs: - if pkg not in installed or wheelhouse[pkg] > installed[pkg]: - check_call([pip, 'install', '-U', '--no-index', '-f', 'wheelhouse', - pkg], env=_get_subprocess_env()) - - -def install_or_update_charm_env(): - # On Trusty python3-pkg-resources is not installed - try: - from pkg_resources import parse_version - except ImportError: - apt_install(['python3-pkg-resources']) - from pkg_resources import parse_version - - try: - installed_version = parse_version( - check_output(['/usr/local/sbin/charm-env', - '--version']).decode('utf8')) - except (CalledProcessError, FileNotFoundError): - installed_version = parse_version('0.0.0') - try: - bundled_version = parse_version( - check_output(['bin/charm-env', - '--version']).decode('utf8')) - except (CalledProcessError, FileNotFoundError): - bundled_version = parse_version('0.0.0') - if installed_version < bundled_version: - shutil.copy2('bin/charm-env', '/usr/local/sbin/') - - -def activate_venv(): - """ - Activate the venv if enabled in ``layer.yaml``. - - This is handled automatically for normal hooks, but actions might - need to invoke this manually, using something like: - - # Load modules from $JUJU_CHARM_DIR/lib - import sys - sys.path.append('lib') - - from charms.layer.basic import activate_venv - activate_venv() - - This will ensure that modules installed in the charm's - virtual environment are available to the action. - """ - from charms.layer import options - venv = os.path.abspath('../.venv') - vbin = os.path.join(venv, 'bin') - vpy = os.path.join(vbin, 'python') - use_venv = options.get('basic', 'use_venv') - if use_venv and '.venv' not in sys.executable: - # activate the venv - os.environ['PATH'] = ':'.join([vbin, os.environ['PATH']]) - reload_interpreter(vpy) - layer.patch_options_interface() - layer.import_layer_libs() - - -def reload_interpreter(python): - """ - Reload the python interpreter to ensure that all deps are available. - - Newly installed modules in namespace packages sometimes seemt to - not be picked up by Python 3. - """ - os.execve(python, [python] + list(sys.argv), os.environ) - - -def apt_install(packages): - """ - Install apt packages. - - This ensures a consistent set of options that are often missed but - should really be set. - """ - if isinstance(packages, (str, bytes)): - packages = [packages] - - env = _get_subprocess_env() - - if 'DEBIAN_FRONTEND' not in env: - env['DEBIAN_FRONTEND'] = 'noninteractive' - - cmd = ['apt-get', - '--option=Dpkg::Options::=--force-confold', - '--assume-yes', - 'install'] - for attempt in range(3): - try: - check_call(cmd + packages, env=env) - except CalledProcessError: - if attempt == 2: # third attempt - raise - try: - # sometimes apt-get update needs to be run - check_call(['apt-get', 'update'], env=env) - except CalledProcessError: - # sometimes it's a dpkg lock issue - pass - sleep(5) - else: - break - - -def yum_install(packages): - """ Installs packages with yum. - This function largely mimics the apt_install function for consistency. - """ - if packages: - env = os.environ.copy() - cmd = ['yum', '-y', 'install'] - for attempt in range(3): - try: - check_call(cmd + packages, env=env) - except CalledProcessError: - if attempt == 2: - raise - try: - check_call(['yum', 'update'], env=env) - except CalledProcessError: - pass - sleep(5) - else: - break - else: - pass - - -def init_config_states(): - import yaml - from charmhelpers.core import hookenv - from charms.reactive import set_state - from charms.reactive import toggle_state - config = hookenv.config() - config_defaults = {} - config_defs = {} - config_yaml = os.path.join(hookenv.charm_dir(), 'config.yaml') - if os.path.exists(config_yaml): - with open(config_yaml) as fp: - config_defs = yaml.safe_load(fp).get('options', {}) - config_defaults = {key: value.get('default') - for key, value in config_defs.items()} - for opt in config_defs.keys(): - if config.changed(opt): - set_state('config.changed') - set_state('config.changed.{}'.format(opt)) - toggle_state('config.set.{}'.format(opt), config.get(opt)) - toggle_state('config.default.{}'.format(opt), - config.get(opt) == config_defaults[opt]) - - -def clear_config_states(): - from charmhelpers.core import hookenv, unitdata - from charms.reactive import remove_state - config = hookenv.config() - remove_state('config.changed') - for opt in config.keys(): - remove_state('config.changed.{}'.format(opt)) - remove_state('config.set.{}'.format(opt)) - remove_state('config.default.{}'.format(opt)) - unitdata.kv().flush() diff --git a/nscharm_user_vnf/charms/vnf-user/lib/charms/layer/execd.py b/nscharm_user_vnf/charms/vnf-user/lib/charms/layer/execd.py deleted file mode 100644 index 438d9a1bc90042fd8b20517d5ecf358dfbf08afc..0000000000000000000000000000000000000000 --- a/nscharm_user_vnf/charms/vnf-user/lib/charms/layer/execd.py +++ /dev/null @@ -1,114 +0,0 @@ -# Copyright 2014-2016 Canonical Limited. -# -# This file is part of layer-basic, the reactive base layer for Juju. -# -# charm-helpers is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 as -# published by the Free Software Foundation. -# -# charm-helpers is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with charm-helpers. If not, see . - -# This module may only import from the Python standard library. -import os -import sys -import subprocess -import time - -''' -execd/preinstall - -Read the layer-basic docs for more info on how to use this feature. -https://charmsreactive.readthedocs.io/en/latest/layer-basic.html#exec-d-support -''' - - -def default_execd_dir(): - return os.path.join(os.environ['JUJU_CHARM_DIR'], 'exec.d') - - -def execd_module_paths(execd_dir=None): - """Generate a list of full paths to modules within execd_dir.""" - if not execd_dir: - execd_dir = default_execd_dir() - - if not os.path.exists(execd_dir): - return - - for subpath in os.listdir(execd_dir): - module = os.path.join(execd_dir, subpath) - if os.path.isdir(module): - yield module - - -def execd_submodule_paths(command, execd_dir=None): - """Generate a list of full paths to the specified command within exec_dir. - """ - for module_path in execd_module_paths(execd_dir): - path = os.path.join(module_path, command) - if os.access(path, os.X_OK) and os.path.isfile(path): - yield path - - -def execd_sentinel_path(submodule_path): - module_path = os.path.dirname(submodule_path) - execd_path = os.path.dirname(module_path) - module_name = os.path.basename(module_path) - submodule_name = os.path.basename(submodule_path) - return os.path.join(execd_path, - '.{}_{}.done'.format(module_name, submodule_name)) - - -def execd_run(command, execd_dir=None, stop_on_error=True, stderr=None): - """Run command for each module within execd_dir which defines it.""" - if stderr is None: - stderr = sys.stdout - for submodule_path in execd_submodule_paths(command, execd_dir): - # Only run each execd once. We cannot simply run them in the - # install hook, as potentially storage hooks are run before that. - # We cannot rely on them being idempotent. - sentinel = execd_sentinel_path(submodule_path) - if os.path.exists(sentinel): - continue - - try: - subprocess.check_call([submodule_path], stderr=stderr, - universal_newlines=True) - with open(sentinel, 'w') as f: - f.write('{} ran successfully {}\n'.format(submodule_path, - time.ctime())) - f.write('Removing this file will cause it to be run again\n') - except subprocess.CalledProcessError as e: - # Logs get the details. We can't use juju-log, as the - # output may be substantial and exceed command line - # length limits. - print("ERROR ({}) running {}".format(e.returncode, e.cmd), - file=stderr) - print("STDOUT< 0: - raise CalledProcessError(returncode=retcode, - cmd=cmd, - output=stderr.decode("utf-8").strip()) - return (stdout.decode('utf-8').strip(), stderr.decode('utf-8').strip()) - - -def _run(cmd, env=None): - """Run a command remotely via SSH. - - Note: The previous behavior was to run the command locally if SSH wasn't - configured, but that can lead to cases where execution succeeds when you'd - expect it not to. - """ - if isinstance(cmd, str): - cmd = shlex.split(cmd) - - if type(cmd) is not list: - cmd = [cmd] - - cfg = get_config() - - if cfg: - if all(k in cfg for k in ['ssh-hostname', 'ssh-username', - 'ssh-password', 'ssh-private-key']): - host = get_host_ip() - user = cfg['ssh-username'] - passwd = cfg['ssh-password'] - key = cfg['ssh-private-key'] # DEPRECATED - - if host and user: - return ssh(cmd, host, user, passwd, key) - - raise Exception("Invalid SSH credentials.") - - -def get_ssh_client(host, user, password=None, key=None): - """Return a connected Paramiko ssh object.""" - client = paramiko.SSHClient() - client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) - - pkey = None - - # Check for the DEPRECATED private-key - if key: - f = io.StringIO(key) - pkey = paramiko.RSAKey.from_private_key(f) - else: - # Otherwise, check for the auto-generated private key - if os.path.exists('/root/.ssh/id_juju_sshproxy'): - with open('/root/.ssh/id_juju_sshproxy', 'r') as f: - pkey = paramiko.RSAKey.from_private_key(f) - - ########################################################################### - # There is a bug in some versions of OpenSSH 4.3 (CentOS/RHEL 5) where # - # the server may not send the SSH_MSG_USERAUTH_BANNER message except when # - # responding to an auth_none request. For example, paramiko will attempt # - # to use password authentication when a password is set, but the server # - # could deny that, instead requesting keyboard-interactive. The hack to # - # workaround this is to attempt a reconnect, which will receive the right # - # banner, and authentication can proceed. See the following for more info # - # https://github.com/paramiko/paramiko/issues/432 # - # https://github.com/paramiko/paramiko/pull/438 # - ########################################################################### - - try: - client.connect(host, port=22, username=user, - password=password, pkey=pkey) - except paramiko.ssh_exception.SSHException as e: - if 'Error reading SSH protocol banner' == str(e): - # Once more, with feeling - client.connect(host, port=22, username=user, - password=password, pkey=pkey) - else: - # Reraise the original exception - raise e - - return client - - -def sftp(local_file, remote_file, host, user, password=None, key=None): - """Copy a local file to a remote host.""" - client = get_ssh_client(host, user, password, key) - - # Create an sftp connection from the underlying transport - sftp = paramiko.SFTPClient.from_transport(client.get_transport()) - sftp.put(local_file, remote_file) - client.close() - - -def ssh(cmd, host, user, password=None, key=None): - """Run an arbitrary command over SSH.""" - client = get_ssh_client(host, user, password, key) - - cmds = ' '.join(cmd) - stdin, stdout, stderr = client.exec_command(cmds, get_pty=True) - retcode = stdout.channel.recv_exit_status() - client.close() # @TODO re-use connections - if retcode > 0: - output = stderr.read().strip() - raise CalledProcessError(returncode=retcode, cmd=cmd, - output=output) - return ( - stdout.read().decode('utf-8').strip(), - stderr.read().decode('utf-8').strip() - ) diff --git a/nscharm_user_vnf/charms/vnf-user/metadata.yaml b/nscharm_user_vnf/charms/vnf-user/metadata.yaml deleted file mode 100644 index db361c49be8212560c0e0ffec0c07efa50326424..0000000000000000000000000000000000000000 --- a/nscharm_user_vnf/charms/vnf-user/metadata.yaml +++ /dev/null @@ -1,16 +0,0 @@ -"name": "vnf-user" -"summary": "" -"maintainer": "Adam Israel " -"description": | - -"tags": - # Replace "misc" with one or more whitelisted tags from this list: - # https://jujucharms.com/docs/stable/authors-charm-metadata -- "misc" -- "osm" -- "vnf" -"series": -- "xenial" -- "bionic" -- "trusty" -"subordinate": !!bool "false" diff --git a/nscharm_user_vnf/charms/vnf-user/reactive/__init__.py b/nscharm_user_vnf/charms/vnf-user/reactive/__init__.py deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/nscharm_user_vnf/charms/vnf-user/reactive/sshproxy.py b/nscharm_user_vnf/charms/vnf-user/reactive/sshproxy.py deleted file mode 100644 index 5ef0f56f09612a9a775a1bc3037685cc1f27755e..0000000000000000000000000000000000000000 --- a/nscharm_user_vnf/charms/vnf-user/reactive/sshproxy.py +++ /dev/null @@ -1,210 +0,0 @@ -## -# Copyright 2016 Canonical Ltd. -# All rights reserved. -# -# 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 charmhelpers.core import unitdata -from charmhelpers.core.hookenv import ( - action_fail, - action_get, - action_set, - config, - log, - status_set, - DEBUG, -) - -from charms.reactive.flags import register_trigger - -from charms.reactive import ( - clear_flag, - set_flag, - when, - when_not, - when_any, -) -import charms.sshproxy -import os -import subprocess - -# Register a trigger so that we can respond to config.changed, even if -# it's being cleared by another handler -register_trigger(when='config.changed', - set_flag='sshproxy.reconfigure') - - -# @when_any('config.changed', 'sshproxy.reconfigure') -@when_any('config.set.ssh-hostname', 'config.set.ssh-username', 'config.set.ssh-password', 'sshproxy.reconfigure') -def ssh_configured(): - """Check if charm is properly configured. - - Check to see if the charm is configured with SSH credentials. If so, - set a state flag that can be used to execute ssh-only actions. - - For example: - - @when('sshproxy.configured') - def run_remote_command(cmd): - ... - - @when_not('sshproxy.configured') - def run_local_command(cmd): - ... - """ - log("Checking sshproxy configuration", DEBUG) - cfg = config() - ssh_keys = ['ssh-hostname', 'ssh-username', - 'ssh-password', 'ssh-private-key'] - - if all(k in cfg for k in ssh_keys): - - # Store config in unitdata so it's accessible to sshproxy - db = unitdata.kv() - db.set('config', cfg) - - # Explicitly flush the kv so it's immediately available - db.flush() - - log("Verifying ssh credentials...", DEBUG) - (verified, output) = charms.sshproxy.verify_ssh_credentials() - if verified: - log("SSH credentials verified.", DEBUG) - set_flag('sshproxy.configured') - status_set('active', 'Ready!') - else: - clear_flag('sshproxy.configured') - status_set('blocked', "Remote machine not ready yet: {}".format(output)) - else: - log("No ssh credentials configured", DEBUG) - clear_flag('sshproxy.configured') - status_set('blocked', 'Invalid SSH credentials.') - - -def generate_ssh_key(): - """Generate a new 4096-bit rsa keypair. - - If there is an existing keypair for this unit, it will be overwritten. - """ - cfg = config() - if all(k in cfg for k in ['ssh-key-type', 'ssh-key-bits']): - keytype = cfg['ssh-key-type'] - bits = str(cfg['ssh-key-bits']) - privatekey = '/root/.ssh/id_juju_sshproxy' - publickey = "{}.pub".format(privatekey) - - if os.path.exists(privatekey): - os.remove(privatekey) - if os.path.exists(publickey): - os.remove(publickey) - - cmd = "ssh-keygen -t {} -b {} -N '' -f {}".format( - keytype, - bits, - privatekey - ) - - output, err = charms.sshproxy.run_local([cmd]) - if len(err) == 0: - return True - return False - - -@when('actions.generate-ssh-key') -def action_generate_ssh_key(): - """Generate a new 4096-bit rsa keypair. - - If there is an existing keypair for this unit, it will be overwritten. - """ - try: - if not generate_ssh_key(): - action_fail('Unable to generate ssh key.') - except subprocess.CalledProcessError as e: - action_fail('Command failed: %s (%s)' % - (' '.join(e.cmd), str(e.output))) - finally: - clear_flag('actions.generate-ssh-key') - - -def get_ssh_public_key(): - """Get the public SSH key of this unit.""" - publickey_path = '/root/.ssh/id_juju_sshproxy.pub' - publickey = None - if os.path.exists(publickey_path): - with open(publickey_path, 'r') as f: - publickey = f.read() - - return publickey - - -@when('actions.get-ssh-public-key') -def action_get_ssh_public_key(): - """Get the public SSH key of this unit.""" - try: - action_set({'pubkey': get_ssh_public_key()}) - except subprocess.CalledProcessError as e: - action_fail('Command failed: %s (%s)' % - (' '.join(e.cmd), str(e.output))) - finally: - clear_flag('actions.get-ssh-public-key') - - -@when('actions.verify-ssh-credentials') -def action_verify_ssh_credentials(): - """Verify the ssh credentials have been installed to the VNF. - - Attempts to run a stock command - `hostname` on the remote host. - """ - try: - (verified, output) = charms.sshproxy.verify_ssh_credentials() - action_set({ - 'output': output, - 'verified': verified, - }) - if not verified: - action_fail("Verification failed: {}".format( - output, - )) - finally: - clear_flag('actions.verify-ssh-credentials') - - -@when('actions.run') -def run_command(): - """Run an arbitrary command. - - Run an arbitrary command, either locally or over SSH with the configured - credentials. - """ - try: - cmd = action_get('command') - output, err = charms.sshproxy._run(cmd) - if len(err): - action_fail("Command '{}' returned error code {}".format(cmd, err)) - else: - action_set({'output': output}) - except subprocess.CalledProcessError as e: - action_fail('Command failed: %s (%s)' % - (' '.join(e.cmd), str(e.output))) - finally: - clear_flag('actions.run') - - -@when_not('sshproxy.installed') -def install_vnf_ubuntu_proxy(): - """Install and Configure SSH Proxy.""" - - log("Generating SSH key...", DEBUG) - generate_ssh_key() - set_flag('sshproxy.installed') diff --git a/nscharm_user_vnf/charms/vnf-user/reactive/vnfproxy.py b/nscharm_user_vnf/charms/vnf-user/reactive/vnfproxy.py deleted file mode 100644 index 6616991df245a920116b9301b52602f15ba7a9bc..0000000000000000000000000000000000000000 --- a/nscharm_user_vnf/charms/vnf-user/reactive/vnfproxy.py +++ /dev/null @@ -1,89 +0,0 @@ -from charmhelpers.core.hookenv import ( - action_fail, - action_set, -) - -from charms.reactive import ( - when, - clear_flag, -) -import charms.sshproxy - - -@when('actions.reboot') -def reboot(): - err = '' - try: - result, err = charms.sshproxy._run("reboot") - except: - action_fail('command failed:' + err) - else: - action_set({'outout': result}) - finally: - clear_flag('actions.reboot') - - -############################################################################### -# Below is an example implementation of the start/stop/restart actions. # -# To use this, copy the below code into your layer and add the appropriate # -# command(s) necessary to perform the action. # -############################################################################### - -# @when('actions.start') -# def start(): -# err = '' -# try: -# cmd = "service myname start" -# result, err = charms.sshproxy._run(cmd) -# except: -# action_fail('command failed:' + err) -# else: -# action_set({'outout': result}) -# finally: -# clear_flag('actions.start') -# -# -# @when('actions.stop') -# def stop(): -# err = '' -# try: -# # Enter the command to stop your service(s) -# cmd = "service myname stop" -# result, err = charms.sshproxy._run(cmd) -# except: -# action_fail('command failed:' + err) -# else: -# action_set({'outout': result}) -# finally: -# clear_flag('actions.stop') -# -# -# @when('actions.restart') -# def restart(): -# err = '' -# try: -# # Enter the command to restart your service(s) -# cmd = "service myname restart" -# result, err = charms.sshproxy._run(cmd) -# except: -# action_fail('command failed:' + err) -# else: -# action_set({'outout': result}) -# finally: -# clear_flag('actions.restart') -# -# -# @when('actions.upgrade') -# def upgrade_vnf(): -# err = '' -# try: -# # Add the command(s) to perform a VNF software upgrade -# cmd = '' -# result, err = charms.sshproxy._run(cmd) -# except: -# action_fail('command failed:' + err) -# else: -# action_set({'outout': result}) -# finally: -# clear_flag('actions.upgrade') -# diff --git a/nscharm_user_vnf/charms/vnf-user/requirements.txt b/nscharm_user_vnf/charms/vnf-user/requirements.txt deleted file mode 100644 index 55543d9b632ff05cf7e6ee20dfec3160d2c554c2..0000000000000000000000000000000000000000 --- a/nscharm_user_vnf/charms/vnf-user/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -mock -flake8 -pytest diff --git a/nscharm_user_vnf/charms/vnf-user/version b/nscharm_user_vnf/charms/vnf-user/version deleted file mode 100644 index 9fac92dcdf62023fb1920ef612b093cd9d1d000f..0000000000000000000000000000000000000000 --- a/nscharm_user_vnf/charms/vnf-user/version +++ /dev/null @@ -1 +0,0 @@ -8c2332f \ No newline at end of file diff --git a/nscharm_user_vnf/charms/vnf-user/wheelhouse.txt b/nscharm_user_vnf/charms/vnf-user/wheelhouse.txt deleted file mode 100644 index 1648a3618d1b0be88145a30665deecb2afd805ee..0000000000000000000000000000000000000000 --- a/nscharm_user_vnf/charms/vnf-user/wheelhouse.txt +++ /dev/null @@ -1,36 +0,0 @@ -# layer:basic -# pip is pinned to <19.0 to avoid https://github.com/pypa/pip/issues/6164 -# even with installing setuptools before upgrading pip ends up with pip seeing -# the older setuptools at the system level if include_system_packages is true -pip>=18.1,<19.0 -# pin Jinja2 and PyYAML to the last versions supporting python 3.4 for trusty -Jinja2<=2.10.1 -PyYAML<=5.2 -setuptools<42 -setuptools-scm<=1.17.0 -charmhelpers>=0.4.0,<1.0.0 -charms.reactive>=0.1.0,<2.0.0 -wheel<0.34 -# pin netaddr to avoid pulling importlib-resources -netaddr<=0.7.19 - -# layer:sshproxy -## -# Copyright 2016 Canonical Ltd. -# All rights reserved. -# -# 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. -## - -paramiko>=1.16.0,<1.17 - diff --git a/nscharm_user_vnf/charms/vnf-user/wheelhouse/setuptools-41.6.0.zip b/nscharm_user_vnf/charms/vnf-user/wheelhouse/setuptools-41.6.0.zip deleted file mode 100644 index 3345759c1ca861c181742e84fc5285e3284a2886..0000000000000000000000000000000000000000 Binary files a/nscharm_user_vnf/charms/vnf-user/wheelhouse/setuptools-41.6.0.zip and /dev/null differ