summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-07-03 09:00:19 +0000
committerGerrit Code Review <review@openstack.org>2018-07-03 09:00:19 +0000
commit47e93f8e23ead0ef9c1bb27ac061c2169e2112f2 (patch)
tree1c3ef4f550a058d2a09aba3b161a85649265f4b7
parente6eef52ef5f1aa35b41661172e46551e38d16650 (diff)
parentf852d35f4a4bb0023fa40f30b795601ebde13a5e (diff)
Merge "Add support for Dell PowerConnect switches"
-rw-r--r--doc/source/configuration.rst13
-rw-r--r--doc/source/supported-devices.rst1
-rw-r--r--networking_generic_switch/devices/netmiko_devices/dell.py110
-rw-r--r--networking_generic_switch/tests/unit/netmiko/test_dell.py107
-rw-r--r--releasenotes/notes/dell-powerconnect-5ce572b9fb2702d3.yaml5
-rw-r--r--setup.cfg1
6 files changed, 203 insertions, 34 deletions
diff --git a/doc/source/configuration.rst b/doc/source/configuration.rst
index 9e68e5f..56b5637 100644
--- a/doc/source/configuration.rst
+++ b/doc/source/configuration.rst
@@ -89,6 +89,19 @@ for the Dell Force10 device::
89 password = password 89 password = password
90 secret = secret 90 secret = secret
91 91
92for the Dell PowerConnect device::
93
94 [genericswitch:dell-hostname]
95 device_type = netmiko_dell_powerconnect
96 ip = <switch mgmt ip address>
97 username = admin
98 password = password
99 secret = secret
100
101Dell PowerConnect devices have been seen to have issues with multiple
102concurrent configuration sessions. See :ref:`synchronization` for details on
103how to limit the number of concurrent active connections to each device.
104
92for the Brocade FastIron (ICX) device:: 105for the Brocade FastIron (ICX) device::
93 106
94 [genericswitch:hostname-for-fast-iron] 107 [genericswitch:hostname-for-fast-iron]
diff --git a/doc/source/supported-devices.rst b/doc/source/supported-devices.rst
index e19f065..f2f46e0 100644
--- a/doc/source/supported-devices.rst
+++ b/doc/source/supported-devices.rst
@@ -10,6 +10,7 @@ The following devices are supported by this plugin:
10* OpenVSwitch 10* OpenVSwitch
11* Arista EOS 11* Arista EOS
12* Dell Force10 12* Dell Force10
13* Dell PowerConnect
13* Brocade ICX (FastIron) 14* Brocade ICX (FastIron)
14* Ruijie switches 15* Ruijie switches
15* HPE 5900 Series switches 16* HPE 5900 Series switches
diff --git a/networking_generic_switch/devices/netmiko_devices/dell.py b/networking_generic_switch/devices/netmiko_devices/dell.py
index 7442ce1..7529ca1 100644
--- a/networking_generic_switch/devices/netmiko_devices/dell.py
+++ b/networking_generic_switch/devices/netmiko_devices/dell.py
@@ -16,37 +16,79 @@ from networking_generic_switch.devices import netmiko_devices
16 16
17 17
18class DellNos(netmiko_devices.NetmikoSwitch): 18class DellNos(netmiko_devices.NetmikoSwitch):
19 ADD_NETWORK = ( 19 """Netmiko device driver for Dell Force10 switches."""
20 'interface vlan {segmentation_id}', 20
21 'name {network_id}', 21 ADD_NETWORK = (
22 'exit', 22 'interface vlan {segmentation_id}',
23 ) 23 'name {network_id}',
24 24 'exit',
25 DELETE_NETWORK = ( 25 )
26 'no interface vlan {segmentation_id}', 26
27 'exit', 27 DELETE_NETWORK = (
28 ) 28 'no interface vlan {segmentation_id}',
29 29 'exit',
30 PLUG_PORT_TO_NETWORK = ( 30 )
31 'interface vlan {segmentation_id}', 31
32 'untagged {port}', 32 PLUG_PORT_TO_NETWORK = (
33 'exit', 33 'interface vlan {segmentation_id}',
34 ) 34 'untagged {port}',
35 35 'exit',
36 DELETE_PORT = ( 36 )
37 'interface vlan {segmentation_id}', 37
38 'no untagged {port}', 38 DELETE_PORT = (
39 'exit', 39 'interface vlan {segmentation_id}',
40 ) 40 'no untagged {port}',
41 41 'exit',
42 ADD_NETWORK_TO_TRUNK = ( 42 )
43 'interface vlan {segmentation_id}', 43
44 'tagged {port}', 44 ADD_NETWORK_TO_TRUNK = (
45 'exit', 45 'interface vlan {segmentation_id}',
46 ) 46 'tagged {port}',
47 47 'exit',
48 REMOVE_NETWORK_FROM_TRUNK = ( 48 )
49 'interface vlan {segmentation_id}', 49
50 'no tagged {port}', 50 REMOVE_NETWORK_FROM_TRUNK = (
51 'exit', 51 'interface vlan {segmentation_id}',
52 ) 52 'no tagged {port}',
53 'exit',
54 )
55
56
57class DellPowerConnect(netmiko_devices.NetmikoSwitch):
58 """Netmiko device driver for Dell PowerConnect switches."""
59
60 ADD_NETWORK = (
61 'vlan database',
62 'vlan {segmentation_id}',
63 'exit',
64 )
65
66 DELETE_NETWORK = (
67 'vlan database',
68 'no vlan {segmentation_id}',
69 'exit',
70 )
71
72 PLUG_PORT_TO_NETWORK = (
73 'interface {port}',
74 'switchport access vlan {segmentation_id}',
75 'exit',
76 )
77
78 DELETE_PORT = (
79 'interface {port}',
80 'switchport access vlan none',
81 'exit',
82 )
83
84 ADD_NETWORK_TO_TRUNK = (
85 'interface {port}',
86 'switchport general allowed vlan add {segmentation_id} tagged',
87 'exit',
88 )
89
90 REMOVE_NETWORK_FROM_TRUNK = (
91 'interface {port}',
92 'switchport general allowed vlan remove {segmentation_id}',
93 'exit',
94 )
diff --git a/networking_generic_switch/tests/unit/netmiko/test_dell.py b/networking_generic_switch/tests/unit/netmiko/test_dell.py
index 12b3420..0052b56 100644
--- a/networking_generic_switch/tests/unit/netmiko/test_dell.py
+++ b/networking_generic_switch/tests/unit/netmiko/test_dell.py
@@ -114,3 +114,110 @@ class TestNetmikoDellNos(test_netmiko_base.NetmikoSwitchTestBase):
114 segmentation_id=33) 114 segmentation_id=33)
115 self.assertEqual(cmd_set, 115 self.assertEqual(cmd_set,
116 ['interface vlan 33', 'no tagged 3333', 'exit']) 116 ['interface vlan 33', 'no tagged 3333', 'exit'])
117
118
119class TestNetmikoDellPowerConnect(test_netmiko_base.NetmikoSwitchTestBase):
120
121 def _make_switch_device(self, extra_cfg={}):
122 device_cfg = {'device_type': 'netmiko_dell_powerconnect'}
123 device_cfg.update(extra_cfg)
124 return dell.DellPowerConnect(device_cfg)
125
126 def test_constants(self):
127 self.assertIsNone(self.switch.SAVE_CONFIGURATION)
128
129 @mock.patch('networking_generic_switch.devices.netmiko_devices.'
130 'NetmikoSwitch.send_commands_to_device')
131 def test_add_network(self, m_exec):
132 self.switch.add_network(33, '0ae071f5-5be9-43e4-80ea-e41fefe85b21')
133 m_exec.assert_called_with(
134 ['vlan database', 'vlan 33', 'exit'])
135
136 @mock.patch('networking_generic_switch.devices.netmiko_devices.'
137 'NetmikoSwitch.send_commands_to_device')
138 def test_add_network_with_trunk_ports(self, mock_exec):
139 switch = self._make_switch_device({'ngs_trunk_ports': 'port1,port2'})
140 switch.add_network(33, '0ae071f5-5be9-43e4-80ea-e41fefe85b21')
141 mock_exec.assert_called_with(
142 ['vlan database', 'vlan 33', 'exit',
143 'interface port1',
144 'switchport general allowed vlan add 33 tagged',
145 'exit',
146 'interface port2',
147 'switchport general allowed vlan add 33 tagged',
148 'exit'])
149
150 @mock.patch('networking_generic_switch.devices.netmiko_devices.'
151 'NetmikoSwitch.send_commands_to_device')
152 def test_del_network(self, mock_exec):
153 self.switch.del_network(33, '0ae071f5-5be9-43e4-80ea-e41fefe85b21')
154 mock_exec.assert_called_with(['vlan database', 'no vlan 33', 'exit'])
155
156 @mock.patch('networking_generic_switch.devices.netmiko_devices.'
157 'NetmikoSwitch.send_commands_to_device')
158 def test_del_network_with_trunk_ports(self, mock_exec):
159 switch = self._make_switch_device({'ngs_trunk_ports': 'port1,port2'})
160 switch.del_network(33, '0ae071f55be943e480eae41fefe85b21')
161 mock_exec.assert_called_with(
162 ['interface port1', 'switchport general allowed vlan remove 33',
163 'exit',
164 'interface port2', 'switchport general allowed vlan remove 33',
165 'exit',
166 'vlan database', 'no vlan 33', 'exit'])
167
168 @mock.patch('networking_generic_switch.devices.netmiko_devices.'
169 'NetmikoSwitch.send_commands_to_device')
170 def test_plug_port_to_network(self, mock_exec):
171 self.switch.plug_port_to_network(3333, 33)
172 mock_exec.assert_called_with(
173 ['interface 3333', 'switchport access vlan 33', 'exit'])
174
175 @mock.patch('networking_generic_switch.devices.netmiko_devices.'
176 'NetmikoSwitch.send_commands_to_device')
177 def test_delete_port(self, mock_exec):
178 self.switch.delete_port(3333, 33)
179 mock_exec.assert_called_with(
180 ['interface 3333', 'switchport access vlan none', 'exit'])
181
182 def test__format_commands(self):
183 cmd_set = self.switch._format_commands(
184 dell.DellPowerConnect.ADD_NETWORK,
185 segmentation_id=22,
186 network_id=22)
187 self.assertEqual(cmd_set, ['vlan database', 'vlan 22', 'exit'])
188
189 cmd_set = self.switch._format_commands(
190 dell.DellPowerConnect.DELETE_NETWORK,
191 segmentation_id=22)
192 self.assertEqual(cmd_set, ['vlan database', 'no vlan 22', 'exit'])
193
194 cmd_set = self.switch._format_commands(
195 dell.DellPowerConnect.PLUG_PORT_TO_NETWORK,
196 port=3333,
197 segmentation_id=33)
198 self.assertEqual(cmd_set,
199 ['interface 3333', 'switchport access vlan 33',
200 'exit'])
201 cmd_set = self.switch._format_commands(
202 dell.DellPowerConnect.DELETE_PORT,
203 port=3333,
204 segmentation_id=33)
205 self.assertEqual(cmd_set,
206 ['interface 3333', 'switchport access vlan none',
207 'exit'])
208
209 cmd_set = self.switch._format_commands(
210 dell.DellPowerConnect.ADD_NETWORK_TO_TRUNK,
211 port=3333,
212 segmentation_id=33)
213 self.assertEqual(cmd_set,
214 ['interface 3333',
215 'switchport general allowed vlan add 33 tagged',
216 'exit'])
217 cmd_set = self.switch._format_commands(
218 dell.DellPowerConnect.REMOVE_NETWORK_FROM_TRUNK,
219 port=3333,
220 segmentation_id=33)
221 self.assertEqual(cmd_set,
222 ['interface 3333',
223 'switchport general allowed vlan remove 33', 'exit'])
diff --git a/releasenotes/notes/dell-powerconnect-5ce572b9fb2702d3.yaml b/releasenotes/notes/dell-powerconnect-5ce572b9fb2702d3.yaml
new file mode 100644
index 0000000..945466b
--- /dev/null
+++ b/releasenotes/notes/dell-powerconnect-5ce572b9fb2702d3.yaml
@@ -0,0 +1,5 @@
1---
2features:
3 - |
4 Adds a new device driver, ``netmiko_dell_powerconnect``, for managing Dell
5 PowerConnect switch devices.
diff --git a/setup.cfg b/setup.cfg
index 21fb1c2..94959e4 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -25,6 +25,7 @@ generic_switch.devices =
25 netmiko_huawei_vrpv8 = networking_generic_switch.devices.netmiko_devices.huawei_vrpv8:Huawei 25 netmiko_huawei_vrpv8 = networking_generic_switch.devices.netmiko_devices.huawei_vrpv8:Huawei
26 netmiko_arista_eos = networking_generic_switch.devices.netmiko_devices.arista:AristaEos 26 netmiko_arista_eos = networking_generic_switch.devices.netmiko_devices.arista:AristaEos
27 netmiko_dell_force10 = networking_generic_switch.devices.netmiko_devices.dell:DellNos 27 netmiko_dell_force10 = networking_generic_switch.devices.netmiko_devices.dell:DellNos
28 netmiko_dell_powerconnect = networking_generic_switch.devices.netmiko_devices.dell:DellPowerConnect
28 netmiko_brocade_fastiron = networking_generic_switch.devices.netmiko_devices.brocade:BrocadeFastIron 29 netmiko_brocade_fastiron = networking_generic_switch.devices.netmiko_devices.brocade:BrocadeFastIron
29 netmiko_ruijie = networking_generic_switch.devices.netmiko_devices.ruijie:Ruijie 30 netmiko_ruijie = networking_generic_switch.devices.netmiko_devices.ruijie:Ruijie
30 netmiko_hpe_comware = networking_generic_switch.devices.netmiko_devices.hpe:HpeComware 31 netmiko_hpe_comware = networking_generic_switch.devices.netmiko_devices.hpe:HpeComware