From: tierno Date: Wed, 9 May 2018 11:22:52 +0000 (+0200) Subject: LWB Added vnfR support X-Git-Tag: v4.0.0~7 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=b9bb08b5bdce25f36e2ccbcab02c11be6aa739a3;p=osm%2FRO.git LWB Added vnfR support Change-Id: I0744773474bbd692b854c3ebca7baede97b336fc Signed-off-by: tierno --- diff --git a/lcm/osm_lcm/ROclient.py b/lcm/osm_lcm/ROclient.py index e0533c5a..08a04076 100644 --- a/lcm/osm_lcm/ROclient.py +++ b/lcm/osm_lcm/ROclient.py @@ -297,23 +297,29 @@ class ROClient: return "BUILD", "VMs: {}/{}, networks: {}/{}".format(vm_done, vm_total, net_done, net_total) @staticmethod - def get_ns_vnf_ip(ns_descriptor): + def get_ns_vnf_info(ns_descriptor): """ - Get a dict with the IPs of every vnf and vdu + Get a dict with the VIM_id, ip_addresses, mac_addresses of every vnf and vdu :param ns_descriptor: instance descriptor obtained with self.show("ns", ) - :return: dict with {member_vnf_index: ip_address, ... member_vnf_index.vdu_id: ip_address ...} + :return: dict with {: {ip_address: XXXX, vdur:{ip_address: XXX, vim_id: XXXX}}} """ - ns_ip = {"vnf": {}, "vdu": {}} + ns_info = {} for vnf in ns_descriptor["vnfs"]: if not vnf.get("ip_address"): raise ROClientException("No ip_address returned for ns member_vnf_index '{}'".format( vnf["member_vnf_index"]), http_code=500) - ns_ip["vnf"][str(vnf["member_vnf_index"])] = vnf.get("ip_address") - ns_ip["vdu"][str(vnf["member_vnf_index"])] = {} + vnfr_info = { + "ip_address": vnf.get("ip_address"), + "vdur": {} + } for vm in vnf["vms"]: - if vm.get("ip_address"): - ns_ip["vdu"][str(vnf["member_vnf_index"])][vm["vdu_osm_id"]] = vm["ip_address"] - return ns_ip + vdur = { + "vim_id": vm.get("vim_vm_id"), + "ip_address": vm.get("ip_address") + } + vnfr_info["vdur"][vm["vdu_osm_id"]] = vdur + ns_info[str(vnf["member_vnf_index"])] = vnfr_info + return ns_info async def _get_item_uuid(self, session, item, item_id_name, all_tenants=False): diff --git a/lcm/osm_lcm/lcm.py b/lcm/osm_lcm/lcm.py index 57810715..aac7e823 100644 --- a/lcm/osm_lcm/lcm.py +++ b/lcm/osm_lcm/lcm.py @@ -603,7 +603,7 @@ class Lcm: # if db_vim["_admin"]["operationalState"] == "PROCESSING": # #TODO check if VIM is creating and wait if db_vim["_admin"]["operationalState"] != "ENABLED": - raise LcmException("VIM={} is not available. operationalSstatus={}".format( + raise LcmException("VIM={} is not available. operationalState={}".format( vim_account, db_vim["_admin"]["operationalState"])) RO_vim_id = db_vim["_admin"]["deployed"]["RO"] vim_2_RO[vim_account] = RO_vim_id @@ -653,6 +653,7 @@ class Lcm: # get all needed from database db_nsr = None db_nslcmop = None + db_vnfr = {} exc = None step = "Getting nsr, nslcmop, RO_vims from db" try: @@ -660,10 +661,12 @@ class Lcm: db_nsr = self.db.get_one("nsrs", {"_id": nsr_id}) nsd = db_nsr["nsd"] nsr_name = db_nsr["name"] # TODO short-name?? - needed_vnfd = {} + vnfr_filter = {"nsr-id-ref": nsr_id, "member-vnf-index-ref": None} for c_vnf in nsd["constituent-vnfd"]: vnfd_id = c_vnf["vnfd-id-ref"] + vnfr_filter["member-vnf-index-ref"] = c_vnf["member-vnf-index"] + db_vnfr[c_vnf["member-vnf-index"]] = self.db.get_one("vnfrs", vnfr_filter) if vnfd_id not in needed_vnfd: step = "Getting vnfd={} from db".format(vnfd_id) needed_vnfd[vnfd_id] = self.db.get_one("vnfds", {"id": vnfd_id}) @@ -744,7 +747,6 @@ class Lcm: self.logger.debug(logging_text + step + " RO_ns_id={}".format(RO_nsr_id)) await RO.delete("ns", RO_nsr_id) RO_nsr_id = nsr_lcm["RO"]["nsr_id"] = None - if not RO_nsr_id: step = db_nsr["detailed-status"] = "Creating ns at RO" self.logger.debug(logging_text + step) @@ -755,7 +757,19 @@ class Lcm: RO_nsr_id = nsr_lcm["RO"]["nsr_id"] = desc["uuid"] db_nsr["_admin"]["nsState"] = "INSTANTIATED" nsr_lcm["RO"]["nsr_status"] = "BUILD" + self.update_db("nsrs", nsr_id, db_nsr) + # update VNFR vimAccount + step = "Updating VNFR vimAcccount" + for vnf_index, vnfr in db_vnfr.items(): + if vnfr.get("vim-account-id"): + continue + if db_nsr["instantiate_params"].get("vnf") and db_nsr["instantiate_params"]["vnf"].get(vnf_index) \ + and db_nsr["instantiate_params"]["vnf"][vnf_index].get("vimAccountId"): + vnfr["vim-account-id"] = db_nsr["instantiate_params"]["vnf"][vnf_index]["vimAccountId"] + else: + vnfr["vim-account-id"] = db_nsr["instantiate_params"]["vimAccountId"] + self.update_db("vnfrs", vnfr["_id"], vnfr) # wait until NS is ready step = ns_status_detailed = "Waiting ns ready at RO" @@ -772,8 +786,8 @@ class Lcm: db_nsr["detailed-status"] = ns_status_detailed + "; {}".format(ns_status_info) self.update_db("nsrs", nsr_id, db_nsr) elif ns_status == "ACTIVE": - step = "Getting ns VNF management IP address" - nsr_lcm["nsr_ip"] = RO.get_ns_vnf_ip(desc) + step = "Getting ns VIM information" + ns_RO_info = nsr_lcm["nsr_ip"] = RO.get_ns_vnf_info(desc) break else: assert False, "ROclient.check_ns_status returns unknown {}".format(ns_status) @@ -782,6 +796,18 @@ class Lcm: deployment_timeout -= 5 if deployment_timeout <= 0: raise ROclient.ROClientException("Timeout waiting ns to be ready") + step = "Updating VNFRs" + for vnf_index, vnfr_deployed in ns_RO_info.items(): + vnfr = db_vnfr[vnf_index] + vnfr["ip-address"] = vnfr_deployed.get("ip_address") + for vdu_id, vdu_deployed in vnfr_deployed["vdur"].items(): + for vdur in vnfr["vdur"]: + if vdur["vdu-id-ref"] == vdu_id: + vdur["vim-id"] = vdu_deployed.get("vim_id") + vdur["ip-address"] = vdu_deployed.get("ip_address") + break + self.update_db("vnfrs", vnfr["_id"], vnfr) + db_nsr["detailed-status"] = "Configuring vnfr" self.update_db("nsrs", nsr_id, db_nsr) @@ -813,7 +839,7 @@ class Lcm: ) # Setup the runtime parameters for this VNF - params['rw_mgmt_ip'] = nsr_lcm['nsr_ip']["vnf"][vnf_index] + params['rw_mgmt_ip'] = db_vnfr[vnf_index]["ip-address"] # ns_name will be ignored in the current version of N2VC # but will be implemented for the next point release. @@ -1071,6 +1097,7 @@ class Lcm: elif db_nslcmop["operationParams"].get("autoremove"): self.db.del_one("nsrs", {"_id": nsr_id}) self.db.del_list("nslcmops", {"nsInstanceId": nsr_id}) + self.db.del_list("vnfrs", {"nsr-id-ref": nsr_id}) else: db_nsr_update = { "operational-status": "terminated", @@ -1110,8 +1137,8 @@ class Lcm: db_nslcmop = None db_nslcmop_update = None exc = None - step = "Getting nsr, nslcmop" try: + step = "Getting information from database" db_nslcmop = self.db.get_one("nslcmops", {"_id": nslcmop_id}) db_nsr = self.db.get_one("nsrs", {"_id": nsr_id}) nsr_lcm = db_nsr["_admin"].get("deployed")