Update vnf instaniation code of gvnfm vnflcm
[vfc/gvnfm/vnflcm.git] / lcm / lcm / pub / vimapi / adaptor.py
index 4b15670..a09943f 100644 (file)
@@ -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"])
     
@@ -165,13 +167,16 @@ def create_port(vim_cache, res_cache, data, port, do_notify, res_type):
     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 = get_res_id(res_cache, RES_NETWORK, port["vl_id"])
-    subnet_id = get_res_id(res_cache, RES_SUBNET, port["vl_id"])
+    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"))
@@ -179,6 +184,7 @@ def create_port(vim_cache, res_cache, data, 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"])