Fix bug #677 osm nsi-op-list name' and 'osm nsi-op-show id' returns null 16/7616/1
authorFelipe Vicens <felipe.vicens@atos.net>
Wed, 5 Jun 2019 17:13:04 +0000 (19:13 +0200)
committerFelipe Vicens <felipe.vicens@atos.net>
Wed, 5 Jun 2019 17:13:04 +0000 (19:13 +0200)
Change-Id: Ie20b1c2b28195b8e4e309623cf5b2619dd8e2459
Signed-off-by: Felipe Vicens <felipe.vicens@atos.net>
osm_nbi/html_out.py
osm_nbi/instance_topics.py
osm_nbi/nbi.py
osm_nbi/validation.py

index 6f07d71..9adf6f5 100644 (file)
@@ -119,7 +119,7 @@ html_nslcmop_body = """
 """
 
 html_nsilcmop_body = """
-<a href="/osm/nsilcm/v1/nsi_lcm_op_occs?nsiInstanceId={id}">nsilcm operations </a>
+<a href="/osm/nsilcm/v1/nsi_lcm_op_occs?netsliceInstanceId={id}">nsilcm operations </a>
 <form action="/osm/nsilcm/v1/netslice_instances/{id}/terminate" method="post" enctype="multipart/form-data">
     <h3> <table style="border: 0;"> <tr>
         <td> <input type="submit" value="Terminate"/> </td>
index 8f2ac0d..48503a9 100644 (file)
@@ -1184,7 +1184,7 @@ class NsiLcmOpTopic(BaseTopic):
             "isCancelPending": False,
             "links": {
                 "self": "/osm/nsilcm/v1/nsi_lcm_op_occs/" + _id,
-                "nsInstance": "/osm/nsilcm/v1/netslice_instances/" + netsliceInstanceId,
+                "netsliceInstanceId": "/osm/nsilcm/v1/netslice_instances/" + netsliceInstanceId,
             }
         }
         return nsilcmop
@@ -1209,7 +1209,7 @@ class NsiLcmOpTopic(BaseTopic):
         :param rollback: list to append created items at database in case a rollback must to be done
         :param session: contains "username", "admin", "force", "public", "project_id", "set_project"
         :param indata: descriptor with the parameters of the operation. It must contains among others
-            nsiInstanceId: _id of the nsir to perform the operation
+            netsliceInstanceId: _id of the nsir to perform the operation
             operation: it can be: instantiate, terminate, action, TODO: update, heal
         :param kwargs: used to override the indata descriptor
         :param headers: http request headers
@@ -1219,12 +1219,12 @@ class NsiLcmOpTopic(BaseTopic):
             # Override descriptor with query string kwargs
             self._update_input_with_kwargs(indata, kwargs)
             operation = indata["lcmOperationType"]
-            nsiInstanceId = indata["nsiInstanceId"]
+            netsliceInstanceId = indata["netsliceInstanceId"]
             validate_input(indata, self.operation_schema[operation])
 
-            # get nsi from nsiInstanceId
+            # get nsi from netsliceInstanceId
             _filter = self._get_project_filter(session)
-            _filter["_id"] = nsiInstanceId
+            _filter["_id"] = netsliceInstanceId
             nsir = self.db.get_one("nsis", _filter)
             del _filter["_id"]
 
@@ -1235,11 +1235,11 @@ class NsiLcmOpTopic(BaseTopic):
                     return None    # a none in this case is used to indicate not instantiated. It can be removed
                 if operation != "instantiate":
                     raise EngineException("netslice_instance '{}' cannot be '{}' because it is not instantiated".format(
-                        nsiInstanceId, operation), HTTPStatus.CONFLICT)
+                        netsliceInstanceId, operation), HTTPStatus.CONFLICT)
             else:
                 if operation == "instantiate" and not session["force"]:
                     raise EngineException("netslice_instance '{}' cannot be '{}' because it is already instantiated".
-                                          format(nsiInstanceId, operation), HTTPStatus.CONFLICT)
+                                          format(netsliceInstanceId, operation), HTTPStatus.CONFLICT)
             
             # Creating all the NS_operation (nslcmop)
             # Get service list from db
@@ -1252,7 +1252,7 @@ class NsiLcmOpTopic(BaseTopic):
                     _filter["_admin.nsrs-detailed-list.ANYINDEX.shared"] = True
                     _filter["_admin.nsrs-detailed-list.ANYINDEX.nsrId"] = nsr_item["nsrId"]
                     _filter["_admin.nsrs-detailed-list.ANYINDEX.nslcmop_instantiate.ne"] = None
-                    _filter["_id.ne"] = nsiInstanceId
+                    _filter["_id.ne"] = netsliceInstanceId
                     nsi = self.db.get_one("nsis", _filter, fail_on_empty=False, fail_on_more=False)
                     if operation == "terminate":
                         _update = {"_admin.nsrs-detailed-list.{}.nslcmop_instantiate".format(index): None}
@@ -1280,7 +1280,7 @@ class NsiLcmOpTopic(BaseTopic):
                     indata_ns["lcmOperationType"] = operation
                     indata_ns["nsInstanceId"] = service["_id"]
                     # Including netslice_id in the ns instantiate Operation
-                    indata_ns["netsliceInstanceId"] = nsiInstanceId
+                    indata_ns["netsliceInstanceId"] = netsliceInstanceId
                     del indata_ns["key-pair-ref"]
                     # Creating NS_LCM_OP with the flag slice_object=True to not trigger the service instantiation 
                     # message via kafka bus
@@ -1302,7 +1302,7 @@ class NsiLcmOpTopic(BaseTopic):
             indata["nslcmops_ids"] = nslcmops
             self._check_nsi_operation(session, nsir, operation, indata)
 
-            nsilcmop_desc = self._create_nsilcmop(session, nsiInstanceId, operation, indata)
+            nsilcmop_desc = self._create_nsilcmop(session, netsliceInstanceId, operation, indata)
             self.format_on_new(nsilcmop_desc, session["project_id"], make_public=session["public"])
             _id = self.db.create("nsilcmops", nsilcmop_desc)
             rollback.append({"topic": "nsilcmops", "_id": _id})
index cc56984..269af33 100644 (file)
@@ -887,13 +887,13 @@ class Server(object):
                     _id = self.engine.new_item(rollback, session, engine_topic, indata, kwargs)
                     self._set_location_header(main_topic, version, topic, _id)
                     indata["lcmOperationType"] = "instantiate"
-                    indata["nsiInstanceId"] = _id
+                    indata["netsliceInstanceId"] = _id
                     nsilcmop_id = self.engine.new_item(rollback, session, "nsilcmops", indata, kwargs)
                     outdata = {"id": _id, "nsilcmop_id": nsilcmop_id}
 
                 elif topic == "netslice_instances" and item:
                     indata["lcmOperationType"] = item
-                    indata["nsiInstanceId"] = _id
+                    indata["netsliceInstanceId"] = _id
                     _id = self.engine.new_item(rollback, session, "nsilcmops", indata, kwargs)
                     self._set_location_header(main_topic, version, "nsi_lcm_op_occs", _id)
                     outdata = {"id": _id}
@@ -926,7 +926,7 @@ class Server(object):
                     elif topic == "netslice_instances_content" and not session["force"]:
                         nsilcmop_desc = {
                             "lcmOperationType": "terminate",
-                            "nsiInstanceId": _id,
+                            "netsliceInstanceId": _id,
                             "autoremove": True
                         }
                         opp_id = self.engine.new_item(rollback, session, "nsilcmops", nsilcmop_desc, None)
index acb53c0..a244ac1 100644 (file)
@@ -712,7 +712,7 @@ nsi_instantiate = {
     "type": "object",
     "properties": {
         "lcmOperationType": string_schema,
-        "nsiInstanceId": id_schema,
+        "netsliceInstanceId": id_schema,
         "nsiName": name_schema,
         "nsiDescription": {"oneOf": [description_schema, null_schema]},
         "nstId": string_schema,