From 62fa0ebdcfb698ebcb5f16aba5fd0054dfc60c69 Mon Sep 17 00:00:00 2001 From: Doug Szumski Date: Thu, 6 Nov 2025 17:45:41 +0000 Subject: [PATCH] Add minimal Dell SONiC driver A Dell SONiC driver has been added upstream: https://review.opendev.org/c/openstack/networking-generic-switch/+/955252 This change adds a minimal Dell SONiC driver downstream. This is essentially the existing SONiC driver, but with a slightly different enable mode command. The change to the enable mode may not be required by the time we end up using the upstream driver. This is because the upstream driver has been developed against SONiC 4.5 which is more recent than the version used to develop this patch. This driver requires the switch to be configured to use the standard or standard-extended naming mode. Change-Id: Id263aa2757152012afdd6facb9f5fcd78fcc7ad8 --- .../devices/netmiko_devices/fake.py | 2 +- .../devices/netmiko_devices/sonic.py | 24 +++++++++++++++++++ setup.cfg | 1 + 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/networking_generic_switch/devices/netmiko_devices/fake.py b/networking_generic_switch/devices/netmiko_devices/fake.py index b754cd08..b939b50a 100644 --- a/networking_generic_switch/devices/netmiko_devices/fake.py +++ b/networking_generic_switch/devices/netmiko_devices/fake.py @@ -44,7 +44,7 @@ def send_config_set(self, config_commands, cmd_verify): if self.device.ngs_config.get('ngs_fake_failure_prob'): failure_prob = self.device.ngs_config['ngs_fake_failure_prob'] if random.random() < float(failure_prob): - raise Exception("Random failure!") + raise Exception("Random failure!") # noqa for cmd in config_commands: LOG.info("%s", cmd) diff --git a/networking_generic_switch/devices/netmiko_devices/sonic.py b/networking_generic_switch/devices/netmiko_devices/sonic.py index 7a78c80a..f1754ac5 100644 --- a/networking_generic_switch/devices/netmiko_devices/sonic.py +++ b/networking_generic_switch/devices/netmiko_devices/sonic.py @@ -84,3 +84,27 @@ def send_config_set(self, net_connect, cmd_set): return net_connect.send_config_set(config_commands=cmd_set, cmd_verify=False, exit_config_mode=False) + + +class DellEnterpriseSonic(Sonic): + """Netmiko device driver for Dell Enterprise switches. + + Developed against SONiC-OS-4.2.3-Edge_Standard. + + This driver must be used with the switch set to + standard or standard-extended naming mode. Do + not use the default setting of native. + """ + + def send_config_set(self, net_connect, cmd_set): + # Netmiko tries to use 'sudo -s' to open a root shell + # which doesn't work. It fails with: + # FATAL: root cannot launch CLI + net_connect.config_mode(config_command='sudo -i') + + # Don't exit configuration mode, as config save requires + # root permissions. + # Verify commands have run before moving on + return net_connect.send_config_set(config_commands=cmd_set, + cmd_verify=True, + exit_config_mode=False) diff --git a/setup.cfg b/setup.cfg index 0356c921..0f9d9ffe 100644 --- a/setup.cfg +++ b/setup.cfg @@ -49,6 +49,7 @@ generic_switch.devices = netmiko_cumulus = networking_generic_switch.devices.netmiko_devices.cumulus:Cumulus netmiko_cumulus_nvue = networking_generic_switch.devices.netmiko_devices.cumulus:CumulusNVUE netmiko_sonic = networking_generic_switch.devices.netmiko_devices.sonic:Sonic + netmiko_dell_enterprise_sonic = networking_generic_switch.devices.netmiko_devices.sonic:DellEnterpriseSonic netmiko_nokia_srl = networking_generic_switch.devices.netmiko_devices.nokia:NokiaSRL netmiko_pluribus = networking_generic_switch.devices.netmiko_devices.pluribus:Pluribus netmiko_aruba_os = networking_generic_switch.devices.netmiko_devices.aruba:ArubaOSCX