diff --git a/tests/generator/test_vlans.py b/tests/generator/test_vlans.py index 3c859ed38..016e7dc1b 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,26 @@ 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 +'''}) 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):