Fix Bug 1607 interface position is not taken into account
[osm/NBI.git] / osm_nbi / instance_topics.py
index 84aeda3..176f86d 100644 (file)
@@ -27,8 +27,10 @@ from osm_nbi.validation import (
     ns_action,
     ns_scale,
     ns_update,
+    ns_heal,
     nsi_instantiate,
     ns_migrate,
+    ns_verticalscale,
 )
 from osm_nbi.base_topic import (
     BaseTopic,
@@ -894,7 +896,10 @@ class NsrTopic(BaseTopic):
                 vdur["internal-connection-point"].append(vdu_icp)
 
                 for iface in icp.get("virtual-network-interface-requirement", ()):
-                    iface_fields = ("name", "mac-address")
+                    # Name, mac-address and interface position is taken from VNFD
+                    # and included into VNFR. By this way RO can process this information
+                    # while creating the VDU.
+                    iface_fields = ("name", "mac-address", "position")
                     vdu_iface = {
                         x: iface[x] for x in iface_fields if iface.get(x) is not None
                     }
@@ -1163,8 +1168,10 @@ class NsLcmOpTopic(BaseTopic):
         "action": ns_action,
         "update": ns_update,
         "scale": ns_scale,
+        "heal": ns_heal,
         "terminate": ns_terminate,
         "migrate": ns_migrate,
+        "verticalscale": ns_verticalscale,
     }
 
     def __init__(self, db, fs, msg, auth):
@@ -1175,7 +1182,7 @@ class NsLcmOpTopic(BaseTopic):
         """
         Check that user has enter right parameters for the operation
         :param session: contains "username", "admin", "force", "public", "project_id", "set_project"
-        :param operation: it can be: instantiate, terminate, action, update. TODO: heal
+        :param operation: it can be: instantiate, terminate, action, update, heal
         :param indata: descriptor with the parameters of the operation
         :return: None
         """
@@ -1185,6 +1192,8 @@ class NsLcmOpTopic(BaseTopic):
             self._check_scale_ns_operation(indata, nsr)
         elif operation == "update":
             self._check_update_ns_operation(indata, nsr)
+        elif operation == "heal":
+            self._check_heal_ns_operation(indata, nsr)
         elif operation == "instantiate":
             self._check_instantiate_ns_operation(indata, nsr, session)
 
@@ -1387,6 +1396,9 @@ class NsLcmOpTopic(BaseTopic):
                 )
             )
 
+    def _check_heal_ns_operation(self, indata, nsr):
+        return
+
     def _check_instantiate_ns_operation(self, indata, nsr, session):
         vnf_member_index_to_vnfd = {}  # map between vnf_member_index to vnf descriptor.
         vim_accounts = []
@@ -1481,7 +1493,7 @@ class NsLcmOpTopic(BaseTopic):
                 if in_vdu["id"] == vdu["id"]:
                     for volume in get_iterable(in_vdu.get("volume")):
                         for volumed in get_iterable(vdu.get("virtual-storage-desc")):
-                            if volumed["id"] == volume["name"]:
+                            if volumed == volume["name"]:
                                 break
                         else:
                             raise EngineException(
@@ -1501,7 +1513,7 @@ class NsLcmOpTopic(BaseTopic):
                         ):
                             vdu_if_names.add(iface.get("name"))
 
-                    for in_iface in get_iterable(in_vdu["interface"]):
+                    for in_iface in get_iterable(in_vdu.get("interface")):
                         if in_iface["name"] in vdu_if_names:
                             break
                         else: