Merge "Add IP_ANY dict to ease choosing between IPv4 and IPv6 "any" address"
This commit is contained in:
commit
1e3b4f119a
|
@ -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))
|
||||
|
|
|
@ -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')
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue