-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"])