From e45aded97f406476e5f03d21f2624a092796f7f9 Mon Sep 17 00:00:00 2001 From: gcalvino Date: Tue, 13 Nov 2018 17:17:28 +0100 Subject: [PATCH] VNFs with only VLDs compatibility Signed-off-by: gcalvino --- osm_nbi/descriptor_topics.py | 21 +++++++++++---------- osm_nbi/instance_topics.py | 2 +- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/osm_nbi/descriptor_topics.py b/osm_nbi/descriptor_topics.py index 2fd7cc0..fd3e3f4 100644 --- a/osm_nbi/descriptor_topics.py +++ b/osm_nbi/descriptor_topics.py @@ -432,17 +432,18 @@ class VnfdTopic(DescriptorTopic): def _validate_input_new(self, indata, force=False): indata = self.pyangbind_validation("vnfds", indata, force) # Cross references validation in the descriptor - if not indata.get("mgmt-interface"): - raise EngineException("'mgmt-interface' is a mandatory field and it is not defined", - http_code=HTTPStatus.UNPROCESSABLE_ENTITY) - if indata["mgmt-interface"].get("cp"): - for cp in get_iterable(indata.get("connection-point")): - if cp["name"] == indata["mgmt-interface"]["cp"]: - break - else: - raise EngineException("mgmt-interface:cp='{}' must match an existing connection-point" - .format(indata["mgmt-interface"]["cp"]), + if indata.get("vdu"): + if not indata.get("mgmt-interface"): + raise EngineException("'mgmt-interface' is a mandatory field and it is not defined", http_code=HTTPStatus.UNPROCESSABLE_ENTITY) + if indata["mgmt-interface"].get("cp"): + for cp in get_iterable(indata.get("connection-point")): + if cp["name"] == indata["mgmt-interface"]["cp"]: + break + else: + raise EngineException("mgmt-interface:cp='{}' must match an existing connection-point" + .format(indata["mgmt-interface"]["cp"]), + http_code=HTTPStatus.UNPROCESSABLE_ENTITY) for vdu in get_iterable(indata.get("vdu")): for interface in get_iterable(vdu.get("interface")): diff --git a/osm_nbi/instance_topics.py b/osm_nbi/instance_topics.py index 5d9705b..ae4417a 100644 --- a/osm_nbi/instance_topics.py +++ b/osm_nbi/instance_topics.py @@ -169,7 +169,7 @@ class NsrTopic(BaseTopic): # vim-id # TODO it would be nice having a vim port id } vnfr_descriptor["connection-point"].append(vnf_cp) - for vdu in vnfd["vdu"]: + for vdu in vnfd.get("vdu", ()): vdur = { "vdu-id-ref": vdu["id"], # TODO "name": "" Name of the VDU in the VIM -- 2.25.1