Merge "Add IP_ANY dict to ease choosing between IPv4 and IPv6 "any" address"

This commit is contained in:
Jenkins 2015-07-08 04:15:50 +00:00 committed by Gerrit Code Review
commit 1e3b4f119a
3 changed files with 3 additions and 6 deletions

View File

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

View File

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

View File

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