diff options
author | Scott Moser <smoser@ubuntu.com> | 2016-07-13 22:03:42 -0400 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2016-07-13 22:03:42 -0400 |
commit | efef1c263ab1c473fd90f3782a785edab7d02430 (patch) | |
tree | bc5313a90762ce0b37ccd509b7d385f49f9bc2dc /tests/unittests/test_net.py | |
parent | 9f7ce5f090689b664ffce7e0b4ac78bfeafd1a79 (diff) | |
download | vyos-cloud-init-efef1c263ab1c473fd90f3782a785edab7d02430.tar.gz vyos-cloud-init-efef1c263ab1c473fd90f3782a785edab7d02430.zip |
ConfigDrive: write 'injected' files and legacy networking
Previous commit disabled the consumption of 'injected' files in
configdrive (openstack server boot --file=/target/file=local-file)
unless the datasource was in 'pass' mode. The default mode is 'net'
so that would never happen.
Also here are:
a.) a fix for 'links_path_prefix' string from debian, to finally
disable the rendering of systemd.link files (LP: #1594546)
b.) some comments to apply_network_config
c.) implement a backwards compatibility for for distros that do
not yet implement apply_network_config by converting the network
config into ENI format and calling apply_network.
This is required because prior to the previous commit, those distros
would have had 'apply_network' called with the openstack provided
ENI file. But after this change they will have apply_network_config
called by cloudinit's main.
d.) a network_state_to_eni helper for converting net config to eni
it supports the not-actually-correct 'hwaddress' field in ENI.
LP: #1602373
Diffstat (limited to 'tests/unittests/test_net.py')
-rw-r--r-- | tests/unittests/test_net.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py index 3ae00fc6..6f4dad13 100644 --- a/tests/unittests/test_net.py +++ b/tests/unittests/test_net.py @@ -269,6 +269,37 @@ iface eth1000 inet dhcp self.assertEqual(expected.lstrip(), contents.lstrip()) +class TestEniNetworkStateToEni(TestCase): + mycfg = { + 'config': [{"type": "physical", "name": "eth0", + "mac_address": "c0:d6:9f:2c:e8:80", + "subnets": [{"type": "dhcp"}]}], + 'version': 1} + my_mac = 'c0:d6:9f:2c:e8:80' + + def test_no_header(self): + rendered = eni.network_state_to_eni( + network_state=network_state.parse_net_config_data(self.mycfg), + render_hwaddress=True) + self.assertIn(self.my_mac, rendered) + self.assertIn("hwaddress", rendered) + + def test_with_header(self): + header = "# hello world\n" + rendered = eni.network_state_to_eni( + network_state=network_state.parse_net_config_data(self.mycfg), + header=header, render_hwaddress=True) + self.assertIn(header, rendered) + self.assertIn(self.my_mac, rendered) + + def test_no_hwaddress(self): + rendered = eni.network_state_to_eni( + network_state=network_state.parse_net_config_data(self.mycfg), + render_hwaddress=False) + self.assertNotIn(self.my_mac, rendered) + self.assertNotIn("hwaddress", rendered) + + class TestCmdlineConfigParsing(TestCase): simple_cfg = { 'config': [{"type": "physical", "name": "eth0", |