Random cleanups
Use 'if (' instead of 'if(' Use common util method for validating vlan tags Change-Id: I26401e3d9c10b581793c1e8abcbcdf7a7ea304f0
This commit is contained in:
parent
43a52e0a58
commit
410af60a91
|
@ -276,9 +276,9 @@ class RouterDistributedDriver(router_driver.RouterBaseDriver):
|
||||||
'fixed_ips': {'subnet_id': [vdr_subnets[0]['id']]}},
|
'fixed_ips': {'subnet_id': [vdr_subnets[0]['id']]}},
|
||||||
fields=['fixed_ips'])
|
fields=['fixed_ips'])
|
||||||
|
|
||||||
if(dhcp_ports
|
if (dhcp_ports
|
||||||
and dhcp_ports[0].get('fixed_ips')
|
and dhcp_ports[0].get('fixed_ips')
|
||||||
and dhcp_ports[0]['fixed_ips'][0]):
|
and dhcp_ports[0]['fixed_ips'][0]):
|
||||||
ip_subnet = dhcp_ports[0]['fixed_ips'][0]
|
ip_subnet = dhcp_ports[0]['fixed_ips'][0]
|
||||||
ip_address = ip_subnet['ip_address']
|
ip_address = ip_subnet['ip_address']
|
||||||
network_id = self.plugin.get_subnet(
|
network_id = self.plugin.get_subnet(
|
||||||
|
@ -306,8 +306,8 @@ class RouterDistributedDriver(router_driver.RouterBaseDriver):
|
||||||
subnet_id = port['fixed_ips'][0]['subnet_id']
|
subnet_id = port['fixed_ips'][0]['subnet_id']
|
||||||
port_subnet = self.plugin.get_subnet(
|
port_subnet = self.plugin.get_subnet(
|
||||||
context, subnet_id)
|
context, subnet_id)
|
||||||
if(port_subnet['id'] != subnet['id']
|
if (port_subnet['id'] != subnet['id']
|
||||||
and port_subnet['enable_dhcp']):
|
and port_subnet['enable_dhcp']):
|
||||||
# We already have a subnet which is connected to
|
# We already have a subnet which is connected to
|
||||||
# DHCP - hence no need to change the metadata route
|
# DHCP - hence no need to change the metadata route
|
||||||
return False
|
return False
|
||||||
|
@ -322,8 +322,8 @@ class RouterDistributedDriver(router_driver.RouterBaseDriver):
|
||||||
routes = edge_utils.get_routes(self.nsx_v, context, router_id)
|
routes = edge_utils.get_routes(self.nsx_v, context, router_id)
|
||||||
|
|
||||||
for route in routes:
|
for route in routes:
|
||||||
if(route['destination'] == METADATA_CIDR
|
if (route['destination'] == METADATA_CIDR
|
||||||
and subnet['network_id'] == route['network_id']):
|
and subnet['network_id'] == route['network_id']):
|
||||||
|
|
||||||
# Metadata requests are transferred via this port
|
# Metadata requests are transferred via this port
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -407,9 +407,9 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
||||||
return subnets
|
return subnets
|
||||||
|
|
||||||
new_subnets = []
|
new_subnets = []
|
||||||
if(not fields
|
if (not fields
|
||||||
or as_providers.ADV_SERVICE_PROVIDERS in fields
|
or as_providers.ADV_SERVICE_PROVIDERS in fields
|
||||||
or (filters and filters.get(as_providers.ADV_SERVICE_PROVIDERS))):
|
or (filters and filters.get(as_providers.ADV_SERVICE_PROVIDERS))):
|
||||||
|
|
||||||
# We only deal metadata provider field when:
|
# We only deal metadata provider field when:
|
||||||
# - All fields are retrieved
|
# - 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)):
|
if md_filter is None or len(set(as_provider) & set(md_filter)):
|
||||||
# Include metadata_providers only if requested in results
|
# Include metadata_providers only if requested in results
|
||||||
if(not fields
|
if (not fields
|
||||||
or as_providers.ADV_SERVICE_PROVIDERS in fields):
|
or as_providers.ADV_SERVICE_PROVIDERS in fields):
|
||||||
subnet[as_providers.ADV_SERVICE_PROVIDERS] = (
|
subnet[as_providers.ADV_SERVICE_PROVIDERS] = (
|
||||||
as_provider)
|
as_provider)
|
||||||
|
|
||||||
|
|
|
@ -537,12 +537,7 @@ class NsxV3Plugin(addr_pair_db.AllowedAddressPairsMixin,
|
||||||
msg = _('Invalid binding:profile. parent_name "%s" must be '
|
msg = _('Invalid binding:profile. parent_name "%s" must be '
|
||||||
'a string.') % parent_name
|
'a string.') % parent_name
|
||||||
raise n_exc.InvalidInput(error_message=msg)
|
raise n_exc.InvalidInput(error_message=msg)
|
||||||
try:
|
if not n_utils.is_valid_vlan_tag(tag):
|
||||||
# FIXME(arosen): use neutron.plugins.common.utils.is_valid_vlan_tag
|
|
||||||
tag = int(tag)
|
|
||||||
if(tag < 0 or tag > 4095):
|
|
||||||
raise ValueError
|
|
||||||
except ValueError:
|
|
||||||
msg = _('Invalid binding:profile. tag "%s" must be '
|
msg = _('Invalid binding:profile. tag "%s" must be '
|
||||||
'an int between 1 and 4096, inclusive.') % tag
|
'an int between 1 and 4096, inclusive.') % tag
|
||||||
raise n_exc.InvalidInput(error_message=msg)
|
raise n_exc.InvalidInput(error_message=msg)
|
||||||
|
|
Loading…
Reference in New Issue