From 54f6ccccfb4f75dc6877b04b42987e834b7a0015 Mon Sep 17 00:00:00 2001 From: Vlastimil Holer Date: Tue, 19 Feb 2013 12:35:12 +0100 Subject: Change network ifaces detection from ifconfig to ip command. --- cloudinit/sources/DataSourceOpenNebula.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'cloudinit') diff --git a/cloudinit/sources/DataSourceOpenNebula.py b/cloudinit/sources/DataSourceOpenNebula.py index 52474675..9b1b5f9c 100644 --- a/cloudinit/sources/DataSourceOpenNebula.py +++ b/cloudinit/sources/DataSourceOpenNebula.py @@ -130,16 +130,15 @@ class NonContextDeviceDir(Exception): class OpenNebulaNetwork(object): - REG_ETH=re.compile('^eth') - REG_DEV_MAC=re.compile('^(eth\d+).*HWaddr (..:..:..:..:..:..)') + REG_DEV_MAC=re.compile('^\d+: (eth\d+):.*link\/ether (..:..:..:..:..:..) ') - def __init__(self, ifconfig, context_sh): - self.ifconfig=ifconfig + def __init__(self, ip, context_sh): + self.ip=ip self.context_sh=context_sh self.ifaces=self.get_ifaces() def get_ifaces(self): - return [self.REG_DEV_MAC.search(f).groups() for f in self.ifconfig.split("\n") if self.REG_ETH.match(f)] + return [self.REG_DEV_MAC.search(f).groups() for f in self.ip.split("\n") if self.REG_DEV_MAC.match(f)] def mac2ip(self, mac): components=mac.split(':')[2:] @@ -341,7 +340,7 @@ def read_context_disk_dir(source_dir): elif "userdata" in context_sh: results['userdata'] = context_sh["userdata"] - (out, err) = util.subp(['/sbin/ifconfig', '-a']) + (out, err) = util.subp(['/sbin/ip', '-o', 'link']) net=OpenNebulaNetwork(out, context_sh) results['network-interfaces']=net.gen_conf() -- cgit v1.2.3