Skip to content

Commit aeba241

Browse files
authored
Merge pull request #114 from stackhpc/revert-vlan
Revert old trunking patches
2 parents a585f35 + 4c02ba6 commit aeba241

File tree

15 files changed

+7
-478
lines changed

15 files changed

+7
-478
lines changed

networking_generic_switch/devices/__init__.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
{'name': 'ngs_network_name_format', 'default': '{network_id}'},
4747
# If false, ngs will not add and delete VLANs from switches
4848
{'name': 'ngs_manage_vlans', 'default': True},
49-
{'name': 'vlan_translation_supported', 'default': False},
5049
# If False, ngs will skip saving configuration on devices
5150
{'name': 'ngs_save_configuration', 'default': True},
5251
# When true try to batch up in flight switch requests
@@ -223,10 +222,6 @@ def add_network(self, segmentation_id, network_id):
223222
def del_network(self, segmentation_id, network_id):
224223
pass
225224

226-
def plug_port_to_network_trunk(self, port_id, segmentation_id,
227-
trunk_details=None, vtr=False):
228-
pass
229-
230225
@abc.abstractmethod
231226
def plug_port_to_network(self, port_id, segmentation_id):
232227
pass

networking_generic_switch/devices/netmiko_devices/__init__.py

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,6 @@ class NetmikoSwitch(devices.GenericSwitchDevice):
9797

9898
SAVE_CONFIGURATION = None
9999

100-
SET_NATIVE_VLAN = None
101-
102-
ALLOW_NETWORK_ON_TRUNK = None
103-
104100
ERROR_MSG_PATTERNS = ()
105101
"""Sequence of error message patterns.
106102
@@ -287,28 +283,6 @@ def del_network(self, segmentation_id, network_id):
287283
network_name=network_name)
288284
return self.send_commands_to_device(cmds)
289285

290-
@check_output('plug port trunk')
291-
def plug_port_to_network_trunk(self, port, segmentation_id,
292-
trunk_details=None, vtr=False):
293-
cmd_set = []
294-
vts = self.ngs_config.get('vlan_translation_supported', False)
295-
# NOTE(vsaienko) Always use vlan translation if it is supported.
296-
if vts:
297-
cmd_set.extend(self.get_trunk_port_cmds_vlan_translation(
298-
port, segmentation_id, trunk_details))
299-
else:
300-
if vtr:
301-
msg = ("Cannot bind_port VLAN aware port as switch %s "
302-
"doesn't support VLAN translation. "
303-
"But it is required.") % self.config['ip']
304-
raise exc.GenericSwitchNotSupported(error=msg)
305-
else:
306-
cmd_set.extend(
307-
self.get_trunk_port_cmds_no_vlan_translation(
308-
port, segmentation_id, trunk_details))
309-
310-
self.send_commands_to_device(cmd_set)
311-
312286
@check_output('plug port')
313287
def plug_port_to_network(self, port, segmentation_id):
314288
cmds = []
@@ -450,22 +424,3 @@ def check_output(self, output, operation):
450424
raise exc.GenericSwitchNetmikoConfigError(
451425
config=device_utils.sanitise_config(self.config),
452426
error=msg)
453-
454-
def get_trunk_port_cmds_no_vlan_translation(self, port_id,
455-
segmentation_id,
456-
trunk_details):
457-
cmd_set = []
458-
cmd_set.extend(
459-
self._format_commands(self.SET_NATIVE_VLAN,
460-
port=port_id,
461-
segmentation_id=segmentation_id))
462-
for sub_port in trunk_details.get('sub_ports'):
463-
cmd_set.extend(
464-
self._format_commands(
465-
self.ALLOW_NETWORK_ON_TRUNK, port=port_id,
466-
segmentation_id=sub_port['segmentation_id']))
467-
return cmd_set
468-
469-
def get_trunk_port_cmds_vlan_translation(self, port_id, segmentation_id,
470-
trunk_details):
471-
pass

networking_generic_switch/devices/netmiko_devices/arista.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,3 @@ class AristaEos(netmiko_devices.NetmikoSwitch):
3737
'no switchport mode trunk',
3838
'switchport trunk allowed vlan none'
3939
)
40-
41-
SET_NATIVE_VLAN = (
42-
'interface {port}',
43-
'switchport mode trunk',
44-
'switchport trunk native vlan {segmentation_id}',
45-
'switchport trunk allowed vlan add {segmentation_id}'
46-
)
47-
48-
ALLOW_NETWORK_ON_TRUNK = (
49-
'interface {port}',
50-
'switchport trunk allowed vlan add {segmentation_id}'
51-
)

networking_generic_switch/devices/netmiko_devices/cisco.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,6 @@ class CiscoIos(netmiko_devices.NetmikoSwitch):
3939
'switchport trunk allowed vlan none'
4040
)
4141

42-
SET_NATIVE_VLAN = (
43-
'interface {port}',
44-
'switchport mode trunk',
45-
'switchport trunk native vlan {segmentation_id}',
46-
'switchport trunk allowed vlan add {segmentation_id}'
47-
)
48-
49-
ALLOW_NETWORK_ON_TRUNK = (
50-
'interface {port}',
51-
'switchport trunk allowed vlan add {segmentation_id}'
52-
)
53-
5442

5543
class CiscoNxOS(netmiko_devices.NetmikoSwitch):
5644
"""Netmiko device driver for Cisco Nexus switches running NX-OS."""

networking_generic_switch/devices/netmiko_devices/cumulus.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,6 @@ class CumulusNVUE(netmiko_devices.NetmikoSwitch):
117117
]
118118

119119
PLUG_PORT_TO_NETWORK = [
120-
'nv unset interface {port} bridge domain br_default vlan',
121-
'nv unset interface {port} bridge domain br_default untagged',
122120
'nv set interface {port} bridge domain br_default access '
123121
'{segmentation_id}',
124122
]
@@ -139,18 +137,6 @@ class CumulusNVUE(netmiko_devices.NetmikoSwitch):
139137
'nv config save',
140138
]
141139

142-
SET_NATIVE_VLAN = [
143-
'nv unset interface {port} bridge domain br_default access',
144-
'nv set interface {port} bridge domain br_default untagged '
145-
'{segmentation_id}',
146-
'nv set interface {port} bridge domain br_default vlan '
147-
'{segmentation_id}'
148-
]
149-
ALLOW_NETWORK_ON_TRUNK = [
150-
'nv set interface {port} bridge domain br_default vlan '
151-
'{segmentation_id}'
152-
]
153-
154140
ERROR_MSG_PATTERNS = [
155141
# Its tempting to add this error message, but as only one
156142
# bridge-access is allowed, we ignore that error for now:

networking_generic_switch/devices/netmiko_devices/dell.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -70,19 +70,6 @@ class DellOS10(netmiko_devices.NetmikoSwitch):
7070
"exit",
7171
)
7272

73-
SET_NATIVE_VLAN = (
74-
'interface {port}',
75-
# Clean all the old trunked vlans by switching to access mode first
76-
'switchport mode access',
77-
'switchport mode trunk',
78-
'switchport access vlan {segmentation_id}',
79-
)
80-
81-
ALLOW_NETWORK_ON_TRUNK = (
82-
'interface {port}',
83-
'switchport trunk allowed vlan {segmentation_id}'
84-
)
85-
8673
ERROR_MSG_PATTERNS = ()
8774
"""Sequence of error message patterns.
8875

networking_generic_switch/exceptions.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,3 @@ class GenericSwitchNetmikoConfigError(GenericSwitchException):
5353

5454
class GenericSwitchBatchError(GenericSwitchException):
5555
message = _("Batching error: %(device)s, error: %(error)s")
56-
57-
58-
class GenericSwitchNotSupported(GenericSwitchException):
59-
message = _("Requested feature is not supported by "
60-
"networking-generic-switch. %(error)s")

networking_generic_switch/generic_switch_mech.py

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
from networking_generic_switch import config as gsw_conf
2525
from networking_generic_switch import devices
2626
from networking_generic_switch.devices import utils as device_utils
27-
from networking_generic_switch import exceptions as ngs_exc
2827

2928
LOG = logging.getLogger(__name__)
3029

@@ -372,35 +371,15 @@ def update_port_postcommit(self, context):
372371

373372
# If segmentation ID is None, set vlan 1
374373
segmentation_id = segment.get(api.SEGMENTATION_ID) or 1
375-
trunk_details = port.get('trunk_details', {})
376374
LOG.debug("Putting switch port %(switch_port)s on "
377375
"%(switch_info)s in vlan %(segmentation_id)s",
378376
{'switch_port': port_id, 'switch_info': switch_info,
379377
'segmentation_id': segmentation_id})
380378
# Move port to network
381-
try:
382-
if trunk_details:
383-
vtr = self._is_vlan_translation_required(trunk_details)
384-
switch.plug_port_to_network_trunk(
385-
port_id, segmentation_id, trunk_details, vtr)
386-
elif is_802_3ad:
387-
switch.plug_bond_to_network(port_id, segmentation_id)
388-
else:
389-
switch.plug_port_to_network(port_id, segmentation_id)
390-
except ngs_exc.GenericSwitchNotSupported as e:
391-
LOG.warning("Operation is not supported by "
392-
"networking-generic-switch. %(err)s)",
393-
{'err': e})
394-
raise e
395-
except Exception as e:
396-
LOG.error("Failed to plug port %(port_id)s in "
397-
"segment %(segment_id)s on device "
398-
"%(device)s due to error %(err)s",
399-
{'port_id': port['id'],
400-
'device': switch_info,
401-
'segment_id': segmentation_id,
402-
'err': e})
403-
raise e
379+
if is_802_3ad:
380+
switch.plug_bond_to_network(port_id, segmentation_id)
381+
else:
382+
switch.plug_port_to_network(port_id, segmentation_id)
404383
LOG.info("Successfully plugged port %(port_id)s in segment "
405384
"%(segment_id)s on device %(device)s",
406385
{'port_id': port['id'], 'device': switch_info,
@@ -445,14 +424,6 @@ def delete_port_postcommit(self, context):
445424
if self._is_port_bound(port):
446425
self._unplug_port_from_segment(port, context.top_bound_segment)
447426

448-
def _is_vlan_translation_required(self, trunk_details):
449-
"""Check if vlan translation is required to configure specific trunk.
450-
451-
:returns: True if vlan translation is required, False otherwise.
452-
"""
453-
# FIXME: removed for simplicity
454-
return False
455-
456427
def bind_port(self, context):
457428
"""Attempt to bind a port.
458429

networking_generic_switch/tests/unit/netmiko/test_arista_eos.py

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414

1515
from unittest import mock
1616

17-
from neutron.plugins.ml2 import driver_context
18-
1917
from networking_generic_switch.devices.netmiko_devices import arista
2018
from networking_generic_switch.tests.unit.netmiko import test_netmiko_base
2119

@@ -62,43 +60,6 @@ def test_delete_port(self, mock_exec):
6260
'no switchport mode trunk',
6361
'switchport trunk allowed vlan none'])
6462

65-
def test_get_trunk_port_cmds_no_vlan_translation(self):
66-
mock_context = mock.create_autospec(driver_context.PortContext)
67-
self.switch.ngs_config['vlan_translation_supported'] = False
68-
trunk_details = {'trunk_id': 'aaa-bbb-ccc-ddd',
69-
'sub_ports': [{'segmentation_id': 130,
70-
'port_id': 'aaa-bbb-ccc-ddd',
71-
'segmentation_type': 'vlan',
72-
'mac_address': u'fa:16:3e:1c:c2:7e'}]}
73-
mock_context.current = {'binding:profile':
74-
{'local_link_information':
75-
[
76-
{
77-
'switch_info': 'foo',
78-
'port_id': '2222'
79-
}
80-
]
81-
},
82-
'binding:vnic_type': 'baremetal',
83-
'id': 'aaaa-bbbb-cccc',
84-
'trunk_details': trunk_details}
85-
mock_context.network = mock.Mock()
86-
mock_context.network.current = {'provider:segmentation_id': 123}
87-
mock_context.segments_to_bind = [
88-
{
89-
'segmentation_id': 777,
90-
'id': 123
91-
}
92-
]
93-
res = self.switch.get_trunk_port_cmds_no_vlan_translation(
94-
'2222', 777, trunk_details)
95-
self.assertEqual(['interface 2222', 'switchport mode trunk',
96-
'switchport trunk native vlan 777',
97-
'switchport trunk allowed vlan add 777',
98-
'interface 2222',
99-
'switchport trunk allowed vlan add 130'],
100-
res)
101-
10263
def test__format_commands(self):
10364
cmd_set = self.switch._format_commands(
10465
arista.AristaEos.ADD_NETWORK,

networking_generic_switch/tests/unit/netmiko/test_cisco_ios.py

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414

1515
from unittest import mock
1616

17-
from neutron.plugins.ml2 import driver_context
18-
1917
from networking_generic_switch.devices.netmiko_devices import cisco
2018
from networking_generic_switch.tests.unit.netmiko import test_netmiko_base
2119

@@ -61,43 +59,6 @@ def test_delete_port(self, mock_exec):
6159
['interface 3333', 'no switchport access vlan 33',
6260
'no switchport mode trunk', 'switchport trunk allowed vlan none'])
6361

64-
def test_get_trunk_port_cmds_no_vlan_translation(self):
65-
mock_context = mock.create_autospec(driver_context.PortContext)
66-
self.switch.ngs_config['vlan_translation_supported'] = True
67-
trunk_details = {'trunk_id': 'aaa-bbb-ccc-ddd',
68-
'sub_ports': [{'segmentation_id': 130,
69-
'port_id': 'aaa-bbb-ccc-ddd',
70-
'segmentation_type': 'vlan',
71-
'mac_address': u'fa:16:3e:1c:c2:7e'}]}
72-
mock_context.current = {'binding:profile':
73-
{'local_link_information':
74-
[
75-
{
76-
'switch_info': 'foo',
77-
'port_id': '2222'
78-
}
79-
]
80-
},
81-
'binding:vnic_type': 'baremetal',
82-
'id': 'aaaa-bbbb-cccc',
83-
'trunk_details': trunk_details}
84-
mock_context.network = mock.Mock()
85-
mock_context.network.current = {'provider:segmentation_id': 123}
86-
mock_context.segments_to_bind = [
87-
{
88-
'segmentation_id': 777,
89-
'id': 123
90-
}
91-
]
92-
res = self.switch.get_trunk_port_cmds_no_vlan_translation(
93-
'2222', 777, trunk_details)
94-
self.assertEqual(['interface 2222', 'switchport mode trunk',
95-
'switchport trunk native vlan 777',
96-
'switchport trunk allowed vlan add 777',
97-
'interface 2222',
98-
'switchport trunk allowed vlan add 130'],
99-
res)
100-
10162
def test__format_commands(self):
10263
cmd_set = self.switch._format_commands(
10364
cisco.CiscoIos.ADD_NETWORK,

0 commit comments

Comments
 (0)