Fix bug 682: NSD cross references between vnffgd classifier and rsp not validated 15/8215/1
authordelacruzramo <pedro.delacruzramos@altran.com>
Fri, 22 Nov 2019 14:06:43 +0000 (15:06 +0100)
committerdelacruzramo <pedro.delacruzramos@altran.com>
Fri, 22 Nov 2019 14:06:56 +0000 (15:06 +0100)
Change-Id: I759844b02afe870403ce317a7f3ec8826128bbbb
Signed-off-by: delacruzramo <pedro.delacruzramos@altran.com>
osm_nbi/descriptor_topics.py

index 58efa55..0939000 100644 (file)
@@ -704,6 +704,19 @@ class NsdTopic(DescriptorTopic):
                                           "does not match any constituent-vnfd:member-vnf-index"
                                           .format(vld["id"], vnfd_cp["member-vnf-index-ref"]),
                                           http_code=HTTPStatus.UNPROCESSABLE_ENTITY)
+        # Check VNFFGD
+        for fgd in get_iterable(indata.get("vnffgd")):
+            for cls in get_iterable(fgd.get("classifier")):
+                rspref = cls.get("rsp-id-ref")
+                for rsp in get_iterable(fgd.get("rsp")):
+                    rspid = rsp.get("id")
+                    if rspid and rspref and rspid == rspref:
+                        break
+                else:
+                    raise EngineException(
+                        "Error at vnffgd[id='{}']:classifier[id='{}']:rsp-id-ref '{}' does not match any rsp:id"
+                        .format(fgd["id"], cls["id"], rspref),
+                        http_code=HTTPStatus.UNPROCESSABLE_ENTITY)
         return indata
 
     def _validate_input_edit(self, indata, force=False):