diff options
author | Vlastimil Holer <vlastimil.holer@gmail.com> | 2013-09-10 18:35:19 +0200 |
---|---|---|
committer | Vlastimil Holer <vlastimil.holer@gmail.com> | 2013-09-10 18:35:19 +0200 |
commit | c0d1a59d96a16c080ad8b8278251294cccc21894 (patch) | |
tree | 5441b97ecf1ac9a8edf15c77841ac0d040b8435c | |
parent | 18ec61a5b5e2c67d84cbdcef1e47cc72b0ba6218 (diff) | |
download | vyos-cloud-init-c0d1a59d96a16c080ad8b8278251294cccc21894.tar.gz vyos-cloud-init-c0d1a59d96a16c080ad8b8278251294cccc21894.zip |
Fix detection of ETHx_IP context variable, add test.
-rw-r--r-- | cloudinit/sources/DataSourceOpenNebula.py | 3 | ||||
-rw-r--r-- | tests/unittests/test_datasource/test_opennebula.py | 6 |
2 files changed, 7 insertions, 2 deletions
diff --git a/cloudinit/sources/DataSourceOpenNebula.py b/cloudinit/sources/DataSourceOpenNebula.py index 1b419cfd..141bd454 100644 --- a/cloudinit/sources/DataSourceOpenNebula.py +++ b/cloudinit/sources/DataSourceOpenNebula.py @@ -376,7 +376,6 @@ def read_context_disk_dir(source_dir, asuser=None): # to shell parser non_empty = re.match(r'.*?^\s*([^# ]+)', content, re.MULTILINE | re.DOTALL) - if non_empty: context = parse_shell_config(content, asuser=asuser) except IOError as e: @@ -420,7 +419,7 @@ def read_context_disk_dir(source_dir, asuser=None): # only if there are any required context variables # http://opennebula.org/documentation:rel3.8:cong#network_configuration for k in context.keys(): - if re.match(r'^ETH\d+_ip$', k): + if re.match(r'^ETH\d+_IP$', k): (out, _) = util.subp(['/sbin/ip', 'link']) net = OpenNebulaNetwork(out, context) results['network-interfaces'] = net.gen_conf() diff --git a/tests/unittests/test_datasource/test_opennebula.py b/tests/unittests/test_datasource/test_opennebula.py index f5103dc0..f2457657 100644 --- a/tests/unittests/test_datasource/test_opennebula.py +++ b/tests/unittests/test_datasource/test_opennebula.py @@ -173,6 +173,12 @@ class TestOpenNebulaDataSource(MockerTestCase): self.assertTrue('local-hostname' in results['metadata']) self.assertEqual(PUBLIC_IP, results['metadata']['local-hostname']) + def test_network_interfaces(self): + populate_context_dir(self.seed_dir, {'ETH0_IP': '1.2.3.4'}) + results = ds.read_context_disk_dir(self.seed_dir) + + self.assertTrue('network-interfaces' in results) + def test_find_candidates(self): def my_devs_with(criteria): return { |