Skip to content

Commit 9ad464f

Browse files
committed
VLAN aware VMs: pep8 fix ups
Change-Id: Ia8b2e2b8ea90830fbdbc60d8a3b64afe693224db
1 parent e57a5c5 commit 9ad464f

File tree

6 files changed

+34
-29
lines changed

6 files changed

+34
-29
lines changed

networking_generic_switch/devices/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ def add_network(self, segmentation_id, network_id):
145145
def del_network(self, segmentation_id, network_id):
146146
pass
147147

148-
def plug_port_to_network_trunk(self, port_id, segmentation_id, trunk_details=None, vtr=False):
148+
def plug_port_to_network_trunk(self, port_id, segmentation_id,
149+
trunk_details=None, vtr=False):
149150
pass
150151

151152
@abc.abstractmethod

networking_generic_switch/devices/netmiko_devices/__init__.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,8 @@ def del_network(self, segmentation_id, network_id):
256256
return self.send_commands_to_device(cmds)
257257

258258
@check_output('plug port trunk')
259-
def plug_port_to_network_trunk(self, port, segmentation_id, trunk_details=None, vtr=False):
259+
def plug_port_to_network_trunk(self, port, segmentation_id,
260+
trunk_details=None, vtr=False):
260261
cmd_set = []
261262
vts = self.ngs_config.get('vlan_translation_supported', False)
262263
# NOTE(vsaienko) Always use vlan translation if it is supported.
@@ -265,9 +266,9 @@ def plug_port_to_network_trunk(self, port, segmentation_id, trunk_details=None,
265266
port, segmentation_id, trunk_details))
266267
else:
267268
if vtr:
268-
msg = _("Cannot bind_port VLAN aware port as switch %s "
269-
"doesn't support VLAN translation. "
270-
"But it is required.") % self.config['ip']
269+
msg = ("Cannot bind_port VLAN aware port as switch %s "
270+
"doesn't support VLAN translation. "
271+
"But it is required.") % self.config['ip']
271272
raise exc.GenericSwitchNotSupported(error=msg)
272273
else:
273274
cmd_set.extend(
@@ -410,7 +411,9 @@ def check_output(self, output, operation):
410411
config=device_utils.sanitise_config(self.config),
411412
error=msg)
412413

413-
def get_trunk_port_cmds_no_vlan_translation(self, port_id, segmentation_id, trunk_details):
414+
def get_trunk_port_cmds_no_vlan_translation(self, port_id,
415+
segmentation_id,
416+
trunk_details):
414417
cmd_set = []
415418
cmd_set.extend(
416419
self._format_commands(self.SET_NATIVE_VLAN,
@@ -423,5 +426,6 @@ def get_trunk_port_cmds_no_vlan_translation(self, port_id, segmentation_id, trun
423426
segmentation_id=sub_port['segmentation_id']))
424427
return cmd_set
425428

426-
def get_trunk_port_cmds_vlan_translation(self, port_id, segmentation_id, trunk_details):
429+
def get_trunk_port_cmds_vlan_translation(self, port_id, segmentation_id,
430+
trunk_details):
427431
pass

networking_generic_switch/generic_switch_mech.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
from neutron_lib.api.definitions import portbindings
1919
from neutron_lib.callbacks import resources
2020
from neutron_lib.plugins.ml2 import api
21-
from neutron_lib.plugins import directory
2221
from oslo_log import log as logging
2322

2423
from networking_generic_switch import config as gsw_conf
@@ -476,25 +475,26 @@ def bind_port(self, context):
476475
vtr = self._is_vlan_translation_required(trunk_details)
477476
switch.plug_port_to_network_trunk(
478477
port_id, segmentation_id, trunk_details, vtr)
479-
elif is_802_3ad and hasattr(switch, 'plug_bond_to_network'):
478+
elif (is_802_3ad
479+
and hasattr(switch, 'plug_bond_to_network')):
480480
switch.plug_bond_to_network(port_id, segmentation_id)
481481
else:
482482
switch.plug_port_to_network(
483483
port_id, segmentation_id)
484484
except ngs_exc.GenericSwitchNotSupported as e:
485485
LOG.warning("Operation is not supported by "
486-
"networking-generic-switch. %(err)s)",
486+
"networking-generic-switch. %(err)s)",
487487
{'err': e})
488488
raise e
489489
except Exception as e:
490-
LOG.error("Failed to bind port %(port_id)s in "
491-
"segment %(segment_id)s on device "
492-
"%(device)s due to error %(err)s",
493-
{'port_id': port['id'],
494-
'device': switch_info,
495-
'segment_id': segmentation_id,
496-
'err': e})
497-
raise e
490+
LOG.error("Failed to bind port %(port_id)s in "
491+
"segment %(segment_id)s on device "
492+
"%(device)s due to error %(err)s",
493+
{'port_id': port['id'],
494+
'device': switch_info,
495+
'segment_id': segmentation_id,
496+
'err': e})
497+
raise e
498498
# END
499499
LOG.info("Successfully bound port %(port_id)s in segment "
500500
"%(segment_id)s on device %(device)s",

networking_generic_switch/tests/unit/netmiko/test_dell.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ def _make_switch_device(self, extra_cfg={}):
2828
device_cfg.update(extra_cfg)
2929
return dell.DellOS10(device_cfg)
3030

31-
3231
def test_get_trunk_port_cmds_no_vlan_translation(self):
3332
mock_context = mock.create_autospec(driver_context.PortContext)
3433
self.switch.ngs_config['vlan_translation_supported'] = True

networking_generic_switch/tests/unit/netmiko/test_netmiko_base.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@
1515
import re
1616
from unittest import mock
1717

18-
from neutron.plugins.ml2 import driver_context
19-
2018
import fixtures
2119
import netmiko
2220
import netmiko.base_connection
21+
from neutron.plugins.ml2 import driver_context
2322
from oslo_config import fixture as config_fixture
2423
import paramiko
2524
import tenacity
@@ -417,8 +416,10 @@ def test_bind_port_trunk_no_vts(self, t_mock, nt_mock, sctd_mock,
417416
'trunk_details': {'sub_ports':
418417
[{'segmentation_id': 123}]}}
419418
trunk_details = {'sub_ports': [{'segmentation_id': 123}]}
420-
self.switch.plug_port_to_network_trunk('2222', None, trunk_details, vtr=False)
421-
nt_mock.assert_called_once_with('2222', None, {'sub_ports': [{'segmentation_id': 123}]})
419+
self.switch.plug_port_to_network_trunk('2222', None, trunk_details,
420+
vtr=False)
421+
nt_mock.assert_called_once_with(
422+
'2222', None, {'sub_ports': [{'segmentation_id': 123}]})
422423
self.assertFalse(t_mock.called)
423424

424425
@mock.patch.object(netmiko_devices.netmiko, 'ConnectHandler')
@@ -448,8 +449,10 @@ def test_bind_port_trunk_vts(self, t_mock, nt_mock, sctd_mock,
448449
'trunk_details': {'sub_ports':
449450
[{'segmentation_id': 123}]}}
450451
trunk_details = {'sub_ports': [{'segmentation_id': 123}]}
451-
self.switch.plug_port_to_network_trunk('2222', None, trunk_details, vtr=False)
452-
t_mock.assert_called_once_with('2222', None, {'sub_ports': [{'segmentation_id': 123}]})
452+
self.switch.plug_port_to_network_trunk('2222', None,
453+
trunk_details, vtr=False)
454+
t_mock.assert_called_once_with(
455+
'2222', None, {'sub_ports': [{'segmentation_id': 123}]})
453456
self.assertFalse(nt_mock.called)
454457

455458
@mock.patch.object(netmiko_devices.netmiko, 'ConnectHandler')
@@ -462,11 +465,11 @@ def test_bind_port_trunk_vts(self, t_mock, nt_mock, sctd_mock,
462465
def test_bind_port_trunk_no_vts_raise(self, t_mock, nt_mock, sctd_mock,
463466
nm_mock):
464467
connect_mock = mock.Mock()
465-
mock_context = mock.create_autospec(driver_context.PortContext)
466468
nm_mock.return_value = connect_mock
467469
self.switch.ngs_config['vlan_translation_supported'] = False
468470
trunk_details = {'sub_ports': [{'segmentation_id': 123}]}
469471
self.assertRaises(exc.GenericSwitchNotSupported,
470-
self.switch.plug_port_to_network_trunk, '2222', None, trunk_details, vtr=True)
472+
self.switch.plug_port_to_network_trunk, '2222', None,
473+
trunk_details, vtr=True)
471474
self.assertFalse(t_mock.called)
472475
self.assertFalse(nt_mock.called)

networking_generic_switch/tests/unit/test_generic_switch_mech.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
from neutron.db import provisioning_blocks
2020
from neutron.plugins.ml2 import driver_context
2121
from neutron_lib.callbacks import resources
22-
from neutron_lib.plugins import directory
2322

2423
from networking_generic_switch import exceptions
2524
from networking_generic_switch import generic_switch_mech as gsm
@@ -836,7 +835,6 @@ def test_bind_port_trunk(self, m_apc, m_list, m_vlan):
836835
resources.PORT,
837836
'GENERICSWITCH')
838837

839-
840838
@mock.patch.object(provisioning_blocks, 'add_provisioning_component')
841839
def test_bind_portgroup(self, m_apc, m_list):
842840
driver = gsm.GenericSwitchDriver()

0 commit comments

Comments
 (0)