diff options
author | Vlastimil Holer <vlastimil.holer@gmail.com> | 2013-02-19 12:35:12 +0100 |
---|---|---|
committer | Vlastimil Holer <vlastimil.holer@gmail.com> | 2013-02-19 12:35:12 +0100 |
commit | 54f6ccccfb4f75dc6877b04b42987e834b7a0015 (patch) | |
tree | 1742e9c389c2d81604244c65e009ddda213b1111 /cloudinit/sources/DataSourceOpenNebula.py | |
parent | 5bfbf7a81872afd426271b0ed3ed65e76b9a584e (diff) | |
download | cloud-init-git-54f6ccccfb4f75dc6877b04b42987e834b7a0015.tar.gz |
Change network ifaces detection from ifconfig to ip command.
Diffstat (limited to 'cloudinit/sources/DataSourceOpenNebula.py')
-rw-r--r-- | cloudinit/sources/DataSourceOpenNebula.py | 11 |
1 files changed, 5 insertions, 6 deletions
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() |