Revert "Updated timeouts for common operations: deploy, delete, primitive"
[osm/LCM.git] / osm_lcm / ns.py
index 83e7147..d538e60 100644 (file)
@@ -242,6 +242,7 @@ class NsLcm(LcmBase):
         :return: The RO ns descriptor
         """
         vim_2_RO = {}
+        wim_2_RO = {}
         # TODO feature 1417: Check that no instantiation is set over PDU
         # check if PDU forces a concrete vim-network-id and add it
         # check if PDU contains a SDN-assist info (dpid, switch, port) and pass it to RO
@@ -258,6 +259,21 @@ class NsLcm(LcmBase):
             vim_2_RO[vim_account] = RO_vim_id
             return RO_vim_id
 
+        def wim_account_2_RO(wim_account):
+            if isinstance(wim_account, str):
+                if wim_account in wim_2_RO:
+                    return wim_2_RO[wim_account]
+
+                db_wim = self.db.get_one("wim_accounts", {"_id": wim_account})
+                if db_wim["_admin"]["operationalState"] != "ENABLED":
+                    raise LcmException("WIM={} is not available. operationalState={}".format(
+                        wim_account, db_wim["_admin"]["operationalState"]))
+                RO_wim_id = db_wim["_admin"]["deployed"]["RO-account"]
+                wim_2_RO[wim_account] = RO_wim_id
+                return RO_wim_id
+            else:
+                return wim_account
+
         def ip_profile_2_RO(ip_profile):
             RO_ip_profile = deepcopy((ip_profile))
             if "dns-server" in RO_ip_profile:
@@ -281,6 +297,7 @@ class NsLcm(LcmBase):
             # "name": ns_params["nsName"],
             # "description": ns_params.get("nsDescription"),
             "datacenter": vim_account_2_RO(ns_params["vimAccountId"]),
+            "wim_account": wim_account_2_RO(ns_params.get("wimAccountId")),
             # "scenario": ns_params["nsdId"],
         }
         if n2vc_key_list:
@@ -402,6 +419,10 @@ class NsLcm(LcmBase):
             if "ip-profile" in vld_params:
                 populate_dict(RO_ns_params, ("networks", vld_params["name"], "ip-profile"),
                               ip_profile_2_RO(vld_params["ip-profile"]))
+
+            if "wimAccountId" in vld_params and vld_params["wimAccountId"] is not None:
+                populate_dict(RO_ns_params, ("networks", vld_params["name"], "wim_account"),
+                              wim_account_2_RO(vld_params["wimAccountId"])),
             if vld_params.get("vim-network-name"):
                 RO_vld_sites = []
                 if isinstance(vld_params["vim-network-name"], dict):
@@ -539,7 +560,7 @@ class NsLcm(LcmBase):
                     continue
                 vnfr_update = {}
                 if vnf_RO.get("ip_address"):
-                    db_vnfr["ip-address"] = vnfr_update["ip-address"] = vnf_RO["ip_address"]
+                    db_vnfr["ip-address"] = vnfr_update["ip-address"] = vnf_RO["ip_address"].split(";")[0]
                 elif not db_vnfr.get("ip-address"):
                     raise LcmExceptionNoMgmtIP("ns member_vnf_index '{}' has no IP address".format(vnf_index))
 
@@ -554,7 +575,8 @@ class NsLcm(LcmBase):
                             vdur_RO_count_index += 1
                             continue
                         vdur["vim-id"] = vdur_RO.get("vim_vm_id")
-                        vdur["ip-address"] = vdur_RO.get("ip_address")
+                        if vdur_RO.get("ip_address"):
+                            vdur["ip-address"] = vdur_RO["ip_address"].split(";")[0]
                         vdur["vdu-id-ref"] = vdur_RO.get("vdu_osm_id")
                         vdur["name"] = vdur_RO.get("vim_name")
                         vdur["status"] = vdur_RO.get("status")
@@ -801,7 +823,7 @@ class NsLcm(LcmBase):
             while time() <= start_deploy + self.total_deploy_timeout:
                 desc = await RO.show("ns", RO_nsr_id)
                 ns_status, ns_status_info = RO.check_ns_status(desc)
-                db_nsr_update["admin.deployed.RO.nsr_status"] = ns_status
+                db_nsr_update["_admin.deployed.RO.nsr_status"] = ns_status
                 if ns_status == "ERROR":
                     raise ROclient.ROClientException(ns_status_info)
                 elif ns_status == "BUILD":