mirror of
https://github.com/xcat2/confluent.git
synced 2025-01-26 19:10:30 +00:00
Implement more context data in discovery
Let the client know the management interface and whether that subnet has the nicest match for a primary network.
This commit is contained in:
parent
86e944b3a4
commit
3fed7ea075
@ -32,6 +32,7 @@ import confluent.config.configmanager as cfm
|
||||
import confluent.neighutil as neighutil
|
||||
import confluent.util as util
|
||||
import confluent.log as log
|
||||
import confluent.netutil as netutil
|
||||
import eventlet.green.select as select
|
||||
import eventlet.green.socket as socket
|
||||
import time
|
||||
@ -191,6 +192,14 @@ def snoop(handler, byehandler=None, protocol=None, uuidlookup=None):
|
||||
seconds = int(currtime)
|
||||
msecs = int(currtime * 1000 % 1000)
|
||||
reply = 'HTTP/1.1 200 OK\r\nNODENAME: {0}\r\nCURRTIME: {1}\r\nCURRMSECS: {2}\r\n'.format(node, seconds, msecs)
|
||||
if '%' in peer[0]:
|
||||
iface = peer[0].split('%', 1)[1]
|
||||
reply += 'MGTIFACE: {0}\r\n'.format(
|
||||
peer[0].split('%', 1)[1])
|
||||
ncfg = netutil.get_nic_config(
|
||||
cfg, node, ifidx=iface)
|
||||
if ncfg.get('matchesnodename', None):
|
||||
reply += 'DEFAULTNET: 1\r\n'
|
||||
if not isinstance(reply, bytes):
|
||||
reply = reply.encode('utf8')
|
||||
s.sendto(reply, peer)
|
||||
|
@ -104,10 +104,11 @@ def myiptonets(svrip):
|
||||
return inametonets(relevantnic)
|
||||
|
||||
|
||||
def idxtonets(ifidx):
|
||||
_rebuildidxmap()
|
||||
iname = _idxtoifnamemap.get(ifidx, None)
|
||||
return inametonets(iname)
|
||||
def _iftonets(ifidx):
|
||||
if isinstance(ifidx, int):
|
||||
_rebuildidxmap()
|
||||
ifidx = _idxtoifnamemap.get(ifidx, None)
|
||||
return inametonets(ifidx)
|
||||
|
||||
def inametonets(iname):
|
||||
addrs = netifaces.ifaddresses(iname)
|
||||
@ -176,7 +177,7 @@ def get_nic_config(configmanager, node, ip=None, mac=None, ifidx=None,
|
||||
needsvrip = False
|
||||
if ifidx is not None:
|
||||
dhcprequested = False
|
||||
nets = list(idxtonets(ifidx))
|
||||
nets = list(_iftonets(ifidx))
|
||||
if not nets:
|
||||
cfgdata['ipv4_broken'] = True
|
||||
if serverip is not None:
|
||||
@ -222,6 +223,7 @@ def get_nic_config(configmanager, node, ip=None, mac=None, ifidx=None,
|
||||
for net in nets:
|
||||
net, prefix, svrip = net
|
||||
if ip_on_same_subnet(net, ipbynodename, prefix):
|
||||
cfgdata['isnodename'] = True
|
||||
cfgdata['ipv4_address'] = ipbynodename
|
||||
cfgdata['ipv4_method'] = 'static'
|
||||
cfgdata['prefix'] = prefix
|
||||
|
Loading…
x
Reference in New Issue
Block a user