Skip to content

Commit 23ff7b4

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Implements basic functionality for use with Pluribus switches."
2 parents 6bc18d4 + 79fc104 commit 23ff7b4

File tree

4 files changed

+98
-0
lines changed

4 files changed

+98
-0
lines changed

doc/source/configuration.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,14 @@ for the Nokia SRL series device::
166166
password = password
167167
ip = <switch mgmt ip address>
168168

169+
for a Pluribus switch::
170+
171+
[genericswitch:sw-hostname]
172+
device_type = netmiko_pluribus
173+
username = admin
174+
password = password
175+
ip = <switch mgmt ip address>
176+
169177
Additionally the ``GenericSwitch`` mechanism driver needs to be enabled from
170178
the ml2 config file ``/etc/neutron/plugins/ml2/ml2_conf.ini``::
171179

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Copyright 2022 EscherCloud.
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 Pluribus(netmiko_devices.NetmikoSwitch):
19+
ADD_NETWORK = (
20+
'vlan-create id {segmentation_id} scope fabric\
21+
ports none description {network_name} auto-vxlan',
22+
)
23+
24+
DELETE_NETWORK = (
25+
'vlan-delete id {segmentation_id}',
26+
)
27+
28+
PLUG_PORT_TO_NETWORK = (
29+
'vlan-port-remove vlan-range all ports {port}',
30+
'port-vlan-add port {port} untagged-vlan {segmentation_id}',
31+
)
32+
33+
DELETE_PORT = (
34+
'vlan-port-remove vlan-range all ports {port}',
35+
)
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Copyright 2022 EscherCloud.
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 pluribus
18+
from networking_generic_switch.tests.unit.netmiko import test_netmiko_base
19+
20+
21+
class TestNetmikoPluribus(test_netmiko_base.NetmikoSwitchTestBase):
22+
23+
def _make_switch_device(self):
24+
device_cfg = {'device_type': 'netmiko_pluribus'}
25+
return pluribus.Pluribus(device_cfg)
26+
27+
@mock.patch('networking_generic_switch.devices.netmiko_devices.'
28+
'NetmikoSwitch.send_commands_to_device')
29+
def test_add_network(self, m_exec):
30+
self.switch.add_network(33, '0ae071f5-5be9-43e4-80ea-e41fefe85b21')
31+
m_exec.assert_called_with(
32+
['vlan-create id 33 scope fabric ports none description\
33+
0ae071f55be943e480eae41fefe85b21 auto-vxlan'])
34+
35+
@mock.patch('networking_generic_switch.devices.netmiko_devices.'
36+
'NetmikoSwitch.send_commands_to_device')
37+
def test_del_network(self, mock_exec):
38+
self.switch.del_network(33, '0ae071f5-5be9-43e4-80ea-e41fefe85b21')
39+
mock_exec.assert_called_with(['vlan-delete id 33'])
40+
41+
@mock.patch('networking_generic_switch.devices.netmiko_devices.'
42+
'NetmikoSwitch.send_commands_to_device')
43+
def test_plug_port_to_network(self, mock_exec):
44+
self.switch.plug_port_to_network(3333, 33)
45+
mock_exec.assert_called_with(
46+
['vlan-port-remove vlan-range all ports 3333',
47+
'port-vlan-add port 3333 untagged-vlan 33', ])
48+
49+
@mock.patch('networking_generic_switch.devices.netmiko_devices.'
50+
'NetmikoSwitch.send_commands_to_device')
51+
def test_delete_port(self, mock_exec):
52+
self.switch.delete_port(3333, 33)
53+
mock_exec.assert_called_with(
54+
['vlan-port-remove vlan-range all ports 3333'])

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,6 @@ generic_switch.devices =
4747
netmiko_cumulus = networking_generic_switch.devices.netmiko_devices.cumulus:Cumulus
4848
netmiko_sonic = networking_generic_switch.devices.netmiko_devices.sonic:Sonic
4949
netmiko_nokia_srl = networking_generic_switch.devices.netmiko_devices.nokia:NokiaSRL
50+
netmiko_pluribus = networking_generic_switch.devices.netmiko_devices.pluribus:Pluribus
5051
tempest.test_plugins =
5152
ngs_tests = tempest_plugin.plugin:NGSTempestPlugin

0 commit comments

Comments
 (0)