Skip to content

Commit 47968e7

Browse files
committed
Fix GenericSwitchNotSupported exceptions
These exceptions were not instantiated with the correct arguments, leading to a TypeError that was hiding the real issue (lack of support for trunks on ports or bonds). Closes-Bug: #2147055 Change-Id: Ifde3a65cb51a237801c49d4c443f222f320f6274 Signed-off-by: Pierre Riteau <pierre@stackhpc.com> (cherry picked from commit eb20591)
1 parent 2d1ec18 commit 47968e7

3 files changed

Lines changed: 18 additions & 5 deletions

File tree

networking_generic_switch/generic_switch_mech.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -394,16 +394,17 @@ def update_port_postcommit(self, context):
394394
if (trunk_details and not
395395
switch.support_trunk_on_bond_ports):
396396
raise ngs_exc.GenericSwitchNotSupported(
397-
"Trunks are not supported by "
398-
"networking-generic-switch %s.",
399-
switch.device_name)
397+
feature="trunks",
398+
switch=switch.device_name,
399+
error="Trunks are not supported on bond ports.")
400400
switch.plug_bond_to_network(port_id, segmentation_id,
401401
**plug_kwargs)
402402
else:
403403
if trunk_details and not switch.support_trunk_on_ports:
404404
raise ngs_exc.GenericSwitchNotSupported(
405405
feature="trunks",
406-
switch=switch.device_name)
406+
switch=switch.device_name,
407+
error="Trunks are not supported on ports.")
407408
switch.plug_port_to_network(port_id, segmentation_id,
408409
**plug_kwargs)
409410
LOG.info("Successfully plugged port %(port_id)s in segment "

networking_generic_switch/tests/unit/test_generic_switch_mech.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,12 @@ def test_update_port_postcommit_trunk_not_supported(self, m_pc, m_list):
854854
self.switch_mock.support_trunk_on_bond_ports = False
855855
self.switch_mock.support_trunk_on_ports = False
856856

857-
with self.assertRaises(exceptions.GenericSwitchNotSupported):
857+
exception_regex = (
858+
'Requested feature trunks is not supported by '
859+
'networking-generic-switch on the .*. Trunks are not supported on '
860+
'ports.')
861+
with self.assertRaisesRegex(exceptions.GenericSwitchNotSupported,
862+
exception_regex):
858863
driver.update_port_postcommit(mock_context)
859864
self.switch_mock.plug_port_to_network.assert_not_called()
860865
m_pc.assert_not_called()
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
fixes:
3+
- |
4+
Fixes incorrect instantiations of GenericSwitchNotSupported exceptions. See
5+
`LP#2147055
6+
<https://bugs.launchpad.net/networking-generic-switch/+bug/2147055>`__ for
7+
details.

0 commit comments

Comments
 (0)