Исправлно определение ip адреса на bridge

legacy27
Mike Hiretsky 5 years ago
parent 44c7a365f5
commit cb2ccd2329

@ -256,6 +256,11 @@ def getInterfaces():
device.sysfs.Path.ClassNet, fullpath=True)
if filter_ethernet(x))
def getMaster(iface):
master_path = [device.sysfs.Path.ClassNet, iface, "master"]
if device.sysfs.exists(*master_path):
return path.split(device.sysfs.realpath(*master_path))[-1]
return None
def getIp(iface):
sockfd = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

@ -62,12 +62,11 @@ class VariableOsNetAllow(ReadonlyVariable):
networks = []
net_interfaces = self.Get("os_net_interfaces")
for i in net_interfaces:
ipaddr, mask = ip.getIp(i), ip.cidrToMask(ip.getMask(i))
iface = ip.getMaster(i) or i
ipaddr, mask = ip.getIp(iface), ip.cidrToMask(ip.getMask(iface))
if ipaddr and mask:
networks.append(ip.getIpNet(ipaddr, mask))
else:
networks.append("")
return ",".join(filter(lambda x: x, networks))
return ",".join(list(set(filter(lambda x: x, networks))))
class VariableOsNetIp(ReadonlyVariable):
@ -80,10 +79,11 @@ class VariableOsNetIp(ReadonlyVariable):
ips = []
net_interfaces = self.Get("os_net_interfaces")
for i in net_interfaces:
ipaddr = ip.getIp(i)
iface = ip.getMaster(i) or i
ipaddr = ip.getIp(iface)
if ipaddr:
ips.append(ipaddr)
return ",".join(ips)
return ",".join(list(set(ips)))
class VariableOsNetInterfaces(ReadonlyVariable):

Loading…
Cancel
Save