Skip to content
Snippets Groups Projects
Commit 85b3f4d6 authored by Mark Beierl's avatar Mark Beierl
Browse files

Merge branch 'ns-relations' into 'master'

Add NS relations packages

See merge request !69
parents 3aa99d92 2bf12ff3
No related branches found
No related tags found
1 merge request!69Add NS relations packages
Showing
with 302 additions and 0 deletions
......@@ -37,3 +37,9 @@
[submodule "charm-packages/vnf_relations_vnf/charms/simple_provides/mod/operator"]
path = charm-packages/vnf_relations_vnf/charms/simple_provides/mod/operator
url = https://github.com/canonical/operator
[submodule "charm-packages/ns_relations_requires_vnf/charms/simple_requires/mod/operator"]
path = charm-packages/ns_relations_requires_vnf/charms/simple_requires/mod/operator
url = https://github.com/canonical/operator
[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
charm-packages/ns_relations_ns/icons/osm.png

54.6 KiB

nsd:nsd-catalog:
nsd:
- id: ns_relations-ns
name: ns_relations-ns
short-name: ns_relations-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: ns_relations_provides-vnf
member-vnf-index: '1'
- vnfd-id-ref: ns_relations_requires-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: ns_relations_provides-vnf
member-vnf-index-ref: '1'
vnfd-connection-point-ref: provides-mgmt
- vnfd-id-ref: ns_relations_requires-vnf
member-vnf-index-ref: '2'
vnfd-connection-point-ref: requires-mgmt
ns-configuration:
relation:
- name: relation
entities:
- id: simple_provides
endpoint: interface
- id: simple_requires
endpoint: interface
\ No newline at end of file
##
# 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
##
# 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
../src/charm.py
\ No newline at end of file
../src/charm.py
\ No newline at end of file
../src/charm.py
\ No newline at end of file
../mod/operator/ops
\ No newline at end of file
##
# 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-provides
summary: A simple native charm
description: |
Simple native charm
series:
- bionic
- xenial
- focal
provides:
interface:
interface: interface
\ No newline at end of file
Subproject commit a84ce8776b368a8b2bccdb173716e342db9a6b36
#!/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)
# Listen to relation changed
self.framework.observe(
self.on.interface_relation_changed, self.on_interface_relation_changed
)
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()
def on_interface_relation_changed(self, event):
parameter = "Hello"
event.relation.data[self.model.unit]["parameter"] = parameter
self.model.unit.status = ActiveStatus("Parameter sent: {}".format(parameter))
if __name__ == "__main__":
main(MyNativeCharm)
#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
charm-packages/ns_relations_provides_vnf/icons/osm.png

54.6 KiB

vnfd:vnfd-catalog:
vnfd:
- id: ns_relations_provides-vnf
name: ns_relations_provides-vnf
short-name: ns_relations_provides-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: provides-mgmt
name: provides-mgmt
short-name: provides-mgmt
type: VPORT
mgmt-interface:
cp: provides-mgmt
vdu:
- id: simple_provides
name: simple_provides
image: ubuntu18.04
count: 1
vm-flavor:
vcpu-count: 1
memory-mb: 1024
storage-gb: 10
interface:
- name: simple_provides-eth0
position: 1
type: EXTERNAL
virtual-interface:
type: PARAVIRT
external-connection-point-ref: provides-mgmt
cloud-init-file: cloud-config.txt
vnf-configuration:
juju:
charm: simple_provides
proxy: false
config-access:
ssh-access:
required: True
default-user: ubuntu
initial-config-primitive:
- seq: 1
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'
##
# 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
##
# 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
../src/charm.py
\ No newline at end of file
../src/charm.py
\ No newline at end of file
../src/charm.py
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment