From a0724690e52dbf02542c138429f95a5f9074f05d Mon Sep 17 00:00:00 2001 From: Matt Crees Date: Mon, 21 Oct 2024 11:22:44 +0100 Subject: [PATCH] Add vlan aware VMs support (backport nvue) --- .../devices/netmiko_devices/cumulus.py | 14 ++++++++++++++ .../tests/unit/netmiko/test_cumulus_nvue.py | 16 ++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/networking_generic_switch/devices/netmiko_devices/cumulus.py b/networking_generic_switch/devices/netmiko_devices/cumulus.py index 5547f489..2547979a 100644 --- a/networking_generic_switch/devices/netmiko_devices/cumulus.py +++ b/networking_generic_switch/devices/netmiko_devices/cumulus.py @@ -117,6 +117,8 @@ class CumulusNVUE(netmiko_devices.NetmikoSwitch): ] PLUG_PORT_TO_NETWORK = [ + 'nv unset interface {port} bridge domain br_default vlan', + 'nv unset interface {port} bridge domain br_default untagged', 'nv set interface {port} bridge domain br_default access ' '{segmentation_id}', ] @@ -137,6 +139,18 @@ class CumulusNVUE(netmiko_devices.NetmikoSwitch): 'nv config save', ] + SET_NATIVE_VLAN = [ + 'nv unset interface {port} bridge domain br_default access', + 'nv set interface {port} bridge domain br_default untagged ' + '{segmentation_id}', + 'nv set interface {port} bridge domain br_default vlan ' + '{segmentation_id}' + ] + ALLOW_NETWORK_ON_TRUNK = [ + 'nv set interface {port} bridge domain br_default vlan ' + '{segmentation_id}' + ] + ERROR_MSG_PATTERNS = [ # Its tempting to add this error message, but as only one # bridge-access is allowed, we ignore that error for now: diff --git a/networking_generic_switch/tests/unit/netmiko/test_cumulus_nvue.py b/networking_generic_switch/tests/unit/netmiko/test_cumulus_nvue.py index 6f7bb738..a981872e 100644 --- a/networking_generic_switch/tests/unit/netmiko/test_cumulus_nvue.py +++ b/networking_generic_switch/tests/unit/netmiko/test_cumulus_nvue.py @@ -54,6 +54,8 @@ def test_plug_port_to_network(self, mock_exec): mock_exec.assert_called_with( ['nv set interface 3333 link state up', 'nv unset interface 3333 bridge domain br_default access', + 'nv unset interface 3333 bridge domain br_default vlan', + 'nv unset interface 3333 bridge domain br_default untagged', 'nv set interface 3333 bridge domain br_default access 33']) @mock.patch('networking_generic_switch.devices.netmiko_devices.' @@ -85,7 +87,9 @@ def test_plug_port_simple(self, mock_exec): }) switch.plug_port_to_network(3333, 33) mock_exec.assert_called_with( - ['nv set interface 3333 bridge domain br_default access 33']) + ['nv unset interface 3333 bridge domain br_default vlan', + 'nv unset interface 3333 bridge domain br_default untagged', + 'nv set interface 3333 bridge domain br_default access 33']) @mock.patch('networking_generic_switch.devices.netmiko_devices.' 'NetmikoSwitch.send_commands_to_device', @@ -95,6 +99,8 @@ def test_delete_port(self, mock_exec): mock_exec.assert_called_with( ['nv unset interface 3333 bridge domain br_default access', 'nv set bridge domain br_default vlan 123', + 'nv unset interface 3333 bridge domain br_default vlan', + 'nv unset interface 3333 bridge domain br_default untagged', 'nv set interface 3333 bridge domain br_default access 123', 'nv set interface 3333 link state down']) @@ -118,6 +124,8 @@ def test_plug_bond_to_network(self, mock_exec): mock_exec.assert_called_with( ['nv set interface 3333 link state up', 'nv unset interface 3333 bridge domain br_default access', + 'nv unset interface 3333 bridge domain br_default vlan', + 'nv unset interface 3333 bridge domain br_default untagged', 'nv set interface 3333 bridge domain br_default access 33']) @mock.patch('networking_generic_switch.devices.netmiko_devices.' @@ -130,7 +138,9 @@ def test_plug_bond_simple(self, mock_exec): }) switch.plug_bond_to_network(3333, 33) mock_exec.assert_called_with( - ['nv set interface 3333 bridge domain br_default access 33']) + ['nv unset interface 3333 bridge domain br_default vlan', + 'nv unset interface 3333 bridge domain br_default untagged', + 'nv set interface 3333 bridge domain br_default access 33']) @mock.patch('networking_generic_switch.devices.netmiko_devices.' 'NetmikoSwitch.send_commands_to_device', @@ -140,6 +150,8 @@ def test_unplug_bond_from_network(self, mock_exec): mock_exec.assert_called_with( ['nv unset interface 3333 bridge domain br_default access', 'nv set bridge domain br_default vlan 123', + 'nv unset interface 3333 bridge domain br_default vlan', + 'nv unset interface 3333 bridge domain br_default untagged', 'nv set interface 3333 bridge domain br_default access 123', 'nv set interface 3333 link state down'])