From: hoban Date: Fri, 2 Mar 2018 14:34:43 +0000 (+0100) Subject: Merge "Set default true to 'port-security-enable'" X-Git-Tag: v3.1.0~9 X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FIM.git;a=commitdiff_plain;h=00be8bb5c4445cc0e8b9a5a90189176a3d82ec42;hp=d4f15a7637357eeb74f105d843ab0a990c4c5638 Merge "Set default true to 'port-security-enable'" --- diff --git a/.gitignore b/.gitignore index 0025eee..c1bcfc2 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,9 @@ dist *egg-info *.gz osm_im +osm_im_trees pyangbind pyang dists pool +.idea diff --git a/Makefile b/Makefile index 706bab4..666c9df 100644 --- a/Makefile +++ b/Makefile @@ -19,11 +19,17 @@ PYANG:= pyang PYBINDPLUGIN:=$(shell /usr/bin/env python -c \ 'import pyangbind; import os; print "%s/plugin" % os.path.dirname(pyangbind.__file__)') -YANG_MODELS := vnfd nsd -PYTHON_MODELS := $(addsuffix .py, $(YANG_MODELS)) -PYTHON_JSONSCHEMAS := $(addsuffix .jsonschema, $(YANG_MODELS)) +YANG_DESC_MODELS := vnfd nsd +YANG_RECORD_MODELS := vnfr nsr +PYTHON_MODELS := $(addsuffix .py, $(YANG_DESC_MODELS)) +PYTHON_JSONSCHEMAS := $(addsuffix .jsonschema, $(YANG_DESC_MODELS)) +YANG_DESC_TREES := $(addsuffix .tree.txt, $(YANG_DESC_MODELS)) +YANG_DESC_JSTREES := $(addsuffix .html, $(YANG_DESC_MODELS)) +YANG_RECORD_TREES := $(addsuffix .rec.tree.txt, $(YANG_RECORD_MODELS)) +YANG_RECORD_JSTREES := $(addsuffix .rec.html, $(YANG_RECORD_MODELS)) OUT_DIR := osm_im +TREES_DIR := osm_im_trees MODEL_DIR := models/yang RW_PB_EXT := build/yang/rw-pb-ext.yang Q?=@ @@ -33,10 +39,15 @@ PYANG_OPTIONS := -Werror all: $(PYTHON_MODELS) pyangbind $(MAKE) package +trees: $(YANG_DESC_TREES) $(YANG_DESC_JSTREES) $(YANG_RECORD_TREES) $(YANG_RECORD_JSTREES) + $(OUT_DIR): $(Q)mkdir -p $(OUT_DIR) $(Q)touch $(OUT_DIR)/__init__.py +$(TREES_DIR): + $(Q)mkdir -p $(TREES_DIR) + %.py: $(OUT_DIR) $(RW_PB_EXT) $(Q)echo generating $@ from $*.yang $(Q)pyang $(PYANG_OPTIONS) --path build/yang --path $(MODEL_DIR) --plugindir $(PYBINDPLUGIN) -f pybind -o $(OUT_DIR)/$@ $(MODEL_DIR)/$*.yang @@ -45,6 +56,28 @@ $(OUT_DIR): $(Q)echo generating $@ from $*.yang $(Q)pyang $(PYANG_OPTIONS) --path build/yang --path $(MODEL_DIR) --plugindir pyang-json-schema-plugin -f json-schema -o $(OUT_DIR)/$@ $(MODEL_DIR)/$*.yang +%.tree.txt: $(TREES_DIR) + $(Q)echo generating $@ from $*.yang + $(Q)pyang $(PYANG_OPTIONS) --path build/yang --path $(MODEL_DIR) -f tree -o $(TREES_DIR)/$@ $(MODEL_DIR)/$*.yang + +%.html: $(TREES_DIR) + $(Q)echo generating $@ from $*.yang + $(Q)pyang $(PYANG_OPTIONS) --path build/yang --path $(MODEL_DIR) -f jstree -o $(TREES_DIR)/$@ $(MODEL_DIR)/$*.yang + $(Q)sed -r -i 's|data\:image/gif\;base64,R0lGODlhS.*RCAA7|https://osm.etsi.org/images/OSM-logo.png\" width=\"175\" height=\"60|g' $(TREES_DIR)/$@ + $(Q)sed -r -i 's|||g' $(TREES_DIR)/$@ + +%.rec.tree.txt: $(TREES_DIR) + $(Q)echo generating $@ from $*.yang + $(Q)pyang $(PYANG_OPTIONS) --path build/yang --path $(MODEL_DIR) -f tree -o $(TREES_DIR)/$@ $(MODEL_DIR)/$*.yang + $(Q)mv $(TREES_DIR)/$@ $(TREES_DIR)/$*.tree.txt + +%.rec.html: $(TREES_DIR) + $(Q)echo generating $@ from $*.yang + $(Q)pyang $(PYANG_OPTIONS) --path build/yang --path $(MODEL_DIR) -f jstree -o $(TREES_DIR)/$@ $(MODEL_DIR)/rw-project.yang $(MODEL_DIR)/$*.yang + $(Q)sed -r -i 's|data\:image/gif\;base64,R0lGODlhS.*RCAA7|https://osm.etsi.org/images/OSM-logo.png\" width=\"175\" height=\"60|g' $(TREES_DIR)/$@ + $(Q)sed -r -i 's|||g' $(TREES_DIR)/$@ + $(Q)mv $(TREES_DIR)/$@ $(TREES_DIR)/$*.html + $(RW_PB_EXT): $(Q)mkdir -p $$(dirname $@) $(Q)wget -q https://raw.githubusercontent.com/RIFTIO/RIFT.ware/RIFT.ware-4.4.1/modules/core/util/yangtools/yang/rw-pb-ext.yang -O $@ @@ -53,8 +86,8 @@ package: tox -e build pyangbind: pyang - git clone https://github.com/robshakir/pyangbind - cd pyangbind; python setup.py --command-packages=stdeb.command bdist_deb; cd .. + git clone https://github.com/alf-tierno/pyangbind + cd pyangbind; git checkout issue151; python setup.py --command-packages=stdeb.command bdist_deb; cd .. mkdir -p deb_dist cp pyangbind/deb_dist/*.deb deb_dist @@ -68,4 +101,4 @@ pyang-json-schema-plugin: git clone https://github.com/cmoberg/pyang-json-schema-plugin clean: - $(Q)rm -rf build dist osm_im.egg-info deb deb_dist *.gz pyang pyangbind pyang-json-schema-plugin $(OUT_DIR) + $(Q)rm -rf build dist osm_im.egg-info deb deb_dist *.gz pyang pyangbind pyang-json-schema-plugin $(OUT_DIR) $(TREES_DIR) diff --git a/models/yang/mano-types.yang b/models/yang/mano-types.yang index 8950c7a..b6350ae 100644 --- a/models/yang/mano-types.yang +++ b/models/yang/mano-types.yang @@ -191,7 +191,7 @@ module mano-types } } } - + grouping image-properties { leaf image { description @@ -202,6 +202,7 @@ module mano-types the same name as entered here. "; type string; + mandatory "true"; } leaf image-checksum { @@ -272,6 +273,11 @@ module mano-types description "Juju charm to use with the VNF or VDU."; type string; } + leaf proxy { + description "Is this a proxy charm?"; + type boolean; + default true; + } uses manotypes:vca-relationships; } } diff --git a/models/yang/nsd.yang b/models/yang/nsd.yang index 4a88eac..55b40eb 100644 --- a/models/yang/nsd.yang +++ b/models/yang/nsd.yang @@ -35,6 +35,10 @@ module nsd prefix "manotypes"; } + import ietf-inet-types { + prefix "inet"; + } + revision 2017-02-28 { description "Update model to support projects."; @@ -100,6 +104,15 @@ module nsd } } + leaf vnfd-connection-point-ref { + description "A reference to a connection point name"; + type leafref { + path "/vnfd:vnfd-catalog/vnfd:vnfd" + + "[vnfd:id = current()/../vnfd-id-ref]/" + + "vnfd:connection-point/vnfd:name"; + } + } + leaf vnfd-id-ref { description "A reference to a VNFD"; @@ -110,14 +123,11 @@ module nsd } } - leaf vnfd-connection-point-ref { - description "A reference to a connection point name"; - type leafref { - path "/vnfd:vnfd-catalog/vnfd:vnfd" + - "[vnfd:id = current()/../vnfd-id-ref]/" + - "vnfd:connection-point/vnfd:name"; - } + leaf ip-address { + description "IP address of the connection point"; + type inet:ip-address; } + } } } @@ -298,6 +308,12 @@ module nsd container nsd-catalog { + leaf schema-version { + description "Schema version for the NSD. If unspecified, it assumes v3.0"; + type string; + default "v3.0"; + } + list nsd { key id; diff --git a/models/yang/nsr.yang b/models/yang/nsr.yang index 12cf850..4f2eb73 100644 --- a/models/yang/nsr.yang +++ b/models/yang/nsr.yang @@ -217,6 +217,12 @@ module nsr key "id"; unique "name"; + leaf schema-version { + description "Schema version for the NSR. If unspecified, it assumes v3.0"; + type string; + default "v3.0"; + } + leaf id { description "Identifier for the NSR."; type yang:uuid; diff --git a/models/yang/vlr.yang b/models/yang/vlr.yang index 6a9b591..9137539 100644 --- a/models/yang/vlr.yang +++ b/models/yang/vlr.yang @@ -50,6 +50,12 @@ module vlr augment "/rw-project:project" { container vlr-catalog { + leaf schema-version { + description "Schema version for the VLR. If unspecified, it assumes v3.0"; + type string; + default "v3.0"; + } + config false; list vlr { diff --git a/models/yang/vnfd-base.yang b/models/yang/vnfd-base.yang index 1fd2295..3ab3eab 100644 --- a/models/yang/vnfd-base.yang +++ b/models/yang/vnfd-base.yang @@ -101,7 +101,7 @@ module vnfd-base E1000 : Emulate E1000 interface. RTL8139 : Emulate RTL8139 interface. PCNET : Emulate PCNET interface. - OM-MGMT : Used to specify openmano mgmt external-connection type"; + OM-MGMT : Deprecated! Use VIRTIO instead and set the VNF management interface at vnfd:mgmt-interface:cp"; type enumeration { enum OM-MGMT; @@ -217,7 +217,7 @@ module vnfd-base case cp { description - "Use the ip address associated with this connection point."; + "Use the ip address associated with this connection point. This cp is then considered as management."; leaf cp { type leafref { path "../../connection-point/name"; @@ -304,6 +304,10 @@ module vnfd-base path "../../../vdu/internal-connection-point/id"; } } + leaf ip-address { + description "IP address of the internal connection point"; + type inet:ip-address; + } } uses manotypes:provider-network; @@ -392,6 +396,25 @@ module vnfd-base uses manotypes:image-properties; + list alternative-images { + key "vim-type"; + description + "List of alternative images per VIM type. + Different images can be used for specific types of VIMs instead + of the default image. This allows deployments in sites where the + image identifier in the VIM is given by the VIM provider and + cannot be modified. + If an alternative image is specified for a VIM type, it will prevail + over the default image"; + + leaf vim-type { + description "VIM type: openvim, openstack, vmware, aws, etc."; + type string; + } + + uses manotypes:image-properties; + } + container vdu-configuration { uses manotypes:vca-configuration; } @@ -465,6 +488,17 @@ module vnfd-base default "EXTERNAL"; } + leaf mac-address { + description + "MAC address of the interface. + Some VNFs require a specific MAC address to be configured + in the interface. While this is not recommended at all in + NFV environments, this parameter exists to allow those + scenarios. + This parameter will be likely deprecated in the future."; + type string; + } + choice connection-point-type { case internal { leaf internal-connection-point-ref { diff --git a/models/yang/vnfd.yang b/models/yang/vnfd.yang index d1c9df6..4816166 100644 --- a/models/yang/vnfd.yang +++ b/models/yang/vnfd.yang @@ -43,6 +43,12 @@ module vnfd description "Virtual Network Function Descriptor (VNFD)."; + leaf schema-version { + description "Schema version for the VNFD. If unspecified, it assumes v3.0"; + type string; + default "v3.0"; + } + list vnfd { key "id"; diff --git a/models/yang/vnfr.yang b/models/yang/vnfr.yang index b669f97..6d23065 100644 --- a/models/yang/vnfr.yang +++ b/models/yang/vnfr.yang @@ -197,6 +197,12 @@ module vnfr augment "/rw-project:project" { container vnfr-catalog { + leaf schema-version { + description "Schema version for the VNFR. If unspecified, it assumes v3.0"; + type string; + default "v3.0"; + } + config false; list vnfr { description diff --git a/tests/test_python.py b/tests/test_python.py new file mode 100644 index 0000000..f6b4f7d --- /dev/null +++ b/tests/test_python.py @@ -0,0 +1,78 @@ +import osm_im.vnfd as vnfd_catalog +from pyangbind.lib.serialise import pybindJSONDecoder +import unittest +import yaml + +VNFD_YAML = """ +vnfd-catalog: + vnfd: + - id: cirros_vnfd + name: cirros_vnf + short-name: cirros_vnf + description: Simple VNF example with a cirros + vendor: OSM + version: '1.0' + + # Place the logo as png in icons directory and provide the name here + logo: cirros-64.png + + # Management interface + mgmt-interface: + cp: eth0 + + # Atleast one VDU need to be specified + vdu: + - id: cirros_vnfd-VM + name: cirros_vnfd-VM + description: cirros_vnfd-VM + count: 1 + + # Flavour of the VM to be instantiated for the VDU + # flavor below can fit into m1.micro + vm-flavor: + vcpu-count: 1 + memory-mb: 256 + storage-gb: 2 + + # Image/checksum or image including the full path + image: 'cirros034' + #checksum: + + interface: + # Specify the external interfaces + # There can be multiple interfaces defined + - name: eth0 + type: EXTERNAL + virtual-interface: + type: VIRTIO + bandwidth: '0' + vpci: 0000:00:0a.0 + external-connection-point-ref: eth0 + + connection-point: + - name: eth0 + type: VPORT +""" + +class PythonTest(unittest.TestCase): + + + def test_python_compatibility(self): + """A simple test to verify Python compatibility. + + This test exercises basic IM interoperability with supported versions + of Python in order to verify the IM libraries compatibility. + + As of 30 Nov 2017, the IM library fails with Python3. This invokes that + failing code so that it can be repeatably tested: + + ValueError: '_pybind_generated_by' in __slots__ conflicts with class variable + """ + + try: + data = yaml.load(VNFD_YAML) + + myvnfd = vnfd_catalog.vnfd() + pybindJSONDecoder.load_ietf_json(data, None, None, obj=myvnfd) + except ValueError: + assert False diff --git a/tox.ini b/tox.ini index 4493390..c1c0215 100644 --- a/tox.ini +++ b/tox.ini @@ -5,6 +5,7 @@ toxworkdir={homedir}/.tox [testenv] deps=nose mock + pyyaml commands=nosetests [testenv:flake8]