diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4f04368ec0aa77a7754163418a8d00f2b814a62d..33105100fc41cbc66a9fd24ef21d5e7412ba8de2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,17 +10,19 @@ publish-repository: - git submodule update - python3 -m pip install wheel pyang pyangbind - git clone https://osm.etsi.org/gerrit/osm/IM.git + - pip3 install -r IM/requirements.txt - pip3 install IM/ - git clone https://osm.etsi.org/gerrit/osm/osmclient.git + - pip3 install -r osmclient/requirements.txt - pip3 install osmclient/ - rm -rf osmclient/ IM/ - mv magma/* . - mv charm-packages/* . - - LC_ALL=C.UTF-8 oLANG=C.UTF-8 osm -vvv repo-index --origin . --destination vnf-catalog - - | - sshpass -p "$VNF_CATALOG_CREDENTIALS" sftp -o "StrictHostKeyChecking no" -P 29419 osmsupport@vnf-catalog.etsi.org << EOF - put -r vnf-catalog/* Testing - EOF + # - LC_ALL=C.UTF-8 oLANG=C.UTF-8 osm -vvv repo-index --origin . --destination vnf-catalog + # - | + # sshpass -p "$VNF_CATALOG_CREDENTIALS" sftp -o "StrictHostKeyChecking no" -P 29419 osmsupport@vnf-catalog.etsi.org << EOF + # put -r vnf-catalog/* Testing + # EOF rules: - if: '$CI_COMMIT_REF_PROTECTED == "true"' when: on_success @@ -38,17 +40,19 @@ build-local-repository: - git submodule update - python3 -m pip install wheel pyang pyangbind - git clone https://osm.etsi.org/gerrit/osm/IM.git + - pip3 install -r IM/requirements.txt - pip3 install IM/ - git clone https://osm.etsi.org/gerrit/osm/osmclient.git + - pip3 install -r osmclient/requirements.txt - pip3 install osmclient/ - rm -rf osmclient/ IM/ - mv magma/* . - mv charm-packages/* . - - LC_ALL=C.UTF-8 oLANG=C.UTF-8 osm -vvv repo-index --origin . --destination vnf-catalog - - | - sshpass -p "$VNF_CATALOG_CREDENTIALS" sftp -o "StrictHostKeyChecking no" -P 29419 osmsupport@vnf-catalog.etsi.org << EOF - put -r vnf-catalog/* Testing/Premerge - EOF + # - LC_ALL=C.UTF-8 oLANG=C.UTF-8 osm -vvv repo-index --origin . --destination vnf-catalog + # - | + # sshpass -p "$VNF_CATALOG_CREDENTIALS" sftp -o "StrictHostKeyChecking no" -P 29419 osmsupport@vnf-catalog.etsi.org << EOF + # put -r vnf-catalog/* Testing/Premerge + # EOF rules: - if: '$CI_COMMIT_REF_PROTECTED == "false"' when: on_success diff --git a/charm-packages/native_charm_centos_ns/icons/osm.png b/charm-packages/native_charm_centos_ns/icons/osm.png new file mode 100644 index 0000000000000000000000000000000000000000..62012d2a2b491bdcd536d62c3c3c863c0d8c1b33 Binary files /dev/null and b/charm-packages/native_charm_centos_ns/icons/osm.png differ diff --git a/charm-packages/native_charm_centos_ns/native_charm_centos_nsd.yaml b/charm-packages/native_charm_centos_ns/native_charm_centos_nsd.yaml new file mode 100644 index 0000000000000000000000000000000000000000..63e9929172d9e2fc651819cdb098e60abcd538f9 --- /dev/null +++ b/charm-packages/native_charm_centos_ns/native_charm_centos_nsd.yaml @@ -0,0 +1,22 @@ +nsd: + nsd: + - description: NS with 1 VNF with cloudinit and charm for centos + df: + - id: default-df + vnf-profile: + - id: '1' + virtual-link-connectivity: + - constituent-cpd-id: + - constituent-base-element-id: '1' + constituent-cpd-id: vnf-mgmt-ext + virtual-link-profile-id: mgmtnet + vnfd-id: native_charm_centos-vnf + id: native_charm_centos-ns + name: native_charm_centos-ns + version: '1.0' + virtual-link-desc: + - id: mgmtnet + mgmt-network: 'true' + - id: datanet + vnfd-id: + - native_charm_centos-vnf diff --git a/charm-packages/native_charm_centos_vnf/charms/ops/simple/actions.yaml b/charm-packages/native_charm_centos_vnf/charms/ops/simple/actions.yaml new file mode 100644 index 0000000000000000000000000000000000000000..53a706b4eba7347764c4711b7077146e72241de4 --- /dev/null +++ b/charm-packages/native_charm_centos_vnf/charms/ops/simple/actions.yaml @@ -0,0 +1,25 @@ +## +# Copyright 2020 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. +## +touch: + description: "Touch a file on the VNF." + params: + filename: + description: "The name of the file to touch." + type: string + default: "" + required: + - filename diff --git a/charm-packages/native_charm_centos_vnf/charms/ops/simple/config.yaml b/charm-packages/native_charm_centos_vnf/charms/ops/simple/config.yaml new file mode 100644 index 0000000000000000000000000000000000000000..2be62318c6ce27156e4af585494b36d0c2b802f8 --- /dev/null +++ b/charm-packages/native_charm_centos_vnf/charms/ops/simple/config.yaml @@ -0,0 +1,17 @@ +## +# Copyright 2020 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. +## +options: {} \ No newline at end of file diff --git a/charm-packages/native_charm_centos_vnf/charms/ops/simple/metadata.yaml b/charm-packages/native_charm_centos_vnf/charms/ops/simple/metadata.yaml new file mode 100644 index 0000000000000000000000000000000000000000..fa52808b4a6fed21bd9a7bd6261f653a5d479298 --- /dev/null +++ b/charm-packages/native_charm_centos_vnf/charms/ops/simple/metadata.yaml @@ -0,0 +1,26 @@ +## +# Copyright 2020 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. +## + +name: simple-native +summary: A simple native charm +description: | + Simple native charm +series: + - bionic + - xenial + - focal + - centos7 diff --git a/charm-packages/native_charm_centos_vnf/charms/ops/simple/requirements.txt b/charm-packages/native_charm_centos_vnf/charms/ops/simple/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..2d81d3bb6fea804d1db7a1549d67244b513aa145 --- /dev/null +++ b/charm-packages/native_charm_centos_vnf/charms/ops/simple/requirements.txt @@ -0,0 +1 @@ +ops diff --git a/charm-packages/native_charm_centos_vnf/charms/ops/simple/src/charm.py b/charm-packages/native_charm_centos_vnf/charms/ops/simple/src/charm.py new file mode 100755 index 0000000000000000000000000000000000000000..9ef7d07286257338ea1ef940fb34f67a9052f998 --- /dev/null +++ b/charm-packages/native_charm_centos_vnf/charms/ops/simple/src/charm.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python3 +## +# Copyright 2020 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 +import subprocess + +sys.path.append("lib") + +from ops.charm import CharmBase +from ops.main import main +from ops.model import ActiveStatus + +class MyNativeCharm(CharmBase): + + def __init__(self, framework, key): + super().__init__(framework, key) + + # Listen to charm events + 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) + + # Listen to the touch action event + self.framework.observe(self.on.touch_action, self.on_touch_action) + + def on_config_changed(self, event): + """Handle changes in configuration""" + self.model.unit.status = ActiveStatus() + + def on_install(self, event): + """Called when the charm is being installed""" + self.model.unit.status = ActiveStatus() + + def on_start(self, event): + """Called when the charm is being started""" + self.model.unit.status = ActiveStatus() + + def on_touch_action(self, event): + """Touch a file.""" + + filename = event.params["filename"] + try: + subprocess.run(["touch", filename], check=True) + event.set_results({"created": True, "filename": filename}) + except subprocess.CalledProcessError as e: + event.fail("Action failed: {}".format(e)) + self.model.unit.status = ActiveStatus() + + +if __name__ == "__main__": + main(MyNativeCharm) + diff --git a/charm-packages/native_charm_centos_vnf/cloud_init/cloud-config.txt b/charm-packages/native_charm_centos_vnf/cloud_init/cloud-config.txt new file mode 100755 index 0000000000000000000000000000000000000000..826bc63cace0e71b4fb87bc557b4c7e26f4aeb13 --- /dev/null +++ b/charm-packages/native_charm_centos_vnf/cloud_init/cloud-config.txt @@ -0,0 +1,25 @@ +#cloud-config +password: osm4u +chpasswd: { expire: False } +ssh_pwauth: True + +write_files: +- content: | + # My new helloworld file + + owner: root:root + permissions: '0644' + path: /root/helloworld.txt + +#yum_repos: +# epel-release: +# baseurl: http://download.fedoraproject.org/pub/epel/7/$basearch +# enabled: true +# failovermethod: priority +# gpgcheck: true +# gpgkey: http://download.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-7 +# name: Extra Packages for Enterprise Linux 7 - Release + +packages: + - python3 +# - python36-PyYAML diff --git a/charm-packages/native_charm_centos_vnf/icons/osm.png b/charm-packages/native_charm_centos_vnf/icons/osm.png new file mode 100644 index 0000000000000000000000000000000000000000..62012d2a2b491bdcd536d62c3c3c863c0d8c1b33 Binary files /dev/null and b/charm-packages/native_charm_centos_vnf/icons/osm.png differ diff --git a/charm-packages/native_charm_centos_vnf/native_charm_centos_vnfd.yaml b/charm-packages/native_charm_centos_vnf/native_charm_centos_vnfd.yaml new file mode 100644 index 0000000000000000000000000000000000000000..8a58aef444e270071cc3f710e0d0bb5e6845fedd --- /dev/null +++ b/charm-packages/native_charm_centos_vnf/native_charm_centos_vnfd.yaml @@ -0,0 +1,78 @@ +vnfd: + description: A VNF consisting of 1 VDU connected to two external VL, and one for + data and another one for management + df: + - id: default-df + instantiation-level: + - id: default-instantiation-level + vdu-level: + - number-of-instances: 1 + vdu-id: mgmtVM + vdu-profile: + - id: mgmtVM + min-number-of-instances: 1 + lcm-operations-configuration: + operate-vnf-op-config: + day1-2: + - config-access: + ssh-access: + default-user: centos + required: true + config-primitive: + - name: touch + execution-environment-ref: simple-ee + parameter: + - data-type: STRING + default-value: /home/centos/touched + name: filename + id: mgmtVM + execution-environment-list: + - id: simple-ee + juju: + charm: simple + proxy: false + initial-config-primitive: + - name: touch + execution-environment-ref: simple-ee + parameter: + - data-type: STRING + name: filename + value: /home/centos/first-touch + seq: 1 + ext-cpd: + - id: vnf-mgmt-ext + int-cpd: + cpd: mgmtVM-eth0-int + vdu-id: mgmtVM + id: native_charm_centos-vnf + mgmt-cp: vnf-mgmt-ext + product-name: native_charm_centos-vnf + sw-image-desc: + - id: centos7 + image: centos7 + name: centos7 + vdu: + - cloud-init-file: cloud-config.txt + id: mgmtVM + int-cpd: + - id: mgmtVM-eth0-int + virtual-network-interface-requirement: + - name: mgmtVM-eth0 + position: 1 + virtual-interface: + type: PARAVIRT + name: mgmtVM + sw-image-desc: centos7 + virtual-compute-desc: mgmtVM-compute + virtual-storage-desc: + - mgmtVM-storage + version: 1.0 + virtual-compute-desc: + - id: mgmtVM-compute + virtual-cpu: + num-virtual-cpu: 1 + virtual-memory: + size: 1.0 + virtual-storage-desc: + - id: mgmtVM-storage + size-of-storage: 10 diff --git a/charm-packages/native_k8s_charm_vnf/juju-bundles/bundle.yaml b/charm-packages/native_k8s_charm_vnf/juju-bundles/bundle.yaml index 8115e959ac4502789c9ecd9d014e3139a8b636a2..ea862df0ce1d3adfc4ed513ea95b63deb5447912 100644 --- a/charm-packages/native_k8s_charm_vnf/juju-bundles/bundle.yaml +++ b/charm-packages/native_k8s_charm_vnf/juju-bundles/bundle.yaml @@ -2,5 +2,5 @@ description: Squid Bundle bundle: kubernetes applications: nginx: - charm: '../charms/nginx-k8s' + charm: './charms/nginx-k8s' scale: 1 diff --git a/charm-packages/native_k8s_charm_vnf/charms/nginx-k8s/actions.yaml b/charm-packages/native_k8s_charm_vnf/juju-bundles/charms/nginx-k8s/actions.yaml similarity index 100% rename from charm-packages/native_k8s_charm_vnf/charms/nginx-k8s/actions.yaml rename to charm-packages/native_k8s_charm_vnf/juju-bundles/charms/nginx-k8s/actions.yaml diff --git a/charm-packages/native_k8s_charm_vnf/charms/nginx-k8s/actions/changecontent b/charm-packages/native_k8s_charm_vnf/juju-bundles/charms/nginx-k8s/actions/changecontent similarity index 100% rename from charm-packages/native_k8s_charm_vnf/charms/nginx-k8s/actions/changecontent rename to charm-packages/native_k8s_charm_vnf/juju-bundles/charms/nginx-k8s/actions/changecontent diff --git a/charm-packages/native_k8s_charm_vnf/charms/nginx-k8s/config.yaml b/charm-packages/native_k8s_charm_vnf/juju-bundles/charms/nginx-k8s/config.yaml similarity index 100% rename from charm-packages/native_k8s_charm_vnf/charms/nginx-k8s/config.yaml rename to charm-packages/native_k8s_charm_vnf/juju-bundles/charms/nginx-k8s/config.yaml diff --git a/charm-packages/native_k8s_charm_vnf/charms/nginx-k8s/hooks/start b/charm-packages/native_k8s_charm_vnf/juju-bundles/charms/nginx-k8s/hooks/start similarity index 100% rename from charm-packages/native_k8s_charm_vnf/charms/nginx-k8s/hooks/start rename to charm-packages/native_k8s_charm_vnf/juju-bundles/charms/nginx-k8s/hooks/start diff --git a/charm-packages/native_k8s_charm_vnf/charms/nginx-k8s/lib/ops/__init__.py b/charm-packages/native_k8s_charm_vnf/juju-bundles/charms/nginx-k8s/lib/ops/__init__.py similarity index 100% rename from charm-packages/native_k8s_charm_vnf/charms/nginx-k8s/lib/ops/__init__.py rename to charm-packages/native_k8s_charm_vnf/juju-bundles/charms/nginx-k8s/lib/ops/__init__.py diff --git a/charm-packages/native_k8s_charm_vnf/charms/nginx-k8s/lib/ops/charm.py b/charm-packages/native_k8s_charm_vnf/juju-bundles/charms/nginx-k8s/lib/ops/charm.py similarity index 100% rename from charm-packages/native_k8s_charm_vnf/charms/nginx-k8s/lib/ops/charm.py rename to charm-packages/native_k8s_charm_vnf/juju-bundles/charms/nginx-k8s/lib/ops/charm.py diff --git a/charm-packages/native_k8s_charm_vnf/charms/nginx-k8s/lib/ops/framework.py b/charm-packages/native_k8s_charm_vnf/juju-bundles/charms/nginx-k8s/lib/ops/framework.py similarity index 100% rename from charm-packages/native_k8s_charm_vnf/charms/nginx-k8s/lib/ops/framework.py rename to charm-packages/native_k8s_charm_vnf/juju-bundles/charms/nginx-k8s/lib/ops/framework.py diff --git a/charm-packages/native_k8s_charm_vnf/charms/nginx-k8s/lib/ops/jujuversion.py b/charm-packages/native_k8s_charm_vnf/juju-bundles/charms/nginx-k8s/lib/ops/jujuversion.py similarity index 100% rename from charm-packages/native_k8s_charm_vnf/charms/nginx-k8s/lib/ops/jujuversion.py rename to charm-packages/native_k8s_charm_vnf/juju-bundles/charms/nginx-k8s/lib/ops/jujuversion.py diff --git a/charm-packages/native_k8s_charm_vnf/charms/nginx-k8s/lib/ops/lib/__init__.py b/charm-packages/native_k8s_charm_vnf/juju-bundles/charms/nginx-k8s/lib/ops/lib/__init__.py similarity index 100% rename from charm-packages/native_k8s_charm_vnf/charms/nginx-k8s/lib/ops/lib/__init__.py rename to charm-packages/native_k8s_charm_vnf/juju-bundles/charms/nginx-k8s/lib/ops/lib/__init__.py diff --git a/charm-packages/native_k8s_charm_vnf/charms/nginx-k8s/lib/ops/log.py b/charm-packages/native_k8s_charm_vnf/juju-bundles/charms/nginx-k8s/lib/ops/log.py similarity index 100% rename from charm-packages/native_k8s_charm_vnf/charms/nginx-k8s/lib/ops/log.py rename to charm-packages/native_k8s_charm_vnf/juju-bundles/charms/nginx-k8s/lib/ops/log.py diff --git a/charm-packages/native_k8s_charm_vnf/charms/nginx-k8s/lib/ops/main.py b/charm-packages/native_k8s_charm_vnf/juju-bundles/charms/nginx-k8s/lib/ops/main.py similarity index 100% rename from charm-packages/native_k8s_charm_vnf/charms/nginx-k8s/lib/ops/main.py rename to charm-packages/native_k8s_charm_vnf/juju-bundles/charms/nginx-k8s/lib/ops/main.py diff --git a/charm-packages/native_k8s_charm_vnf/charms/nginx-k8s/lib/ops/model.py b/charm-packages/native_k8s_charm_vnf/juju-bundles/charms/nginx-k8s/lib/ops/model.py similarity index 100% rename from charm-packages/native_k8s_charm_vnf/charms/nginx-k8s/lib/ops/model.py rename to charm-packages/native_k8s_charm_vnf/juju-bundles/charms/nginx-k8s/lib/ops/model.py diff --git a/charm-packages/native_k8s_charm_vnf/charms/nginx-k8s/lib/ops/testing.py b/charm-packages/native_k8s_charm_vnf/juju-bundles/charms/nginx-k8s/lib/ops/testing.py similarity index 100% rename from charm-packages/native_k8s_charm_vnf/charms/nginx-k8s/lib/ops/testing.py rename to charm-packages/native_k8s_charm_vnf/juju-bundles/charms/nginx-k8s/lib/ops/testing.py diff --git a/charm-packages/native_k8s_charm_vnf/charms/nginx-k8s/metadata.yaml b/charm-packages/native_k8s_charm_vnf/juju-bundles/charms/nginx-k8s/metadata.yaml similarity index 100% rename from charm-packages/native_k8s_charm_vnf/charms/nginx-k8s/metadata.yaml rename to charm-packages/native_k8s_charm_vnf/juju-bundles/charms/nginx-k8s/metadata.yaml diff --git a/charm-packages/native_k8s_charm_vnf/charms/nginx-k8s/src/charm.py b/charm-packages/native_k8s_charm_vnf/juju-bundles/charms/nginx-k8s/src/charm.py similarity index 100% rename from charm-packages/native_k8s_charm_vnf/charms/nginx-k8s/src/charm.py rename to charm-packages/native_k8s_charm_vnf/juju-bundles/charms/nginx-k8s/src/charm.py diff --git a/hackfest_multivdu_vnf/hackfest_multivdu_vnfd.yaml b/hackfest_multivdu_vnf/hackfest_multivdu_vnfd.yaml index b8a7083e60d2a9a3250ad8f7f7d25780ba018cd7..32cdb0038fdbc3c643f088af13595bfd6c125cd4 100644 --- a/hackfest_multivdu_vnf/hackfest_multivdu_vnfd.yaml +++ b/hackfest_multivdu_vnf/hackfest_multivdu_vnfd.yaml @@ -29,16 +29,16 @@ vnfd: mgmt-cp: vnf-mgmt-ext product-name: hackfest_multivdu-vnf sw-image-desc: - - id: ubuntu18.04 - image: ubuntu18.04 - name: ubuntu18.04 - - id: ubuntu18.04-aws - name: ubuntu18.04-aws + - id: ubuntu20.04 + image: ubuntu20.04 + name: ubuntu20.04 + - id: ubuntu20.04-aws + name: ubuntu20.04-aws image: ubuntu/images/hvm-ssd/ubuntu-artful-17.10-amd64-server-20180509 vim-type: aws - - id: ubuntu18.04-azure - name: ubuntu18.04-azure - image: Canonical:UbuntuServer:18.04-LTS:latest + - id: ubuntu20.04-azure + name: ubuntu20.04-azure + image: Canonical:UbuntuServer:20.04-LTS:latest vim-type: azure vdu: - id: mgmtVM @@ -57,10 +57,10 @@ vnfd: virtual-interface: type: PARAVIRT name: mgmtVM - sw-image-desc: ubuntu18.04 + sw-image-desc: ubuntu20.04 alternative-sw-image-desc: - - ubuntu18.04-aws - - ubuntu18.04-azure + - ubuntu20.04-aws + - ubuntu20.04-azure virtual-compute-desc: mgmtVM-compute virtual-storage-desc: - mgmtVM-storage @@ -80,10 +80,10 @@ vnfd: virtual-interface: type: PARAVIRT name: dataVM - sw-image-desc: ubuntu18.04 + sw-image-desc: ubuntu20.04 alternative-sw-image-desc: - - ubuntu18.04-aws - - ubuntu18.04-azure + - ubuntu20.04-aws + - ubuntu20.04-azure virtual-compute-desc: dataVM-compute virtual-storage-desc: - dataVM-storage diff --git a/hackfest_virtual-pc_vnfd/charms/virtual-pc-src/actions.yaml b/hackfest_virtual-pc_vnfd/charms/virtual-pc-src/actions.yaml index e4b157ae1c0dfd901e05a717309ca3420171b6fe..d1e5d4f7b7b1b6791028dae91857cf8e404c4669 100644 --- a/hackfest_virtual-pc_vnfd/charms/virtual-pc-src/actions.yaml +++ b/hackfest_virtual-pc_vnfd/charms/virtual-pc-src/actions.yaml @@ -61,3 +61,19 @@ remove-snap: update-system: description: "Updates all software to latest version." +integrate-ldap: + description: "Adds support for ldap." + params: + ldap_host: + description: "Ip or domain of the ldap host." + type: string + ldap_domain: + description: "Ldap domian." + type: string + ldap_password: + description: "Password for the admin user." + type: string + required: + - ldap_host + - ldap_domain + - ldap_password diff --git a/hackfest_virtual-pc_vnfd/charms/virtual-pc-src/src/charm.py b/hackfest_virtual-pc_vnfd/charms/virtual-pc-src/src/charm.py index 41e3c64201ded3be2b440a423d3db2c47809ad15..50729e7455009b6ce240a413957bfb639f6391f6 100755 --- a/hackfest_virtual-pc_vnfd/charms/virtual-pc-src/src/charm.py +++ b/hackfest_virtual-pc_vnfd/charms/virtual-pc-src/src/charm.py @@ -70,6 +70,7 @@ class VirtualPCCharm(CharmBase, InstallProgress): self._stored.set_default() self.last_status_update = time.time() + self._stored.set_default(ldap_installed=False) # Basic hooks self.framework.observe(self.on.install, self._on_install) @@ -86,6 +87,7 @@ class VirtualPCCharm(CharmBase, InstallProgress): self.framework.observe(self.on["remove-package"].action, self._remove_package) self.framework.observe(self.on["remove-snap"].action, self._remove_snap) self.framework.observe(self.on["update-system"].action, self._update_system) + self.framework.observe(self.on["integrate-ldap"].action, self._ldap_integration) # Relations hooks @@ -201,6 +203,23 @@ class VirtualPCCharm(CharmBase, InstallProgress): upgrade_apt(update=True, progress=self) self.unit.status = self._get_current_status() + def _ldap_integration(self, event): + self.unit.status = MaintenanceStatus("Configuring Ldap autentication") + self._configure_ldap(event.params["ldap_host"], event.params["ldap_domain"], event.params["ldap_password"]) + if not self._stored.ldap_installed: + install_apt(packages=["ldap-auth-client", "nscd"], + update=True, progress=self) + # edit /etc/nsswitch.conf + shell("sudo sed -E -i '/passwd|group|shadow/ !b; s/$/ ldap/' /etc/nsswitch.conf") + # restart nscd + shell("sudo systemctl restart nscd") + #create a home directory when user login + shell("echo session required pam_mkhomedir.so skel=/etc/skel umask=077 | sudo tee /etc/pam.d/common-session") + self._stored.ldap_installed = True + else: + shell("dpkg-reconfigure -f noninteractive ldap-auth-client") + self.unit.status = ActiveStatus("Ldap autentication configured") + # Relation hooks # Private functions @@ -211,6 +230,21 @@ class VirtualPCCharm(CharmBase, InstallProgress): status_msg = "Ready" return status_type(status_msg) + def _configure_ldap(self, host, domain, password): + #configure ldap-auth-config with debconf + shell("echo ldap-auth-config ldap-auth-config/rootbindpw password {} | sudo debconf-set-selections".format(password)) + shell("echo ldap-auth-config ldap-auth-config/bindpw password {} | sudo debconf-set-selections".format(password)) + shell("echo ldap-auth-config ldap-auth-config/binddn string cn=admin,dc={},dc={} | sudo debconf-set-selections".format(domain.split(".")[0],domain.split(".")[1])) + shell("echo ldap-auth-config ldap-auth-config/dblogin boolean false | sudo debconf-set-selections") + shell("echo ldap-auth-config ldap-auth-config/rootbinddn string cn=admin,dc={},dc={} | sudo debconf-set-selections".format(domain.split(".")[0],domain.split(".")[1])) + shell("echo ldap-auth-config ldap-auth-config/ldapns/ldap-server string ldap://{} | sudo debconf-set-selections".format(host)) + shell("echo ldap-auth-config ldap-auth-config/override boolean true | sudo debconf-set-selections") + shell("echo ldap-auth-config ldap-auth-config/ldapns/ldap_version select 3 | sudo debconf-set-selections") + shell("echo ldap-auth-config ldap-auth-config/dbrootlogin boolean true | sudo debconf-set-selections") + shell("echo ldap-auth-config ldap-auth-config/ldapns/base-dn string dc={},dc={} | sudo debconf-set-selections".format(domain.split(".")[0],domain.split(".")[1])) + shell("echo ldap-auth-config ldap-auth-config/move-to-debconf boolean true | sudo debconf-set-selections") + shell("echo ldap-auth-config ldap-auth-config/pam_password select clear | sudo debconf-set-selections") + if __name__ == "__main__": main(VirtualPCCharm) diff --git a/hackfest_virtual-pc_vnfd/charms/virtual-pc/actions.yaml b/hackfest_virtual-pc_vnfd/charms/virtual-pc/actions.yaml index e4b157ae1c0dfd901e05a717309ca3420171b6fe..d1e5d4f7b7b1b6791028dae91857cf8e404c4669 100644 --- a/hackfest_virtual-pc_vnfd/charms/virtual-pc/actions.yaml +++ b/hackfest_virtual-pc_vnfd/charms/virtual-pc/actions.yaml @@ -61,3 +61,19 @@ remove-snap: update-system: description: "Updates all software to latest version." +integrate-ldap: + description: "Adds support for ldap." + params: + ldap_host: + description: "Ip or domain of the ldap host." + type: string + ldap_domain: + description: "Ldap domian." + type: string + ldap_password: + description: "Password for the admin user." + type: string + required: + - ldap_host + - ldap_domain + - ldap_password diff --git a/hackfest_virtual-pc_vnfd/charms/virtual-pc/src/charm.py b/hackfest_virtual-pc_vnfd/charms/virtual-pc/src/charm.py index 41e3c64201ded3be2b440a423d3db2c47809ad15..50729e7455009b6ce240a413957bfb639f6391f6 100755 --- a/hackfest_virtual-pc_vnfd/charms/virtual-pc/src/charm.py +++ b/hackfest_virtual-pc_vnfd/charms/virtual-pc/src/charm.py @@ -70,6 +70,7 @@ class VirtualPCCharm(CharmBase, InstallProgress): self._stored.set_default() self.last_status_update = time.time() + self._stored.set_default(ldap_installed=False) # Basic hooks self.framework.observe(self.on.install, self._on_install) @@ -86,6 +87,7 @@ class VirtualPCCharm(CharmBase, InstallProgress): self.framework.observe(self.on["remove-package"].action, self._remove_package) self.framework.observe(self.on["remove-snap"].action, self._remove_snap) self.framework.observe(self.on["update-system"].action, self._update_system) + self.framework.observe(self.on["integrate-ldap"].action, self._ldap_integration) # Relations hooks @@ -201,6 +203,23 @@ class VirtualPCCharm(CharmBase, InstallProgress): upgrade_apt(update=True, progress=self) self.unit.status = self._get_current_status() + def _ldap_integration(self, event): + self.unit.status = MaintenanceStatus("Configuring Ldap autentication") + self._configure_ldap(event.params["ldap_host"], event.params["ldap_domain"], event.params["ldap_password"]) + if not self._stored.ldap_installed: + install_apt(packages=["ldap-auth-client", "nscd"], + update=True, progress=self) + # edit /etc/nsswitch.conf + shell("sudo sed -E -i '/passwd|group|shadow/ !b; s/$/ ldap/' /etc/nsswitch.conf") + # restart nscd + shell("sudo systemctl restart nscd") + #create a home directory when user login + shell("echo session required pam_mkhomedir.so skel=/etc/skel umask=077 | sudo tee /etc/pam.d/common-session") + self._stored.ldap_installed = True + else: + shell("dpkg-reconfigure -f noninteractive ldap-auth-client") + self.unit.status = ActiveStatus("Ldap autentication configured") + # Relation hooks # Private functions @@ -211,6 +230,21 @@ class VirtualPCCharm(CharmBase, InstallProgress): status_msg = "Ready" return status_type(status_msg) + def _configure_ldap(self, host, domain, password): + #configure ldap-auth-config with debconf + shell("echo ldap-auth-config ldap-auth-config/rootbindpw password {} | sudo debconf-set-selections".format(password)) + shell("echo ldap-auth-config ldap-auth-config/bindpw password {} | sudo debconf-set-selections".format(password)) + shell("echo ldap-auth-config ldap-auth-config/binddn string cn=admin,dc={},dc={} | sudo debconf-set-selections".format(domain.split(".")[0],domain.split(".")[1])) + shell("echo ldap-auth-config ldap-auth-config/dblogin boolean false | sudo debconf-set-selections") + shell("echo ldap-auth-config ldap-auth-config/rootbinddn string cn=admin,dc={},dc={} | sudo debconf-set-selections".format(domain.split(".")[0],domain.split(".")[1])) + shell("echo ldap-auth-config ldap-auth-config/ldapns/ldap-server string ldap://{} | sudo debconf-set-selections".format(host)) + shell("echo ldap-auth-config ldap-auth-config/override boolean true | sudo debconf-set-selections") + shell("echo ldap-auth-config ldap-auth-config/ldapns/ldap_version select 3 | sudo debconf-set-selections") + shell("echo ldap-auth-config ldap-auth-config/dbrootlogin boolean true | sudo debconf-set-selections") + shell("echo ldap-auth-config ldap-auth-config/ldapns/base-dn string dc={},dc={} | sudo debconf-set-selections".format(domain.split(".")[0],domain.split(".")[1])) + shell("echo ldap-auth-config ldap-auth-config/move-to-debconf boolean true | sudo debconf-set-selections") + shell("echo ldap-auth-config ldap-auth-config/pam_password select clear | sudo debconf-set-selections") + if __name__ == "__main__": main(VirtualPCCharm) diff --git a/hackfest_virtual-pc_vnfd/virtual-pc_vnfd.yaml b/hackfest_virtual-pc_vnfd/virtual-pc_vnfd.yaml index 511baf03fda4e2d659a2929fe83580dd6dfac05d..dff3c9d8def2a7db858012c7153ed1e77418fe26 100644 --- a/hackfest_virtual-pc_vnfd/virtual-pc_vnfd.yaml +++ b/hackfest_virtual-pc_vnfd/virtual-pc_vnfd.yaml @@ -57,6 +57,16 @@ vnfd: name: package - name: update-system execution-environment-ref: virtual-pc-ee + - name: integrate-ldap + execution-environment-ref: virtual-pc-ee + parameter: + - name: ldap_host + data-type: STRING + - name: ldap_domain + data-type: STRING + - name: ldap_password + data-type: STRING + ext-cpd: - id: virtual-pc-private-ext diff --git a/wiki_webserver_autoscale_vnfd/wiki_webserver_autoscale_vnfd.yaml b/wiki_webserver_autoscale_vnfd/wiki_webserver_autoscale_vnfd.yaml index bcd0b037c5df92c4057ad7cd89775a3adf31524e..3154afe8d8db5ac2d69e2a43de1a2ef669aee228 100644 --- a/wiki_webserver_autoscale_vnfd/wiki_webserver_autoscale_vnfd.yaml +++ b/wiki_webserver_autoscale_vnfd/wiki_webserver_autoscale_vnfd.yaml @@ -17,7 +17,7 @@ vnfd: - id: apache_vdu number-of-instances: 1 id: apache_vdu_autoscale - max-scale-level: 10 + max-scale-level: 4 name: apache_vdu_autoscale scaling-policy: - cooldown-time: 180 @@ -27,7 +27,7 @@ vnfd: scale-in-relational-operation: LT scale-in-threshold: 20 scale-out-relational-operation: GT - scale-out-threshold: 80 + scale-out-threshold: 60 vnf-monitoring-param-ref: apache_vnf_cpu_util scaling-type: automatic threshold-time: 10