From 70434c15924602743b05f4fcb745fabc94445c59 Mon Sep 17 00:00:00 2001 From: gcalvino Date: Tue, 27 Nov 2018 15:17:04 +0100 Subject: [PATCH] Pyangbind checks for Network Slices descriptors Change-Id: I7ffa2aa3506340c6eef9b029aa852b9596469156 Signed-off-by: gcalvino --- osm_nbi/descriptor_topics.py | 11 +++++++++++ osm_nbi/tests/cirros_slice/cirros_slice.yaml | 4 ++-- osm_nbi/tests/cirros_slice/cirros_slice_vld.yaml | 4 ++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/osm_nbi/descriptor_topics.py b/osm_nbi/descriptor_topics.py index 5612fdf..e9339e0 100644 --- a/osm_nbi/descriptor_topics.py +++ b/osm_nbi/descriptor_topics.py @@ -24,6 +24,7 @@ from validation import ValidationError, pdu_new_schema, pdu_edit_schema from base_topic import BaseTopic, EngineException, get_iterable from osm_im.vnfd import vnfd as vnfd_im from osm_im.nsd import nsd as nsd_im +from osm_im.nst import nst as nst_im from pyangbind.lib.serialise import pybindJSONDecoder import pyangbind.lib.pybindJSON as pybindJSON @@ -378,6 +379,11 @@ class DescriptorTopic(BaseTopic): pybindJSONDecoder.load_ietf_json({'nsd:nsd-catalog': {'nsd': [data]}}, None, None, obj=mynsd, path_helper=True, skip_unknown=force) out = pybindJSON.dumps(mynsd, mode="ietf") + elif item == "nsts": + mynst = nst_im() + pybindJSONDecoder.load_ietf_json({'nst': [data]}, None, None, obj=mynst, + path_helper=True, skip_unknown=force) + out = pybindJSON.dumps(mynst, mode="ietf") else: raise EngineException("Not possible to validate '{}' item".format(item), http_code=HTTPStatus.INTERNAL_SERVER_ERROR) @@ -743,6 +749,10 @@ class NstTopic(DescriptorTopic): if not isinstance(clean_indata['nst'], list) or len(clean_indata['nst']) != 1: raise EngineException("'nst' must be a list only one element") clean_indata = clean_indata['nst'][0] + elif clean_indata.get('nst:nst'): + if not isinstance(clean_indata['nst:nst'], list) or len(clean_indata['nst:nst']) != 1: + raise EngineException("'nst:nst' must be a list only one element") + clean_indata = clean_indata['nst:nst'][0] return clean_indata def _validate_input_edit(self, indata, force=False): @@ -750,6 +760,7 @@ class NstTopic(DescriptorTopic): return indata def _validate_input_new(self, indata, force=False): + indata = self.pyangbind_validation("nsts", indata, force) return indata.copy() def _check_descriptor_dependencies(self, session, descriptor): diff --git a/osm_nbi/tests/cirros_slice/cirros_slice.yaml b/osm_nbi/tests/cirros_slice/cirros_slice.yaml index 4f510ce..b3b6598 100644 --- a/osm_nbi/tests/cirros_slice/cirros_slice.yaml +++ b/osm_nbi/tests/cirros_slice/cirros_slice.yaml @@ -16,9 +16,9 @@ nst: - id: 'cirros_nst' name: cirros_netslice_template SNSSAI-identifier: - - slice-service-type: eMBB + slice-service-type: eMBB quality-of-service: - - id: 1 + id: 1 netslice-subnet: - id: cirros_nsd_1 is-shared-nss: 'false' diff --git a/osm_nbi/tests/cirros_slice/cirros_slice_vld.yaml b/osm_nbi/tests/cirros_slice/cirros_slice_vld.yaml index 0cb21bb..6016f3f 100644 --- a/osm_nbi/tests/cirros_slice/cirros_slice_vld.yaml +++ b/osm_nbi/tests/cirros_slice/cirros_slice_vld.yaml @@ -15,9 +15,9 @@ nst: - id: cirros_nst name: cirros_netslice_template SNSSAI-identifier: - - slice-service-type: eMBB + slice-service-type: eMBB quality-of-service: - - id: 1 + id: 1 netslice-subnet: - id: cirros_nsd_1 is-shared-nss: 'false' -- 2.25.1