Skip to content

Commit e041713

Browse files
Add ArubaOS-CX switch support
Change-Id: I6e6b7be42448bdf5ea94ba416440d4b59680b55d
1 parent 3fed0d9 commit e041713

File tree

6 files changed

+212
-0
lines changed

6 files changed

+212
-0
lines changed

doc/source/configuration.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,14 @@ for a Pluribus switch::
184184
password = password
185185
ip = <switch mgmt ip address>
186186

187+
for an ArubaOS-CX switch::
188+
189+
[genericswitch:aruba-hostname]
190+
device_type = netmiko_aruba_os
191+
username = admin
192+
password = password
193+
ip = <switch mgmt ip address>
194+
187195
Additionally the ``GenericSwitch`` mechanism driver needs to be enabled from
188196
the ml2 config file ``/etc/neutron/plugins/ml2/ml2_conf.ini``::
189197

@@ -250,6 +258,7 @@ using the ``ngs_disable_inactive_ports`` flag::
250258
This is currently supported by the following devices:
251259

252260
* Juniper Junos OS
261+
* ArubaOS-CX
253262

254263
Network Name Format
255264
===================

doc/source/supported-devices.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Supported Devices
55
The following devices are supported by this plugin:
66

77
* Arista EOS
8+
* ArubaOS-CX switches
89
* Brocade ICX (FastIron)
910
* Cisco 300-series switches
1011
* Cisco IOS switches
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Copyright (c) 2022 VEXXHOST, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
4+
# not use this file except in compliance with the License. You may obtain
5+
# a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12+
# License for the specific language governing permissions and limitations
13+
# under the License.
14+
15+
from networking_generic_switch.devices import netmiko_devices
16+
17+
18+
class ArubaOSCX(netmiko_devices.NetmikoSwitch):
19+
"""Built for ArubaOS-CX"""
20+
21+
ADD_NETWORK = (
22+
'vlan {segmentation_id}',
23+
'name {network_name}',
24+
)
25+
26+
DELETE_NETWORK = (
27+
'no vlan {segmentation_id}',
28+
)
29+
30+
PLUG_PORT_TO_NETWORK = (
31+
'interface {port}',
32+
'no routing',
33+
'vlan access {segmentation_id}',
34+
)
35+
36+
DELETE_PORT = (
37+
'interface {port}',
38+
'no vlan access {segmentation_id}',
39+
)
40+
41+
ADD_NETWORK_TO_TRUNK = (
42+
"interface {port}",
43+
"no routing",
44+
"vlan trunk allowed {segmentation_id}",
45+
)
46+
47+
REMOVE_NETWORK_FROM_TRUNK = (
48+
"interface {port}",
49+
"no vlan trunk allowed {segmentation_id}",
50+
)
51+
52+
ENABLE_PORT = (
53+
"interface {port}",
54+
"no shutdown",
55+
)
56+
57+
DISABLE_PORT = (
58+
"interface {port}",
59+
"shutdown",
60+
)
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
# Copyright (c) 2022 VEXXHOST, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
4+
# not use this file except in compliance with the License. You may obtain
5+
# a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12+
# License for the specific language governing permissions and limitations
13+
# under the License.
14+
15+
from unittest import mock
16+
17+
from networking_generic_switch.devices.netmiko_devices import aruba
18+
from networking_generic_switch.tests.unit.netmiko import test_netmiko_base
19+
20+
21+
class TestNetmikoAruba(test_netmiko_base.NetmikoSwitchTestBase):
22+
23+
def _make_switch_device(self, extra_cfg={}):
24+
device_cfg = {'device_type': 'netmiko_aruba_os'}
25+
device_cfg.update(extra_cfg)
26+
return aruba.ArubaOSCX(device_cfg)
27+
28+
def test_constants(self):
29+
self.assertIsNone(self.switch.SAVE_CONFIGURATION)
30+
31+
@mock.patch('networking_generic_switch.devices.netmiko_devices.'
32+
'NetmikoSwitch.send_commands_to_device')
33+
def test_add_network(self, m_exec):
34+
self.switch.add_network(33, '0ae071f5-5be9-43e4-80ea-e41fefe85b21')
35+
m_exec.assert_called_with(
36+
['vlan 33', 'name 0ae071f55be943e480eae41fefe85b21'])
37+
38+
@mock.patch('networking_generic_switch.devices.netmiko_devices.'
39+
'NetmikoSwitch.send_commands_to_device')
40+
def test_del_network(self, mock_exec):
41+
self.switch.del_network(33, '0ae071f5-5be9-43e4-80ea-e41fefe85b21')
42+
mock_exec.assert_called_with(['no vlan 33'])
43+
44+
@mock.patch('networking_generic_switch.devices.netmiko_devices.'
45+
'NetmikoSwitch.send_commands_to_device')
46+
def test_plug_port_to_network(self, mock_exec):
47+
self.switch.plug_port_to_network(3333, 33)
48+
mock_exec.assert_called_with(
49+
['interface 3333', 'no routing', 'vlan access 33'])
50+
51+
@mock.patch('networking_generic_switch.devices.netmiko_devices.'
52+
'NetmikoSwitch.send_commands_to_device')
53+
def test_plug_port_to_network_disable_inactive(self, m_sctd):
54+
switch = self._make_switch_device(
55+
{'ngs_disable_inactive_ports': 'true'})
56+
switch.plug_port_to_network(3333, 33)
57+
m_sctd.assert_called_with(
58+
['interface 3333', 'no shutdown',
59+
'interface 3333', 'no routing', 'vlan access 33'])
60+
61+
@mock.patch('networking_generic_switch.devices.netmiko_devices.'
62+
'NetmikoSwitch.send_commands_to_device')
63+
def test_delete_port(self, mock_exec):
64+
self.switch.delete_port(3333, 33)
65+
mock_exec.assert_called_with(['interface 3333', 'no vlan access 33'])
66+
67+
@mock.patch('networking_generic_switch.devices.netmiko_devices.'
68+
'NetmikoSwitch.send_commands_to_device')
69+
def test_delete_port_disable_inactive(self, m_sctd):
70+
switch = self._make_switch_device(
71+
{'ngs_disable_inactive_ports': 'true'})
72+
switch.delete_port(3333, 33)
73+
m_sctd.assert_called_with(
74+
['interface 3333', 'no vlan access 33',
75+
'interface 3333', 'shutdown'])
76+
77+
@mock.patch('networking_generic_switch.devices.netmiko_devices.'
78+
'NetmikoSwitch.send_commands_to_device')
79+
def test_add_network_with_trunk_ports(self, mock_exec):
80+
switch = self._make_switch_device({'ngs_trunk_ports': 'port1, port2'})
81+
switch.add_network(33, '0ae071f5-5be9-43e4-80ea-e41fefe85b21')
82+
mock_exec.assert_called_with(
83+
['vlan 33',
84+
'name 0ae071f55be943e480eae41fefe85b21',
85+
'interface port1', 'no routing', 'vlan trunk allowed 33',
86+
'interface port2', 'no routing', 'vlan trunk allowed 33'])
87+
88+
@mock.patch('networking_generic_switch.devices.netmiko_devices.'
89+
'NetmikoSwitch.send_commands_to_device')
90+
def test_del_network_with_trunk_ports(self, mock_exec):
91+
switch = self._make_switch_device({'ngs_trunk_ports': 'port1, port2'})
92+
switch.del_network(33, '0ae071f55be943e480eae41fefe85b21')
93+
mock_exec.assert_called_with(
94+
['interface port1', 'no vlan trunk allowed 33',
95+
'interface port2', 'no vlan trunk allowed 33',
96+
'no vlan 33'])
97+
98+
def test__format_commands(self):
99+
cmd_set = self.switch._format_commands(
100+
aruba.ArubaOSCX.ADD_NETWORK,
101+
segmentation_id=22,
102+
network_id=22,
103+
network_name='vlan-22')
104+
self.assertEqual(cmd_set, ['vlan 22', 'name vlan-22'])
105+
106+
cmd_set = self.switch._format_commands(
107+
aruba.ArubaOSCX.DELETE_NETWORK,
108+
segmentation_id=22)
109+
self.assertEqual(cmd_set, ['no vlan 22'])
110+
111+
cmd_set = self.switch._format_commands(
112+
aruba.ArubaOSCX.PLUG_PORT_TO_NETWORK,
113+
port=3333,
114+
segmentation_id=33)
115+
plug_exp = ['interface 3333', 'no routing', 'vlan access 33']
116+
self.assertEqual(plug_exp, cmd_set)
117+
118+
cmd_set = self.switch._format_commands(
119+
aruba.ArubaOSCX.DELETE_PORT,
120+
port=3333,
121+
segmentation_id=33)
122+
del_exp = ['interface 3333', 'no vlan access 33']
123+
self.assertEqual(del_exp, cmd_set)
124+
125+
cmd_set = self.switch._format_commands(
126+
aruba.ArubaOSCX.ADD_NETWORK_TO_TRUNK,
127+
port=3333,
128+
segmentation_id=33)
129+
trunk_exp = ['interface 3333', 'no routing', 'vlan trunk allowed 33']
130+
self.assertEqual(trunk_exp, cmd_set)
131+
cmd_set = self.switch._format_commands(
132+
aruba.ArubaOSCX.REMOVE_NETWORK_FROM_TRUNK,
133+
port=3333,
134+
segmentation_id=33)
135+
self.assertEqual(cmd_set,
136+
['interface 3333', 'no vlan trunk allowed 33'])
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
features:
3+
- |
4+
Adds a new device driver, ``netmiko_aruba_os``, for managing ArubaOS-CX
5+
switch devices.

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,6 @@ generic_switch.devices =
4949
netmiko_sonic = networking_generic_switch.devices.netmiko_devices.sonic:Sonic
5050
netmiko_nokia_srl = networking_generic_switch.devices.netmiko_devices.nokia:NokiaSRL
5151
netmiko_pluribus = networking_generic_switch.devices.netmiko_devices.pluribus:Pluribus
52+
netmiko_aruba_os = networking_generic_switch.devices.netmiko_devices.aruba:ArubaOSCX
5253
tempest.test_plugins =
5354
ngs_tests = tempest_plugin.plugin:NGSTempestPlugin

0 commit comments

Comments
 (0)