From 2c393582cd67d743d06917490c668885da8e169a Mon Sep 17 00:00:00 2001 From: Shih-Hao Li Date: Thu, 18 Aug 2016 09:13:52 -0700 Subject: [PATCH] NSX|V3: validate if 'destination' exists Some tempest tests did not configure the host_routes correctly. This would result in a exception from the plugin when trying to access the destination IP for host routes. This also skips tests that are problematic: 1. no agents 2. only can create one subnet per network A luta continua!! Change-Id: Ie8732c08f362db3b8fdbe552db46f26b73ac3422 --- devstack/nsx_v3/devstackgaterc | 8 +++++++- vmware_nsx/nsxlib/v3/native_dhcp.py | 8 ++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/devstack/nsx_v3/devstackgaterc b/devstack/nsx_v3/devstackgaterc index 8eae66e6b5..04c7b0ee45 100644 --- a/devstack/nsx_v3/devstackgaterc +++ b/devstack/nsx_v3/devstackgaterc @@ -24,7 +24,13 @@ r="$r(?:tempest\.api\.network\.test_extensions\.ExtensionsTestJSON.*)" r="$r|(?:tempest\.api\.network\.test_routers\.DvrRoutersTest.*)" r="$r|(?:tempest\.api\.network\.test_routers_negative\.DvrRoutersNegativeTest.*)" -r="$r|(?:tempest\.api\.network\.test_allowed_address_pair\.AllowedAddressPairTestJSON\.test_update_port_with_cidr_address_pair*)" +r="$r|(?:tempest\.api\.network\.test_allowed_address_pair\.AllowedAddressPairTestJSON\.test_update_port_with_cidr_address_pair.*)" +#Native DHCP has no agents +r="$r|(?:tempest\.api\.network\.admin\.test_agent_management\.AgentManagementTestJSON.*)" +#Can not create more than one DHCP-enabled subnet +r="$r|(?:tempest\.api\.network\.test_ports\.PortsTestJSON\.test_create_update_port_with_second_ip.*)" +r="$r|(?:tempest\.api\.network\.test_ports\.PortsTestJSON\.test_update_port_with_security_group_and_extra_attributes.*)" +r="$r|(?:tempest\.api\.network\.test_ports\.PortsTestJSON\.test_update_port_with_two_security_groups_and_extra_attributes.*)" # End list of exclusions. r="$r)" diff --git a/vmware_nsx/nsxlib/v3/native_dhcp.py b/vmware_nsx/nsxlib/v3/native_dhcp.py index 637a3128b5..3d2f02817d 100644 --- a/vmware_nsx/nsxlib/v3/native_dhcp.py +++ b/vmware_nsx/nsxlib/v3/native_dhcp.py @@ -39,12 +39,12 @@ def build_dhcp_server_config(network, subnet, port, project_name): host_routes = [{'network': subnet['cidr'], 'next_hop': '0.0.0.0'}] # Copy routes from subnet host_routes attribute. for hr in subnet['host_routes']: - if hr.destination == constants.IPv4_ANY: + if hr['destination'] == constants.IPv4_ANY: if not gateway_ip: - gateway_ip = hr.nexthop + gateway_ip = hr['nexthop'] else: - host_routes.append({'network': hr.destination, - 'next_hop': hr.nexthop}) + host_routes.append({'network': hr['destination'], + 'next_hop': hr['nexthop']}) # If gateway_ip is defined, add default route via this gateway. if gateway_ip: host_routes.append({'network': constants.IPv4_ANY,