diff --git a/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/params.yaml b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/params.yaml new file mode 100644 index 0000000000000000000000000000000000000000..db14311c270b30ab3dd1154c0306762f688029e4 --- /dev/null +++ b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/params.yaml @@ -0,0 +1,12 @@ +additionalParamsForVnf: +- member-vnf-index: 'vnf-epc' + additionalParams: + password: 'osm4u' + +vld: +- name: mgmtnet + vim-network-name: osm-ext +- name: s1 + vim-network-name: S1 +- name: sgi + vim-network-name: SGi \ No newline at end of file diff --git a/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_ns/vEPC_nsd.yaml b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_ns/vEPC_nsd.yaml new file mode 100644 index 0000000000000000000000000000000000000000..9006f8aa0896d6826411d2a15696ea1aa3d29efd --- /dev/null +++ b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_ns/vEPC_nsd.yaml @@ -0,0 +1,41 @@ +nsd: + nsd: + - description: NS with EPC VNF + df: + - id: default-df + vnf-profile: + - id: vnf-epc + virtual-link-connectivity: + - constituent-cpd-id: + - constituent-base-element-id: vnf-epc + constituent-cpd-id: spgwmme-mgmt-ext + virtual-link-profile-id: mgmtnet + - constituent-cpd-id: + - constituent-base-element-id: vnf-epc + constituent-cpd-id: hss-mgmt-ext + virtual-link-profile-id: mgmtnet + - constituent-cpd-id: + - constituent-base-element-id: vnf-epc + constituent-cpd-id: spgwmme-s1-ext + ip-address: 192.168.0.11 + virtual-link-profile-id: s1 + - constituent-cpd-id: + - constituent-base-element-id: vnf-epc + constituent-cpd-id: spgwmme-sgi-ext + ip-address: 192.168.2.11 + virtual-link-profile-id: sgi + vnfd-id: vEPC-vnf + + + id: vEPC-ns + name: vEPC-ns + version: 1.0 + + virtual-link-desc: + - id: mgmtnet + mgmt-network: true + - id: s1 + - id: sgi + + vnfd-id: + - vEPC-vnf diff --git a/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/hss/.flake8 b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/hss/.flake8 new file mode 100644 index 0000000000000000000000000000000000000000..8ef84fcd43f3b7a46768c31b20f36cab48ffdfe0 --- /dev/null +++ b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/hss/.flake8 @@ -0,0 +1,9 @@ +[flake8] +max-line-length = 99 +select: E,W,F,C,N +exclude: + venv + .git + build + dist + *.egg_info diff --git a/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/hss/.gitignore b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/hss/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..2c3f0e5ed7915b3800370e2f37f7661e29df6742 --- /dev/null +++ b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/hss/.gitignore @@ -0,0 +1,7 @@ +venv/ +build/ +*.charm + +.coverage +__pycache__/ +*.py[cod] diff --git a/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/hss/.jujuignore b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/hss/.jujuignore new file mode 100644 index 0000000000000000000000000000000000000000..6ccd559eabeae93e4d23215fa450130fa9b37ace --- /dev/null +++ b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/hss/.jujuignore @@ -0,0 +1,3 @@ +/venv +*.py[cod] +*.charm diff --git a/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/hss/CONTRIBUTING.md b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/hss/CONTRIBUTING.md new file mode 100644 index 0000000000000000000000000000000000000000..d2258a423831611d7758da2ec947225fd69bfb48 --- /dev/null +++ b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/hss/CONTRIBUTING.md @@ -0,0 +1,34 @@ +# hss + +## Developing + +Create and activate a virtualenv with the development requirements: + + virtualenv -p python3 venv + source venv/bin/activate + pip install -r requirements-dev.txt + +## Code overview + +TEMPLATE-TODO: +One of the most important things a consumer of your charm (or library) +needs to know is what set of functionality it provides. Which categories +does it fit into? Which events do you listen to? Which libraries do you +consume? Which ones do you export and how are they used? + +## Intended use case + +TEMPLATE-TODO: +Why were these decisions made? What's the scope of your charm? + +## Roadmap + +If this Charm doesn't fulfill all of the initial functionality you were +hoping for or planning on, please add a Roadmap or TODO here + +## Testing + +The Python operator framework includes a very nice harness for testing +operator behaviour without full deployment. Just `run_tests`: + + ./run_tests diff --git a/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/hss/LICENSE b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/hss/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..d645695673349e3947e8e5ae42332d0ac3164cd7 --- /dev/null +++ b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/hss/LICENSE @@ -0,0 +1,202 @@ + + 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/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/hss/README.md b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/hss/README.md new file mode 100644 index 0000000000000000000000000000000000000000..37b15811183bd4223b47cd18a06caf15fad26b6e --- /dev/null +++ b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/hss/README.md @@ -0,0 +1,5 @@ +# hss + +## Description + +Proxy charm used by Open Source Mano (OSM) to configure NextEPC HSS, written in the Python Operator Framwork diff --git a/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/hss/actions.yaml b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/hss/actions.yaml new file mode 100644 index 0000000000000000000000000000000000000000..a7a07dd4752b2f46d69e2f4b2c2abaee14f4d79e --- /dev/null +++ b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/hss/actions.yaml @@ -0,0 +1,25 @@ +# Copyright 2022 preethika.p +# See LICENSE file for licensing details. +# +# TEMPLATE-TODO: change this example to suit your needs. +# If you don't need actions, you can remove the file entirely. +# It ties in to the example _on_fortune_action handler in src/charm.py +# +# Learn more about actions at: https://juju.is/docs/sdk/actions + +# Required by charms.osm.sshproxy +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." diff --git a/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/hss/charmcraft.yaml b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/hss/charmcraft.yaml new file mode 100644 index 0000000000000000000000000000000000000000..be706d54bd759f210e272622b885c191e3f6658b --- /dev/null +++ b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/hss/charmcraft.yaml @@ -0,0 +1,14 @@ +# Learn more about charmcraft.yaml configuration at: +# https://juju.is/docs/sdk/charmcraft-config +type: "charm" +bases: + - build-on: + - name: "ubuntu" + channel: "20.04" + run-on: + - name: "ubuntu" + channel: "20.04" +parts: + charm: + build-packages: + - git diff --git a/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/hss/config.yaml b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/hss/config.yaml new file mode 100644 index 0000000000000000000000000000000000000000..05d6cb59807c9c173f897dc6b81db2e8fcb1378e --- /dev/null +++ b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/hss/config.yaml @@ -0,0 +1,34 @@ +# Copyright 2022 preethika.p +# See LICENSE file for licensing details. +# +# TEMPLATE-TODO: change this example to suit your needs. +# If you don't need a config, you can remove the file entirely. +# It ties in to the example _on_config_changed handler in src/charm.py +# +# Learn more about config at: https://juju.is/docs/sdk/config + +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-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: 4096 + description: "The number of bits to use for the SSH key." diff --git a/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/hss/metadata.yaml b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/hss/metadata.yaml new file mode 100644 index 0000000000000000000000000000000000000000..6f148d8910ccaad62baf1e7e70a625dfe8fe6e4f --- /dev/null +++ b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/hss/metadata.yaml @@ -0,0 +1,24 @@ +# Copyright 2022 preethika.p +# See LICENSE file for licensing details. + +# For a complete list of supported options, see: +# https://juju.is/docs/sdk/metadata-reference +name: hss +display-name: | + hss +description: | + hss +summary: | + Charm for hss to exchange s6a interface ip establish HSS - MME session. + +peers: + proxypeer: + interface: proxypeer + +provides: + nextepchss: + interface: hss-interface + +requires: + mme: + interface: mme-interface diff --git a/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/hss/requirements-dev.txt b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/hss/requirements-dev.txt new file mode 100644 index 0000000000000000000000000000000000000000..4f2a3f5bcd8cf79122b586c767c812b481079593 --- /dev/null +++ b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/hss/requirements-dev.txt @@ -0,0 +1,3 @@ +-r requirements.txt +coverage +flake8 diff --git a/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/hss/requirements.txt b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/hss/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..8e3f4049a4600a17cfed7d8a4c821b28204a5aae --- /dev/null +++ b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/hss/requirements.txt @@ -0,0 +1,2 @@ +ops >= 1.4.0 +git+https://github.com/charmed-osm/charms.osm#egg=charms.osm \ No newline at end of file diff --git a/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/hss/run_tests b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/hss/run_tests new file mode 100755 index 0000000000000000000000000000000000000000..bb6d3b1f4ab02640bcb33d89ed9207f36f25a89e --- /dev/null +++ b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/hss/run_tests @@ -0,0 +1,17 @@ +#!/bin/sh -e +# Copyright 2022 preethika.p +# See LICENSE file for licensing details. + +if [ -z "$VIRTUAL_ENV" -a -d venv/ ]; then + . venv/bin/activate +fi + +if [ -z "$PYTHONPATH" ]; then + export PYTHONPATH="lib:src" +else + export PYTHONPATH="lib:src:$PYTHONPATH" +fi + +flake8 +coverage run --branch --source=src -m unittest -v "$@" +coverage report -m diff --git a/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/hss/src/charm.py b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/hss/src/charm.py new file mode 100755 index 0000000000000000000000000000000000000000..ed218cda6c9977daf06768eb2f6c4eb6ee842574 --- /dev/null +++ b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/hss/src/charm.py @@ -0,0 +1,96 @@ +#!/usr/bin/env python3 +# Copyright 2022 preethika.p +# See LICENSE file for licensing details. +# +# Learn more at: https://juju.is/docs/sdk + +"""Charm the service. + +Refer to the following post for a quick-start guide that will help you +develop a new k8s charm using the Operator Framework: + + https://discourse.charmhub.io/t/4208 +""" + +import logging + +from ops.charm import CharmBase +from ops.framework import StoredState +from ops.main import main +from ops.model import ActiveStatus +from charms.osm.sshproxy import SSHProxyCharm + +logger = logging.getLogger(__name__) + + +class HssCharm(SSHProxyCharm): + """Charm the service.""" + + _stored = StoredState() + + def __init__(self, *args): + super().__init__(*args) + self.state.set_default(ready=False) + self.framework.observe(self.on.config_changed, self.on_config_changed) + self.framework.observe(self.on.install, self.on_install) + self.framework.observe(self.on.start, self.on_start) + + self.framework.observe(self.on.nextepchss_relation_joined, self.on_nextepchss_relation_joined) + self.framework.observe(self.on.mme_relation_changed, self.on_mme_relation_changed) + self._stored.set_default(things=[]) + + def on_config_changed(self, event): + super().on_config_changed(event) + self.state.ready = True + + def on_install(self, event): + """Called when the charm is being installed""" + super().on_install(event) + + def on_start(self, event): + """Called when the charm is being started""" + super().on_start(event) + if not self.verify_credentials(): + event.defer() + return + proxy = self.get_ssh_proxy() + ips, _ = proxy.run("hostname -I") + ip_list = ips.split(" ") + self.state.hss_ip = ip_list[1] + + + def on_nextepchss_relation_joined(self, event): + if self.unit.is_leader(): + if not self.state.ready: + event.defer() + return + relation = self.model.get_relation("nextepchss") + if relation is not None: + relation.data[self.unit]["hss_ip"] = self.state.hss_ip + self.model.unit.status = ActiveStatus("Parameter sent from hss:{}". format(self.state.hss_ip)) + + def on_mme_relation_changed(self, event): + if self.model.unit.is_leader(): + stderr = None + try: + spgw_ip = event.relation.data[event.unit].get("spgwmme_ip") + if spgw_ip is None: + return + proxy = self.get_ssh_proxy() + cmd1='sudo sed -i "\'s/$hss_ip/{}/g\'" /etc/nextepc/freeDiameter/hss.conf'.format(self.state.hss_ip) + stdout, stderr = proxy.run(cmd1) + cmd2='sudo sed -i "\'s/$spgw_ip/{}/g\'" /etc/nextepc/freeDiameter/hss.conf'.format(spgw_ip) + stdout, stderr = proxy.run(cmd2) + self._restart_hss() + except Exception as e: + event.fail("Action failed {}. Stderr: {}".format(e, stderr)) + else: + event.fail("Unit is not leader") + + def _restart_hss(self): + cmd = "sudo systemctl restart nextepc-hssd" + proxy = self.get_ssh_proxy() + stdout, stderr = proxy.run(cmd) + +if __name__ == "__main__": + main(HssCharm) diff --git a/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/hss/tests/__init__.py b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/hss/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e163492b41c6a2063dc0a25a8650ed964e67d543 --- /dev/null +++ b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/hss/tests/__init__.py @@ -0,0 +1,2 @@ +import ops.testing +ops.testing.SIMULATE_CAN_CONNECT = True diff --git a/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/hss/tests/test_charm.py b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/hss/tests/test_charm.py new file mode 100644 index 0000000000000000000000000000000000000000..7c1b4b1368bc947830940d1dc050d13099903ba6 --- /dev/null +++ b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/hss/tests/test_charm.py @@ -0,0 +1,68 @@ +# Copyright 2022 preethika.p +# See LICENSE file for licensing details. +# +# Learn more about testing at: https://juju.is/docs/sdk/testing + +import unittest +from unittest.mock import Mock + +from charm import HssCharm +from ops.model import ActiveStatus +from ops.testing import Harness + + +class TestCharm(unittest.TestCase): + def setUp(self): + self.harness = Harness(HssCharm) + self.addCleanup(self.harness.cleanup) + self.harness.begin() + + def test_config_changed(self): + self.assertEqual(list(self.harness.charm._stored.things), []) + self.harness.update_config({"thing": "foo"}) + self.assertEqual(list(self.harness.charm._stored.things), ["foo"]) + + def test_action(self): + # the harness doesn't (yet!) help much with actions themselves + action_event = Mock(params={"fail": ""}) + self.harness.charm._on_fortune_action(action_event) + + self.assertTrue(action_event.set_results.called) + + def test_action_fail(self): + action_event = Mock(params={"fail": "fail this"}) + self.harness.charm._on_fortune_action(action_event) + + self.assertEqual(action_event.fail.call_args, [("fail this",)]) + + def test_httpbin_pebble_ready(self): + # Simulate making the Pebble socket available + self.harness.set_can_connect("httpbin", True) + # Check the initial Pebble plan is empty + initial_plan = self.harness.get_container_pebble_plan("httpbin") + self.assertEqual(initial_plan.to_yaml(), "{}\n") + # Expected plan after Pebble ready with default config + expected_plan = { + "services": { + "httpbin": { + "override": "replace", + "summary": "httpbin", + "command": "gunicorn -b 0.0.0.0:80 httpbin:app -k gevent", + "startup": "enabled", + "environment": {"thing": "🎁"}, + } + }, + } + # Get the httpbin container from the model + container = self.harness.model.unit.get_container("httpbin") + # Emit the PebbleReadyEvent carrying the httpbin container + self.harness.charm.on.httpbin_pebble_ready.emit(container) + # Get the plan now we've run PebbleReady + updated_plan = self.harness.get_container_pebble_plan("httpbin").to_dict() + # Check we've got the plan we expected + self.assertEqual(expected_plan, updated_plan) + # Check the service was started + service = self.harness.model.unit.get_container("httpbin").get_service("httpbin") + self.assertTrue(service.is_running()) + # Ensure we set an ActiveStatus with no message + self.assertEqual(self.harness.model.unit.status, ActiveStatus()) diff --git a/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/hss_ubuntu-20.04-amd64.charm b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/hss_ubuntu-20.04-amd64.charm new file mode 100644 index 0000000000000000000000000000000000000000..01e00d3fc641b266693317da73152a1fa4dd0028 Binary files /dev/null and b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/hss_ubuntu-20.04-amd64.charm differ diff --git a/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/spgwmme/.flake8 b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/spgwmme/.flake8 new file mode 100644 index 0000000000000000000000000000000000000000..8ef84fcd43f3b7a46768c31b20f36cab48ffdfe0 --- /dev/null +++ b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/spgwmme/.flake8 @@ -0,0 +1,9 @@ +[flake8] +max-line-length = 99 +select: E,W,F,C,N +exclude: + venv + .git + build + dist + *.egg_info diff --git a/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/spgwmme/.gitignore b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/spgwmme/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..2c3f0e5ed7915b3800370e2f37f7661e29df6742 --- /dev/null +++ b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/spgwmme/.gitignore @@ -0,0 +1,7 @@ +venv/ +build/ +*.charm + +.coverage +__pycache__/ +*.py[cod] diff --git a/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/spgwmme/.jujuignore b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/spgwmme/.jujuignore new file mode 100644 index 0000000000000000000000000000000000000000..6ccd559eabeae93e4d23215fa450130fa9b37ace --- /dev/null +++ b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/spgwmme/.jujuignore @@ -0,0 +1,3 @@ +/venv +*.py[cod] +*.charm diff --git a/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/spgwmme/CONTRIBUTING.md b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/spgwmme/CONTRIBUTING.md new file mode 100644 index 0000000000000000000000000000000000000000..49e2ee05d54c1ffcdf9b11c4351e2c342ccf6d50 --- /dev/null +++ b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/spgwmme/CONTRIBUTING.md @@ -0,0 +1,34 @@ +# spgwmme + +## Developing + +Create and activate a virtualenv with the development requirements: + + virtualenv -p python3 venv + source venv/bin/activate + pip install -r requirements-dev.txt + +## Code overview + +TEMPLATE-TODO: +One of the most important things a consumer of your charm (or library) +needs to know is what set of functionality it provides. Which categories +does it fit into? Which events do you listen to? Which libraries do you +consume? Which ones do you export and how are they used? + +## Intended use case + +TEMPLATE-TODO: +Why were these decisions made? What's the scope of your charm? + +## Roadmap + +If this Charm doesn't fulfill all of the initial functionality you were +hoping for or planning on, please add a Roadmap or TODO here + +## Testing + +The Python operator framework includes a very nice harness for testing +operator behaviour without full deployment. Just `run_tests`: + + ./run_tests diff --git a/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/spgwmme/LICENSE b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/spgwmme/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..d645695673349e3947e8e5ae42332d0ac3164cd7 --- /dev/null +++ b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/spgwmme/LICENSE @@ -0,0 +1,202 @@ + + 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/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/spgwmme/README.md b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/spgwmme/README.md new file mode 100644 index 0000000000000000000000000000000000000000..377efabf8699bf04c41a343397f9a24482d6175d --- /dev/null +++ b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/spgwmme/README.md @@ -0,0 +1,4 @@ +# spgwmme + +## Description +Proxy charm used by Open Source Mano (OSM) to configure NextEPC MME, written in the Python Operator Framwork diff --git a/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/spgwmme/actions.yaml b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/spgwmme/actions.yaml new file mode 100644 index 0000000000000000000000000000000000000000..402e8c99b9d9a839e28ed44b185f2462c64e62b6 --- /dev/null +++ b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/spgwmme/actions.yaml @@ -0,0 +1,39 @@ +# Copyright 2022 Ubuntu +# See LICENSE file for licensing details. +# +# TEMPLATE-TODO: change this example to suit your needs. +# If you don't need actions, you can remove the file entirely. +# It ties in to the example _on_fortune_action handler in src/charm.py +# +# Learn more about actions at: https://juju.is/docs/sdk/actions + +add-route: + description: "Adds a route to the SPGW" + params: + external-prefix: + description: "Destinaton prefix IP" + type: string + default: "8.8.8.8/32" + next-hop: + description: "SGI next hop" + type: string + default: "192.168.2.1" + + +# Required by charms.osm.sshproxy +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." + diff --git a/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/spgwmme/charmcraft.yaml b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/spgwmme/charmcraft.yaml new file mode 100644 index 0000000000000000000000000000000000000000..1fb08d72b82bc4bd3385e89d714cd55e178e5c25 --- /dev/null +++ b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/spgwmme/charmcraft.yaml @@ -0,0 +1,16 @@ +# Learn more about charmcraft.yaml configuration at: +# https://juju.is/docs/sdk/charmcraft-config +type: "charm" +bases: + - build-on: + - name: "ubuntu" + channel: "20.04" + run-on: + - name: "ubuntu" + channel: "20.04" +parts: + charm: + build-packages: + - git + + diff --git a/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/spgwmme/config.yaml b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/spgwmme/config.yaml new file mode 100644 index 0000000000000000000000000000000000000000..1f5896493055ead09d904b20049e50aef1370604 --- /dev/null +++ b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/spgwmme/config.yaml @@ -0,0 +1,34 @@ +# Copyright 2022 Ubuntu +# See LICENSE file for licensing details. +# +# TEMPLATE-TODO: change this example to suit your needs. +# If you don't need a config, you can remove the file entirely. +# It ties in to the example _on_config_changed handler in src/charm.py +# +# Learn more about config at: https://juju.is/docs/sdk/config + +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-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: 4096 + description: "The number of bits to use for the SSH key." diff --git a/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/spgwmme/metadata.yaml b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/spgwmme/metadata.yaml new file mode 100644 index 0000000000000000000000000000000000000000..e642838758736dfce7c5678bdd1a2d909d31521e --- /dev/null +++ b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/spgwmme/metadata.yaml @@ -0,0 +1,26 @@ +# Copyright 2022 Ubuntu +# See LICENSE file for licensing details. + +# For a complete list of supported options, see: +# https://juju.is/docs/sdk/metadata-reference +name: spgwmme +display-name: | + NextEPC spgwmme +description: | + NextEPC spgwmme +summary: | + Charm for spgwmme to exchange s6a interface ip establish HSS - MME session. + +peers: + proxypeer: + interface: proxypeer + +provides: + nextepcmme: + interface: mme-interface + +requires: + hss: + interface: hss-interface + + diff --git a/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/spgwmme/requirements-dev.txt b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/spgwmme/requirements-dev.txt new file mode 100644 index 0000000000000000000000000000000000000000..4f2a3f5bcd8cf79122b586c767c812b481079593 --- /dev/null +++ b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/spgwmme/requirements-dev.txt @@ -0,0 +1,3 @@ +-r requirements.txt +coverage +flake8 diff --git a/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/spgwmme/requirements.txt b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/spgwmme/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..3db6e5e9f88169ff796d887e88425746e7b6655c --- /dev/null +++ b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/spgwmme/requirements.txt @@ -0,0 +1,2 @@ +ops >= 1.4.0 +git+https://github.com/charmed-osm/charms.osm#egg=charms.osm diff --git a/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/spgwmme/run_tests b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/spgwmme/run_tests new file mode 100755 index 0000000000000000000000000000000000000000..a0d9b53f5937ded7730c8939518b129f521361dc --- /dev/null +++ b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/spgwmme/run_tests @@ -0,0 +1,17 @@ +#!/bin/sh -e +# Copyright 2022 Ubuntu +# See LICENSE file for licensing details. + +if [ -z "$VIRTUAL_ENV" -a -d venv/ ]; then + . venv/bin/activate +fi + +if [ -z "$PYTHONPATH" ]; then + export PYTHONPATH="lib:src" +else + export PYTHONPATH="lib:src:$PYTHONPATH" +fi + +flake8 +coverage run --branch --source=src -m unittest -v "$@" +coverage report -m diff --git a/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/spgwmme/src/charm.py b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/spgwmme/src/charm.py new file mode 100755 index 0000000000000000000000000000000000000000..a6dce074c0d98a546ff31e00dabd012e7c4e3fdc --- /dev/null +++ b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/spgwmme/src/charm.py @@ -0,0 +1,112 @@ +#!/usr/bin/env python3 +# Copyright 2022 Ubuntu +# See LICENSE file for licensing details. +# +# Learn more at: https://juju.is/docs/sdk + +"""Charm the service. + +Refer to the following post for a quick-start guide that will help you +develop a new k8s charm using the Operator Framework: + + https://discourse.charmhub.io/t/4208 +""" + +import logging + + +from ops.charm import CharmBase +from ops.framework import StoredState +from ops.main import main +from ops.model import ActiveStatus +from charms.osm.sshproxy import SSHProxyCharm + +logger = logging.getLogger(__name__) + +class SpgwmmeCharm(SSHProxyCharm): + """Charm the service.""" + + _stored = StoredState() + + def __init__(self, *args): + super().__init__(*args) + self.state.set_default(ready=False) + self.framework.observe(self.on.config_changed, self.on_config_changed) + self.framework.observe(self.on.install, self.on_install) + self.framework.observe(self.on.start, self.on_start) + + self.framework.observe(self.on.hss_relation_changed, self.on_hss_relation_changed) + self.framework.observe(self.on.nextepcmme_relation_joined, self.on_nextepcmme_relation_joined) + + self.framework.observe(self.on.add_route_action, self._on_add_route) + + self._stored.set_default(things=[]) + + def on_config_changed(self, event): + super().on_config_changed(event) + self.state.ready = True + + def on_install(self, event): + """Called when the charm is being installed""" + super().on_install(event) + + def on_start(self, event): + """Called when the charm is being started""" + super().on_start(event) + if not self.verify_credentials(): + event.defer() + return + proxy = self.get_ssh_proxy() + ips, _ = proxy.run("hostname -I") + ip_list = ips.split(" ") + self.state.spgwmme_ip = ip_list[3] + + def on_nextepcmme_relation_joined(self, event): + if self.unit.is_leader(): + if not self.state.ready: + event.defer() + return + relation = self.model.get_relation("nextepcmme") + if relation is not None: + relation.data[self.unit]["spgwmme_ip"] = self.state.spgwmme_ip + self.model.unit.status = ActiveStatus("Parameter sent from spgwmme:{}". format(self.state.spgwmme_ip)) + + def on_hss_relation_changed(self, event): + if self.model.unit.is_leader(): + stderr = None + try: + hss_ip = event.relation.data[event.unit].get("hss_ip") + if hss_ip is None: + return + proxy = self.get_ssh_proxy() + cmd1='sudo sed -i "\'s/$hss_ip/{}/g\'" /etc/nextepc/freeDiameter/mme.conf'.format(hss_ip) + stdout, stderr = proxy.run(cmd1) + cmd2='sudo sed -i "\'s/$spgw_ip/{}/g\'" /etc/nextepc/freeDiameter/mme.conf'.format(self.state.spgwmme_ip) + stdout, stderr = proxy.run(cmd2) + self._restart_spgw() + except Exception as e: + event.fail("Action failed {}. Stderr: {}".format(e, stderr)) + else: + event.fail("Unit is not leader") + + def _restart_spgw(self): + cmd = "sudo systemctl restart nextepc-mmed" + proxy = self.get_ssh_proxy() + stdout, stderr = proxy.run(cmd) + + def _on_add_route(self, event): + if self.model.unit.is_leader(): + stderr = None + try: + external_prefix = event.params["external-prefix"] + next_hop = event.params["next-hop"] + proxy = self.get_ssh_proxy() + cmd = "sudo route add -net " + external_prefix + " gw " + next_hop + stdout, stderr = proxy.run(cmd) + except Exception as e: + event.fail("Action failed {}. Stderr: {}".format(e, stderr)) + else: + event.fail("Unit is not leader") + +if __name__ == "__main__": + main(SpgwmmeCharm) diff --git a/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/spgwmme/tests/__init__.py b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/spgwmme/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e163492b41c6a2063dc0a25a8650ed964e67d543 --- /dev/null +++ b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/spgwmme/tests/__init__.py @@ -0,0 +1,2 @@ +import ops.testing +ops.testing.SIMULATE_CAN_CONNECT = True diff --git a/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/spgwmme/tests/test_charm.py b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/spgwmme/tests/test_charm.py new file mode 100644 index 0000000000000000000000000000000000000000..c0686874cf414088b42f74eb218fb7cf8018ea7c --- /dev/null +++ b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/spgwmme/tests/test_charm.py @@ -0,0 +1,68 @@ +# Copyright 2022 Ubuntu +# See LICENSE file for licensing details. +# +# Learn more about testing at: https://juju.is/docs/sdk/testing + +import unittest +from unittest.mock import Mock + +from charm import SpgwmmeCharm +from ops.model import ActiveStatus +from ops.testing import Harness + + +class TestCharm(unittest.TestCase): + def setUp(self): + self.harness = Harness(SpgwmmeCharm) + self.addCleanup(self.harness.cleanup) + self.harness.begin() + + def test_config_changed(self): + self.assertEqual(list(self.harness.charm._stored.things), []) + self.harness.update_config({"thing": "foo"}) + self.assertEqual(list(self.harness.charm._stored.things), ["foo"]) + + def test_action(self): + # the harness doesn't (yet!) help much with actions themselves + action_event = Mock(params={"fail": ""}) + self.harness.charm._on_fortune_action(action_event) + + self.assertTrue(action_event.set_results.called) + + def test_action_fail(self): + action_event = Mock(params={"fail": "fail this"}) + self.harness.charm._on_fortune_action(action_event) + + self.assertEqual(action_event.fail.call_args, [("fail this",)]) + + def test_httpbin_pebble_ready(self): + # Simulate making the Pebble socket available + self.harness.set_can_connect("httpbin", True) + # Check the initial Pebble plan is empty + initial_plan = self.harness.get_container_pebble_plan("httpbin") + self.assertEqual(initial_plan.to_yaml(), "{}\n") + # Expected plan after Pebble ready with default config + expected_plan = { + "services": { + "httpbin": { + "override": "replace", + "summary": "httpbin", + "command": "gunicorn -b 0.0.0.0:80 httpbin:app -k gevent", + "startup": "enabled", + "environment": {"thing": "🎁"}, + } + }, + } + # Get the httpbin container from the model + container = self.harness.model.unit.get_container("httpbin") + # Emit the PebbleReadyEvent carrying the httpbin container + self.harness.charm.on.httpbin_pebble_ready.emit(container) + # Get the plan now we've run PebbleReady + updated_plan = self.harness.get_container_pebble_plan("httpbin").to_dict() + # Check we've got the plan we expected + self.assertEqual(expected_plan, updated_plan) + # Check the service was started + service = self.harness.model.unit.get_container("httpbin").get_service("httpbin") + self.assertTrue(service.is_running()) + # Ensure we set an ActiveStatus with no message + self.assertEqual(self.harness.model.unit.status, ActiveStatus()) diff --git a/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/spgwmme_ubuntu-20.04-amd64.charm b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/spgwmme_ubuntu-20.04-amd64.charm new file mode 100644 index 0000000000000000000000000000000000000000..1e5a7688e15dcd5a6eeec57e4b64db9e7b047b23 Binary files /dev/null and b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/charms/spgwmme_ubuntu-20.04-amd64.charm differ diff --git a/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/cloud_init/hss-init b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/cloud_init/hss-init new file mode 100644 index 0000000000000000000000000000000000000000..88556450a78c53412ac7fd9d00d5cd3b00c93912 --- /dev/null +++ b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/cloud_init/hss-init @@ -0,0 +1,9 @@ +#cloud-config +hostname: nextepc-hss +password: {{ password }} +chpasswd: { expire: False } +ssh_pwauth: True + +runcmd: + - sudo ip link set ens4 up && sudo dhclient ens4 + diff --git a/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/cloud_init/spgwmme-init b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/cloud_init/spgwmme-init new file mode 100644 index 0000000000000000000000000000000000000000..5c561f64868aba3090f6b1ca171c5a6fc17ef47a --- /dev/null +++ b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/cloud_init/spgwmme-init @@ -0,0 +1,13 @@ +#cloud-config +hostname: nextepc-spgw +password: {{ password }} +chpasswd: { expire: False } +ssh_pwauth: True + +runcmd: + - sudo dhclient ens4 && sudo route del default dev ens4 + - sudo dhclient ens5 && sudo route del default dev ens5 + - sudo dhclient ens6 && sudo route del default dev ens6 + + + diff --git a/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/vEPC_vnfd.yaml b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/vEPC_vnfd.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ef78a6bd25920e1b04d273ad8a543dee91d60415 --- /dev/null +++ b/Hackfest_Demos/OSM-MR13/1.2-VNF/NextEPC/vEPC_vnf/vEPC_vnfd.yaml @@ -0,0 +1,215 @@ +vnfd: + description: vEPC VNF + df: + - id: default-df + instantiation-level: + - id: default-instantiation-level + vdu-level: + - number-of-instances: 1 + vdu-id: spgwmme + - number-of-instances: 1 + vdu-id: hss + vdu-profile: + - id: spgwmme + min-number-of-instances: 1 + - id: hss + min-number-of-instances: 1 + virtual-link-profile: + - flavour: + id: s6a + virtual-link-protocol-data: + l3-protocol-data: + cidr: 10.0.6.0/24 + description: s6a test network + dhcp-enabled: true + ip-version: ipv4 + name: s6a-protocol-data + lcm-operations-configuration: + operate-vnf-op-config: + day1-2: + - id: vEPC-vnf + relation: + - name: spgwmme-hss + provider: + endpoint: nextepcmme + vdu-profile-id: spgwmme + requirer: + endpoint: mme + vdu-profile-id: hss + - name: hss-spgwmme + provider: + endpoint: nextepchss + vdu-profile-id: hss + requirer: + vdu-profile-id: spgwmme + endpoint: hss + - id: spgwmme + config-access: + ssh-access: + default-user: ubuntu + required: true + execution-environment-list: + - id: spgwmme-proxy-ee + juju: + charm: spgwmme_ubuntu-20.04-amd64.charm + proxy: true + initial-config-primitive: + - name: config + execution-environment-ref: spgwmme-proxy-ee + parameter: + - name: ssh-hostname + value: + - name: ssh-username + value: ubuntu + - name: ssh-password + value: + seq: 1 + config-primitive: + - name: add-route + execution-environment-ref: spgwmme-proxy-ee + parameter: + - name: external-prefix + default-value: '8.8.8.8/32' + - name: next-hop + default-value: '192.168.2.1' + - id: hss + config-access: + ssh-access: + default-user: ubuntu + required: true + execution-environment-list: + - id: hss-proxy-ee + juju: + charm: hss_ubuntu-20.04-amd64.charm + proxy: true + initial-config-primitive: + - name: config + execution-environment-ref: hss-proxy-ee + parameter: + - name: ssh-hostname + value: + - name: ssh-username + value: ubuntu + - name: ssh-password + value: + seq: 1 + + ext-cpd: + - id: spgwmme-mgmt-ext + int-cpd: + cpd: spgwmme-mgmt + vdu-id: spgwmme + - id: spgwmme-s1-ext + int-cpd: + cpd: spgwmme-s1 + vdu-id: spgwmme + - id: spgwmme-sgi-ext + int-cpd: + cpd: spgwmme-sgi + vdu-id: spgwmme + - id: hss-mgmt-ext + int-cpd: + cpd: hss-mgmt + vdu-id: hss + id: vEPC-vnf + int-virtual-link-desc: + - id: s6a + mgmt-cp: spgwmme-mgmt-ext + product-name: vEPC-vnf + sw-image-desc: + - id: nextepc-spgwmme-base + image: nextepc-spgwmme-base + name: nextepc-spgwmme-base + - id: nextepc-hss-base + image: nextepc-hss-base + name: nextepc-hss-base + - id: ubuntu20.04-aws + name: ubuntu20.04-aws + image: ubuntu/images/hvm-ssd/ubuntu-artful-17.10-amd64-server-20180509 + vim-type: aws + vdu: + - id: spgwmme + cloud-init-file: spgwmme-init + int-cpd: + - id: spgwmme-mgmt + virtual-network-interface-requirement: + - name: eth0 + position: 1 + virtual-interface: + type: PARAVIRT + - id: spgwmme-s1 + virtual-network-interface-requirement: + - name: eth1 + position: 2 + virtual-interface: + type: PARAVIRT + - id: spgwmme-sgi + virtual-network-interface-requirement: + - name: eth2 + position: 3 + virtual-interface: + type: PARAVIRT + - id: spgwmme-s6a + int-virtual-link-desc: s6a + virtual-network-interface-requirement: + - name: eth3 + position: 4 + virtual-interface: + type: PARAVIRT + name: spgwmme + sw-image-desc: nextepc-spgwmme-base + virtual-compute-desc: spgwmme-compute + virtual-storage-desc: + - spgwmme-storage + monitoring-parameter: + - id: spgwmme_vnf_cpu_util + name: spgwmme_vnf_cpu_util + performance-metric: cpu_utilization + - id: spgwmme_vnf_memory_util + name: spgwmme_vnf_memory_util + performance-metric: average_memory_utilization + - id: spgwmme_vnf_packets_sent + name: spgwmme_vnf_packets_sent + performance-metric: packets_sent + - id: spgwmme_vnf_packets_received + name: spgwmme_vnf_packets_received + performance-metric: packets_received + - id: hss + cloud-init-file: hss-init + int-cpd: + - id: hss-mgmt + virtual-network-interface-requirement: + - name: eth0 + position: 1 + virtual-interface: + type: PARAVIRT + - id: hss-s6a + int-virtual-link-desc: s6a + virtual-network-interface-requirement: + - name: eth1 + position: 2 + virtual-interface: + type: PARAVIRT + name: hss + sw-image-desc: nextepc-hss-base + virtual-compute-desc: hss-compute + virtual-storage-desc: + - hss-storage + version: 1.0 + virtual-compute-desc: + - id: spgwmme-compute + virtual-memory: + size: 4.0 + virtual-cpu: + num-virtual-cpu: 2 + - id: hss-compute + virtual-memory: + size: 2.0 + virtual-cpu: + num-virtual-cpu: 1 + virtual-storage-desc: + - id: spgwmme-storage + size-of-storage: 10 + - id: hss-storage + size-of-storage: 10 + diff --git a/Hackfest_Demos/OSM-MR13/1.2-VNF/wiki_webserver_autoscale_nsd/wiki_webserver_autoscale_nsd.yaml b/Hackfest_Demos/OSM-MR13/1.2-VNF/wiki_webserver_autoscale_nsd/wiki_webserver_autoscale_nsd.yaml new file mode 100644 index 0000000000000000000000000000000000000000..59d0ccca89d6739a28f5149bc3fe6ccf27ef34eb --- /dev/null +++ b/Hackfest_Demos/OSM-MR13/1.2-VNF/wiki_webserver_autoscale_nsd/wiki_webserver_autoscale_nsd.yaml @@ -0,0 +1,24 @@ +nsd: + nsd: + - description: Scaling wiki web server with load balancer NS + designer: Altran + df: + - id: default-df + vnf-profile: + - id: vnf + virtual-link-connectivity: + - constituent-cpd-id: + - constituent-base-element-id: vnf + constituent-cpd-id: haproxy_public-ext + virtual-link-profile-id: public_vld + vnfd-id: wiki_webserver_autoscale_vnf + id: wiki_webserver_autoscale_ns + name: wiki_webserver_autoscale_ns + version: 1.0 + virtual-link-desc: + - id: public_vld + mgmt-network: true + vim-network-name: osm-ext + vnfd-id: + - wiki_webserver_autoscale_vnf + diff --git a/Hackfest_Demos/OSM-MR13/1.2-VNF/wiki_webserver_autoscale_vnfd/cloud_init/.DS_Store b/Hackfest_Demos/OSM-MR13/1.2-VNF/wiki_webserver_autoscale_vnfd/cloud_init/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 Binary files /dev/null and b/Hackfest_Demos/OSM-MR13/1.2-VNF/wiki_webserver_autoscale_vnfd/cloud_init/.DS_Store differ diff --git a/Hackfest_Demos/OSM-MR13/1.2-VNF/wiki_webserver_autoscale_vnfd/cloud_init/cloud_init_apache b/Hackfest_Demos/OSM-MR13/1.2-VNF/wiki_webserver_autoscale_vnfd/cloud_init/cloud_init_apache new file mode 100644 index 0000000000000000000000000000000000000000..2d3e0a33b8418f6de9e9542952e6e1fd5f7de61d --- /dev/null +++ b/Hackfest_Demos/OSM-MR13/1.2-VNF/wiki_webserver_autoscale_vnfd/cloud_init/cloud_init_apache @@ -0,0 +1,10 @@ +#cloud-config +hostname: apachevdu +password: osm2021 +chpasswd: { expire: False } +ssh_pwauth: True + +runcmd: + - ip=$(ifconfig | grep -A 1 "ens3" | tail -1 | cut -d ":" -f 2 | cut -d " " -f 1) + - sudo -S sed -i "/Active web server VDUs in this VNF/d" /var/www/html/index.php + - sudo -S sed -i "/OSM!/a\ echo \'

Data Serving From ${ip} <\/p>\';" /var/www/html/index.php diff --git a/Hackfest_Demos/OSM-MR13/1.2-VNF/wiki_webserver_autoscale_vnfd/cloud_init/cloud_init_haproxy b/Hackfest_Demos/OSM-MR13/1.2-VNF/wiki_webserver_autoscale_vnfd/cloud_init/cloud_init_haproxy new file mode 100644 index 0000000000000000000000000000000000000000..8fc9a001c41587f34dc69366ee0cb3001fe20392 --- /dev/null +++ b/Hackfest_Demos/OSM-MR13/1.2-VNF/wiki_webserver_autoscale_vnfd/cloud_init/cloud_init_haproxy @@ -0,0 +1,17 @@ +#cloud-config +hostname: haproxyvdu +password: osm2021 +chpasswd: { expire: False } +ssh_pwauth: True + +runcmd: + - ip=$(ifconfig | grep -A 1 "ens4" | tail -1 | cut -d ":" -f 2 | cut -d " " -f 1) + - sudo -S sed -i "s/ipv4@\(.*:9999\)/ipv4@${ip}\:9999/" /etc/haproxy/haproxy.cfg + - sudo -S sed -i "/option forwardfor/d" /etc/haproxy/haproxy.cfg + - sudo -S sed -i "/http\-request set\-header X\-Forwarded-Port \%\[dst\_port\]/d" /etc/haproxy/haproxy.cfg + - sudo -S sed -i "/http\-request add\-header X\-Forwarded-Proto https if { ssl_fc }/d" /etc/haproxy/haproxy.cfg + - sudo -S sed -i "/option httpchk HEAD/d" /etc/haproxy/haproxy.cfg + - sudo -S sed -i "/roundrobin/a\ server node0 192.168.28.2:8080 check" /etc/haproxy/haproxy.cfg + - sleep 60 + - echo "osm2021" | sudo service haproxy restart + diff --git a/Hackfest_Demos/OSM-MR13/1.2-VNF/wiki_webserver_autoscale_vnfd/wiki_webserver_autoscale_vnfd.yaml b/Hackfest_Demos/OSM-MR13/1.2-VNF/wiki_webserver_autoscale_vnfd/wiki_webserver_autoscale_vnfd.yaml new file mode 100644 index 0000000000000000000000000000000000000000..15eec08208eff284f498864081bdeda2fe9de894 --- /dev/null +++ b/Hackfest_Demos/OSM-MR13/1.2-VNF/wiki_webserver_autoscale_vnfd/wiki_webserver_autoscale_vnfd.yaml @@ -0,0 +1,137 @@ +vnfd: + description: Scaling wiki web server with load balancer and metrics + df: + - id: default-df + instantiation-level: + - id: default-instantiation-level + vdu-level: + - number-of-instances: 1 + vdu-id: haproxy_vdu + - number-of-instances: 2 + vdu-id: apache_vdu + vdu-profile: + - id: haproxy_vdu + min-number-of-instances: 1 + - id: apache_vdu + max-number-of-instances: 11 + min-number-of-instances: 2 + virtual-link-profile: + - flavour: + id: internal_services + virtual-link-protocol-data: + l3-protocol-data: + cidr: 192.168.28.0/28 + description: Services Subnet + dhcp-enabled: true + gateway-ip: 192.168.28.14 + ip-version: ipv4 + name: internal_services-l3-protocol-data + healing-aspect: + - id: apache-VM_autoheal + healing-policy: + - vdu-id: apache_vdu + event-name: heal-alarm + recovery-type: automatic + action-on-recovery: REDEPLOY_ONLY + cooldown-time: 180 + day1: false + ext-cpd: + - id: haproxy_public-ext + int-cpd: + cpd: haproxy_vdu_eth1-int + vdu-id: haproxy_vdu + id: wiki_webserver_autoscale_vnf + int-virtual-link-desc: + - id: internal_services + mgmt-cp: haproxy_public-ext + product-name: wiki_webserver_autoscale_vnf + provider: Altran + sw-image-desc: + - id: haproxy_ubuntu + image: haproxy_ubuntu + name: haproxy_ubuntu + - id: apache_ubuntu + image: apache_ubuntu + name: apache_ubuntu + vdu: + - cloud-init-file: cloud_init_haproxy + description: haproxy_vdu + id: haproxy_vdu + int-cpd: + - id: haproxy_vdu_eth1-int + virtual-network-interface-requirement: + - name: haproxy_vdu_eth0 + position: 1 + virtual-interface: + type: VIRTIO + - id: haproxy_vdu_eth2-int + int-virtual-link-desc: internal_services + virtual-network-interface-requirement: + - name: haproxy_vdu_eth2 + position: 2 + virtual-interface: + type: VIRTIO + name: haproxy_vdu + sw-image-desc: haproxy_ubuntu + virtual-compute-desc: haproxy_vdu-compute + virtual-storage-desc: + - haproxy_vdu-storage + - alarm: + - actions: + alarm: + - url: https://webhook.site/2b627634-6e75-4c9a-8b81-810b113f73b6 + insufficient-data: + - url: https://webhook.site/ee011b3e-bb1a-43bd-87d0-5da401212121 + ok: + - url: https://webhook.site/2b627634-6e75-4c9a-8b81-810b113f73b6 + alarm-id: alarm-1 + operation: GT + value: 60 + vnf-monitoring-param-ref: apache_vnf_cpu_util + cloud-init-file: cloud_init_apache + description: apache_vdu + id: apache_vdu + int-cpd: + - id: apache_vdu_eth1-int + int-virtual-link-desc: internal_services + virtual-network-interface-requirement: + - name: apache_vdu_eth1 + position: 1 + virtual-interface: + type: VIRTIO + monitoring-parameter: + - id: apache_vnf_cpu_util + name: apache_vnf_cpu_util + performance-metric: cpu_utilization + - id: apache_vnf_memory_util + name: apache_vnf_memory_util + performance-metric: average_memory_utilization + - id: apache_vnf_packets_sent + name: apache_vnf_packets_sent + performance-metric: packets_sent + - id: apache_vnf_packets_received + name: apache_vnf_packets_received + performance-metric: packets_received + name: apache_vdu + sw-image-desc: apache_ubuntu + virtual-compute-desc: apache_vdu-compute + virtual-storage-desc: + - apache_vdu-storage + version: 3.1 + virtual-compute-desc: + - id: haproxy_vdu-compute + virtual-cpu: + num-virtual-cpu: 4 + virtual-memory: + size: 4.0 + - id: apache_vdu-compute + virtual-cpu: + num-virtual-cpu: 1 + virtual-memory: + size: 1.0 + virtual-storage-desc: + - id: haproxy_vdu-storage + size-of-storage: 10 + - id: apache_vdu-storage + size-of-storage: 10 +