diff --git a/neutron/agent/l3/ha_router.py b/neutron/agent/l3/ha_router.py index b430f44e5a3..31a2c18dc58 100644 --- a/neutron/agent/l3/ha_router.py +++ b/neutron/agent/l3/ha_router.py @@ -191,9 +191,7 @@ class HaRouter(router.RouterInfo): for gw_ip in gateway_ips: # TODO(Carl) This is repeated everywhere. A method would # be nice. - default_gw = (n_consts.IPv4_ANY if - netaddr.IPAddress(gw_ip).version == 4 else - n_consts.IPv6_ANY) + default_gw = n_consts.IP_ANY[netaddr.IPAddress(gw_ip).version] instance = self._get_keepalived_instance() default_gw_rts.append(keepalived.KeepalivedVirtualRoute( default_gw, gw_ip, interface_name)) diff --git a/neutron/agent/linux/ip_lib.py b/neutron/agent/linux/ip_lib.py index edb35d5a7d7..36d2b09523b 100644 --- a/neutron/agent/linux/ip_lib.py +++ b/neutron/agent/linux/ip_lib.py @@ -282,8 +282,6 @@ class IPRule(SubProcessBase): class IpRuleCommand(IpCommandBase): COMMAND = 'rule' - ALL = {4: constants.IPv4_ANY, 6: constants.IPv6_ANY} - def _parse_line(self, ip_version, line): # Typical rules from 'ip rule show': # 4030201: from 1.2.3.4/24 lookup 10203040 @@ -299,7 +297,7 @@ class IpRuleCommand(IpCommandBase): # Canonicalize some arguments if settings.get('from') == "all": - settings['from'] = self.ALL[ip_version] + settings['from'] = constants.IP_ANY[ip_version] if 'lookup' in settings: settings['table'] = settings.pop('lookup') diff --git a/neutron/common/constants.py b/neutron/common/constants.py index d935273e527..fc9c4b24633 100644 --- a/neutron/common/constants.py +++ b/neutron/common/constants.py @@ -74,6 +74,7 @@ IPv6_BITS = 128 IPv4_ANY = '0.0.0.0/0' IPv6_ANY = '::/0' +IP_ANY = {IP_VERSION_4: IPv4_ANY, IP_VERSION_6: IPv6_ANY} DHCP_RESPONSE_PORT = 68