X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=lcm%2Flcm%2Fpub%2Fvimapi%2Fadaptor.py;h=5c8386bd8f7407ef449c989eb1ebeaf66335cc9c;hb=391f841b3c4ec5a0e10ae5c242f7e16209ec98d6;hp=55f6d16483be166412400019f2420c52bbfa6ec8;hpb=d36b8189117b5b6832460bc8ae413242ce4c107f;p=vfc%2Fgvnfm%2Fvnflcm.git diff --git a/lcm/lcm/pub/vimapi/adaptor.py b/lcm/lcm/pub/vimapi/adaptor.py index 55f6d164..5c8386bd 100644 --- a/lcm/lcm/pub/vimapi/adaptor.py +++ b/lcm/lcm/pub/vimapi/adaptor.py @@ -252,9 +252,10 @@ def create_port(vim_cache, res_cache, data, port, do_notify, res_type): 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 port["vl_id"] == "": - return + if not network_id: + if port["vl_id"] == "": + return 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 = { @@ -264,6 +265,7 @@ def create_port(vim_cache, res_cache, data, port, do_notify, res_type): set_opt_val(param, "subnetId", subnet_id) set_opt_val(param, "macAddress", ignore_case_get(port["properties"], "mac_address")) ip_address = [] + logger.debug("port['properties']:%s" % port["properties"]) for one_protocol_data in port["properties"]["protocol_data"]: l3_address_data = one_protocol_data["address_data"]["l3_address_data"] # l3 is not 13 fixed_ip_address = ignore_case_get(l3_address_data, "fixed_ip_address") @@ -292,7 +294,7 @@ def create_flavor(vim_cache, res_cache, data, flavor, do_notify, res_type): location_info = flavor["properties"]["location_info"] vim_id, tenant_name = location_info["vimid"], location_info["tenant"] virtual_compute = flavor["virtual_compute"] - virtual_storages = flavor["virtual_storages"] + virtual_storages = ignore_case_get(flavor, "virtual_storages") virtual_cpu = ignore_case_get(virtual_compute, "virtual_cpu") virtual_memory = ignore_case_get(virtual_compute, "virtual_memory") param = { @@ -316,18 +318,26 @@ def create_flavor(vim_cache, res_cache, data, flavor, do_notify, res_type): if flavor_id: set_res_cache(res_cache, res_type, flavor["vdu_id"], flavor_id) else: - for virtual_storage in virtual_storages: - vs_id = virtual_storage["virtual_storage_id"] - for vs in data["volume_storages"]: - if vs["volume_storage_id"] == vs_id: - disk_type = ignore_case_get(vs["properties"], "type_of_storage") - disk_size = int(ignore_case_get(vs["properties"], "size_of_storage").replace('GB', '').replace('"', '').strip()) - if disk_type == "root": - param["disk"] = disk_size - elif disk_type == "ephemeral": - param["ephemeral"] = disk_size - elif disk_type == "swap": - param["swap"] = disk_size + if virtual_storages: + for virtual_storage in virtual_storages: + vs_id = virtual_storage["virtual_storage_id"] + for vs in data["volume_storages"]: + if vs["volume_storage_id"] == vs_id: + disk_type = ignore_case_get(vs["properties"], "type_of_storage") + size_of_storage = ignore_case_get(vs["properties"], "size_of_storage") + disk_size = int(size_of_storage.replace('GB', '').replace('"', '').strip()) + if disk_type == "root": + param["disk"] = disk_size + elif disk_type == "ephemeral": + param["ephemeral"] = disk_size + elif disk_type == "swap": + param["swap"] = disk_size + else: + virtual_storages = ignore_case_get(virtual_compute, "virtual_storages") + size_of_storage = ignore_case_get(virtual_storages[0], "size_of_storage") + disk_size = int(size_of_storage.replace('GB', '').replace('"', '').strip()) + param["disk"] = disk_size + tenant_id = get_tenant_id(vim_cache, vim_id, tenant_name) logger.debug("param:%s" % param) ret = api.create_flavor(vim_id, tenant_id, param) @@ -516,7 +526,7 @@ def create_port_of_vm(vim_cache, res_cache, data, port, do_notify, res_type): } ret = api.create_vm_port(vim_id, tenant_id, vm_id, param) ret["nodeId"] = port["cp_id"] - do_notify(res_type, ret) + do_notify("create", res_type, ret) def delete_port_of_vm(vim_cache, res_cache, data, port, do_notify, res_type):