}
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", 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"]
"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"]
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({
})
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