diff --git a/vmware_nsx/plugins/nsx_v/drivers/distributed_router_driver.py b/vmware_nsx/plugins/nsx_v/drivers/distributed_router_driver.py index b0d055a614..3ccc4e24b5 100644 --- a/vmware_nsx/plugins/nsx_v/drivers/distributed_router_driver.py +++ b/vmware_nsx/plugins/nsx_v/drivers/distributed_router_driver.py @@ -276,9 +276,9 @@ class RouterDistributedDriver(router_driver.RouterBaseDriver): 'fixed_ips': {'subnet_id': [vdr_subnets[0]['id']]}}, fields=['fixed_ips']) - if(dhcp_ports - and dhcp_ports[0].get('fixed_ips') - and dhcp_ports[0]['fixed_ips'][0]): + if (dhcp_ports + and dhcp_ports[0].get('fixed_ips') + and dhcp_ports[0]['fixed_ips'][0]): ip_subnet = dhcp_ports[0]['fixed_ips'][0] ip_address = ip_subnet['ip_address'] network_id = self.plugin.get_subnet( @@ -306,8 +306,8 @@ class RouterDistributedDriver(router_driver.RouterBaseDriver): subnet_id = port['fixed_ips'][0]['subnet_id'] port_subnet = self.plugin.get_subnet( context, subnet_id) - if(port_subnet['id'] != subnet['id'] - and port_subnet['enable_dhcp']): + if (port_subnet['id'] != subnet['id'] + and port_subnet['enable_dhcp']): # We already have a subnet which is connected to # DHCP - hence no need to change the metadata route return False @@ -322,8 +322,8 @@ class RouterDistributedDriver(router_driver.RouterBaseDriver): routes = edge_utils.get_routes(self.nsx_v, context, router_id) for route in routes: - if(route['destination'] == METADATA_CIDR - and subnet['network_id'] == route['network_id']): + if (route['destination'] == METADATA_CIDR + and subnet['network_id'] == route['network_id']): # Metadata requests are transferred via this port return True diff --git a/vmware_nsx/plugins/nsx_v/plugin.py b/vmware_nsx/plugins/nsx_v/plugin.py index 5426db3046..f0d37c2435 100644 --- a/vmware_nsx/plugins/nsx_v/plugin.py +++ b/vmware_nsx/plugins/nsx_v/plugin.py @@ -407,9 +407,9 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin, return subnets new_subnets = [] - if(not fields - or as_providers.ADV_SERVICE_PROVIDERS in fields - or (filters and filters.get(as_providers.ADV_SERVICE_PROVIDERS))): + if (not fields + or as_providers.ADV_SERVICE_PROVIDERS in fields + or (filters and filters.get(as_providers.ADV_SERVICE_PROVIDERS))): # We only deal metadata provider field when: # - All fields are retrieved @@ -423,8 +423,8 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin, if md_filter is None or len(set(as_provider) & set(md_filter)): # Include metadata_providers only if requested in results - if(not fields - or as_providers.ADV_SERVICE_PROVIDERS in fields): + if (not fields + or as_providers.ADV_SERVICE_PROVIDERS in fields): subnet[as_providers.ADV_SERVICE_PROVIDERS] = ( as_provider) diff --git a/vmware_nsx/plugins/nsx_v3/plugin.py b/vmware_nsx/plugins/nsx_v3/plugin.py index ce396d7adc..d7f89cc404 100644 --- a/vmware_nsx/plugins/nsx_v3/plugin.py +++ b/vmware_nsx/plugins/nsx_v3/plugin.py @@ -537,12 +537,7 @@ class NsxV3Plugin(addr_pair_db.AllowedAddressPairsMixin, msg = _('Invalid binding:profile. parent_name "%s" must be ' 'a string.') % parent_name raise n_exc.InvalidInput(error_message=msg) - try: - # FIXME(arosen): use neutron.plugins.common.utils.is_valid_vlan_tag - tag = int(tag) - if(tag < 0 or tag > 4095): - raise ValueError - except ValueError: + if not n_utils.is_valid_vlan_tag(tag): msg = _('Invalid binding:profile. tag "%s" must be ' 'an int between 1 and 4096, inclusive.') % tag raise n_exc.InvalidInput(error_message=msg)