Browse Source

Merge "Add support for Dell PowerConnect switches"

Zuul 9 months ago
parent
commit
47e93f8e23

+ 13
- 0
doc/source/configuration.rst View File

@@ -89,6 +89,19 @@ for the Dell Force10 device::
89 89
     password = password
90 90
     secret = secret
91 91
 
92
+for 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
+
101
+Dell PowerConnect devices have been seen to have issues with multiple
102
+concurrent configuration sessions. See :ref:`synchronization` for details on
103
+how to limit the number of concurrent active connections to each device.
104
+
92 105
 for the Brocade FastIron (ICX) device::
93 106
 
94 107
     [genericswitch:hostname-for-fast-iron]

+ 1
- 0
doc/source/supported-devices.rst View File

@@ -10,6 +10,7 @@ The following devices are supported by this plugin:
10 10
 * OpenVSwitch
11 11
 * Arista EOS
12 12
 * Dell Force10
13
+* Dell PowerConnect
13 14
 * Brocade ICX (FastIron)
14 15
 * Ruijie switches
15 16
 * HPE 5900 Series switches

+ 76
- 34
networking_generic_switch/devices/netmiko_devices/dell.py View File

@@ -16,37 +16,79 @@ from networking_generic_switch.devices import netmiko_devices
16 16
 
17 17
 
18 18
 class DellNos(netmiko_devices.NetmikoSwitch):
19
-        ADD_NETWORK = (
20
-            'interface vlan {segmentation_id}',
21
-            'name {network_id}',
22
-            'exit',
23
-        )
24
-
25
-        DELETE_NETWORK = (
26
-            'no interface vlan {segmentation_id}',
27
-            'exit',
28
-        )
29
-
30
-        PLUG_PORT_TO_NETWORK = (
31
-            'interface vlan {segmentation_id}',
32
-            'untagged {port}',
33
-            'exit',
34
-        )
35
-
36
-        DELETE_PORT = (
37
-            'interface vlan {segmentation_id}',
38
-            'no untagged {port}',
39
-            'exit',
40
-        )
41
-
42
-        ADD_NETWORK_TO_TRUNK = (
43
-            'interface vlan {segmentation_id}',
44
-            'tagged {port}',
45
-            'exit',
46
-        )
47
-
48
-        REMOVE_NETWORK_FROM_TRUNK = (
49
-            'interface vlan {segmentation_id}',
50
-            'no tagged {port}',
51
-            'exit',
52
-        )
19
+    """Netmiko device driver for Dell Force10 switches."""
20
+
21
+    ADD_NETWORK = (
22
+        'interface vlan {segmentation_id}',
23
+        'name {network_id}',
24
+        'exit',
25
+    )
26
+
27
+    DELETE_NETWORK = (
28
+        'no interface vlan {segmentation_id}',
29
+        'exit',
30
+    )
31
+
32
+    PLUG_PORT_TO_NETWORK = (
33
+        'interface vlan {segmentation_id}',
34
+        'untagged {port}',
35
+        'exit',
36
+    )
37
+
38
+    DELETE_PORT = (
39
+        'interface vlan {segmentation_id}',
40
+        'no untagged {port}',
41
+        'exit',
42
+    )
43
+
44
+    ADD_NETWORK_TO_TRUNK = (
45
+        'interface vlan {segmentation_id}',
46
+        'tagged {port}',
47
+        'exit',
48
+    )
49
+
50
+    REMOVE_NETWORK_FROM_TRUNK = (
51
+        'interface vlan {segmentation_id}',
52
+        'no tagged {port}',
53
+        'exit',
54
+    )
55
+
56
+
57
+class 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
+    )

+ 107
- 0
networking_generic_switch/tests/unit/netmiko/test_dell.py View File

@@ -114,3 +114,110 @@ class TestNetmikoDellNos(test_netmiko_base.NetmikoSwitchTestBase):
114 114
             segmentation_id=33)
115 115
         self.assertEqual(cmd_set,
116 116
                          ['interface vlan 33', 'no tagged 3333', 'exit'])
117
+
118
+
119
+class 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'])

+ 5
- 0
releasenotes/notes/dell-powerconnect-5ce572b9fb2702d3.yaml View File

@@ -0,0 +1,5 @@
1
+---
2
+features:
3
+  - |
4
+    Adds a new device driver, ``netmiko_dell_powerconnect``, for managing Dell
5
+    PowerConnect switch devices.

+ 1
- 0
setup.cfg View File

@@ -25,6 +25,7 @@ generic_switch.devices =
25 25
     netmiko_huawei_vrpv8 = networking_generic_switch.devices.netmiko_devices.huawei_vrpv8:Huawei
26 26
     netmiko_arista_eos = networking_generic_switch.devices.netmiko_devices.arista:AristaEos
27 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 29
     netmiko_brocade_fastiron = networking_generic_switch.devices.netmiko_devices.brocade:BrocadeFastIron
29 30
     netmiko_ruijie = networking_generic_switch.devices.netmiko_devices.ruijie:Ruijie
30 31
     netmiko_hpe_comware = networking_generic_switch.devices.netmiko_devices.hpe:HpeComware

Loading…
Cancel
Save