Skip to content

Commit 0ecd02a

Browse files
committed
Add support for Dell OS10
This adds a new driver for Dell OS10 based switches. Original change by msherman64[1]. [1] ChameleonCloud#14 Change-Id: Ib5bba3067352e6c7e12120982fcf5b206c9dd365
1 parent e9edfd4 commit 0ecd02a

File tree

6 files changed

+195
-0
lines changed

6 files changed

+195
-0
lines changed

doc/source/configuration.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,16 @@ for the Dell Force10 device::
9292
password = password
9393
secret = secret
9494

95+
for the Dell OS10 device::
96+
97+
[genericswitch:dell-hostname]
98+
device_type = netmiko_dell_os10
99+
ngs_mac_address = <switch mac address>
100+
ip = <switch mgmt ip address>
101+
username = admin
102+
password = password
103+
secret = secret
104+
95105
for the Dell PowerConnect device::
96106

97107
[genericswitch:dell-hostname]

doc/source/supported-devices.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ The following devices are supported by this plugin:
1010
* Cisco IOS switches
1111
* Cumulus Linux (via NCLU)
1212
* Dell Force10
13+
* Dell OS10
1314
* Dell PowerConnect
1415
* HPE 5900 Series switches
1516
* Huawei switches

networking_generic_switch/devices/netmiko_devices/dell.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,66 @@
1818
from networking_generic_switch import exceptions as exc
1919

2020

21+
class DellOS10(netmiko_devices.NetmikoSwitch):
22+
"""Netmiko device driver for Dell PowerSwitch switches."""
23+
24+
ADD_NETWORK = (
25+
"interface vlan {segmentation_id}",
26+
"description {network_name}",
27+
"exit",
28+
)
29+
30+
DELETE_NETWORK = (
31+
"no interface vlan {segmentation_id}",
32+
"exit",
33+
)
34+
35+
PLUG_PORT_TO_NETWORK = (
36+
"interface {port}",
37+
"switchport mode access",
38+
"switchport access vlan {segmentation_id}",
39+
"exit",
40+
)
41+
42+
DELETE_PORT = (
43+
"interface {port}",
44+
"no switchport access vlan",
45+
"exit",
46+
)
47+
48+
ADD_NETWORK_TO_TRUNK = (
49+
"interface {port}",
50+
"switchport mode trunk",
51+
"switchport trunk allowed vlan {segmentation_id}",
52+
"exit",
53+
)
54+
55+
REMOVE_NETWORK_FROM_TRUNK = (
56+
"interface {port}",
57+
"no switchport trunk allowed vlan {segmentation_id}",
58+
"exit",
59+
)
60+
61+
ENABLE_PORT = (
62+
"interface {port}",
63+
"no shutdown",
64+
"exit",
65+
)
66+
67+
DISABLE_PORT = (
68+
"interface {port}",
69+
"shutdown",
70+
"exit",
71+
)
72+
73+
ERROR_MSG_PATTERNS = ()
74+
"""Sequence of error message patterns.
75+
76+
Sequence of re.RegexObject objects representing patterns to check for in
77+
device output that indicate a failure to apply configuration.
78+
"""
79+
80+
2181
class DellNos(netmiko_devices.NetmikoSwitch):
2282
"""Netmiko device driver for Dell Force10 (OS9) switches."""
2383

networking_generic_switch/tests/unit/netmiko/test_dell.py

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,124 @@ def test__format_commands(self):
121121
['interface vlan 33', 'no tagged 3333', 'exit'])
122122

123123

124+
class TestNetmikoDellOS10(test_netmiko_base.NetmikoSwitchTestBase):
125+
126+
def _make_switch_device(self, extra_cfg={}):
127+
device_cfg = {'device_type': 'netmiko_dell_os10'}
128+
device_cfg.update(extra_cfg)
129+
return dell.DellOS10(device_cfg)
130+
131+
def test_constants(self):
132+
self.assertIsNone(self.switch.SAVE_CONFIGURATION)
133+
134+
@mock.patch('networking_generic_switch.devices.netmiko_devices.'
135+
'NetmikoSwitch.send_commands_to_device')
136+
def test_add_network(self, m_exec):
137+
self.switch.add_network(33, '0ae071f5-5be9-43e4-80ea-e41fefe85b21')
138+
m_exec.assert_called_with(
139+
['interface vlan 33',
140+
'description 0ae071f55be943e480eae41fefe85b21',
141+
'exit']
142+
)
143+
144+
@mock.patch('networking_generic_switch.devices.netmiko_devices.'
145+
'NetmikoSwitch.send_commands_to_device')
146+
def test_add_network_with_trunk_ports(self, mock_exec):
147+
switch = self._make_switch_device({'ngs_trunk_ports': 'port1, port2'})
148+
switch.add_network(33, '0ae071f5-5be9-43e4-80ea-e41fefe85b21')
149+
mock_exec.assert_called_with(
150+
['interface vlan 33',
151+
'description 0ae071f55be943e480eae41fefe85b21',
152+
'exit',
153+
'interface port1', 'switchport mode trunk',
154+
'switchport trunk allowed vlan 33', 'exit',
155+
'interface port2', 'switchport mode trunk',
156+
'switchport trunk allowed vlan 33', 'exit']
157+
)
158+
159+
@mock.patch('networking_generic_switch.devices.netmiko_devices.'
160+
'NetmikoSwitch.send_commands_to_device')
161+
def test_del_network(self, mock_exec):
162+
self.switch.del_network(33, '0ae071f5-5be9-43e4-80ea-e41fefe85b21')
163+
mock_exec.assert_called_with(['no interface vlan 33', 'exit'])
164+
165+
@mock.patch('networking_generic_switch.devices.netmiko_devices.'
166+
'NetmikoSwitch.send_commands_to_device')
167+
def test_del_network_with_trunk_ports(self, mock_exec):
168+
switch = self._make_switch_device({'ngs_trunk_ports': 'port1, port2'})
169+
switch.del_network(33, '0ae071f55be943e480eae41fefe85b21')
170+
mock_exec.assert_called_with(
171+
['interface port1', 'no switchport trunk allowed vlan 33', 'exit',
172+
'interface port2', 'no switchport trunk allowed vlan 33', 'exit',
173+
'no interface vlan 33', 'exit'])
174+
175+
@mock.patch('networking_generic_switch.devices.netmiko_devices.'
176+
'NetmikoSwitch.send_commands_to_device')
177+
def test_plug_port_to_network(self, mock_exec):
178+
self.switch.plug_port_to_network(3333, 33)
179+
mock_exec.assert_called_with(
180+
['interface 3333', 'switchport mode access',
181+
'switchport access vlan 33',
182+
'exit']
183+
)
184+
185+
@mock.patch('networking_generic_switch.devices.netmiko_devices.'
186+
'NetmikoSwitch.send_commands_to_device')
187+
def test_delete_port(self, mock_exec):
188+
self.switch.delete_port(3333, 33)
189+
mock_exec.assert_called_with(
190+
['interface 3333', 'no switchport access vlan', 'exit']
191+
)
192+
193+
def test__format_commands(self):
194+
cmd_set = self.switch._format_commands(
195+
dell.DellOS10.ADD_NETWORK,
196+
segmentation_id=22,
197+
network_id=22,
198+
network_name='vlan-22')
199+
self.assertEqual(cmd_set,
200+
['interface vlan 22',
201+
'description vlan-22',
202+
'exit']
203+
)
204+
205+
cmd_set = self.switch._format_commands(
206+
dell.DellOS10.DELETE_NETWORK,
207+
segmentation_id=22)
208+
self.assertEqual(cmd_set, ['no interface vlan 22', 'exit'])
209+
210+
cmd_set = self.switch._format_commands(
211+
dell.DellOS10.PLUG_PORT_TO_NETWORK,
212+
port=3333,
213+
segmentation_id=33)
214+
self.assertEqual(cmd_set, ['interface 3333', 'switchport mode access',
215+
'switchport access vlan 33', 'exit'])
216+
cmd_set = self.switch._format_commands(
217+
dell.DellOS10.DELETE_PORT,
218+
port=3333,
219+
segmentation_id=33)
220+
self.assertEqual(cmd_set,
221+
['interface 3333', 'no switchport access vlan',
222+
'exit'])
223+
224+
cmd_set = self.switch._format_commands(
225+
dell.DellOS10.ADD_NETWORK_TO_TRUNK,
226+
port=3333,
227+
segmentation_id=33)
228+
self.assertEqual(cmd_set,
229+
['interface 3333', 'switchport mode trunk',
230+
'switchport trunk allowed vlan 33',
231+
'exit'])
232+
cmd_set = self.switch._format_commands(
233+
dell.DellOS10.REMOVE_NETWORK_FROM_TRUNK,
234+
port=3333,
235+
segmentation_id=33)
236+
self.assertEqual(cmd_set,
237+
['interface 3333',
238+
'no switchport trunk allowed vlan 33',
239+
'exit'])
240+
241+
124242
class TestNetmikoDellPowerConnect(test_netmiko_base.NetmikoSwitchTestBase):
125243

126244
def _make_switch_device(self, extra_cfg={}):
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_dell_os10``, for managing Dell OS10
5+
based switch devices.

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ generic_switch.devices =
3636
netmiko_huawei = networking_generic_switch.devices.netmiko_devices.huawei:Huawei
3737
netmiko_huawei_vrpv8 = networking_generic_switch.devices.netmiko_devices.huawei_vrpv8:Huawei
3838
netmiko_arista_eos = networking_generic_switch.devices.netmiko_devices.arista:AristaEos
39+
netmiko_dell_os10 = networking_generic_switch.devices.netmiko_devices.dell:DellOS10
3940
netmiko_dell_force10 = networking_generic_switch.devices.netmiko_devices.dell:DellNos
4041
netmiko_dell_powerconnect = networking_generic_switch.devices.netmiko_devices.dell:DellPowerConnect
4142
netmiko_brocade_fastiron = networking_generic_switch.devices.netmiko_devices.brocade:BrocadeFastIron

0 commit comments

Comments
 (0)