Fix Bug 924: User is not allowed to upload NS Descriptors for project_user(role)
[osm/NBI.git] / osm_nbi / instance_topics.py
index d04d99b..decb9c7 100644 (file)
@@ -141,12 +141,14 @@ class NsrTopic(BaseTopic):
                     item_vdu = next((x for x in item["additionalParamsForVdu"] if x["vdu_id"] == vdu_id), None)
                     if item_vdu and item_vdu.get("additionalParams"):
                         where_ += ".additionalParamsForVdu[vdu_id={}]".format(vdu_id)
                     item_vdu = next((x for x in item["additionalParamsForVdu"] if x["vdu_id"] == vdu_id), None)
                     if item_vdu and item_vdu.get("additionalParams"):
                         where_ += ".additionalParamsForVdu[vdu_id={}]".format(vdu_id)
-                        additional_params.update(item_vdu["additionalParams"])
-                if kdu_name and item.get("additionalParamsForKdu"):
-                    item_kdu = next((x for x in item["additionalParamsForKdu"] if x["kdu_name"] == kdu_name), None)
-                    if item_kdu and item_kdu.get("additionalParams"):
-                        where_ += ".additionalParamsForKdu[kdu_name={}]".format(kdu_name)
-                        additional_params.update(item_kdu["additionalParams"])
+                        additional_params = item_vdu["additionalParams"]
+                if kdu_name:
+                    additional_params = {}
+                    if item.get("additionalParamsForKdu"):
+                        item_kdu = next((x for x in item["additionalParamsForKdu"] if x["kdu_name"] == kdu_name), None)
+                        if item_kdu and item_kdu.get("additionalParams"):
+                            where_ += ".additionalParamsForKdu[kdu_name={}]".format(kdu_name)
+                            additional_params = item_kdu["additionalParams"]
 
         if additional_params:
             for k, v in additional_params.items():
 
         if additional_params:
             for k, v in additional_params.items():
@@ -348,10 +350,10 @@ class NsrTopic(BaseTopic):
                     kdur = {x: kdu[x] for x in kdu if x in ("helm-chart", "juju-bundle")}
                     kdur["kdu-name"] = kdu["name"]
                     # TODO      "name": ""     Name of the VDU in the VIM
                     kdur = {x: kdu[x] for x in kdu if x in ("helm-chart", "juju-bundle")}
                     kdur["kdu-name"] = kdu["name"]
                     # TODO      "name": ""     Name of the VDU in the VIM
-                    kdur["ip-address"] = None,  # mgmt-interface filled by LCM
-                    kdur["k8s-cluster"] = {},
+                    kdur["ip-address"] = None  # mgmt-interface filled by LCM
+                    kdur["k8s-cluster"] = {}
                     kdur["additionalParams"] = self._format_addional_params(ns_request, member_vnf["member-vnf-index"],
                     kdur["additionalParams"] = self._format_addional_params(ns_request, member_vnf["member-vnf-index"],
-                                                                            kdu_name=kdu["name"], descriptor=vnfd),
+                                                                            kdu_name=kdu["name"], descriptor=vnfd)
                     if not vnfr_descriptor.get("kdur"):
                         vnfr_descriptor["kdur"] = []
                     vnfr_descriptor["kdur"].append(kdur)
                     if not vnfr_descriptor.get("kdur"):
                         vnfr_descriptor["kdur"] = []
                     vnfr_descriptor["kdur"].append(kdur)
@@ -365,7 +367,7 @@ class NsrTopic(BaseTopic):
                         "internal-connection-point": [],
                         "interfaces": [],
                         "additionalParams": self._format_addional_params(ns_request, member_vnf["member-vnf-index"],
                         "internal-connection-point": [],
                         "interfaces": [],
                         "additionalParams": self._format_addional_params(ns_request, member_vnf["member-vnf-index"],
-                                                                         vdu_id=vdu["id"], descriptor=vnfd),
+                                                                         vdu_id=vdu["id"], descriptor=vnfd)
                     }
                     if vdu.get("pdu-type"):
                         vdur["pdu-type"] = vdu["pdu-type"]
                     }
                     if vdu.get("pdu-type"):
                         vdur["pdu-type"] = vdu["pdu-type"]
@@ -673,7 +675,6 @@ class NsLcmOpTopic(BaseTopic):
         Look for a free PDU in the catalog matching vdur type and interfaces. Fills vnfr.vdur with the interface
         (ip_address, ...) information.
         Modifies PDU _admin.usageState to 'IN_USE'
         Look for a free PDU in the catalog matching vdur type and interfaces. Fills vnfr.vdur with the interface
         (ip_address, ...) information.
         Modifies PDU _admin.usageState to 'IN_USE'
-        
         :param session: contains "username", "admin", "force", "public", "project_id", "set_project"
         :param rollback: list with the database modifications to rollback if needed
         :param vnfr: vnfr to be updated. It is modified with pdu interface info if pdu is found
         :param session: contains "username", "admin", "force", "public", "project_id", "set_project"
         :param rollback: list with the database modifications to rollback if needed
         :param vnfr: vnfr to be updated. It is modified with pdu interface info if pdu is found
@@ -1229,7 +1230,7 @@ class NsiTopic(BaseTopic):
                 nsi_vlds.append(nsi_vld)
 
             nsi_descriptor["_admin"]["netslice-vld"] = nsi_vlds
                 nsi_vlds.append(nsi_vld)
 
             nsi_descriptor["_admin"]["netslice-vld"] = nsi_vlds
-            # Creating netslice-subnet_record. 
+            # Creating netslice-subnet_record.
             needed_nsds = {}
             services = []
 
             needed_nsds = {}
             services = []