Skip to content

Commit 40399f2

Browse files
committed
Fix regression plugging 802.3ad port group
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
1 parent 202177f commit 40399f2

File tree

4 files changed

+46
-0
lines changed

4 files changed

+46
-0
lines changed

networking_generic_switch/devices/netmiko_devices/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,10 @@ def delete_port(self, port, segmentation_id):
319319

320320
@check_output('plug bond')
321321
def plug_bond_to_network(self, bond, segmentation_id):
322+
# Fallback to regular plug port if no specialist PLUG_BOND_TO_NETWORK
323+
# commands set
324+
if not self.PLUG_BOND_TO_NETWORK:
325+
return self.plug_port_to_network(bond, segmentation_id)
322326
cmds = []
323327
if self._disable_inactive_ports() and self.ENABLE_BOND:
324328
cmds += self._format_commands(self.ENABLE_BOND, bond=bond)
@@ -336,6 +340,10 @@ def plug_bond_to_network(self, bond, segmentation_id):
336340

337341
@check_output('unplug bond')
338342
def unplug_bond_from_network(self, bond, segmentation_id):
343+
# Fallback to regular port delete if no specialist
344+
# UNPLUG_BOND_FROM_NETWORK commands set
345+
if not self.UNPLUG_BOND_FROM_NETWORK:
346+
return self.delete_port(bond, segmentation_id)
339347
cmds = self._format_commands(self.UNPLUG_BOND_FROM_NETWORK,
340348
bond=bond,
341349
segmentation_id=segmentation_id)

networking_generic_switch/tests/unit/netmiko/test_dell.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,25 @@ def test_del_network(self, mock_exec):
162162
self.switch.del_network(33, '0ae071f5-5be9-43e4-80ea-e41fefe85b21')
163163
mock_exec.assert_called_with(['no interface vlan 33', 'exit'])
164164

165+
@mock.patch('networking_generic_switch.devices.netmiko_devices.'
166+
'NetmikoSwitch.send_commands_to_device',
167+
return_value="")
168+
def test_plug_bond_to_network(self, mock_exec):
169+
self.switch.plug_bond_to_network(3333, 33)
170+
mock_exec.assert_called_with(
171+
['interface 3333', 'switchport mode access',
172+
'switchport access vlan 33',
173+
'exit']
174+
)
175+
176+
@mock.patch('networking_generic_switch.devices.netmiko_devices.'
177+
'NetmikoSwitch.send_commands_to_device')
178+
def test_unplug_bond_from_network(self, mock_exec):
179+
self.switch.unplug_bond_from_network(3333, 33)
180+
mock_exec.assert_called_with(
181+
['interface 3333', 'no switchport access vlan', 'exit']
182+
)
183+
165184
@mock.patch('networking_generic_switch.devices.netmiko_devices.'
166185
'NetmikoSwitch.send_commands_to_device')
167186
def test_del_network_with_trunk_ports(self, mock_exec):

networking_generic_switch/tests/unit/netmiko/test_netmiko_base.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,20 @@ def test_delete_port_disable_inactive(self, m_check, m_sctd):
186186
m_sctd.assert_called_with([])
187187
m_check.assert_called_once_with('fake output', 'unplug port')
188188

189+
@mock.patch('networking_generic_switch.devices.netmiko_devices.'
190+
'NetmikoSwitch.plug_port_to_network',
191+
return_value='fake output')
192+
def test_plug_bond_to_network_fallback(self, m_plug):
193+
self.switch.plug_bond_to_network(2222, 22)
194+
m_plug.assert_called_with(2222, 22)
195+
196+
@mock.patch('networking_generic_switch.devices.netmiko_devices.'
197+
'NetmikoSwitch.delete_port',
198+
return_value='fake output')
199+
def test_unplug_bond_from_network_fallback(self, m_delete):
200+
self.switch.unplug_bond_from_network(2222, 22)
201+
m_delete.assert_called_with(2222, 22)
202+
189203
def test__format_commands(self):
190204
self.switch._format_commands(
191205
netmiko_devices.NetmikoSwitch.ADD_NETWORK,
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
fixes:
3+
- |
4+
Fixes a regression when binding 802.3ad port groups on netmiko devices
5+
other than cumulus.

0 commit comments

Comments
 (0)