summaryrefslogtreecommitdiff
path: root/tests/unittests/test_net.py
diff options
context:
space:
mode:
authorRyan Harper <ryan.harper@canonical.com>2017-06-15 13:12:03 -0500
committerScott Moser <smoser@brickies.net>2017-07-20 16:22:38 -0400
commit8317bcab7cd08f1dcd96095c0cb746b57cb27234 (patch)
tree2fa1ae081f95daf1c4ff281be6235d5dbf0e8a43 /tests/unittests/test_net.py
parent31fa6f9d0f945868349c033fa049d2467ddcd478 (diff)
downloadvyos-cloud-init-8317bcab7cd08f1dcd96095c0cb746b57cb27234.tar.gz
vyos-cloud-init-8317bcab7cd08f1dcd96095c0cb746b57cb27234.zip
sysconfig: handle manual type subnets
Implement manual control for sysconfig by using ONBOOT=N. This allows an interface to be configured but not brought up. Note that ONBOOT is per-interface not per address. LP: #1687725
Diffstat (limited to 'tests/unittests/test_net.py')
-rw-r--r--tests/unittests/test_net.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py
index c012600f..e625934f 100644
--- a/tests/unittests/test_net.py
+++ b/tests/unittests/test_net.py
@@ -1031,6 +1031,39 @@ pre-down route del -net 10.0.0.0 netmask 255.0.0.0 gw 11.0.0.1 metric 3 || true
"""),
},
},
+ 'manual': {
+ 'yaml': textwrap.dedent("""
+ version: 1
+ config:
+ - type: physical
+ name: eth0
+ mac_address: "52:54:00:12:34:00"
+ subnets:
+ - type: static
+ address: 192.168.1.2/24
+ control: manual"""),
+ 'expected_eni': textwrap.dedent("""\
+ auto lo
+ iface lo inet loopback
+
+ # control-manual eth0
+ iface eth0 inet static
+ address 192.168.1.2/24
+ """),
+ 'expected_sysconfig': {
+ 'ifcfg-eth0': textwrap.dedent("""\
+ BOOTPROTO=none
+ DEVICE=eth0
+ HWADDR=52:54:00:12:34:00
+ IPADDR=192.168.1.2
+ NETMASK=255.255.255.0
+ NM_CONTROLLED=no
+ ONBOOT=no
+ TYPE=Ethernet
+ USERCTL=no
+ """),
+ },
+ },
}
@@ -1460,6 +1493,12 @@ USERCTL=no
self._compare_files_to_expected(entry['expected_sysconfig'], found)
self._assert_headers(found)
+ def test_manual_config(self):
+ entry = NETWORK_CONFIGS['manual']
+ found = self._render_and_read(network_config=yaml.load(entry['yaml']))
+ self._compare_files_to_expected(entry['expected_sysconfig'], found)
+ self._assert_headers(found)
+
class TestEniNetRendering(CiTestCase):
@@ -1911,6 +1950,13 @@ class TestEniRoundTrip(CiTestCase):
entry['expected_eni'].splitlines(),
files['/etc/network/interfaces'].splitlines())
+ def testsimple_render_manual(self):
+ entry = NETWORK_CONFIGS['manual']
+ files = self._render_and_read(network_config=yaml.load(entry['yaml']))
+ self.assertEqual(
+ entry['expected_eni'].splitlines(),
+ files['/etc/network/interfaces'].splitlines())
+
def test_routes_rendered(self):
# as reported in bug 1649652
conf = [