X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=lcm%2Flcm%2Fpub%2Fvimapi%2Fadaptor.py;h=a09943f5698e859bcf2d1a8e9d31e138b2b8e9ec;hb=b51f79348b419a755dd08f758c45ed56c2ea0a10;hp=e1d7537b66b1cb004c06c8f503919f27bbf32e79;hpb=c896ac50fd771af03326df4e765267f02e8f0432;p=vfc%2Fgvnfm%2Fvnflcm.git diff --git a/lcm/lcm/pub/vimapi/adaptor.py b/lcm/lcm/pub/vimapi/adaptor.py index e1d7537b..a09943f5 100644 --- a/lcm/lcm/pub/vimapi/adaptor.py +++ b/lcm/lcm/pub/vimapi/adaptor.py @@ -70,7 +70,7 @@ def create_vim_res(data, do_notify): for subnet in ignore_case_get(data, "vls"): create_subnet(vim_cache, res_cache, subnet, do_notify, RES_SUBNET) for port in ignore_case_get(data, "cps"): - create_port(vim_cache, res_cache, port, do_notify, RES_PORT) + create_port(vim_cache, res_cache, data, port, do_notify, RES_PORT) for flavor in ignore_case_get(data, "vdus"): create_flavor(vim_cache, res_cache, data, flavor, do_notify, RES_FLAVOR) for vm in ignore_case_get(data, "vdus"): @@ -101,6 +101,7 @@ def create_volume(vim_cache, res_cache, vol, do_notify, res_type): vim_id, tenant_name = location_info["vimid"], location_info["tenant"] tenant_id = get_tenant_id(vim_cache, vim_id, tenant_name) ret = api.create_volume(vim_id, tenant_id, param) + ret["nodeId"] = vol["volume_storage_id"] do_notify(res_type, ret) vol_id, vol_name, return_code = ret["id"], ret["name"], ret["returnCode"] set_res_cache(res_cache, res_type, vol["volume_storage_id"], vol_id) @@ -128,6 +129,7 @@ def create_network(vim_cache, res_cache, network, do_notify, res_type): vim_id, tenant_name = location_info["vimid"], location_info["tenant"] tenant_id = get_tenant_id(vim_cache, vim_id, tenant_name) ret = api.create_network(vim_id, tenant_id, param) + ret["nodeId"] = network["vl_id"] do_notify(res_type, ret) set_res_cache(res_cache, res_type, network["vl_id"], ret["id"]) @@ -155,15 +157,26 @@ def create_subnet(vim_cache, res_cache, subnet, do_notify, res_type): do_notify(res_type, ret) set_res_cache(res_cache, res_type, subnet["vl_id"], ret["id"]) -def create_port(vim_cache, res_cache, port, do_notify, res_type): - location_info = port["properties"]["location_info"] - network_id = get_res_id(res_cache, RES_NETWORK, port["vl_id"]) - subnet_id = get_res_id(res_cache, RES_SUBNET, port["vl_id"]) +def create_port(vim_cache, res_cache, data, port, do_notify, res_type): + location_info = None + port_ref_vdu_id = ignore_case_get(port, "vdu_id") + for vdu in ignore_case_get(data, "vdus"): + if vdu["vdu_id"] == port_ref_vdu_id: + location_info = vdu["properties"]["location_info"] + break + if not location_info: + err_msg = "vdu_id(%s) for cp(%s) is not defined" + raise VimException(err_msg % (port_ref_vdu_id, port["cp_id"]), ERR_CODE) + network_id = ignore_case_get(port, "networkId") + subnet_id = ignore_case_get(port, "subnetId") + if not network_id: + network_id = get_res_id(res_cache, RES_NETWORK, port["vl_id"]) + subnet_id = get_res_id(res_cache, RES_SUBNET, port["vl_id"]) param = { "networkId": network_id, - "subnetId": subnet_id, "name": port["properties"]["name"] } + set_opt_val(param, "subnetId", subnet_id) set_opt_val(param, "macAddress", ignore_case_get(port["properties"], "mac_address")) set_opt_val(param, "ip", ignore_case_get(port["properties"], "ip_address")) set_opt_val(param, "vnicType", ignore_case_get(port["properties"], "vnic_type")) @@ -171,6 +184,7 @@ def create_port(vim_cache, res_cache, port, do_notify, res_type): vim_id, tenant_name = location_info["vimid"], location_info["tenant"] tenant_id = get_tenant_id(vim_cache, vim_id, tenant_name) ret = api.create_subnet(vim_id, tenant_id, param) + ret["nodeId"] = port["cp_id"] do_notify(res_type, ret) set_res_cache(res_cache, res_type, port["cp_id"], ret["id"]) @@ -269,7 +283,7 @@ def create_vm(vim_cache, res_cache, data, vm, do_notify, res_type): opt_vm_status = "Timeout" retry_count, max_retry_count = 0, 100 while retry_count < max_retry_count: - vm_info = api.get_vm(vim_id, vm_id) + vm_info = api.get_vm(vim_id, tenant_id, vm_id) if vm_info["status"].upper() == "ACTIVE": logger.debug("Vm(%s) is active", vim_id) return