diff --git a/simple_nopasswd_ns/README b/simple_nopasswd_ns/README new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/simple_nopasswd_ns/icons/osm.png b/simple_nopasswd_ns/icons/osm.png new file mode 100644 index 0000000000000000000000000000000000000000..62012d2a2b491bdcd536d62c3c3c863c0d8c1b33 Binary files /dev/null and b/simple_nopasswd_ns/icons/osm.png differ diff --git a/simple_nopasswd_ns/simple_nopasswd_nsd.yaml b/simple_nopasswd_ns/simple_nopasswd_nsd.yaml new file mode 100644 index 0000000000000000000000000000000000000000..a9bf29eea394ab30c8f04bd9c9350cac121dd0ee --- /dev/null +++ b/simple_nopasswd_ns/simple_nopasswd_nsd.yaml @@ -0,0 +1,39 @@ +nsd:nsd-catalog: + nsd: + - id: simple_nopasswd-ns + name: simple_nopasswd-ns + short-name: simple_nopasswd-ns + description: NS with 2 VNFs simple_nopasswd-vnf connected by datanet and mgmtnet VLs + version: '1.0' + logo: osm.png + constituent-vnfd: + - vnfd-id-ref: simple_nopasswd-vnf + member-vnf-index: '1' + # - vnfd-id-ref: hackfest-simplecharm-vnf + # member-vnf-index: '2' + vld: + - id: mgmtnet + name: mgmtnet + short-name: mgmtnet + type: ELAN + mgmt-network: 'true' + vim-network-name: mgmt + vnfd-connection-point-ref: + - vnfd-id-ref: simple_nopasswd-vnf + member-vnf-index-ref: '1' + vnfd-connection-point-ref: vnf-mgmt + # - vnfd-id-ref: hackfest-simplecharm-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: simple_nopasswd-vnf + member-vnf-index-ref: '1' + vnfd-connection-point-ref: vnf-data + # - vnfd-id-ref: hackfest-simplecharm-vnf + # member-vnf-index-ref: '2' + # vnfd-connection-point-ref: vnf-data + diff --git a/simple_nopasswd_vnf/README b/simple_nopasswd_vnf/README new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/simple_nopasswd_vnf/charms/layers/simple/README.ex b/simple_nopasswd_vnf/charms/layers/simple/README.ex new file mode 100644 index 0000000000000000000000000000000000000000..b6816b22ade2fa36326d7e1f612b6f6203768949 --- /dev/null +++ b/simple_nopasswd_vnf/charms/layers/simple/README.ex @@ -0,0 +1,65 @@ +# Overview + +Describe the intended usage of this charm and anything unique about how this +charm relates to others here. + +This README will be displayed in the Charm Store, it should be either Markdown +or RST. Ideal READMEs include instructions on how to use the charm, expected +usage, and charm features that your audience might be interested in. For an +example of a well written README check out Hadoop: +http://jujucharms.com/charms/precise/hadoop + +Use this as a Markdown reference if you need help with the formatting of this +README: http://askubuntu.com/editing-help + +This charm provides [service][]. Add a description here of what the service +itself actually does. + +Also remember to check the [icon guidelines][] so that your charm looks good +in the Juju GUI. + +# Usage + +Step by step instructions on using the charm: + +juju deploy servicename + +and so on. If you're providing a web service or something that the end user +needs to go to, tell them here, especially if you're deploying a service that +might listen to a non-default port. + +You can then browse to http://ip-address to configure the service. + +## Scale out Usage + +If the charm has any recommendations for running at scale, outline them in +examples here. For example if you have a memcached relation that improves +performance, mention it here. + +## Known Limitations and Issues + +This not only helps users but gives people a place to start if they want to help +you add features to your charm. + +# Configuration + +The configuration options will be listed on the charm store, however If you're +making assumptions or opinionated decisions in the charm (like setting a default +administrator password), you should detail that here so the user knows how to +change it immediately, etc. + +# Contact Information + +Though this will be listed in the charm store itself don't assume a user will +know that, so include that information here: + +## Upstream Project Name + + - Upstream website + - Upstream bug tracker + - Upstream mailing list or contact information + - Feel free to add things if it's useful for users + + +[service]: http://example.com +[icon guidelines]: https://jujucharms.com/docs/stable/authors-charm-icon diff --git a/simple_nopasswd_vnf/charms/layers/simple/actions.yaml b/simple_nopasswd_vnf/charms/layers/simple/actions.yaml new file mode 100644 index 0000000000000000000000000000000000000000..f40782a27dddc1038166a686ad85a041565b4f54 --- /dev/null +++ b/simple_nopasswd_vnf/charms/layers/simple/actions.yaml @@ -0,0 +1,26 @@ +## +# Copyright 2016 Canonical Ltd. +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +## + +"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/simple_nopasswd_vnf/charms/layers/simple/actions/touch b/simple_nopasswd_vnf/charms/layers/simple/actions/touch new file mode 100755 index 0000000000000000000000000000000000000000..d85d3facc597b486ac5b5cfa26ee9d74089c90cb --- /dev/null +++ b/simple_nopasswd_vnf/charms/layers/simple/actions/touch @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 +## +# Copyright 2016 Canonical Ltd. +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +## +import sys +sys.path.append('lib') + +from charms.reactive import main +from charms.reactive import set_state +from charmhelpers.core.hookenv import action_fail, action_name + +""" +`set_state` only works here because it's flushed to disk inside the `main()` +loop. remove_state will need to be called inside the action method. +""" +set_state('actions.{}'.format(action_name())) + +try: + main() +except Exception as e: + action_fail(repr(e)) diff --git a/simple_nopasswd_vnf/charms/layers/simple/config.yaml b/simple_nopasswd_vnf/charms/layers/simple/config.yaml new file mode 100644 index 0000000000000000000000000000000000000000..51f2ce4a07bddfbc72679ec14280fd6461cb307d --- /dev/null +++ b/simple_nopasswd_vnf/charms/layers/simple/config.yaml @@ -0,0 +1,14 @@ +options: + string-option: + type: string + default: "Default Value" + description: "A short description of the configuration option" + boolean-option: + type: boolean + default: False + description: "A short description of the configuration option" + int-option: + type: int + default: 9001 + description: "A short description of the configuration option" + diff --git a/simple_nopasswd_vnf/charms/layers/simple/icon.svg b/simple_nopasswd_vnf/charms/layers/simple/icon.svg new file mode 100644 index 0000000000000000000000000000000000000000..96a5d0c068d4b3271c7e397f76cf77fdf0651038 --- /dev/null +++ b/simple_nopasswd_vnf/charms/layers/simple/icon.svg @@ -0,0 +1,279 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/simple_nopasswd_vnf/charms/layers/simple/layer.yaml b/simple_nopasswd_vnf/charms/layers/simple/layer.yaml new file mode 100644 index 0000000000000000000000000000000000000000..9187216ba37080c543adb1a4a7950391e8bd5724 --- /dev/null +++ b/simple_nopasswd_vnf/charms/layers/simple/layer.yaml @@ -0,0 +1,4 @@ +includes: ['layer:basic', 'layer:vnfproxy'] +options: + basic: + use_venv: false \ No newline at end of file diff --git a/simple_nopasswd_vnf/charms/layers/simple/metadata.yaml b/simple_nopasswd_vnf/charms/layers/simple/metadata.yaml new file mode 100644 index 0000000000000000000000000000000000000000..72df2a6f3ae0377fba3018d9b7bcacc8a698b150 --- /dev/null +++ b/simple_nopasswd_vnf/charms/layers/simple/metadata.yaml @@ -0,0 +1,16 @@ +name: simple +summary: A simple VNF proxy charm +maintainer: Adam Israel +description: | + VNF proxy charms are a lightweight version of a charm that, rather than + installing software on the same machine, execute commands over an ssh channel. +tags: + # Replace misc with one or more whitelisted tags from this list: + # https://jujucharms.com/docs/stable/authors-charm-metadata + - misc + - osm + - vnf +series: +- xenial +- trusty +subordinate: false \ No newline at end of file diff --git a/simple_nopasswd_vnf/charms/layers/simple/reactive/simple.py b/simple_nopasswd_vnf/charms/layers/simple/reactive/simple.py new file mode 100644 index 0000000000000000000000000000000000000000..21e3ff9175516ff66fa3eeac0cd3d4229a8ed9e8 --- /dev/null +++ b/simple_nopasswd_vnf/charms/layers/simple/reactive/simple.py @@ -0,0 +1,35 @@ +from charmhelpers.core.hookenv import ( + action_get, + action_fail, + action_set, + status_set, +) +from charms.reactive import ( + clear_flag, + set_flag, + when, + when_not, +) +import charms.sshproxy + + +@when('sshproxy.configured') +@when_not('simple.installed') +def install_simple_proxy_charm(): + set_flag('simple.installed') + status_set('active', 'Ready!') + + +@when('actions.touch') +def touch(): + err = '' + try: + filename = action_get('filename') + cmd = ['touch {}'.format(filename)] + result, err = charms.sshproxy._run(cmd) + except: + action_fail('command failed:' + err) + else: + action_set({'outout': result}) + finally: + clear_flag('actions.touch') diff --git a/simple_nopasswd_vnf/charms/layers/simple/tests/00-setup b/simple_nopasswd_vnf/charms/layers/simple/tests/00-setup new file mode 100644 index 0000000000000000000000000000000000000000..f0616a560a811bae78d7872dd433d612909c73cd --- /dev/null +++ b/simple_nopasswd_vnf/charms/layers/simple/tests/00-setup @@ -0,0 +1,5 @@ +#!/bin/bash + +sudo add-apt-repository ppa:juju/stable -y +sudo apt-get update +sudo apt-get install amulet python-requests -y diff --git a/simple_nopasswd_vnf/charms/layers/simple/tests/10-deploy b/simple_nopasswd_vnf/charms/layers/simple/tests/10-deploy new file mode 100644 index 0000000000000000000000000000000000000000..9a26117089498423ebba7dda3f7e3acb50ba54e7 --- /dev/null +++ b/simple_nopasswd_vnf/charms/layers/simple/tests/10-deploy @@ -0,0 +1,35 @@ +#!/usr/bin/python3 + +import amulet +import requests +import unittest + + +class TestCharm(unittest.TestCase): + def setUp(self): + self.d = amulet.Deployment() + + self.d.add('simple') + self.d.expose('simple') + + self.d.setup(timeout=900) + self.d.sentry.wait() + + self.unit = self.d.sentry['simple'][0] + + def test_service(self): + # test we can access over http + page = requests.get('http://{}'.format(self.unit.info['public-address'])) + self.assertEqual(page.status_code, 200) + # Now you can use self.d.sentry[SERVICE][UNIT] to address each of the units and perform + # more in-depth steps. Each self.d.sentry[SERVICE][UNIT] has the following methods: + # - .info - An array of the information of that unit from Juju + # - .file(PATH) - Get the details of a file on that unit + # - .file_contents(PATH) - Get plain text output of PATH file from that unit + # - .directory(PATH) - Get details of directory + # - .directory_contents(PATH) - List files and folders in PATH on that unit + # - .relation(relation, service:rel) - Get relation data from return service + + +if __name__ == '__main__': + unittest.main() diff --git a/simple_nopasswd_vnf/cloud_init/cloud-config.txt b/simple_nopasswd_vnf/cloud_init/cloud-config.txt new file mode 100644 index 0000000000000000000000000000000000000000..f6c1b9dcf3a0506e7366e58d0318a5df5f2639ce --- /dev/null +++ b/simple_nopasswd_vnf/cloud_init/cloud-config.txt @@ -0,0 +1,13 @@ +#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/simple_nopasswd_vnf/icons/osm.png b/simple_nopasswd_vnf/icons/osm.png new file mode 100644 index 0000000000000000000000000000000000000000..62012d2a2b491bdcd536d62c3c3c863c0d8c1b33 Binary files /dev/null and b/simple_nopasswd_vnf/icons/osm.png differ diff --git a/simple_nopasswd_vnf/simple_nopasswd_vnfd.yaml b/simple_nopasswd_vnf/simple_nopasswd_vnfd.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c4a2696308a1d29be6199a588444ee97990cbfc2 --- /dev/null +++ b/simple_nopasswd_vnf/simple_nopasswd_vnfd.yaml @@ -0,0 +1,108 @@ +vnfd:vnfd-catalog: + vnfd: + - 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 + description: A VNF consisting of 2 VDUs connected to an internal VL, and one VDU + with cloud-init + id: simple_nopasswd-vnf + internal-vld: + - id: internal + internal-connection-point: + - id-ref: mgmtVM-internal + - id-ref: dataVM-internal + name: internal + short-name: internal + type: ELAN + logo: osm.png + mgmt-interface: + cp: vnf-mgmt + name: simple_nopasswd-vnf + short-name: simple_nopasswd-vnf + vdu: + - cloud-init-file: cloud-config.txt + count: '1' + id: mgmtVM + image: ubuntu16.04 + interface: + - external-connection-point-ref: vnf-mgmt + name: mgmtVM-eth0 + position: '1' + type: EXTERNAL + virtual-interface: + type: PARAVIRT + - internal-connection-point-ref: mgmtVM-internal + name: mgmtVM-eth1 + position: '2' + type: INTERNAL + virtual-interface: + type: PARAVIRT + internal-connection-point: + - id: mgmtVM-internal + name: mgmtVM-internal + short-name: mgmtVM-internal + type: VPORT + name: mgmtVM + vm-flavor: + memory-mb: '1024' + storage-gb: '10' + vcpu-count: '1' + - count: '1' + id: dataVM + image: ubuntu16.04 + interface: + - internal-connection-point-ref: dataVM-internal + name: dataVM-eth0 + position: '1' + type: INTERNAL + virtual-interface: + type: PARAVIRT + - external-connection-point-ref: vnf-data + name: dataVM-xe0 + position: '2' + type: EXTERNAL + virtual-interface: + type: PARAVIRT + internal-connection-point: + - id: dataVM-internal + name: dataVM-internal + short-name: dataVM-internal + type: VPORT + name: dataVM + vm-flavor: + memory-mb: '1024' + storage-gb: '10' + vcpu-count: '1' + version: '1.0' + vnf-configuration: + config-access: + ssh-access: + default-user: ubuntu + required: true + config-primitive: + - name: touch + parameter: + - data-type: STRING + default-value: /home/ubuntu/touched + name: filename + initial-config-primitive: + - name: config + parameter: + - name: ssh-hostname + value: + - name: ssh-username + value: ubuntu + seq: '1' + - name: touch + parameter: + - name: filename + value: /home/ubuntu/first-touch + seq: '2' + juju: + charm: simple diff --git a/ubuntu_cloudinit_ns/README b/ubuntu_cloudinit_ns/README new file mode 100644 index 0000000000000000000000000000000000000000..eeb8e117ba11d728b9825f77976fc7207971d8c3 --- /dev/null +++ b/ubuntu_cloudinit_ns/README @@ -0,0 +1,2 @@ +Descriptor created by OSM descriptor package generated +Created on Mon May 27 13:17:59 UTC 2019 diff --git a/ubuntu_cloudinit_ns/ubuntu_cloudinit_nsd.yaml b/ubuntu_cloudinit_ns/ubuntu_cloudinit_nsd.yaml new file mode 100644 index 0000000000000000000000000000000000000000..56da9c7aef6b716e9acf70596043cbbeb4e5b9e8 --- /dev/null +++ b/ubuntu_cloudinit_ns/ubuntu_cloudinit_nsd.yaml @@ -0,0 +1,26 @@ +nsd:nsd-catalog: + nsd: + - id: ubuntu_cloudinit-ns + name: ubuntu_cloudinit-ns + short-name: ubuntu_cloudinit-ns + description: Generated by OSM package generator + vendor: OSM + version: '1.0' + + + constituent-vnfd: + - member-vnf-index: 1 + vnfd-id-ref: ubuntu_cloudinit-vnf + + vld: + # Networks for the VNFs + - id: mgmtnet + name: mgmtnet + short-name: mgmtnet + type: ELAN + mgmt-network: 'true' + # vim-network-name: + vnfd-connection-point-ref: + - member-vnf-index-ref: 1 + vnfd-id-ref: ubuntu_cloudinit-vnf + vnfd-connection-point-ref: vnf-cp0 diff --git a/ubuntu_cloudinit_vnf/README b/ubuntu_cloudinit_vnf/README new file mode 100644 index 0000000000000000000000000000000000000000..55a357d6ae53865bca7298288735a962fe4d3cad --- /dev/null +++ b/ubuntu_cloudinit_vnf/README @@ -0,0 +1,2 @@ +Descriptor created by OSM descriptor package generated +Created on Mon May 27 13:11:46 UTC 2019 diff --git a/ubuntu_cloudinit_vnf/cloud_init/cloud-init.cfg b/ubuntu_cloudinit_vnf/cloud_init/cloud-init.cfg new file mode 100644 index 0000000000000000000000000000000000000000..fae0cf1a8ec349186a29a2b0ed2373285044d9b8 --- /dev/null +++ b/ubuntu_cloudinit_vnf/cloud_init/cloud-init.cfg @@ -0,0 +1,5 @@ +#cloud-config +password: {{ password }} +chpasswd: { expire: False } +ssh_pwauth: True + diff --git a/ubuntu_cloudinit_vnf/ubuntu_cloudinit_vnfd.yaml b/ubuntu_cloudinit_vnf/ubuntu_cloudinit_vnfd.yaml new file mode 100644 index 0000000000000000000000000000000000000000..8136f659e48793f42d64adb22baa43cfbf6e60a3 --- /dev/null +++ b/ubuntu_cloudinit_vnf/ubuntu_cloudinit_vnfd.yaml @@ -0,0 +1,38 @@ +vnfd:vnfd-catalog: + vnfd: + - id: ubuntu_cloudinit-vnf + name: ubuntu_cloudinit-vnf + short-name: ubuntu_cloudinit-vnf + description: Generated by OSM package generator + vendor: OSM + version: '1.0' + + # Management interface + mgmt-interface: + cp: vnf-cp0 + + vdu: + - id: ubuntu_cloudinit-vnf-VM + name: ubuntu_cloudinit-vnf-VM + description: ubuntu_cloudinit-vnf-VM + count: 1 + cloud-init-file: cloud-init.cfg + + vm-flavor: + vcpu-count: 2 + memory-mb: 2048 + storage-gb: 10 + + # Image including the full path + image: 'ubuntu16.04' + + interface: + - name: eth0 + type: EXTERNAL + virtual-interface: + type: PARAVIRT + external-connection-point-ref: vnf-cp0 + + connection-point: + - name: vnf-cp0 +