diff options
author | Kailun Qin <kailun.qin@intel.com> | 2018-04-10 21:12:54 +0800 |
---|---|---|
committer | Kailun Qin <kailun.qin@intel.com> | 2018-04-10 23:26:07 +0800 |
commit | cc348c69ebfeb5697d1861191f9449dfffc1c4bc (patch) | |
tree | e46bf67d0933c27726e9eebc7aa25b136e4be1d3 /lcm/lcm/pub/vimapi/adaptor.py | |
parent | 653ba9efebb7d28d9ee3a7e09aea9d34af63a2be (diff) |
Create network/subnet refer to the new datamodel
Change-Id: Ibb02c88fc433abd58b3ebaabb53edc59550a7a68
Issue-ID: VFC-869
Signed-off-by: Kailun Qin <kailun.qin@intel.com>
Diffstat (limited to 'lcm/lcm/pub/vimapi/adaptor.py')
-rw-r--r-- | lcm/lcm/pub/vimapi/adaptor.py | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/lcm/lcm/pub/vimapi/adaptor.py b/lcm/lcm/pub/vimapi/adaptor.py index 34856197..3264f94f 100644 --- a/lcm/lcm/pub/vimapi/adaptor.py +++ b/lcm/lcm/pub/vimapi/adaptor.py @@ -126,14 +126,15 @@ def create_volume(vim_cache, res_cache, vol, do_notify, res_type): def create_network(vim_cache, res_cache, network, do_notify, res_type): location_info = network["properties"]["location_info"] + vl_profile = network["properties"]["vl_profile"] param = { - "name": network["properties"]["network_name"], + "name": vl_profile["networkName"], "shared": False, - "networkType": network["properties"]["network_type"], - "physicalNetwork": ignore_case_get(network["properties"], "physical_network") + "networkType": vl_profile["networkType"], + "physicalNetwork": ignore_case_get(vl_profile, "physicalNetwork") } - set_opt_val(param, "vlanTransparent", ignore_case_get(network["properties"], "vlan_transparent")) - set_opt_val(param, "segmentationId", int(ignore_case_get(network["properties"], "segmentation_id", "0"))) + set_opt_val(param, "vlanTransparent", ignore_case_get(vl_profile, "vlanTransparent")) + set_opt_val(param, "segmentationId", int(ignore_case_get(vl_profile, "segmentationId", "0"))) set_opt_val(param, "routerExternal", ignore_case_get(network, "route_external")) vim_id, tenant_name = location_info["vimid"], location_info["tenant"] tenant_id = get_tenant_id(vim_cache, vim_id, tenant_name) @@ -146,18 +147,20 @@ def create_network(vim_cache, res_cache, network, do_notify, res_type): def create_subnet(vim_cache, res_cache, subnet, do_notify, res_type): location_info = subnet["properties"]["location_info"] network_id = get_res_id(res_cache, RES_NETWORK, subnet["vl_id"]) + vl_profile = subnet["properties"]["vl_profile"] + layer_protocol = ignore_case_get(subnet["properties"]["connectivity_type"], "layer_protocol") param = { "networkId": network_id, - "name": subnet["properties"]["name"], - "cidr": ignore_case_get(subnet["properties"], "cidr"), - "ipVersion": ignore_case_get(subnet["properties"], "ip_version", IP_V4) + "name": vl_profile["networkName"] + "_subnet", + "cidr": ignore_case_get(vl_profile, "cidr"), + "ipVersion": IP_V4 if(layer_protocol == 'ipv4') else (IP_V6 if(layer_protocol == 'ipv6') else None) } - set_opt_val(param, "enableDhcp", ignore_case_get(subnet["properties"], "dhcp_enabled")) - set_opt_val(param, "gatewayIp", ignore_case_get(subnet["properties"], "gateway_ip")) + set_opt_val(param, "enableDhcp", ignore_case_get(vl_profile, "dhcpEnabled")) + set_opt_val(param, "gatewayIp", ignore_case_get(vl_profile, "gatewayIp")) set_opt_val(param, "dnsNameservers", ignore_case_get(subnet["properties"], "dns_nameservers")) allocation_pool = {} - set_opt_val(allocation_pool, "start", ignore_case_get(subnet["properties"], "start_ip")) - set_opt_val(allocation_pool, "end", ignore_case_get(subnet["properties"], "end_ip")) + set_opt_val(allocation_pool, "start", ignore_case_get(vl_profile, "startIp")) + set_opt_val(allocation_pool, "end", ignore_case_get(vl_profile, "endIp")) if allocation_pool: param["allocationPools"] = [allocation_pool] set_opt_val(param, "hostRoutes", ignore_case_get(subnet["properties"], "host_routes")) |