Skip to content

Commit

Permalink
Fix regression plugging 802.3ad port group
Browse files Browse the repository at this point in the history
Netmiko devices were sending no commands to the switch since
plug_bond_to_network is overridden in
networking_generic_switch/devices/netmiko_devices/__init__.py
and PLUG_BOND_TO_NETWORK to set to None.

Closes-Bug: #2041516
Change-Id: I27425c2fc0318688f730a4e84816bcfc7e901b51
(cherry picked from commit 40399f2)
  • Loading branch information
jovial authored and gmoss-eschercloud committed Nov 16, 2023
1 parent 0f1c5dd commit 5ea181e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
8 changes: 8 additions & 0 deletions networking_generic_switch/devices/netmiko_devices/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,10 @@ def delete_port(self, port, segmentation_id):

@check_output('plug bond')
def plug_bond_to_network(self, bond, segmentation_id):
# Fallback to regular plug port if no specialist PLUG_BOND_TO_NETWORK
# commands set
if not self.PLUG_BOND_TO_NETWORK:
return self.plug_port_to_network(bond, segmentation_id)
cmds = []
if self._disable_inactive_ports() and self.ENABLE_BOND:
cmds += self._format_commands(self.ENABLE_BOND, bond=bond)
Expand All @@ -311,6 +315,10 @@ def plug_bond_to_network(self, bond, segmentation_id):

@check_output('unplug bond')
def unplug_bond_from_network(self, bond, segmentation_id):
# Fallback to regular port delete if no specialist
# UNPLUG_BOND_FROM_NETWORK commands set
if not self.UNPLUG_BOND_FROM_NETWORK:
return self.delete_port(bond, segmentation_id)
cmds = self._format_commands(self.UNPLUG_BOND_FROM_NETWORK,
bond=bond,
segmentation_id=segmentation_id)
Expand Down
14 changes: 14 additions & 0 deletions networking_generic_switch/tests/unit/netmiko/test_netmiko_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,20 @@ def test_delete_port_disable_inactive(self, m_check, m_sctd):
m_sctd.assert_called_with([])
m_check.assert_called_once_with('fake output', 'unplug port')

@mock.patch('networking_generic_switch.devices.netmiko_devices.'
'NetmikoSwitch.plug_port_to_network',
return_value='fake output')
def test_plug_bond_to_network_fallback(self, m_plug):
self.switch.plug_bond_to_network(2222, 22)
m_plug.assert_called_with(2222, 22)

@mock.patch('networking_generic_switch.devices.netmiko_devices.'
'NetmikoSwitch.delete_port',
return_value='fake output')
def test_unplug_bond_from_network_fallback(self, m_delete):
self.switch.unplug_bond_from_network(2222, 22)
m_delete.assert_called_with(2222, 22)

def test__format_commands(self):
self.switch._format_commands(
netmiko_devices.NetmikoSwitch.ADD_NETWORK,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
fixes:
- |
Fixes a regression when binding 802.3ad port groups on netmiko devices
other than cumulus.

0 comments on commit 5ea181e

Please sign in to comment.