Skip to content

Commit

Permalink
Add support for Dell OS10
Browse files Browse the repository at this point in the history
This adds a new driver for Dell OS10 based switches.
Original change by msherman64[1].

[1] ChameleonCloud#14

Change-Id: Ib5bba3067352e6c7e12120982fcf5b206c9dd365
(cherry picked from commit 0ecd02a)
  • Loading branch information
jovial authored and Alex-Welsh committed Jul 13, 2023
1 parent 8fa4b7b commit c397a0f
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 0 deletions.
10 changes: 10 additions & 0 deletions doc/source/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@ for the Dell Force10 device::
password = password
secret = secret

for the Dell OS10 device::

[genericswitch:dell-hostname]
device_type = netmiko_dell_os10
ngs_mac_address = <switch mac address>
ip = <switch mgmt ip address>
username = admin
password = password
secret = secret

for the Dell PowerConnect device::

[genericswitch:dell-hostname]
Expand Down
1 change: 1 addition & 0 deletions doc/source/supported-devices.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ The following devices are supported by this plugin:
* Cisco IOS switches
* Cumulus Linux (via NCLU)
* Dell Force10
* Dell OS10
* Dell PowerConnect
* HPE 5900 Series switches
* Huawei switches
Expand Down
1 change: 1 addition & 0 deletions networking_generic_switch/devices/netmiko_devices/dell.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class DellOS10(netmiko_devices.NetmikoSwitch):

ADD_NETWORK = (
"interface vlan {segmentation_id}",
"description {network_name}",
"exit",
)

Expand Down
118 changes: 118 additions & 0 deletions networking_generic_switch/tests/unit/netmiko/test_dell.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,124 @@ def test__format_commands(self):
['interface vlan 33', 'no tagged 3333', 'exit'])


class TestNetmikoDellOS10(test_netmiko_base.NetmikoSwitchTestBase):

def _make_switch_device(self, extra_cfg={}):
device_cfg = {'device_type': 'netmiko_dell_os10'}
device_cfg.update(extra_cfg)
return dell.DellOS10(device_cfg)

def test_constants(self):
self.assertIsNone(self.switch.SAVE_CONFIGURATION)

@mock.patch('networking_generic_switch.devices.netmiko_devices.'
'NetmikoSwitch.send_commands_to_device')
def test_add_network(self, m_exec):
self.switch.add_network(33, '0ae071f5-5be9-43e4-80ea-e41fefe85b21')
m_exec.assert_called_with(
['interface vlan 33',
'description 0ae071f55be943e480eae41fefe85b21',
'exit']
)

@mock.patch('networking_generic_switch.devices.netmiko_devices.'
'NetmikoSwitch.send_commands_to_device')
def test_add_network_with_trunk_ports(self, mock_exec):
switch = self._make_switch_device({'ngs_trunk_ports': 'port1, port2'})
switch.add_network(33, '0ae071f5-5be9-43e4-80ea-e41fefe85b21')
mock_exec.assert_called_with(
['interface vlan 33',
'description 0ae071f55be943e480eae41fefe85b21',
'exit',
'interface port1', 'switchport mode trunk',
'switchport trunk allowed vlan 33', 'exit',
'interface port2', 'switchport mode trunk',
'switchport trunk allowed vlan 33', 'exit']
)

@mock.patch('networking_generic_switch.devices.netmiko_devices.'
'NetmikoSwitch.send_commands_to_device')
def test_del_network(self, mock_exec):
self.switch.del_network(33, '0ae071f5-5be9-43e4-80ea-e41fefe85b21')
mock_exec.assert_called_with(['no interface vlan 33', 'exit'])

@mock.patch('networking_generic_switch.devices.netmiko_devices.'
'NetmikoSwitch.send_commands_to_device')
def test_del_network_with_trunk_ports(self, mock_exec):
switch = self._make_switch_device({'ngs_trunk_ports': 'port1, port2'})
switch.del_network(33, '0ae071f55be943e480eae41fefe85b21')
mock_exec.assert_called_with(
['interface port1', 'no switchport trunk allowed vlan 33', 'exit',
'interface port2', 'no switchport trunk allowed vlan 33', 'exit',
'no interface vlan 33', 'exit'])

@mock.patch('networking_generic_switch.devices.netmiko_devices.'
'NetmikoSwitch.send_commands_to_device')
def test_plug_port_to_network(self, mock_exec):
self.switch.plug_port_to_network(3333, 33)
mock_exec.assert_called_with(
['interface 3333', 'switchport mode access',
'switchport access vlan 33',
'exit']
)

@mock.patch('networking_generic_switch.devices.netmiko_devices.'
'NetmikoSwitch.send_commands_to_device')
def test_delete_port(self, mock_exec):
self.switch.delete_port(3333, 33)
mock_exec.assert_called_with(
['interface 3333', 'no switchport access vlan', 'exit']
)

def test__format_commands(self):
cmd_set = self.switch._format_commands(
dell.DellOS10.ADD_NETWORK,
segmentation_id=22,
network_id=22,
network_name='vlan-22')
self.assertEqual(cmd_set,
['interface vlan 22',
'description vlan-22',
'exit']
)

cmd_set = self.switch._format_commands(
dell.DellOS10.DELETE_NETWORK,
segmentation_id=22)
self.assertEqual(cmd_set, ['no interface vlan 22', 'exit'])

cmd_set = self.switch._format_commands(
dell.DellOS10.PLUG_PORT_TO_NETWORK,
port=3333,
segmentation_id=33)
self.assertEqual(cmd_set, ['interface 3333', 'switchport mode access',
'switchport access vlan 33', 'exit'])
cmd_set = self.switch._format_commands(
dell.DellOS10.DELETE_PORT,
port=3333,
segmentation_id=33)
self.assertEqual(cmd_set,
['interface 3333', 'no switchport access vlan',
'exit'])

cmd_set = self.switch._format_commands(
dell.DellOS10.ADD_NETWORK_TO_TRUNK,
port=3333,
segmentation_id=33)
self.assertEqual(cmd_set,
['interface 3333', 'switchport mode trunk',
'switchport trunk allowed vlan 33',
'exit'])
cmd_set = self.switch._format_commands(
dell.DellOS10.REMOVE_NETWORK_FROM_TRUNK,
port=3333,
segmentation_id=33)
self.assertEqual(cmd_set,
['interface 3333',
'no switchport trunk allowed vlan 33',
'exit'])


class TestNetmikoDellPowerConnect(test_netmiko_base.NetmikoSwitchTestBase):

def _make_switch_device(self, extra_cfg={}):
Expand Down
5 changes: 5 additions & 0 deletions releasenotes/notes/add-dellos10-support-c6426372f960ded4.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
features:
- |
Adds a new device driver, ``netmiko_dell_os10``, for managing Dell OS10
based switch devices.
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ generic_switch.devices =
netmiko_huawei = networking_generic_switch.devices.netmiko_devices.huawei:Huawei
netmiko_huawei_vrpv8 = networking_generic_switch.devices.netmiko_devices.huawei_vrpv8:Huawei
netmiko_arista_eos = networking_generic_switch.devices.netmiko_devices.arista:AristaEos
netmiko_dell_os10 = networking_generic_switch.devices.netmiko_devices.dell:DellOS10
netmiko_dell_force10 = networking_generic_switch.devices.netmiko_devices.dell:DellNos
netmiko_dell_powerconnect = networking_generic_switch.devices.netmiko_devices.dell:DellPowerConnect
netmiko_brocade_fastiron = networking_generic_switch.devices.netmiko_devices.brocade:BrocadeFastIron
Expand Down

0 comments on commit c397a0f

Please sign in to comment.