mirror of
https://github.com/xcat2/confluent.git
synced 2025-02-14 01:29:23 +00:00
Rdeuce netlink traffic to get net config
Avoid superfluous calls to get addresses and reuse result through the lifetime of a reply.
This commit is contained in:
parent
5a7f0db899
commit
7eeba4e42a
@ -148,12 +148,19 @@ def inametonets(iname):
|
||||
class NetManager(object):
|
||||
def __init__(self, myaddrs, node, configmanager):
|
||||
self.myaddrs = myaddrs
|
||||
self._allmyaddrs = None
|
||||
self.cfm = configmanager
|
||||
self.node = node
|
||||
self.myattribs = {}
|
||||
self.consumednames4 = set([])
|
||||
self.consumednames6 = set([])
|
||||
|
||||
@property
|
||||
def allmyaddrs(self):
|
||||
if not self._allmyaddrs:
|
||||
self._allmyaddrs = get_my_addresses()
|
||||
return self._allmyaddrs
|
||||
|
||||
def process_attribs(self, netname, attribs):
|
||||
self.myattribs[netname] = {}
|
||||
ipv4addr = None
|
||||
@ -246,7 +253,7 @@ class NetManager(object):
|
||||
if '/' not in myattribs.get('ipv6_address', '/'):
|
||||
ipn = socket.inet_pton(socket.AF_INET6, myattribs['ipv6_address'])
|
||||
plen = 64
|
||||
for addr in get_my_addresses():
|
||||
for addr in self.allmyaddrs:
|
||||
if addr[0] != socket.AF_INET6:
|
||||
continue
|
||||
if ipn_on_same_subnet(addr[0], ipn, addr[1], addr[2]):
|
||||
@ -255,7 +262,7 @@ class NetManager(object):
|
||||
if '/' not in myattribs.get('ipv4_address', '/'):
|
||||
ipn = socket.inet_pton(socket.AF_INET, myattribs['ipv4_address'])
|
||||
plen = 16
|
||||
for addr in get_my_addresses():
|
||||
for addr in self.allmyaddrs:
|
||||
if addr[0] != socket.AF_INET:
|
||||
continue
|
||||
if ipn_on_same_subnet(addr[0], ipn, addr[1], addr[2]):
|
||||
|
Loading…
x
Reference in New Issue
Block a user