Skip to content

Commit

Permalink
Merge pull request #94 from stackhpc/nvue-vlan-aware
Browse files Browse the repository at this point in the history
Add vlan aware VMs support (backport nvue)
  • Loading branch information
priteau authored Oct 29, 2024
2 parents da901c4 + 356dfe3 commit 737063c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
14 changes: 14 additions & 0 deletions networking_generic_switch/devices/netmiko_devices/cumulus.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}',
]
Expand All @@ -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:
Expand Down
16 changes: 14 additions & 2 deletions networking_generic_switch/tests/unit/netmiko/test_cumulus_nvue.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
Expand Down Expand Up @@ -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',
Expand All @@ -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'])

Expand All @@ -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.'
Expand All @@ -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',
Expand All @@ -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'])

Expand Down

0 comments on commit 737063c

Please sign in to comment.