Fix bug 1441: set flag in NSR and VNFR to indicate that SRIOV and PT interfaces are...
[osm/NBI.git] / osm_nbi / instance_topics.py
index b3eca02..05ca347 100644 (file)
@@ -592,13 +592,25 @@ class NsrTopic(BaseTopic):
                         # TODO: Change for multiple df support
                         for df in get_iterable(nsd.get("df")):
                             for vnf_profile in get_iterable(df.get("vnf-profile")):
-                                for vlc in get_iterable(vnf_profile.get("virtual-link-connectivity")):
+                                for vlc_index, vlc in \
+                                        enumerate(get_iterable(vnf_profile.get("virtual-link-connectivity"))):
                                     for cpd in get_iterable(vlc.get("constituent-cpd-id")):
                                         if cpd.get("constituent-cpd-id") == iface_ext_cp:
                                             vdu_iface["ns-vld-id"] = vlc.get("virtual-link-profile-id")
+                                            # if iface type is SRIOV or PASSTHROUGH, set pci-interfaces flag to True
+                                            if vdu_iface.get("type") in ("SR-IOV", "PCI-PASSTHROUGH"):
+                                                nsr_descriptor["vld"][vlc_index]["pci-interfaces"] = True
                                             break
                     elif vdu_iface.get("internal-connection-point-ref"):
                         vdu_iface["vnf-vld-id"] = icp.get("int-virtual-link-desc")
+                        # TODO: store fixed IP address in the record (if it exists in the ICP)
+                        # if iface type is SRIOV or PASSTHROUGH, set pci-interfaces flag to True
+                        if vdu_iface.get("type") in ("SR-IOV", "PCI-PASSTHROUGH"):
+                            ivld_index = utils.find_index_in_list(vnfd.get("int-virtual-link-desc", ()),
+                                                                  lambda ivld:
+                                                                  ivld["id"] == icp.get("int-virtual-link-desc")
+                                                                  )
+                            vnfr_descriptor["vld"][ivld_index]["pci-interfaces"] = True
 
                     vdur["interfaces"].append(vdu_iface)