From 88d19dda1b6894cfaf919c6f4cd7497b45be49d7 Mon Sep 17 00:00:00 2001 From: Austin de Coup-Crank Date: Wed, 6 Sep 2023 09:54:01 -0500 Subject: [PATCH 1/3] Closes #2003: Fix NXOS ping source_interface bugs --- napalm/nxos/nxos.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/napalm/nxos/nxos.py b/napalm/nxos/nxos.py index 0b46da0dd..b97fbbf25 100644 --- a/napalm/nxos/nxos.py +++ b/napalm/nxos/nxos.py @@ -369,14 +369,14 @@ def ping( if source != "": command += " source {}".format(source) elif source_interface != "": - command += " source {}".format(source_interface) + command += " source-interface {}".format(source_interface) if vrf != "": command += " vrf {}".format(vrf) output = self._send_command(command, raw_text=True) assert isinstance(output, str) - if "connect:" in output: + if "connect:" in output.lower() or 'invalid' in output.lower(): ping_dict["error"] = output elif "PING" in output: ping_dict["success"] = { From 0923ffaeb7cb75203c6865ef32e95dfbe63efe14 Mon Sep 17 00:00:00 2001 From: Austin de Coup-Crank Date: Wed, 6 Sep 2023 09:58:27 -0500 Subject: [PATCH 2/3] black --- napalm/nxos/nxos.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/napalm/nxos/nxos.py b/napalm/nxos/nxos.py index b97fbbf25..70e01978b 100644 --- a/napalm/nxos/nxos.py +++ b/napalm/nxos/nxos.py @@ -376,7 +376,7 @@ def ping( output = self._send_command(command, raw_text=True) assert isinstance(output, str) - if "connect:" in output.lower() or 'invalid' in output.lower(): + if "connect:" in output.lower() or "invalid" in output.lower(): ping_dict["error"] = output elif "PING" in output: ping_dict["success"] = { From e017bce7547e5510069a8d821342c19ac04b0df1 Mon Sep 17 00:00:00 2001 From: Austin de Coup-Crank Date: Thu, 14 Sep 2023 11:00:30 -0500 Subject: [PATCH 3/3] Fix bug where source_interface and vrf are both provided --- napalm/nxos/nxos.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/napalm/nxos/nxos.py b/napalm/nxos/nxos.py index 70e01978b..822c30f41 100644 --- a/napalm/nxos/nxos.py +++ b/napalm/nxos/nxos.py @@ -371,8 +371,12 @@ def ping( elif source_interface != "": command += " source-interface {}".format(source_interface) - if vrf != "": - command += " vrf {}".format(vrf) + # source_interface and vrf are mutually exclusive, but since they + # provide the same behavior, no need to raise an exception--just + # prefer source_interface. + if not source_interface: + if vrf != "": + command += " vrf {}".format(vrf) output = self._send_command(command, raw_text=True) assert isinstance(output, str)