Skip to content

Commit 657d0ec

Browse files
jovialcityofships
authored andcommitted
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 (cherry picked from commit 40399f2)
1 parent 7e9e9a0 commit 657d0ec

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
@@ -339,6 +339,10 @@ def delete_port(self, port, segmentation_id):
339339

340340
@check_output('plug bond')
341341
def plug_bond_to_network(self, bond, segmentation_id):
342+
# Fallback to regular plug port if no specialist PLUG_BOND_TO_NETWORK
343+
# commands set
344+
if not self.PLUG_BOND_TO_NETWORK:
345+
return self.plug_port_to_network(bond, segmentation_id)
342346
cmds = []
343347
if self._disable_inactive_ports() and self.ENABLE_BOND:
344348
cmds += self._format_commands(self.ENABLE_BOND, bond=bond)
@@ -356,6 +360,10 @@ def plug_bond_to_network(self, bond, segmentation_id):
356360

357361
@check_output('unplug bond')
358362
def unplug_bond_from_network(self, bond, segmentation_id):
363+
# Fallback to regular port delete if no specialist
364+
# UNPLUG_BOND_FROM_NETWORK commands set
365+
if not self.UNPLUG_BOND_FROM_NETWORK:
366+
return self.delete_port(bond, segmentation_id)
359367
cmds = self._format_commands(self.UNPLUG_BOND_FROM_NETWORK,
360368
bond=bond,
361369
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
@@ -164,6 +164,25 @@ def test_del_network(self, mock_exec):
164164
self.switch.del_network(33, '0ae071f5-5be9-43e4-80ea-e41fefe85b21')
165165
mock_exec.assert_called_with(['no interface vlan 33', 'exit'])
166166

167+
@mock.patch('networking_generic_switch.devices.netmiko_devices.'
168+
'NetmikoSwitch.send_commands_to_device',
169+
return_value="")
170+
def test_plug_bond_to_network(self, mock_exec):
171+
self.switch.plug_bond_to_network(3333, 33)
172+
mock_exec.assert_called_with(
173+
['interface 3333', 'switchport mode access',
174+
'switchport access vlan 33',
175+
'exit']
176+
)
177+
178+
@mock.patch('networking_generic_switch.devices.netmiko_devices.'
179+
'NetmikoSwitch.send_commands_to_device')
180+
def test_unplug_bond_from_network(self, mock_exec):
181+
self.switch.unplug_bond_from_network(3333, 33)
182+
mock_exec.assert_called_with(
183+
['interface 3333', 'no switchport access vlan', 'exit']
184+
)
185+
167186
@mock.patch('networking_generic_switch.devices.netmiko_devices.'
168187
'NetmikoSwitch.send_commands_to_device')
169188
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
@@ -187,6 +187,20 @@ def test_delete_port_disable_inactive(self, m_check, m_sctd):
187187
m_sctd.assert_called_with([])
188188
m_check.assert_called_once_with('fake output', 'unplug port')
189189

190+
@mock.patch('networking_generic_switch.devices.netmiko_devices.'
191+
'NetmikoSwitch.plug_port_to_network',
192+
return_value='fake output')
193+
def test_plug_bond_to_network_fallback(self, m_plug):
194+
self.switch.plug_bond_to_network(2222, 22)
195+
m_plug.assert_called_with(2222, 22)
196+
197+
@mock.patch('networking_generic_switch.devices.netmiko_devices.'
198+
'NetmikoSwitch.delete_port',
199+
return_value='fake output')
200+
def test_unplug_bond_from_network_fallback(self, m_delete):
201+
self.switch.unplug_bond_from_network(2222, 22)
202+
m_delete.assert_called_with(2222, 22)
203+
190204
def test__format_commands(self):
191205
self.switch._format_commands(
192206
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)