X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_lcm%2Fns.py;h=1cc5dc44025336d9abb7f2544768a2620f83b199;hb=e5532a21bff8093b7b6752d755af1fcd5cc172c8;hp=3972c59acb623293c830cf1f20b606161146a75c;hpb=77677d90626755970d87895be5054f4d8c1af8a3;p=osm%2FLCM.git diff --git a/osm_lcm/ns.py b/osm_lcm/ns.py index 3972c59..1cc5dc4 100644 --- a/osm_lcm/ns.py +++ b/osm_lcm/ns.py @@ -53,7 +53,7 @@ def get_iterable(in_dict, in_key): def populate_dict(target_dict, key_list, value): """ - Upate target_dict creating nested dictionaries with the key_list. Last key_list item is asigned the value. + Update target_dict creating nested dictionaries with the key_list. Last key_list item is asigned the value. Example target_dict={K: J}; key_list=[a,b,c]; target_dict will be {K: J, a: {b: {c: value}}} :param target_dict: dictionary to be changed :param key_list: list of keys to insert at target_dict @@ -101,6 +101,7 @@ class NsLcm(LcmBase): artifacts=None, juju_public_key=vca_config.get('pubkey'), ca_cert=vca_config.get('cacert'), + api_proxy=vca_config.get('apiproxy') ) self.RO = ROclient.ROClient(self.loop, **self.ro_config) @@ -456,7 +457,7 @@ class NsLcm(LcmBase): for vld_id, instance_scenario_id in vld_params["ns-net"].items(): RO_vld_ns_net = {"instance_scenario_id": instance_scenario_id, "osm_id": vld_id} if RO_vld_ns_net: - populate_dict(RO_ns_params, ("networks", vld_params["name"], "use-network"), RO_vld_ns_net) + populate_dict(RO_ns_params, ("networks", vld_params["name"], "use-network"), RO_vld_ns_net) if "vnfd-connection-point-ref" in vld_params: for cp_params in vld_params["vnfd-connection-point-ref"]: # look for interface @@ -601,12 +602,13 @@ class NsLcm(LcmBase): break else: raise LcmException("ns_update_vnfr: Not found member_vnf_index={} vdur={} interface={} " - "at RO info".format(vnf_index, vdur["vdu-id-ref"], ifacer["name"])) + "from VIM info".format(vnf_index, vdur["vdu-id-ref"], + ifacer["name"])) vnfr_update["vdur.{}".format(vdu_index)] = vdur break else: - raise LcmException("ns_update_vnfr: Not found member_vnf_index={} vdur={} count_index={} at " - "RO info".format(vnf_index, vdur["vdu-id-ref"], vdur["count-index"])) + raise LcmException("ns_update_vnfr: Not found member_vnf_index={} vdur={} count_index={} from " + "VIM info".format(vnf_index, vdur["vdu-id-ref"], vdur["count-index"])) for vld_index, vld in enumerate(get_iterable(db_vnfr, "vld")): for net_RO in get_iterable(nsr_desc_RO, "nets"): @@ -619,14 +621,14 @@ class NsLcm(LcmBase): vnfr_update["vld.{}".format(vld_index)] = vld break else: - raise LcmException("ns_update_vnfr: Not found member_vnf_index={} vld={} at RO info".format( + raise LcmException("ns_update_vnfr: Not found member_vnf_index={} vld={} from VIM info".format( vnf_index, vld["id"])) self.update_db_2("vnfrs", db_vnfr["_id"], vnfr_update) break else: - raise LcmException("ns_update_vnfr: Not found member_vnf_index={} at RO info".format(vnf_index)) + raise LcmException("ns_update_vnfr: Not found member_vnf_index={} from VIM info".format(vnf_index)) async def instantiate(self, nsr_id, nslcmop_id): @@ -652,6 +654,7 @@ class NsLcm(LcmBase): exc = None try: # wait for any previous tasks in process + step = "Waiting for previous tasks" await self.lcm_tasks.waitfor_related_HA('ns', 'nslcmops', nslcmop_id) step = "Getting nslcmop={} from db".format(nslcmop_id) @@ -720,7 +723,7 @@ class NsLcm(LcmBase): machine_spec = {} if native_charm: - machine_spec["username"] = charm_params.get("username"), + machine_spec["username"] = charm_params.get("username") machine_spec["hostname"] = charm_params.get("rw_mgmt_ip") # Note: The charm needs to exist on disk at the location @@ -847,7 +850,6 @@ class NsLcm(LcmBase): if vdu_config["juju"].get("proxy") is False: # native_charm, will be deployed after VM. Skip proxy_charm = None - if proxy_charm: if not vca_model_name: step = "creating VCA model name" @@ -881,7 +883,6 @@ class NsLcm(LcmBase): if ns_config["juju"].get("proxy") is False: # native_charm, will be deployed after VM. Skip proxy_charm = None - if proxy_charm: step = "deploying proxy charm to configure ns" # TODO is NS magmt IP address needed? @@ -1151,7 +1152,7 @@ class NsLcm(LcmBase): n2vc_key_list.append(n2vc_key) RO_ns_params = self.ns_params_2_RO(ns_params, nsd, db_vnfds_ref, n2vc_key_list) - step = db_nsr_update["detailed-status"] = "Creating ns at RO" + step = db_nsr_update["detailed-status"] = "Deploying ns at VIM" desc = await self.RO.create("ns", descriptor=RO_ns_params, name=db_nsr["name"], scenario=RO_nsd_uuid) @@ -1162,7 +1163,7 @@ class NsLcm(LcmBase): self.update_db_2("nsrs", nsr_id, db_nsr_update) # wait until NS is ready - step = ns_status_detailed = detailed_status = "Waiting ns ready at RO. RO_id={}".format(RO_nsr_id) + step = ns_status_detailed = detailed_status = "Waiting VIM to deploy ns. RO_id={}".format(RO_nsr_id) detailed_status_old = None self.logger.debug(logging_text + step) @@ -1280,8 +1281,8 @@ class NsLcm(LcmBase): vnf_config = vnfd.get("vnf-configuration") if vnf_config and vnf_config.get("juju"): native_charm = vnf_config["juju"].get("proxy") is False - - if native_charm: + proxy_charm = vnf_config["juju"]["charm"] + if native_charm and proxy_charm: if not vca_model_name: step = "creating VCA model name '{}'".format(nsr_id) self.logger.debug(logging_text + step) @@ -1290,6 +1291,8 @@ class NsLcm(LcmBase): db_nsr_update["_admin.deployed.VCA-model-name"] = nsr_id self.update_db_2("nsrs", nsr_id, db_nsr_update) step = "deploying native charm for vnf_member_index={}".format(vnf_index) + self.logger.debug(logging_text + step) + vnfr_params["rw_mgmt_ip"] = db_vnfrs[vnf_index]["ip-address"] charm_params = { "user_values": vnfr_params, @@ -1322,8 +1325,8 @@ class NsLcm(LcmBase): if vdu_config and vdu_config.get("juju"): native_charm = vdu_config["juju"].get("proxy") is False - - if native_charm: + proxy_charm = vdu_config["juju"]["charm"] + if native_charm and proxy_charm: if not vca_model_name: step = "creating VCA model name" await self.n2vc.CreateNetworkService(nsr_id) @@ -1332,8 +1335,11 @@ class NsLcm(LcmBase): self.update_db_2("nsrs", nsr_id, db_nsr_update) step = "deploying native charm for vnf_member_index={} vdu_id={}".format(vnf_index, vdu["id"]) - await self.n2vc.login() + + self.logger.debug(logging_text + step) + vdur = db_vnfrs[vnf_index]["vdur"][vdu_index] + # TODO for the moment only first vdu_id contains a charm deployed if vdur["vdu-id-ref"] != vdu["id"]: raise LcmException("Mismatch vdur {}, vdu {} at index {} for vnf {}" @@ -1357,6 +1363,8 @@ class NsLcm(LcmBase): charm_params["username"] = vdu_config["config-access"]["ssh-access"].get( "default-user") + await self.n2vc.login() + deploy_charm(vnf_index, vdu["id"], vdur.get("name"), vdur["count-index"], charm_params, n2vc_info, native_charm) number_to_configure += 1 @@ -1366,8 +1374,8 @@ class NsLcm(LcmBase): ns_config = nsd.get("ns-configuration") if ns_config and ns_config.get("juju"): native_charm = ns_config["juju"].get("proxy") is False - - if native_charm: + proxy_charm = ns_config["juju"]["charm"] + if native_charm and proxy_charm: step = "deploying native charm to configure ns" # TODO is NS magmt IP address needed? @@ -1783,7 +1791,8 @@ class NsLcm(LcmBase): RO_delete_action = nsr_deployed["RO"].get("nsr_delete_action_id") try: if RO_nsr_id: - step = db_nsr_update["detailed-status"] = db_nslcmop_update["detailed-status"] = "Deleting ns at RO" + step = db_nsr_update["detailed-status"] = db_nslcmop_update["detailed-status"] = \ + "Deleting ns from VIM" self.update_db_2("nslcmops", nslcmop_id, db_nslcmop_update) self.update_db_2("nsrs", nsr_id, db_nsr_update) self.logger.debug(logging_text + step) @@ -1844,7 +1853,7 @@ class NsLcm(LcmBase): RO_nsd_id = nsr_deployed["RO"]["nsd_id"] try: step = db_nsr_update["detailed-status"] = db_nslcmop_update["detailed-status"] =\ - "Deleting nsd at RO" + "Deleting nsd from RO" await self.RO.delete("nsd", RO_nsd_id) self.logger.debug(logging_text + "RO_nsd_id={} deleted".format(RO_nsd_id)) db_nsr_update["_admin.deployed.RO.nsd_id"] = None @@ -2254,7 +2263,7 @@ class NsLcm(LcmBase): # break # TODO check if ns is in a proper status - step = "Sending scale order to RO" + step = "Sending scale order to VIM" nb_scale_op = 0 if not db_nsr["_admin"].get("scaling-group"): self.update_db_2("nsrs", nsr_id, {"_admin.scaling-group": [{"name": scaling_group, "nb-scale-op": 0}]}) @@ -2384,7 +2393,7 @@ class NsLcm(LcmBase): detailed_status = step + "; {}".format(ns_status_info) elif ns_status == "ACTIVE": RO_task_done = True - step = detailed_status = "Waiting ns ready at RO. RO_id={}".format(RO_nsr_id) + step = detailed_status = "Waiting VIM to deploy ns. RO_id={}".format(RO_nsr_id) self.logger.debug(logging_text + step) else: assert False, "ROclient.check_action_status returns unknown {}".format(ns_status)