Fix detection of ETHx_IP context variable, add test.
This commit is contained in:
parent
d8476cf5f1
commit
d151eab415
@ -376,7 +376,6 @@ def read_context_disk_dir(source_dir, asuser=None):
|
|||||||
# to shell parser
|
# to shell parser
|
||||||
non_empty = re.match(r'.*?^\s*([^# ]+)', content,
|
non_empty = re.match(r'.*?^\s*([^# ]+)', content,
|
||||||
re.MULTILINE | re.DOTALL)
|
re.MULTILINE | re.DOTALL)
|
||||||
|
|
||||||
if non_empty:
|
if non_empty:
|
||||||
context = parse_shell_config(content, asuser=asuser)
|
context = parse_shell_config(content, asuser=asuser)
|
||||||
except IOError as e:
|
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
|
# only if there are any required context variables
|
||||||
# http://opennebula.org/documentation:rel3.8:cong#network_configuration
|
# http://opennebula.org/documentation:rel3.8:cong#network_configuration
|
||||||
for k in context.keys():
|
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'])
|
(out, _) = util.subp(['/sbin/ip', 'link'])
|
||||||
net = OpenNebulaNetwork(out, context)
|
net = OpenNebulaNetwork(out, context)
|
||||||
results['network-interfaces'] = net.gen_conf()
|
results['network-interfaces'] = net.gen_conf()
|
||||||
|
@ -173,6 +173,12 @@ class TestOpenNebulaDataSource(MockerTestCase):
|
|||||||
self.assertTrue('local-hostname' in results['metadata'])
|
self.assertTrue('local-hostname' in results['metadata'])
|
||||||
self.assertEqual(PUBLIC_IP, results['metadata']['local-hostname'])
|
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 test_find_candidates(self):
|
||||||
def my_devs_with(criteria):
|
def my_devs_with(criteria):
|
||||||
return {
|
return {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user