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