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 | |
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>
-rw-r--r-- | lcm/lcm/pub/vimapi/adaptor.py | 27 | ||||
-rw-r--r-- | lcm/lcm/samples/tests.py | 27 |
2 files changed, 30 insertions, 24 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")) diff --git a/lcm/lcm/samples/tests.py b/lcm/lcm/samples/tests.py index e34f6a1f..9c57d84e 100644 --- a/lcm/lcm/samples/tests.py +++ b/lcm/lcm/samples/tests.py @@ -166,23 +166,26 @@ inst_res_data = { "vl_id": "vl_vNat", "description": "", "properties": { - "name": "vNat_big_subnet", - "network_name": "vNat_big", + "connectivity_type": { + "layer_protocol": "ipv4" + }, + "vl_profile": { + "networkName": "vNat_big", + "networkType": "vlan", + "physicalNetwork": "physnet1", + "segmentationId": "30", + "vlanTransparent": False, + "cidr": "10.43.38.0/24", + "gatewayIp": "10.43.38.1", + "dhcpEnabled": False, + "startIp": "10.43.38.2", + "endIp": "10.43.38.254" + }, "is_predefined": False, "vendor": "zte", "netmask": "255.255.255.0", "mtu": 1500, - "network_type": "vlan", - "physical_network": "physnet1", - "segmentation_id": "30", - "vlan_transparent": False, "vds_name": "vds1", - "cidr": "10.43.38.0/24", - "ip_version": 4, - "gateway_ip": "10.43.38.1", - "dhcp_enabled": False, - "start_ip": "10.43.38.2", - "end_ip": "10.43.38.254", "host_routes": [ { "destination": "10.43.26.0/24", |