From 98fd1c8e1c64e30f39bd5b922d0bc1f762e83ba9 Mon Sep 17 00:00:00 2001 From: Andy Bavier Date: Wed, 11 May 2011 19:23:49 +0000 Subject: [PATCH] Updates for change in sioc.gifconf() semantics --- topo.py | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/topo.py b/topo.py index 63e707b..2f7b6dd 100755 --- a/topo.py +++ b/topo.py @@ -13,6 +13,7 @@ import re import vserver import os from time import strftime +import socket dryrun = 0 vinidir = "/usr/share/vini/" @@ -30,6 +31,33 @@ def run(cmd): else: return subprocess.call(cmd, shell=True); +""" +From old pyplnet, former semantics needed for VINI +""" +def gifconf(): + try: + interfaces = os.listdir("/sys/class/net") + except: + interfaces = [] + s = None + ret = {} + try: + s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, 0) + for interface in interfaces: + try: + ifreq = fcntl.ioctl(s.fileno(), SIOCGIFADDR, + struct.pack("16sH14x", interface, socket.AF_INET)) + (family, ip) = struct.unpack(SIOCGIFADDR_struct, ifreq) + if family == socket.AF_INET: + ret[interface] = _format_ip(ip) + else: + raise Exception + except: + ret[interface] = "0.0.0.0" + finally: + if s is not None: + s.close() + return ret """ Subnet used for virtual interfaces by setup-egre-link script @@ -389,7 +417,7 @@ Creating the virtual link depends on the contents of """ def GetSlivers(data, config = None, plc = None): global ifaces, old_ifaces - ifaces = old_ifaces = sioc.gifconf() + ifaces = old_ifaces = gifconf() slicekeys = {} for sliver in data['slivers']: -- 2.43.0