X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=lcm%2Flcm%2Fpub%2Fvimapi%2Fadaptor.py;h=9956f7e7ae9cf0070025fd5195746f123085a716;hb=638f176eabf0f100112c3e0185d7cc5339c82ef5;hp=3264f94f948e0426aa3fc0beb1477e28c1e2c716;hpb=233e84f5a6c7f796bc8d231d8a5edb93c6bece8a;p=vfc%2Fgvnfm%2Fvnflcm.git diff --git a/lcm/lcm/pub/vimapi/adaptor.py b/lcm/lcm/pub/vimapi/adaptor.py index 3264f94f..9956f7e7 100644 --- a/lcm/lcm/pub/vimapi/adaptor.py +++ b/lcm/lcm/pub/vimapi/adaptor.py @@ -194,7 +194,12 @@ 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")) - set_opt_val(param, "ip", ignore_case_get(port["properties"], "ip_address")) + ip_address = [] + for one_protocol_data in port["properties"]["protocol_data"]: + l3_address_data = one_protocol_data["address_data"]["l3_address_data"] + fixed_ip_address = ignore_case_get(l3_address_data, "fixed_ip_address") + ip_address.extend(fixed_ip_address) + set_opt_val(param, "ip", ",".join(ip_address)) set_opt_val(param, "vnicType", ignore_case_get(port["properties"], "vnic_type")) set_opt_val(param, "securityGroups", "") # TODO vim_id, tenant_name = location_info["vimid"], location_info["tenant"] @@ -284,22 +289,23 @@ def create_vm(vim_cache, res_cache, data, vm, do_notify, res_type): "volumeArray": [] } # set boot param - if "image_file" in vm and vm["image_file"]: + if "artifacts" in vm and vm["artifacts"]: param["boot"]["type"] = BOOT_FROM_IMAGE img_name = "" - for img in ignore_case_get(data, "image_files"): - if vm["image_file"] == img["image_file_id"]: - img_name = img["properties"]["name"] + for artifact in vm["artifacts"]: + if artifact["artifact_name"] == "sw_image": + # TODO: after DM define + img_name = artifact["file"] break if not img_name: - raise VimException("Undefined image(%s)" % vm["image_file"], ERR_CODE) + raise VimException("Undefined image(%s)" % vm["artifacts"], ERR_CODE) images = api.list_image(vim_id, tenant_id) for image in images["images"]: if img_name == image["name"]: param["boot"]["imageId"] = image["id"] break if "imageId" not in param["boot"]: - raise VimException("Image(%s) not found in Vim(%s)" % (img_name, vim_id), ERR_CODE) + raise VimException("Undefined artifacts image(%s)" % vm["artifacts"], ERR_CODE) elif vm["volume_storages"]: param["boot"]["type"] = BOOT_FROM_VOLUME vol_id = vm["volume_storages"][0]["volume_storage_id"] @@ -311,11 +317,13 @@ def create_vm(vim_cache, res_cache, data, vm, do_notify, res_type): param["nicArray"].append({ "portId": get_res_id(res_cache, RES_PORT, cp_id) }) - for inject_data in ignore_case_get(vm["properties"], "inject_data_list"): - param["contextArray"].append({ - "fileName": inject_data["file_name"], - "fileData": inject_data["file_data"] - }) + # TODO: use config drive + for inject_data in ignore_case_get(vm["properties"], "inject_files"): + for key, value in inject_data.items(): + param["contextArray"].append({ + "fileName": key, + "fileData": value + }) for vol_data in ignore_case_get(vm, "volume_storages"): vol_id = vol_data["volume_storage_id"] param["volumeArray"].append({ @@ -323,8 +331,8 @@ def create_vm(vim_cache, res_cache, data, vm, do_notify, res_type): }) set_opt_val(param, "availabilityZone", ignore_case_get(location_info, "availability_zone")) - set_opt_val(param, "userdata", "") # TODO Configuration information or scripts to use upon launch - set_opt_val(param, "metadata", "") # TODO [{"keyName": "foo", "value": "foo value"}] + set_opt_val(param, "userdata", ignore_case_get(vm["properties"], "user_data")) + set_opt_val(param, "metadata", ignore_case_get(vm["properties"], "meta_data")) set_opt_val(param, "securityGroups", "") # TODO List of names of security group set_opt_val(param, "serverGroup", "") # TODO the ServerGroup for anti-affinity and affinity