Skip to content

Commit 7528b81

Browse files
committed
Merge branch 'stackhpc/master' into upstream/master-2025-03-10
2 parents b351b91 + 3b1bf80 commit 7528b81

File tree

18 files changed

+498
-7
lines changed

18 files changed

+498
-7
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @stackhpc/openstack
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
name: Tag & Release
3+
'on':
4+
push:
5+
branches:
6+
- stackhpc/master
7+
permissions:
8+
actions: read
9+
contents: write
10+
jobs:
11+
tag-and-release:
12+
uses: stackhpc/.github/.github/workflows/tag-and-release.yml@main

.github/workflows/tox.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
name: Tox Continuous Integration
3+
'on':
4+
pull_request:
5+
jobs:
6+
tox:
7+
uses: stackhpc/.github/.github/workflows/tox.yml@main

networking_generic_switch/devices/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
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},
4950
# If False, ngs will skip saving configuration on devices
5051
{'name': 'ngs_save_configuration', 'default': True},
5152
# When true try to batch up in flight switch requests
@@ -222,6 +223,10 @@ def add_network(self, segmentation_id, network_id):
222223
def del_network(self, segmentation_id, network_id):
223224
pass
224225

226+
def plug_port_to_network_trunk(self, port_id, segmentation_id,
227+
trunk_details=None, vtr=False):
228+
pass
229+
225230
@abc.abstractmethod
226231
def plug_port_to_network(self, port_id, segmentation_id):
227232
pass

networking_generic_switch/devices/netmiko_devices/__init__.py

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

9898
SAVE_CONFIGURATION = None
9999

100+
SET_NATIVE_VLAN = None
101+
102+
ALLOW_NETWORK_ON_TRUNK = None
103+
100104
ERROR_MSG_PATTERNS = ()
101105
"""Sequence of error message patterns.
102106
@@ -283,6 +287,28 @@ def del_network(self, segmentation_id, network_id):
283287
network_name=network_name)
284288
return self.send_commands_to_device(cmds)
285289

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+
286312
@check_output('plug port')
287313
def plug_port_to_network(self, port, segmentation_id):
288314
cmds = []
@@ -424,3 +450,22 @@ def check_output(self, output, operation):
424450
raise exc.GenericSwitchNetmikoConfigError(
425451
config=device_utils.sanitise_config(self.config),
426452
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: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,15 @@ 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: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,18 @@ 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+
4254

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

networking_generic_switch/devices/netmiko_devices/cumulus.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ 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',
120122
'nv set interface {port} bridge domain br_default access '
121123
'{segmentation_id}',
122124
]
@@ -137,6 +139,18 @@ class CumulusNVUE(netmiko_devices.NetmikoSwitch):
137139
'nv config save',
138140
]
139141

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+
140154
ERROR_MSG_PATTERNS = [
141155
# Its tempting to add this error message, but as only one
142156
# bridge-access is allowed, we ignore that error for now:

networking_generic_switch/devices/netmiko_devices/dell.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,19 @@ 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+
7386
ERROR_MSG_PATTERNS = ()
7487
"""Sequence of error message patterns.
7588

networking_generic_switch/exceptions.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,8 @@ 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")

0 commit comments

Comments
 (0)