diff --git a/tests/generator/test_vlans.py b/tests/generator/test_vlans.py index 3c859ed38..bf9590607 100644 --- a/tests/generator/test_vlans.py +++ b/tests/generator/test_vlans.py @@ -136,6 +136,14 @@ def test_vlan_parent_match(self): self.assert_nm(None) self.assert_nm_udev(NM_UNMANAGED % 'lan' + NM_UNMANAGED_MAC % '11:22:33:44:55:66' + NM_UNMANAGED % 'vlan20') + def test_vlan_parent_must_exist(self): + out = self.generate('''network: + version: 2 + renderer: networkd + vlans: + vlan20: {id: 20, link: lan}''', expect_fail=True) + self.assertIn('vlan20: interface \'lan\' is not defined', out) + class TestNetworkManager(TestBase): @@ -300,3 +308,54 @@ def test_vlan_sriov(self): ip6-privacy=0 '''}) self.assert_nm_udev(NM_MANAGED % 'en1' + NM_MANAGED % 'enblue' + NM_MANAGED % 'engreen') + + def test_vlan_parent_is_allowed_to_be_missing_for_nm(self): + self.generate('''network: + version: 2 + renderer: NetworkManager + vlans: + vlan20: {id: 20, link: lan}''') + + self.assert_nm({'vlan20': '''[connection] +id=netplan-vlan20 +type=vlan +interface-name=vlan20 + +[vlan] +id=20 +parent=lan + +[ipv4] +method=link-local + +[ipv6] +method=ignore +'''}) + + def test_vlan_with_missing_netdef_found_in_the_next_file_wont_fail(self): + ''' If eth0 was registered as missing (and created as a placeholder netdef) + if shouldn't fail if it's defined in a file that was parsed *after* the file where + the VLAN is defined + ''' + out = self.generate('''network: + renderer: NetworkManager + version: 2 + vlans: + vlan100: + id: 100 + link: eth0''', confs={'b': '''network: + renderer: NetworkManager + version: 2 + ethernets: {eth0: {}}'''}) + + self.assertNotIn('Updated definition \'eth0\' changes device type', out) + + def test_vlan_with_parent_uuid(self): + ''' Check the generate accepts a link pointing to the NM connection UUID ''' + self.generate('''network: + renderer: NetworkManager + version: 2 + vlans: + vlan100: + id: 100 + link: 53125f52-f9a7-4d2a-a853-5f3b9e02299f''') diff --git a/tests/parser/test_keyfile.py b/tests/parser/test_keyfile.py index 5ffee69bd..ffd4b9128 100644 --- a/tests/parser/test_keyfile.py +++ b/tests/parser/test_keyfile.py @@ -400,9 +400,6 @@ def test_keyfile_type_bridge(self): def test_keyfile_type_bond(self): self._template_keyfile_type('bonds', 'bond') - def test_keyfile_type_vlan(self): - self._template_keyfile_type('nm-devices', 'vlan', False) - def test_keyfile_type_tunnel(self): self._template_keyfile_type('tunnels', 'ip-tunnel', False) @@ -824,20 +821,18 @@ def test_keyfile_vlan(self): '''.format(UUID)) self.assert_netplan({UUID: '''network: version: 2 - nm-devices: + vlans: NM-{}: renderer: NetworkManager + addresses: + - "1.2.3.4/24" + id: 1 + link: "en1" networkmanager: uuid: "{}" name: "netplan-enblue" passthrough: - connection.type: "vlan" connection.interface-name: "enblue" - vlan.id: "1" - vlan.parent: "en1" - ipv4.method: "manual" - ipv4.address1: "1.2.3.4/24" - ipv6.method: "ignore" '''.format(UUID, UUID)}) def test_keyfile_bridge(self):