Random cleanups

Use 'if (' instead of 'if('

Use common util method for validating vlan tags

Change-Id: I26401e3d9c10b581793c1e8abcbcdf7a7ea304f0
This commit is contained in:
Gary Kotton 2015-11-19 05:39:24 -08:00
parent 43a52e0a58
commit 410af60a91
3 changed files with 13 additions and 18 deletions

View File

@ -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

View File

@ -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)

View File

@ -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)