diff --git a/.gitmodules b/.gitmodules index 228d7ccb55a376b1d573d2b4611f0190130d3cb2..b113e87b26a7943e48dfb13289307ae2aa991d36 100644 --- a/.gitmodules +++ b/.gitmodules @@ -43,3 +43,15 @@ [submodule "charm-packages/ns_relations_provides_vnf/charms/simple_provides/mod/operator"] path = charm-packages/ns_relations_provides_vnf/charms/simple_provides/mod/operator url = https://github.com/canonical/operator +[submodule "charm-packages/nopasswd_k8s_proxy_charm_vnf/charms/simple/mod/operator"] + path = charm-packages/nopasswd_k8s_proxy_charm_vnf/charms/simple/mod/operator + url = https://github.com/canonical/operator.git +[submodule "charm-packages/nopasswd_proxy_charm_vnf/charms/simple/mod/operator"] + path = charm-packages/nopasswd_proxy_charm_vnf/charms/simple/mod/operator + url = https://github.com/canonical/operator.git +[submodule "charm-packages/nopasswd_k8s_proxy_charm_vnf/charms/simple/mod/charms.osm"] + path = charm-packages/nopasswd_k8s_proxy_charm_vnf/charms/simple/mod/charms.osm + url = https://github.com/charmed-osm/charms.osm +[submodule "charm-packages/nopasswd_proxy_charm_vnf/charms/simple/mod/charms.osm"] + path = charm-packages/nopasswd_proxy_charm_vnf/charms/simple/mod/charms.osm + url = https://github.com/charmed-osm/charms.osm diff --git a/charm-packages/nopasswd_k8s_proxy_charm_ns/icons/osm.png b/charm-packages/nopasswd_k8s_proxy_charm_ns/icons/osm.png new file mode 100644 index 0000000000000000000000000000000000000000..62012d2a2b491bdcd536d62c3c3c863c0d8c1b33 Binary files /dev/null and b/charm-packages/nopasswd_k8s_proxy_charm_ns/icons/osm.png differ diff --git a/charm-packages/nopasswd_k8s_proxy_charm_ns/nopasswd_k8s_proxy_charm_nsd.yaml b/charm-packages/nopasswd_k8s_proxy_charm_ns/nopasswd_k8s_proxy_charm_nsd.yaml new file mode 100755 index 0000000000000000000000000000000000000000..942dfa4df7faae99225ca18aac0cf106cd8fcf7e --- /dev/null +++ b/charm-packages/nopasswd_k8s_proxy_charm_ns/nopasswd_k8s_proxy_charm_nsd.yaml @@ -0,0 +1,39 @@ +nsd:nsd-catalog: + nsd: + - id: nopasswd_k8s_proxy_charm-ns + name: nopasswd_k8s_proxy_charm-ns + short-name: nopasswd_k8s_proxy_charm-ns + description: NS with 2 VNFs with cloudinit connected by datanet and mgmtnet VLs + version: '1.0' + logo: osm.png + constituent-vnfd: + - vnfd-id-ref: nopasswd_k8s_proxy_charm-vnf + member-vnf-index: '1' + - vnfd-id-ref: nopasswd_k8s_proxy_charm-vnf + member-vnf-index: '2' + vld: + - id: mgmtnet + name: mgmtnet + short-name: mgmtnet + type: ELAN + mgmt-network: 'true' + vim-network-name: osm-ext + vnfd-connection-point-ref: + - vnfd-id-ref: nopasswd_k8s_proxy_charm-vnf + member-vnf-index-ref: '1' + vnfd-connection-point-ref: vnf-mgmt + - vnfd-id-ref: nopasswd_k8s_proxy_charm-vnf + member-vnf-index-ref: '2' + vnfd-connection-point-ref: vnf-mgmt + - id: datanet + name: datanet + short-name: datanet + type: ELAN + vnfd-connection-point-ref: + - vnfd-id-ref: nopasswd_k8s_proxy_charm-vnf + member-vnf-index-ref: '1' + vnfd-connection-point-ref: vnf-data + - vnfd-id-ref: nopasswd_k8s_proxy_charm-vnf + member-vnf-index-ref: '2' + vnfd-connection-point-ref: vnf-data + diff --git a/charm-packages/nopasswd_k8s_proxy_charm_vnf/charms/simple/actions.yaml b/charm-packages/nopasswd_k8s_proxy_charm_vnf/charms/simple/actions.yaml new file mode 100644 index 0000000000000000000000000000000000000000..f9882c47bba960254e0381e5b5ab1c0688de6cf5 --- /dev/null +++ b/charm-packages/nopasswd_k8s_proxy_charm_vnf/charms/simple/actions.yaml @@ -0,0 +1,54 @@ +## +# 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 + +# Standard OSM functions +start: + description: "Stop the service on the VNF." +stop: + description: "Stop the service on the VNF." +restart: + description: "Stop the service on the VNF." +reboot: + description: "Reboot the VNF virtual machine." +upgrade: + description: "Upgrade the software on the VNF." + +# 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/charm-packages/nopasswd_k8s_proxy_charm_vnf/charms/simple/config.yaml b/charm-packages/nopasswd_k8s_proxy_charm_vnf/charms/simple/config.yaml new file mode 100644 index 0000000000000000000000000000000000000000..93e3cab01c0843418c57e4bc918eb933f2daf934 --- /dev/null +++ b/charm-packages/nopasswd_k8s_proxy_charm_vnf/charms/simple/config.yaml @@ -0,0 +1,41 @@ +## +# 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: + 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/charm-packages/nopasswd_k8s_proxy_charm_vnf/charms/simple/hooks/install b/charm-packages/nopasswd_k8s_proxy_charm_vnf/charms/simple/hooks/install new file mode 120000 index 0000000000000000000000000000000000000000..25b1f68fa39d58d33c08ca420c3d439d19be0c55 --- /dev/null +++ b/charm-packages/nopasswd_k8s_proxy_charm_vnf/charms/simple/hooks/install @@ -0,0 +1 @@ +../src/charm.py \ No newline at end of file diff --git a/charm-packages/nopasswd_k8s_proxy_charm_vnf/charms/simple/hooks/start b/charm-packages/nopasswd_k8s_proxy_charm_vnf/charms/simple/hooks/start new file mode 120000 index 0000000000000000000000000000000000000000..25b1f68fa39d58d33c08ca420c3d439d19be0c55 --- /dev/null +++ b/charm-packages/nopasswd_k8s_proxy_charm_vnf/charms/simple/hooks/start @@ -0,0 +1 @@ +../src/charm.py \ No newline at end of file diff --git a/charm-packages/nopasswd_k8s_proxy_charm_vnf/charms/simple/hooks/upgrade-charm b/charm-packages/nopasswd_k8s_proxy_charm_vnf/charms/simple/hooks/upgrade-charm new file mode 120000 index 0000000000000000000000000000000000000000..25b1f68fa39d58d33c08ca420c3d439d19be0c55 --- /dev/null +++ b/charm-packages/nopasswd_k8s_proxy_charm_vnf/charms/simple/hooks/upgrade-charm @@ -0,0 +1 @@ +../src/charm.py \ No newline at end of file diff --git a/charm-packages/nopasswd_k8s_proxy_charm_vnf/charms/simple/lib/charms b/charm-packages/nopasswd_k8s_proxy_charm_vnf/charms/simple/lib/charms new file mode 120000 index 0000000000000000000000000000000000000000..5abf77aa5a04fddc6d4eb9d0d6d17e36fd00272a --- /dev/null +++ b/charm-packages/nopasswd_k8s_proxy_charm_vnf/charms/simple/lib/charms @@ -0,0 +1 @@ +../mod/charms.osm/charms/ \ No newline at end of file diff --git a/charm-packages/nopasswd_k8s_proxy_charm_vnf/charms/simple/lib/ops b/charm-packages/nopasswd_k8s_proxy_charm_vnf/charms/simple/lib/ops new file mode 120000 index 0000000000000000000000000000000000000000..c36dab1ed4a93aee97a31b0eba0438852c5e05bf --- /dev/null +++ b/charm-packages/nopasswd_k8s_proxy_charm_vnf/charms/simple/lib/ops @@ -0,0 +1 @@ +../mod/operator/ops/ \ No newline at end of file diff --git a/charm-packages/nopasswd_k8s_proxy_charm_vnf/charms/simple/metadata.yaml b/charm-packages/nopasswd_k8s_proxy_charm_vnf/charms/simple/metadata.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4b5b352850eb98a4e2028942957cebc622a2395e --- /dev/null +++ b/charm-packages/nopasswd_k8s_proxy_charm_vnf/charms/simple/metadata.yaml @@ -0,0 +1,28 @@ +## +# 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-k8s-proxy +summary: A simple example proxy charm +description: | + Simple proxy charm is an example charm used in OSM Hackfests +series: + - kubernetes +peers: + proxypeer: + interface: proxypeer +deployment: + mode: operator \ No newline at end of file diff --git a/charm-packages/nopasswd_k8s_proxy_charm_vnf/charms/simple/mod/charms.osm b/charm-packages/nopasswd_k8s_proxy_charm_vnf/charms/simple/mod/charms.osm new file mode 160000 index 0000000000000000000000000000000000000000..3d517f5e42550d0b5c81aa4be20f7679020854d5 --- /dev/null +++ b/charm-packages/nopasswd_k8s_proxy_charm_vnf/charms/simple/mod/charms.osm @@ -0,0 +1 @@ +Subproject commit 3d517f5e42550d0b5c81aa4be20f7679020854d5 diff --git a/charm-packages/nopasswd_k8s_proxy_charm_vnf/charms/simple/mod/operator b/charm-packages/nopasswd_k8s_proxy_charm_vnf/charms/simple/mod/operator new file mode 160000 index 0000000000000000000000000000000000000000..89b51be8588a19fcc9c93410707aeb5856dd8d8f --- /dev/null +++ b/charm-packages/nopasswd_k8s_proxy_charm_vnf/charms/simple/mod/operator @@ -0,0 +1 @@ +Subproject commit 89b51be8588a19fcc9c93410707aeb5856dd8d8f diff --git a/charm-packages/nopasswd_k8s_proxy_charm_vnf/charms/simple/src/charm.py b/charm-packages/nopasswd_k8s_proxy_charm_vnf/charms/simple/src/charm.py new file mode 100755 index 0000000000000000000000000000000000000000..e23b12b7bcfddfd49d4efbc1b0ac72d92579778a --- /dev/null +++ b/charm-packages/nopasswd_k8s_proxy_charm_vnf/charms/simple/src/charm.py @@ -0,0 +1,65 @@ +#!/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 + +sys.path.append("lib") + +from charms.osm.sshproxy import SSHProxyCharm +from ops.main import main + +class MySSHProxyCharm(SSHProxyCharm): + + 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""" + super().on_config_changed(event) + + 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) + + def on_touch_action(self, event): + """Touch a file.""" + + if self.model.unit.is_leader(): + filename = event.params["filename"] + proxy = self.get_ssh_proxy() + stdout, stderr = proxy.run("touch {}".format(filename)) + event.set_results({"output": stdout}) + else: + event.fail("Unit is not leader") + return + +if __name__ == "__main__": + main(MySSHProxyCharm) + diff --git a/charm-packages/nopasswd_k8s_proxy_charm_vnf/cloud_init/cloud-config.txt b/charm-packages/nopasswd_k8s_proxy_charm_vnf/cloud_init/cloud-config.txt new file mode 100755 index 0000000000000000000000000000000000000000..36c8d1bf2cdebbc4e50d1e8348003f64f419cd0b --- /dev/null +++ b/charm-packages/nopasswd_k8s_proxy_charm_vnf/cloud_init/cloud-config.txt @@ -0,0 +1,12 @@ +#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 diff --git a/charm-packages/nopasswd_k8s_proxy_charm_vnf/icons/osm.png b/charm-packages/nopasswd_k8s_proxy_charm_vnf/icons/osm.png new file mode 100644 index 0000000000000000000000000000000000000000..62012d2a2b491bdcd536d62c3c3c863c0d8c1b33 Binary files /dev/null and b/charm-packages/nopasswd_k8s_proxy_charm_vnf/icons/osm.png differ diff --git a/charm-packages/nopasswd_k8s_proxy_charm_vnf/nopasswd_k8s_proxy_charm_vnfd.yaml b/charm-packages/nopasswd_k8s_proxy_charm_vnf/nopasswd_k8s_proxy_charm_vnfd.yaml new file mode 100644 index 0000000000000000000000000000000000000000..1771daaaf791a57fd332f1b1e7dcbc17804b904d --- /dev/null +++ b/charm-packages/nopasswd_k8s_proxy_charm_vnf/nopasswd_k8s_proxy_charm_vnfd.yaml @@ -0,0 +1,70 @@ +vnfd:vnfd-catalog: + vnfd: + - id: nopasswd_k8s_proxy_charm-vnf + name: nopasswd_k8s_proxy_charm-vnf + short-name: nopasswd_k8s_proxy_charm-vnf + version: 1.0 + description: A VNF consisting of 1 VDU connected to two external VL, and one for data and another one for management + logo: osm.png + connection-point: + - id: vnf-mgmt + name: vnf-mgmt + short-name: vnf-mgmt + type: VPORT + - id: vnf-data + name: vnf-data + short-name: vnf-data + type: VPORT + mgmt-interface: + cp: vnf-mgmt + vdu: + - id: mgmtVM + name: mgmtVM + image: ubuntu18.04 + count: 1 + vm-flavor: + vcpu-count: 1 + memory-mb: 1024 + storage-gb: 10 + interface: + - name: mgmtVM-eth0 + position: 1 + type: EXTERNAL + virtual-interface: + type: PARAVIRT + external-connection-point-ref: vnf-mgmt + - name: dataVM-xe0 + position: 2 + type: EXTERNAL + virtual-interface: + type: PARAVIRT + external-connection-point-ref: vnf-data + cloud-init-file: cloud-config.txt + vnf-configuration: + juju: + charm: simple + cloud: k8s + initial-config-primitive: + - seq: 1 + name: config + parameter: + - name: ssh-hostname + value: + - name: ssh-username + value: ubuntu + - seq: 2 + name: touch + parameter: + - name: filename + data-type: STRING + value: '/home/ubuntu/first-touch' + config-primitive: + - name: touch + parameter: + - name: filename + data-type: STRING + default-value: '/home/ubuntu/touched' + config-access: + ssh-access: + default-user: ubuntu + required: true \ No newline at end of file diff --git a/charm-packages/nopasswd_proxy_charm_ns/icons/osm.png b/charm-packages/nopasswd_proxy_charm_ns/icons/osm.png new file mode 100644 index 0000000000000000000000000000000000000000..62012d2a2b491bdcd536d62c3c3c863c0d8c1b33 Binary files /dev/null and b/charm-packages/nopasswd_proxy_charm_ns/icons/osm.png differ diff --git a/charm-packages/nopasswd_proxy_charm_ns/nopasswd_proxy_charm_nsd.yaml b/charm-packages/nopasswd_proxy_charm_ns/nopasswd_proxy_charm_nsd.yaml new file mode 100755 index 0000000000000000000000000000000000000000..7edea372bfab07238c3091bd3bc9e946e428e28b --- /dev/null +++ b/charm-packages/nopasswd_proxy_charm_ns/nopasswd_proxy_charm_nsd.yaml @@ -0,0 +1,39 @@ +nsd:nsd-catalog: + nsd: + - id: nopasswd_proxy_charm-ns + name: nopasswd_proxy_charm-ns + short-name: nopasswd_proxy_charm-ns + description: NS with 2 VNFs with cloudinit connected by datanet and mgmtnet VLs + version: '1.0' + logo: osm.png + constituent-vnfd: + - vnfd-id-ref: nopasswd_proxy_charm-vnf + member-vnf-index: '1' + - vnfd-id-ref: nopasswd_proxy_charm-vnf + member-vnf-index: '2' + vld: + - id: mgmtnet + name: mgmtnet + short-name: mgmtnet + type: ELAN + mgmt-network: 'true' + vim-network-name: osm-ext + vnfd-connection-point-ref: + - vnfd-id-ref: nopasswd_proxy_charm-vnf + member-vnf-index-ref: '1' + vnfd-connection-point-ref: vnf-mgmt + - vnfd-id-ref: nopasswd_proxy_charm-vnf + member-vnf-index-ref: '2' + vnfd-connection-point-ref: vnf-mgmt + - id: datanet + name: datanet + short-name: datanet + type: ELAN + vnfd-connection-point-ref: + - vnfd-id-ref: nopasswd_proxy_charm-vnf + member-vnf-index-ref: '1' + vnfd-connection-point-ref: vnf-data + - vnfd-id-ref: nopasswd_proxy_charm-vnf + member-vnf-index-ref: '2' + vnfd-connection-point-ref: vnf-data + diff --git a/charm-packages/nopasswd_proxy_charm_vnf/charms/simple/actions.yaml b/charm-packages/nopasswd_proxy_charm_vnf/charms/simple/actions.yaml new file mode 100644 index 0000000000000000000000000000000000000000..f9882c47bba960254e0381e5b5ab1c0688de6cf5 --- /dev/null +++ b/charm-packages/nopasswd_proxy_charm_vnf/charms/simple/actions.yaml @@ -0,0 +1,54 @@ +## +# 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 + +# Standard OSM functions +start: + description: "Stop the service on the VNF." +stop: + description: "Stop the service on the VNF." +restart: + description: "Stop the service on the VNF." +reboot: + description: "Reboot the VNF virtual machine." +upgrade: + description: "Upgrade the software on the VNF." + +# 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/charm-packages/nopasswd_proxy_charm_vnf/charms/simple/config.yaml b/charm-packages/nopasswd_proxy_charm_vnf/charms/simple/config.yaml new file mode 100644 index 0000000000000000000000000000000000000000..93e3cab01c0843418c57e4bc918eb933f2daf934 --- /dev/null +++ b/charm-packages/nopasswd_proxy_charm_vnf/charms/simple/config.yaml @@ -0,0 +1,41 @@ +## +# 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: + 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/charm-packages/nopasswd_proxy_charm_vnf/charms/simple/hooks/install b/charm-packages/nopasswd_proxy_charm_vnf/charms/simple/hooks/install new file mode 120000 index 0000000000000000000000000000000000000000..25b1f68fa39d58d33c08ca420c3d439d19be0c55 --- /dev/null +++ b/charm-packages/nopasswd_proxy_charm_vnf/charms/simple/hooks/install @@ -0,0 +1 @@ +../src/charm.py \ No newline at end of file diff --git a/charm-packages/nopasswd_proxy_charm_vnf/charms/simple/hooks/start b/charm-packages/nopasswd_proxy_charm_vnf/charms/simple/hooks/start new file mode 120000 index 0000000000000000000000000000000000000000..25b1f68fa39d58d33c08ca420c3d439d19be0c55 --- /dev/null +++ b/charm-packages/nopasswd_proxy_charm_vnf/charms/simple/hooks/start @@ -0,0 +1 @@ +../src/charm.py \ No newline at end of file diff --git a/charm-packages/nopasswd_proxy_charm_vnf/charms/simple/hooks/upgrade-charm b/charm-packages/nopasswd_proxy_charm_vnf/charms/simple/hooks/upgrade-charm new file mode 120000 index 0000000000000000000000000000000000000000..25b1f68fa39d58d33c08ca420c3d439d19be0c55 --- /dev/null +++ b/charm-packages/nopasswd_proxy_charm_vnf/charms/simple/hooks/upgrade-charm @@ -0,0 +1 @@ +../src/charm.py \ No newline at end of file diff --git a/charm-packages/nopasswd_proxy_charm_vnf/charms/simple/lib/charms b/charm-packages/nopasswd_proxy_charm_vnf/charms/simple/lib/charms new file mode 120000 index 0000000000000000000000000000000000000000..5abf77aa5a04fddc6d4eb9d0d6d17e36fd00272a --- /dev/null +++ b/charm-packages/nopasswd_proxy_charm_vnf/charms/simple/lib/charms @@ -0,0 +1 @@ +../mod/charms.osm/charms/ \ No newline at end of file diff --git a/charm-packages/nopasswd_proxy_charm_vnf/charms/simple/lib/ops b/charm-packages/nopasswd_proxy_charm_vnf/charms/simple/lib/ops new file mode 120000 index 0000000000000000000000000000000000000000..c36dab1ed4a93aee97a31b0eba0438852c5e05bf --- /dev/null +++ b/charm-packages/nopasswd_proxy_charm_vnf/charms/simple/lib/ops @@ -0,0 +1 @@ +../mod/operator/ops/ \ No newline at end of file diff --git a/charm-packages/nopasswd_proxy_charm_vnf/charms/simple/metadata.yaml b/charm-packages/nopasswd_proxy_charm_vnf/charms/simple/metadata.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d6d0cd70360fb011c2b2a36442d967b104050810 --- /dev/null +++ b/charm-packages/nopasswd_proxy_charm_vnf/charms/simple/metadata.yaml @@ -0,0 +1,27 @@ +## +# 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-ha-proxy +summary: A simple example proxy charm +description: | + Simple proxy charm is an example charm used in OSM Hackfests +series: + - xenial + - bionic +peers: + proxypeer: + interface: proxypeer diff --git a/charm-packages/nopasswd_proxy_charm_vnf/charms/simple/mod/charms.osm b/charm-packages/nopasswd_proxy_charm_vnf/charms/simple/mod/charms.osm new file mode 160000 index 0000000000000000000000000000000000000000..3d517f5e42550d0b5c81aa4be20f7679020854d5 --- /dev/null +++ b/charm-packages/nopasswd_proxy_charm_vnf/charms/simple/mod/charms.osm @@ -0,0 +1 @@ +Subproject commit 3d517f5e42550d0b5c81aa4be20f7679020854d5 diff --git a/charm-packages/nopasswd_proxy_charm_vnf/charms/simple/mod/operator b/charm-packages/nopasswd_proxy_charm_vnf/charms/simple/mod/operator new file mode 160000 index 0000000000000000000000000000000000000000..89b51be8588a19fcc9c93410707aeb5856dd8d8f --- /dev/null +++ b/charm-packages/nopasswd_proxy_charm_vnf/charms/simple/mod/operator @@ -0,0 +1 @@ +Subproject commit 89b51be8588a19fcc9c93410707aeb5856dd8d8f diff --git a/charm-packages/nopasswd_proxy_charm_vnf/charms/simple/src/charm.py b/charm-packages/nopasswd_proxy_charm_vnf/charms/simple/src/charm.py new file mode 100755 index 0000000000000000000000000000000000000000..e23b12b7bcfddfd49d4efbc1b0ac72d92579778a --- /dev/null +++ b/charm-packages/nopasswd_proxy_charm_vnf/charms/simple/src/charm.py @@ -0,0 +1,65 @@ +#!/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 + +sys.path.append("lib") + +from charms.osm.sshproxy import SSHProxyCharm +from ops.main import main + +class MySSHProxyCharm(SSHProxyCharm): + + 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""" + super().on_config_changed(event) + + 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) + + def on_touch_action(self, event): + """Touch a file.""" + + if self.model.unit.is_leader(): + filename = event.params["filename"] + proxy = self.get_ssh_proxy() + stdout, stderr = proxy.run("touch {}".format(filename)) + event.set_results({"output": stdout}) + else: + event.fail("Unit is not leader") + return + +if __name__ == "__main__": + main(MySSHProxyCharm) + diff --git a/charm-packages/nopasswd_proxy_charm_vnf/cloud_init/cloud-config.txt b/charm-packages/nopasswd_proxy_charm_vnf/cloud_init/cloud-config.txt new file mode 100755 index 0000000000000000000000000000000000000000..36c8d1bf2cdebbc4e50d1e8348003f64f419cd0b --- /dev/null +++ b/charm-packages/nopasswd_proxy_charm_vnf/cloud_init/cloud-config.txt @@ -0,0 +1,12 @@ +#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 diff --git a/charm-packages/nopasswd_proxy_charm_vnf/icons/osm.png b/charm-packages/nopasswd_proxy_charm_vnf/icons/osm.png new file mode 100644 index 0000000000000000000000000000000000000000..62012d2a2b491bdcd536d62c3c3c863c0d8c1b33 Binary files /dev/null and b/charm-packages/nopasswd_proxy_charm_vnf/icons/osm.png differ diff --git a/charm-packages/nopasswd_proxy_charm_vnf/nopasswd_proxy_charm_vnfd.yaml b/charm-packages/nopasswd_proxy_charm_vnf/nopasswd_proxy_charm_vnfd.yaml new file mode 100644 index 0000000000000000000000000000000000000000..f5765faa36945a072e883353f90c3bf26c825266 --- /dev/null +++ b/charm-packages/nopasswd_proxy_charm_vnf/nopasswd_proxy_charm_vnfd.yaml @@ -0,0 +1,69 @@ +vnfd:vnfd-catalog: + vnfd: + - id: nopasswd_proxy_charm-vnf + name: nopasswd_proxy_charm-vnf + short-name: nopasswd_proxy_charm-vnf + version: 1.0 + description: A VNF consisting of 1 VDU connected to two external VL, and one for data and another one for management + logo: osm.png + connection-point: + - id: vnf-mgmt + name: vnf-mgmt + short-name: vnf-mgmt + type: VPORT + - id: vnf-data + name: vnf-data + short-name: vnf-data + type: VPORT + mgmt-interface: + cp: vnf-mgmt + vdu: + - id: mgmtVM + name: mgmtVM + image: ubuntu18.04 + count: 1 + vm-flavor: + vcpu-count: 1 + memory-mb: 1024 + storage-gb: 10 + interface: + - name: mgmtVM-eth0 + position: 1 + type: EXTERNAL + virtual-interface: + type: PARAVIRT + external-connection-point-ref: vnf-mgmt + - name: dataVM-xe0 + position: 2 + type: EXTERNAL + virtual-interface: + type: PARAVIRT + external-connection-point-ref: vnf-data + cloud-init-file: cloud-config.txt + vnf-configuration: + juju: + charm: simple + initial-config-primitive: + - seq: 1 + name: config + parameter: + - name: ssh-hostname + value: + - name: ssh-username + value: ubuntu + - seq: 2 + name: touch + parameter: + - name: filename + data-type: STRING + value: '/home/ubuntu/first-touch' + config-primitive: + - name: touch + parameter: + - name: filename + data-type: STRING + default-value: '/home/ubuntu/touched' + config-access: + ssh-access: + default-user: ubuntu + required: true \ No newline at end of file