From 0650045043395af465aad94f8bc19f74f31fecc7 Mon Sep 17 00:00:00 2001 From: Elisa Jasinska Date: Thu, 16 Nov 2017 10:05:03 +0000 Subject: [PATCH 01/62] adding extreme telnet class --- netmiko/extreme/__init__.py | 3 ++- netmiko/extreme/extreme_ssh.py | 7 +++++++ netmiko/ssh_dispatcher.py | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/netmiko/extreme/__init__.py b/netmiko/extreme/__init__.py index 150eff194..d5ee5d119 100644 --- a/netmiko/extreme/__init__.py +++ b/netmiko/extreme/__init__.py @@ -1,5 +1,6 @@ from __future__ import unicode_literals from netmiko.extreme.extreme_ssh import ExtremeSSH +from netmiko.extreme.extreme_ssh import ExtremeTelnet from netmiko.extreme.extreme_wing_ssh import ExtremeWingSSH -__all__ = ['ExtremeSSH', 'ExtremeWingSSH'] +__all__ = ['ExtremeSSH', 'ExtremeWingSSH', 'ExtremeTelnet'] diff --git a/netmiko/extreme/extreme_ssh.py b/netmiko/extreme/extreme_ssh.py index 01a09cfb5..4f64d3d80 100644 --- a/netmiko/extreme/extreme_ssh.py +++ b/netmiko/extreme/extreme_ssh.py @@ -63,3 +63,10 @@ def check_config_mode(self, check_string='#'): def exit_config_mode(self, exit_config=''): """No configuration mode on Extreme.""" return '' + + +class ExtremeTelnet(ExtremeSSH): + def __init__(self, *args, **kwargs): + default_enter = kwargs.get('default_enter') + kwargs['default_enter'] = '\r\n' if default_enter is None else default_enter + super(ExtremeTelnet, self).__init__(*args, **kwargs) diff --git a/netmiko/ssh_dispatcher.py b/netmiko/ssh_dispatcher.py index 2f9564341..14df1f2b8 100644 --- a/netmiko/ssh_dispatcher.py +++ b/netmiko/ssh_dispatcher.py @@ -32,6 +32,7 @@ from netmiko.enterasys import EnterasysSSH from netmiko.extreme import ExtremeSSH from netmiko.extreme import ExtremeWingSSH +from netmiko.extreme import ExtremeTelnet from netmiko.f5 import F5LtmSSH from netmiko.fortinet import FortinetSSH from netmiko.hp import HPProcurveSSH, HPComwareSSH @@ -134,6 +135,7 @@ CLASS_MAPPER['cisco_ios_telnet'] = CiscoIosTelnet CLASS_MAPPER['dell_powerconnect_telnet'] = DellPowerConnectTelnet CLASS_MAPPER['generic_termserver_telnet'] = TerminalServerTelnet +CLASS_MAPPER['extreme_telnet'] = ExtremeTelnet # Add serial drivers CLASS_MAPPER['cisco_ios_serial'] = CiscoIosSerial From 92441c3b810b994d607f75ef51bbfedad3d16a7e Mon Sep 17 00:00:00 2001 From: Ansel Gaddy Date: Thu, 11 Jan 2018 15:14:51 -0600 Subject: [PATCH 02/62] add junos search term --- netmiko/ssh_autodetect.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netmiko/ssh_autodetect.py b/netmiko/ssh_autodetect.py index 88c909342..c77a1f9f4 100644 --- a/netmiko/ssh_autodetect.py +++ b/netmiko/ssh_autodetect.py @@ -102,7 +102,7 @@ }, 'juniper_junos': { "cmd": "show version | match JUNOS", - "search_patterns": ["JUNOS Software Release", "JUNOS .+ Software"], + "search_patterns": ["JUNOS Software Release", "JUNOS .+ Software", "JUNOS OS Kernel"], "priority": 99, "dispatch": "_autodetect_std", }, From 71a5f1bf83bc886f9f18024b724fce0a3fa30309 Mon Sep 17 00:00:00 2001 From: Zhangfei Gao Date: Mon, 11 Dec 2017 17:12:08 +0800 Subject: [PATCH 03/62] Support huawei_vrpv8 switch Huawei VRPV8 switch need to execute the command 'commit' to complete the command Add new class HuaweiVrpv8SSH to support this switch --- netmiko/huawei/__init__.py | 4 ++-- netmiko/huawei/huawei_ssh.py | 32 ++++++++++++++++++++++++++++++++ netmiko/ssh_dispatcher.py | 3 ++- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/netmiko/huawei/__init__.py b/netmiko/huawei/__init__.py index 5e219b01f..9a9a938e4 100644 --- a/netmiko/huawei/__init__.py +++ b/netmiko/huawei/__init__.py @@ -1,4 +1,4 @@ from __future__ import unicode_literals -from netmiko.huawei.huawei_ssh import HuaweiSSH +from netmiko.huawei.huawei_ssh import HuaweiSSH, HuaweiVrpv8SSH -__all__ = ['HuaweiSSH'] +__all__ = ['HuaweiSSH', 'HuaweiVrpv8SSH'] diff --git a/netmiko/huawei/huawei_ssh.py b/netmiko/huawei/huawei_ssh.py index 67474afc7..b056b3e05 100644 --- a/netmiko/huawei/huawei_ssh.py +++ b/netmiko/huawei/huawei_ssh.py @@ -80,3 +80,35 @@ def set_base_prompt(self, pri_prompt_terminator='>', alt_prompt_terminator=']', log.debug("prompt: {0}".format(self.base_prompt)) return self.base_prompt + + +class HuaweiVrpv8SSH(HuaweiSSH): + + def commit(self, comment='', delay_factor=1): + """ + Commit the candidate configuration. + + Commit the entered configuration. Raise an error and return the failure + if the commit fails. + + default: + command_string = commit + comment: + command_string = commit comment + + """ + delay_factor = self.select_delay_factor(delay_factor) + error_marker = 'Failed to generate committed config' + command_string = 'commit' + + if comment: + command_string += ' comment "{}"'.format(comment) + + output = self.config_mode() + output += self.send_command_expect(command_string, strip_prompt=False, + strip_command=False, delay_factor=delay_factor) + output += self.exit_config_mode() + + if error_marker in output: + raise ValueError('Commit failed with following errors:\n\n{}'.format(output)) + return output diff --git a/netmiko/ssh_dispatcher.py b/netmiko/ssh_dispatcher.py index ee130914b..e1b5b5a58 100644 --- a/netmiko/ssh_dispatcher.py +++ b/netmiko/ssh_dispatcher.py @@ -33,7 +33,7 @@ from netmiko.f5 import F5LtmSSH from netmiko.fortinet import FortinetSSH from netmiko.hp import HPProcurveSSH, HPComwareSSH -from netmiko.huawei import HuaweiSSH +from netmiko.huawei import HuaweiSSH, HuaweiVrpv8SSH from netmiko.juniper import JuniperSSH, JuniperFileTransfer from netmiko.linux import LinuxSSH from netmiko.mellanox import MellanoxSSH @@ -90,6 +90,7 @@ 'hp_comware': HPComwareSSH, 'hp_procurve': HPProcurveSSH, 'huawei': HuaweiSSH, + 'huawei_vrpv8': HuaweiVrpv8SSH, 'juniper': JuniperSSH, 'juniper_junos': JuniperSSH, 'linux': LinuxSSH, From dc3a921ab16cc7a41d2700ec206087b8fad4424f Mon Sep 17 00:00:00 2001 From: Jay Crotts Date: Tue, 16 Jan 2018 11:03:41 -0800 Subject: [PATCH 04/62] Added save config to cisco_xr_ssh --- netmiko/cisco/cisco_xr_ssh.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/netmiko/cisco/cisco_xr_ssh.py b/netmiko/cisco/cisco_xr_ssh.py index 4cce75fdf..2683c24bd 100644 --- a/netmiko/cisco/cisco_xr_ssh.py +++ b/netmiko/cisco/cisco_xr_ssh.py @@ -123,5 +123,14 @@ def exit_config_mode(self, exit_config='end'): if "Uncommitted changes found" in output: output += self.send_command_timing('no', strip_prompt=False, strip_command=False) if self.check_config_mode(): - raise ValueError("Failed to exit configuration mode") + raise ValueErrr("Failed to exit configuration mode") return output + + def save_config(self, confirm=False, confirm_delay=None, comment='', label='', delay_factor=1): + """Saves current config, calls self.commit() if it exists""" + try: + self.commit(self, confirm, confirm_delay, comment, label, delay_factor) + except AttributeError: + # commit method doesn't exist run alternative logic instead + print("Missing the commit method in ", self) + raise From 7370fdd88fe93e4d709de934502807e4059e39af Mon Sep 17 00:00:00 2001 From: Luis San Martin Date: Tue, 16 Jan 2018 19:55:40 -0300 Subject: [PATCH 05/62] S4048 SSH autodetect support --- netmiko/ssh_autodetect.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/netmiko/ssh_autodetect.py b/netmiko/ssh_autodetect.py index c77a1f9f4..288386500 100644 --- a/netmiko/ssh_autodetect.py +++ b/netmiko/ssh_autodetect.py @@ -106,6 +106,12 @@ "priority": 99, "dispatch": "_autodetect_std", }, + 'dell_force10': { + "cmd": "show version | grep Type", + "search_patterns": ["S4048-ON"], + "priority": 99, + "dispatch": "_autodetect_std", + }, } From 2569982924b08e2ebd9a6b304a01beaa2a94d1aa Mon Sep 17 00:00:00 2001 From: Jay Crotts Date: Wed, 17 Jan 2018 14:59:29 -0800 Subject: [PATCH 06/62] add save_config to cisco_wlc_ssh.py --- netmiko/cisco/cisco_wlc_ssh.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/netmiko/cisco/cisco_wlc_ssh.py b/netmiko/cisco/cisco_wlc_ssh.py index 95d65e54b..c9684fc4d 100644 --- a/netmiko/cisco/cisco_wlc_ssh.py +++ b/netmiko/cisco/cisco_wlc_ssh.py @@ -158,3 +158,9 @@ def send_config_set(self, config_commands=None, exit_config_mode=True, delay_fac output = self._sanitize_output(output) log.debug("{}".format(output)) return output + + def save_config(self): + """ Saves config """ + self.exit_config_mode() # need to be in root prompt to save config on WLC + self.send_command(command_string='save config', expect_string='(y/n') + self.send_command(command_string='y') From efda2270cb304dfff5837cdf59e927b2a364112e Mon Sep 17 00:00:00 2001 From: Jay Crotts Date: Wed, 17 Jan 2018 15:01:15 -0800 Subject: [PATCH 07/62] fix typo --- netmiko/cisco/cisco_wlc_ssh.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netmiko/cisco/cisco_wlc_ssh.py b/netmiko/cisco/cisco_wlc_ssh.py index c9684fc4d..d8fa4b8e2 100644 --- a/netmiko/cisco/cisco_wlc_ssh.py +++ b/netmiko/cisco/cisco_wlc_ssh.py @@ -162,5 +162,5 @@ def send_config_set(self, config_commands=None, exit_config_mode=True, delay_fac def save_config(self): """ Saves config """ self.exit_config_mode() # need to be in root prompt to save config on WLC - self.send_command(command_string='save config', expect_string='(y/n') + self.send_command(command_string='save config', expect_string='(y/n)') self.send_command(command_string='y') From 973e73e794f652d942c7d215f28f4d9cc6be706b Mon Sep 17 00:00:00 2001 From: Jay Crotts Date: Wed, 17 Jan 2018 15:21:10 -0800 Subject: [PATCH 08/62] add save_config to cisco_s300 --- netmiko/cisco/cisco_s300.py | 7 ++++++- netmiko/cisco/cisco_xr_ssh.py | 7 +------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/netmiko/cisco/cisco_s300.py b/netmiko/cisco/cisco_s300.py index 8d31e717c..c055ba29a 100644 --- a/netmiko/cisco/cisco_s300.py +++ b/netmiko/cisco/cisco_s300.py @@ -21,4 +21,9 @@ def session_preparation(self): self.set_terminal_width(command='terminal width 511') # Clear the read buffer time.sleep(.3 * self.global_delay_factor) - self.clear_buffer() + + def save_config(self): + """ Saves config """ + self.enable() + self.send_command(command_string='write', expect_string='[Yes') + self.send_command(command_string='Yes') \ No newline at end of file diff --git a/netmiko/cisco/cisco_xr_ssh.py b/netmiko/cisco/cisco_xr_ssh.py index 2683c24bd..6b63f8af2 100644 --- a/netmiko/cisco/cisco_xr_ssh.py +++ b/netmiko/cisco/cisco_xr_ssh.py @@ -128,9 +128,4 @@ def exit_config_mode(self, exit_config='end'): def save_config(self, confirm=False, confirm_delay=None, comment='', label='', delay_factor=1): """Saves current config, calls self.commit() if it exists""" - try: - self.commit(self, confirm, confirm_delay, comment, label, delay_factor) - except AttributeError: - # commit method doesn't exist run alternative logic instead - print("Missing the commit method in ", self) - raise + self.commit(self, confirm, confirm_delay, comment, label, delay_factor) From a56ed5466b557a35b037477c7e276f41ae2848bb Mon Sep 17 00:00:00 2001 From: Jay Crotts Date: Wed, 17 Jan 2018 15:26:24 -0800 Subject: [PATCH 09/62] add save_config to CiscoNxosSSH --- netmiko/cisco/cisco_nxos_ssh.py | 5 +++++ netmiko/cisco/cisco_s300.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/netmiko/cisco/cisco_nxos_ssh.py b/netmiko/cisco/cisco_nxos_ssh.py index f4effc620..6c828f421 100644 --- a/netmiko/cisco/cisco_nxos_ssh.py +++ b/netmiko/cisco/cisco_nxos_ssh.py @@ -24,6 +24,11 @@ def normalize_linefeeds(self, a_string): newline = re.compile(r'(\r\r\n|\r\n)') return newline.sub(self.RESPONSE_RETURN, a_string).replace('\r', '') + def save_config(self): + """Saves Config Using Copy Run Start""" + self.enable() + self.send_command(command_string='copy running-config startup-config') + class CiscoNxosFileTransfer(CiscoFileTransfer): """Cisco NXOS SCP File Transfer driver.""" diff --git a/netmiko/cisco/cisco_s300.py b/netmiko/cisco/cisco_s300.py index c055ba29a..b7f9550ee 100644 --- a/netmiko/cisco/cisco_s300.py +++ b/netmiko/cisco/cisco_s300.py @@ -26,4 +26,4 @@ def save_config(self): """ Saves config """ self.enable() self.send_command(command_string='write', expect_string='[Yes') - self.send_command(command_string='Yes') \ No newline at end of file + self.send_command(command_string='Yes') From f90e60b2e83b2ed06064309862d3b7f86b0c3ca5 Mon Sep 17 00:00:00 2001 From: Jay Crotts Date: Wed, 17 Jan 2018 15:29:27 -0800 Subject: [PATCH 10/62] add save_config to CiscoTpTcCeSSH (not implemented) --- netmiko/cisco/cisco_tp_tcce.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/netmiko/cisco/cisco_tp_tcce.py b/netmiko/cisco/cisco_tp_tcce.py index 0bd20714d..b2dc6aba0 100644 --- a/netmiko/cisco/cisco_tp_tcce.py +++ b/netmiko/cisco/cisco_tp_tcce.py @@ -85,3 +85,6 @@ def send_command(self, *args, **kwargs): output = super(CiscoSSHConnection, self).send_command(*args, **kwargs) return output + + def save_config(self): + raise NotImplementedError From 358fa7802d6a8fef737262beb656686d7c40e29a Mon Sep 17 00:00:00 2001 From: Jay Crotts Date: Wed, 17 Jan 2018 16:15:53 -0800 Subject: [PATCH 11/62] add save_config toCiscoIosBase --- netmiko/cisco/cisco_ios.py | 7 ++++++- netmiko/cisco/cisco_nxos_ssh.py | 2 +- netmiko/cisco/cisco_tp_tcce.py | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/netmiko/cisco/cisco_ios.py b/netmiko/cisco/cisco_ios.py index b774269a7..030d6ae99 100644 --- a/netmiko/cisco/cisco_ios.py +++ b/netmiko/cisco/cisco_ios.py @@ -20,7 +20,12 @@ def session_preparation(self): # Clear the read buffer time.sleep(.3 * self.global_delay_factor) self.clear_buffer() - + + def save_config(self): + """Saves Config Using Copy Run Start""" + self.enable() + self.send_command(command_string='copy running-config startup-config') + self.send_command_timing(self) # enter to confirm filename class CiscoIosSSH(CiscoIosBase): """Cisco IOS SSH driver.""" diff --git a/netmiko/cisco/cisco_nxos_ssh.py b/netmiko/cisco/cisco_nxos_ssh.py index 6c828f421..27f848bfe 100644 --- a/netmiko/cisco/cisco_nxos_ssh.py +++ b/netmiko/cisco/cisco_nxos_ssh.py @@ -28,7 +28,7 @@ def save_config(self): """Saves Config Using Copy Run Start""" self.enable() self.send_command(command_string='copy running-config startup-config') - + self.send_command_timing(self) # enter to confirm class CiscoNxosFileTransfer(CiscoFileTransfer): """Cisco NXOS SCP File Transfer driver.""" diff --git a/netmiko/cisco/cisco_tp_tcce.py b/netmiko/cisco/cisco_tp_tcce.py index b2dc6aba0..30509bb0e 100644 --- a/netmiko/cisco/cisco_tp_tcce.py +++ b/netmiko/cisco/cisco_tp_tcce.py @@ -85,6 +85,6 @@ def send_command(self, *args, **kwargs): output = super(CiscoSSHConnection, self).send_command(*args, **kwargs) return output - + def save_config(self): raise NotImplementedError From b111df4f39893e44bc144a48f19d7642ed37a680 Mon Sep 17 00:00:00 2001 From: Jay Crotts Date: Wed, 17 Jan 2018 16:16:36 -0800 Subject: [PATCH 12/62] fix typos --- netmiko/cisco/cisco_ios.py | 2 +- netmiko/cisco/cisco_nxos_ssh.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/netmiko/cisco/cisco_ios.py b/netmiko/cisco/cisco_ios.py index 030d6ae99..a2000bfa3 100644 --- a/netmiko/cisco/cisco_ios.py +++ b/netmiko/cisco/cisco_ios.py @@ -25,7 +25,7 @@ def save_config(self): """Saves Config Using Copy Run Start""" self.enable() self.send_command(command_string='copy running-config startup-config') - self.send_command_timing(self) # enter to confirm filename + self.send_command_timing() # enter to confirm filename class CiscoIosSSH(CiscoIosBase): """Cisco IOS SSH driver.""" diff --git a/netmiko/cisco/cisco_nxos_ssh.py b/netmiko/cisco/cisco_nxos_ssh.py index 27f848bfe..daeef3f5a 100644 --- a/netmiko/cisco/cisco_nxos_ssh.py +++ b/netmiko/cisco/cisco_nxos_ssh.py @@ -28,7 +28,7 @@ def save_config(self): """Saves Config Using Copy Run Start""" self.enable() self.send_command(command_string='copy running-config startup-config') - self.send_command_timing(self) # enter to confirm + self.send_command_timing() # enter to confirm class CiscoNxosFileTransfer(CiscoFileTransfer): """Cisco NXOS SCP File Transfer driver.""" From 714d2d82bbe9ebc82337a33212bab8b184330be2 Mon Sep 17 00:00:00 2001 From: Jay Crotts Date: Wed, 17 Jan 2018 16:19:25 -0800 Subject: [PATCH 13/62] add command_string argument --- netmiko/cisco/cisco_ios.py | 2 +- netmiko/cisco/cisco_nxos_ssh.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/netmiko/cisco/cisco_ios.py b/netmiko/cisco/cisco_ios.py index a2000bfa3..8e609e532 100644 --- a/netmiko/cisco/cisco_ios.py +++ b/netmiko/cisco/cisco_ios.py @@ -25,7 +25,7 @@ def save_config(self): """Saves Config Using Copy Run Start""" self.enable() self.send_command(command_string='copy running-config startup-config') - self.send_command_timing() # enter to confirm filename + self.send_command_timing(command_string='\r\n') # enter to confirm class CiscoIosSSH(CiscoIosBase): """Cisco IOS SSH driver.""" diff --git a/netmiko/cisco/cisco_nxos_ssh.py b/netmiko/cisco/cisco_nxos_ssh.py index daeef3f5a..77920ed07 100644 --- a/netmiko/cisco/cisco_nxos_ssh.py +++ b/netmiko/cisco/cisco_nxos_ssh.py @@ -28,7 +28,7 @@ def save_config(self): """Saves Config Using Copy Run Start""" self.enable() self.send_command(command_string='copy running-config startup-config') - self.send_command_timing() # enter to confirm + self.send_command_timing(command_string='\r\n') # enter to confirm class CiscoNxosFileTransfer(CiscoFileTransfer): """Cisco NXOS SCP File Transfer driver.""" From b542e7beafd1a6da63aee7eb671f9b69fd285411 Mon Sep 17 00:00:00 2001 From: Jay Crotts Date: Wed, 17 Jan 2018 16:25:47 -0800 Subject: [PATCH 14/62] add save_config tocisco_asa_ssh --- netmiko/cisco/cisco_asa_ssh.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/netmiko/cisco/cisco_asa_ssh.py b/netmiko/cisco/cisco_asa_ssh.py index f0df10c6c..c0ef0752f 100644 --- a/netmiko/cisco/cisco_asa_ssh.py +++ b/netmiko/cisco/cisco_asa_ssh.py @@ -102,7 +102,12 @@ def asa_login(self): else: self.write_channel("login" + self.RETURN) i += 1 - + def save_config(self): + """Saves Config Using Copy Run Start""" + self.enable() + self.config_mode() + self.send_command(command_string='write memory') + self.send_command_timing(command_string='\r\n') class CiscoAsaFileTransfer(CiscoFileTransfer): """Cisco ASA SCP File Transfer driver.""" From 759ad90f6697e206c792abbe483dabd69e39f30a Mon Sep 17 00:00:00 2001 From: Jay Crotts Date: Wed, 17 Jan 2018 16:26:20 -0800 Subject: [PATCH 15/62] fix missing new line --- netmiko/cisco/cisco_asa_ssh.py | 1 + 1 file changed, 1 insertion(+) diff --git a/netmiko/cisco/cisco_asa_ssh.py b/netmiko/cisco/cisco_asa_ssh.py index c0ef0752f..2edbb1ee2 100644 --- a/netmiko/cisco/cisco_asa_ssh.py +++ b/netmiko/cisco/cisco_asa_ssh.py @@ -102,6 +102,7 @@ def asa_login(self): else: self.write_channel("login" + self.RETURN) i += 1 + def save_config(self): """Saves Config Using Copy Run Start""" self.enable() From f348f9ce4b763f310712f027b58363456feed168 Mon Sep 17 00:00:00 2001 From: Jay Crotts Date: Wed, 17 Jan 2018 16:36:59 -0800 Subject: [PATCH 16/62] fix typo in cisco_xr_ssh --- netmiko/cisco/cisco_xr_ssh.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netmiko/cisco/cisco_xr_ssh.py b/netmiko/cisco/cisco_xr_ssh.py index 6b63f8af2..25788dc85 100644 --- a/netmiko/cisco/cisco_xr_ssh.py +++ b/netmiko/cisco/cisco_xr_ssh.py @@ -123,7 +123,7 @@ def exit_config_mode(self, exit_config='end'): if "Uncommitted changes found" in output: output += self.send_command_timing('no', strip_prompt=False, strip_command=False) if self.check_config_mode(): - raise ValueErrr("Failed to exit configuration mode") + raise ValueError("Failed to exit configuration mode") return output def save_config(self, confirm=False, confirm_delay=None, comment='', label='', delay_factor=1): From 8b386d16bf1fcd936f71cb03fafc955db42af3f7 Mon Sep 17 00:00:00 2001 From: Jay Crotts Date: Wed, 17 Jan 2018 16:45:29 -0800 Subject: [PATCH 17/62] fix pylama issues --- netmiko/cisco/cisco_asa_ssh.py | 1 + netmiko/cisco/cisco_ios.py | 5 +++-- netmiko/cisco/cisco_nxos_ssh.py | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/netmiko/cisco/cisco_asa_ssh.py b/netmiko/cisco/cisco_asa_ssh.py index 2edbb1ee2..5073c9318 100644 --- a/netmiko/cisco/cisco_asa_ssh.py +++ b/netmiko/cisco/cisco_asa_ssh.py @@ -110,6 +110,7 @@ def save_config(self): self.send_command(command_string='write memory') self.send_command_timing(command_string='\r\n') + class CiscoAsaFileTransfer(CiscoFileTransfer): """Cisco ASA SCP File Transfer driver.""" pass diff --git a/netmiko/cisco/cisco_ios.py b/netmiko/cisco/cisco_ios.py index 8e609e532..e86a9a170 100644 --- a/netmiko/cisco/cisco_ios.py +++ b/netmiko/cisco/cisco_ios.py @@ -20,12 +20,13 @@ def session_preparation(self): # Clear the read buffer time.sleep(.3 * self.global_delay_factor) self.clear_buffer() - + def save_config(self): """Saves Config Using Copy Run Start""" self.enable() self.send_command(command_string='copy running-config startup-config') - self.send_command_timing(command_string='\r\n') # enter to confirm + self.send_command_timing(command_string='\r\n') # enter to confirm + class CiscoIosSSH(CiscoIosBase): """Cisco IOS SSH driver.""" diff --git a/netmiko/cisco/cisco_nxos_ssh.py b/netmiko/cisco/cisco_nxos_ssh.py index 77920ed07..e27c0a2c0 100644 --- a/netmiko/cisco/cisco_nxos_ssh.py +++ b/netmiko/cisco/cisco_nxos_ssh.py @@ -28,7 +28,8 @@ def save_config(self): """Saves Config Using Copy Run Start""" self.enable() self.send_command(command_string='copy running-config startup-config') - self.send_command_timing(command_string='\r\n') # enter to confirm + self.send_command_timing(command_string='\r\n') # enter to confirm + class CiscoNxosFileTransfer(CiscoFileTransfer): """Cisco NXOS SCP File Transfer driver.""" From d3df0241eeb1698ad8541b28e2daf73b3b659aa2 Mon Sep 17 00:00:00 2001 From: Elisa Jasinska Date: Mon, 22 Jan 2018 11:08:49 -0400 Subject: [PATCH 18/62] adding extreme telnet class --- netmiko/cisco/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netmiko/cisco/__init__.py b/netmiko/cisco/__init__.py index 6c01582c1..e34087ea0 100644 --- a/netmiko/cisco/__init__.py +++ b/netmiko/cisco/__init__.py @@ -1,5 +1,5 @@ from __future__ import unicode_literals -from netmiko.cisco.cisco_ios import CiscoIosBase, CiscoIosSSH, CiscoIosTelnet, CiscoIosFileTransfer +from netmiko.cisco.cisco_ios import CiscoIosBase, CiscoIosSSH, CiscoIosTelnet, CiscoIosFileTransfer, CiscoIosSerial from netmiko.cisco.cisco_ios import InLineTransfer from netmiko.cisco.cisco_asa_ssh import CiscoAsaSSH, CiscoAsaFileTransfer from netmiko.cisco.cisco_nxos_ssh import CiscoNxosSSH, CiscoNxosFileTransfer From 100527cf62ad3b6e4861bb2b7e5979edbbca9e06 Mon Sep 17 00:00:00 2001 From: Jay Crotts Date: Mon, 22 Jan 2018 12:14:05 -0800 Subject: [PATCH 19/62] Switch to RESPONSE_RETURN instead of '\n' --- netmiko/cisco/cisco_asa_ssh.py | 2 +- netmiko/cisco/cisco_ios.py | 2 +- netmiko/cisco/cisco_nxos_ssh.py | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/netmiko/cisco/cisco_asa_ssh.py b/netmiko/cisco/cisco_asa_ssh.py index 5073c9318..9990bd5ce 100644 --- a/netmiko/cisco/cisco_asa_ssh.py +++ b/netmiko/cisco/cisco_asa_ssh.py @@ -108,7 +108,7 @@ def save_config(self): self.enable() self.config_mode() self.send_command(command_string='write memory') - self.send_command_timing(command_string='\r\n') + self.send_command_timing(command_string=self.RESPONSE_RETURN) class CiscoAsaFileTransfer(CiscoFileTransfer): diff --git a/netmiko/cisco/cisco_ios.py b/netmiko/cisco/cisco_ios.py index e86a9a170..38bfe3e81 100644 --- a/netmiko/cisco/cisco_ios.py +++ b/netmiko/cisco/cisco_ios.py @@ -25,7 +25,7 @@ def save_config(self): """Saves Config Using Copy Run Start""" self.enable() self.send_command(command_string='copy running-config startup-config') - self.send_command_timing(command_string='\r\n') # enter to confirm + self.send_command_timing(command_string=self.RESPONSE_RETURN) # enter to confirm class CiscoIosSSH(CiscoIosBase): diff --git a/netmiko/cisco/cisco_nxos_ssh.py b/netmiko/cisco/cisco_nxos_ssh.py index e27c0a2c0..009bea9eb 100644 --- a/netmiko/cisco/cisco_nxos_ssh.py +++ b/netmiko/cisco/cisco_nxos_ssh.py @@ -28,8 +28,7 @@ def save_config(self): """Saves Config Using Copy Run Start""" self.enable() self.send_command(command_string='copy running-config startup-config') - self.send_command_timing(command_string='\r\n') # enter to confirm - + self.send_command_timing(command_string=self.RESPONSE_RETURN) # enter to confirm class CiscoNxosFileTransfer(CiscoFileTransfer): """Cisco NXOS SCP File Transfer driver.""" From 6386c970685abe1f7b436c6bb39c7aa58315c43c Mon Sep 17 00:00:00 2001 From: Jay Crotts Date: Mon, 22 Jan 2018 12:14:46 -0800 Subject: [PATCH 20/62] Add save_config for arista_ssh --- netmiko/arista/arista_ssh.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/netmiko/arista/arista_ssh.py b/netmiko/arista/arista_ssh.py index f0605db34..55387e0f0 100644 --- a/netmiko/arista/arista_ssh.py +++ b/netmiko/arista/arista_ssh.py @@ -35,6 +35,11 @@ def check_config_mode(self, check_string=')#', pattern=''): log.debug("check_config_mode: {0}".format(repr(output))) return check_string in output + def save_config(self): + self.enable() + self.send_command('copy running-config startup-config') + self.sennd_command(self.RESPONSE_RETURN) + class AristaFileTransfer(CiscoFileTransfer): """Arista SCP File Transfer driver.""" From 4479df7cb870c5f0b46ecf2f87d657ae8967fd3d Mon Sep 17 00:00:00 2001 From: Jay Crotts Date: Mon, 22 Jan 2018 12:16:09 -0800 Subject: [PATCH 21/62] Add docstring and fix typo --- netmiko/arista/arista_ssh.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/netmiko/arista/arista_ssh.py b/netmiko/arista/arista_ssh.py index 55387e0f0..bd1e657d9 100644 --- a/netmiko/arista/arista_ssh.py +++ b/netmiko/arista/arista_ssh.py @@ -36,9 +36,12 @@ def check_config_mode(self, check_string=')#', pattern=''): return check_string in output def save_config(self): + """ + Saves Running Config using default file name. + """ self.enable() self.send_command('copy running-config startup-config') - self.sennd_command(self.RESPONSE_RETURN) + self.send_command(self.RESPONSE_RETURN) class AristaFileTransfer(CiscoFileTransfer): From 1656f22bac2c62d5e87acda07371b781ef851d9a Mon Sep 17 00:00:00 2001 From: Jay Crotts Date: Mon, 22 Jan 2018 12:18:05 -0800 Subject: [PATCH 22/62] Remove keyword arguments for calls with one parameter --- netmiko/cisco/cisco_ios.py | 2 +- netmiko/cisco/cisco_nxos_ssh.py | 4 ++-- netmiko/cisco/cisco_s300.py | 2 +- netmiko/cisco/cisco_wlc_ssh.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/netmiko/cisco/cisco_ios.py b/netmiko/cisco/cisco_ios.py index 38bfe3e81..571989d3c 100644 --- a/netmiko/cisco/cisco_ios.py +++ b/netmiko/cisco/cisco_ios.py @@ -25,7 +25,7 @@ def save_config(self): """Saves Config Using Copy Run Start""" self.enable() self.send_command(command_string='copy running-config startup-config') - self.send_command_timing(command_string=self.RESPONSE_RETURN) # enter to confirm + self.send_command_timing(self.RESPONSE_RETURN) # enter to confirm class CiscoIosSSH(CiscoIosBase): diff --git a/netmiko/cisco/cisco_nxos_ssh.py b/netmiko/cisco/cisco_nxos_ssh.py index 009bea9eb..bb5d0e192 100644 --- a/netmiko/cisco/cisco_nxos_ssh.py +++ b/netmiko/cisco/cisco_nxos_ssh.py @@ -27,8 +27,8 @@ def normalize_linefeeds(self, a_string): def save_config(self): """Saves Config Using Copy Run Start""" self.enable() - self.send_command(command_string='copy running-config startup-config') - self.send_command_timing(command_string=self.RESPONSE_RETURN) # enter to confirm + self.send_command('copy running-config startup-config') + self.send_command_timing(self.RESPONSE_RETURN) # enter to confirm class CiscoNxosFileTransfer(CiscoFileTransfer): """Cisco NXOS SCP File Transfer driver.""" diff --git a/netmiko/cisco/cisco_s300.py b/netmiko/cisco/cisco_s300.py index b7f9550ee..c47d81982 100644 --- a/netmiko/cisco/cisco_s300.py +++ b/netmiko/cisco/cisco_s300.py @@ -26,4 +26,4 @@ def save_config(self): """ Saves config """ self.enable() self.send_command(command_string='write', expect_string='[Yes') - self.send_command(command_string='Yes') + self.send_command('Yes') diff --git a/netmiko/cisco/cisco_wlc_ssh.py b/netmiko/cisco/cisco_wlc_ssh.py index d8fa4b8e2..e128dd503 100644 --- a/netmiko/cisco/cisco_wlc_ssh.py +++ b/netmiko/cisco/cisco_wlc_ssh.py @@ -163,4 +163,4 @@ def save_config(self): """ Saves config """ self.exit_config_mode() # need to be in root prompt to save config on WLC self.send_command(command_string='save config', expect_string='(y/n)') - self.send_command(command_string='y') + self.send_command('y') From ecdf0212464c74131a946d87133ca62a57d63b74 Mon Sep 17 00:00:00 2001 From: Jay Crotts Date: Mon, 22 Jan 2018 12:23:53 -0800 Subject: [PATCH 23/62] fix spacing --- netmiko/arista/arista_ssh.py | 4 +--- netmiko/cisco/cisco_nxos_ssh.py | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/netmiko/arista/arista_ssh.py b/netmiko/arista/arista_ssh.py index bd1e657d9..a71f2a945 100644 --- a/netmiko/arista/arista_ssh.py +++ b/netmiko/arista/arista_ssh.py @@ -36,9 +36,7 @@ def check_config_mode(self, check_string=')#', pattern=''): return check_string in output def save_config(self): - """ - Saves Running Config using default file name. - """ + """Saves Running Config using default file name.""" self.enable() self.send_command('copy running-config startup-config') self.send_command(self.RESPONSE_RETURN) diff --git a/netmiko/cisco/cisco_nxos_ssh.py b/netmiko/cisco/cisco_nxos_ssh.py index bb5d0e192..303ba5838 100644 --- a/netmiko/cisco/cisco_nxos_ssh.py +++ b/netmiko/cisco/cisco_nxos_ssh.py @@ -30,6 +30,7 @@ def save_config(self): self.send_command('copy running-config startup-config') self.send_command_timing(self.RESPONSE_RETURN) # enter to confirm + class CiscoNxosFileTransfer(CiscoFileTransfer): """Cisco NXOS SCP File Transfer driver.""" def __init__(self, ssh_conn, source_file, dest_file, file_system='bootflash:', direction='put'): From 9c5bbe8bbac106ebef5156f07538dba9d1a5c8f1 Mon Sep 17 00:00:00 2001 From: Jay Crotts Date: Mon, 22 Jan 2018 14:34:47 -0800 Subject: [PATCH 24/62] Add save_config for hp devices --- netmiko/hp/hp_comware_ssh.py | 7 +++++++ netmiko/hp/hp_procurve_ssh.py | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/netmiko/hp/hp_comware_ssh.py b/netmiko/hp/hp_comware_ssh.py index b115bb1c1..151cc60e1 100644 --- a/netmiko/hp/hp_comware_ssh.py +++ b/netmiko/hp/hp_comware_ssh.py @@ -76,3 +76,10 @@ def exit_enable_mode(self, exit_command='return'): def check_enable_mode(self, check_string=']'): """enable mode on Comware is system-view.""" return self.check_config_mode(check_string=check_string) + + def save_config(self): + """Save Config using write memory.""" + if not self.check_enable_mode(): + self.enable() + self.send_command('save', '[Y/N]') + self.send_command('y') diff --git a/netmiko/hp/hp_procurve_ssh.py b/netmiko/hp/hp_procurve_ssh.py index d92367914..866822e83 100644 --- a/netmiko/hp/hp_procurve_ssh.py +++ b/netmiko/hp/hp_procurve_ssh.py @@ -72,3 +72,10 @@ def cleanup(self): except socket.error: break count += 1 + + def save_config(self): + """Save Config using write memory.""" + if self.check_config_mode(): + self.send_command('write memory') + else: + self.send_config_set(['write memory']) From 56a04f601eaca469f759a03c4314631eb71a0851 Mon Sep 17 00:00:00 2001 From: Jay Crotts Date: Mon, 22 Jan 2018 14:41:03 -0800 Subject: [PATCH 25/62] Add save_config wrapper for juniper --- netmiko/juniper/juniper_ssh.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/netmiko/juniper/juniper_ssh.py b/netmiko/juniper/juniper_ssh.py index b46f95d1e..a31a53648 100644 --- a/netmiko/juniper/juniper_ssh.py +++ b/netmiko/juniper/juniper_ssh.py @@ -186,6 +186,10 @@ def strip_context_items(self, a_string): return self.RESPONSE_RETURN.join(response_list[:-1]) return a_string + def save_config(self, confirm=False, confirm_delay=None, check=False, comment='', + and_quit=False, delay_factor=1): + """Wrapper around commit() for API consistency""" + self.commit(self, confirm, confirm_delay, check, comment, and_quit, delay_factor) class JuniperFileTransfer(BaseFileTransfer): """Juniper SCP File Transfer driver.""" From 9648a3bf3bd6b97f83b1056b3d8df299a8dcdd93 Mon Sep 17 00:00:00 2001 From: Jay Crotts Date: Mon, 22 Jan 2018 15:04:05 -0800 Subject: [PATCH 26/62] Save Config using write erase for juniperos --- netmiko/juniper/juniper_ssh.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/netmiko/juniper/juniper_ssh.py b/netmiko/juniper/juniper_ssh.py index a31a53648..4bbdf11ef 100644 --- a/netmiko/juniper/juniper_ssh.py +++ b/netmiko/juniper/juniper_ssh.py @@ -186,10 +186,12 @@ def strip_context_items(self, a_string): return self.RESPONSE_RETURN.join(response_list[:-1]) return a_string - def save_config(self, confirm=False, confirm_delay=None, check=False, comment='', - and_quit=False, delay_factor=1): - """Wrapper around commit() for API consistency""" - self.commit(self, confirm, confirm_delay, check, comment, and_quit, delay_factor) + def save_config(self): + """Saves Config in Automatic or Manual Mode""" + if not self.check_enable_mode(): + self.enable() + self.send_command('write memory') + self.send_command(self.RESPONSE_RETURN) class JuniperFileTransfer(BaseFileTransfer): """Juniper SCP File Transfer driver.""" From 95e7eb2277b4696ca136bb959edb2982e781b287 Mon Sep 17 00:00:00 2001 From: Jay Crotts Date: Mon, 22 Jan 2018 15:06:19 -0800 Subject: [PATCH 27/62] Remove Exec check --- netmiko/juniper/juniper_ssh.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/netmiko/juniper/juniper_ssh.py b/netmiko/juniper/juniper_ssh.py index 4bbdf11ef..7acc1fb04 100644 --- a/netmiko/juniper/juniper_ssh.py +++ b/netmiko/juniper/juniper_ssh.py @@ -188,8 +188,6 @@ def strip_context_items(self, a_string): def save_config(self): """Saves Config in Automatic or Manual Mode""" - if not self.check_enable_mode(): - self.enable() self.send_command('write memory') self.send_command(self.RESPONSE_RETURN) From 52ec2022ff069f94212df085a9913ad292f80be0 Mon Sep 17 00:00:00 2001 From: Jay Crotts Date: Mon, 22 Jan 2018 15:13:53 -0800 Subject: [PATCH 28/62] Add save config for Avaya devices --- netmiko/avaya/avaya_ers_ssh.py | 6 ++++++ netmiko/avaya/avaya_vsp_ssh.py | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/netmiko/avaya/avaya_ers_ssh.py b/netmiko/avaya/avaya_ers_ssh.py index 281a8c029..c81be1cb2 100644 --- a/netmiko/avaya/avaya_ers_ssh.py +++ b/netmiko/avaya/avaya_ers_ssh.py @@ -36,3 +36,9 @@ def special_login_handler(self, delay_factor=1): self.write_channel(self.RETURN) time.sleep(1 * delay_factor) i += 1 + + def save_config(self): + """Save Config""" + if not self.check_enable_mode(): + self.enable() + self.send_command('save config') diff --git a/netmiko/avaya/avaya_vsp_ssh.py b/netmiko/avaya/avaya_vsp_ssh.py index fd68f940c..2fcdd4b19 100644 --- a/netmiko/avaya/avaya_vsp_ssh.py +++ b/netmiko/avaya/avaya_vsp_ssh.py @@ -15,3 +15,9 @@ def session_preparation(self): # Clear the read buffer time.sleep(.3 * self.global_delay_factor) self.clear_buffer() + + def save_config(self): + """Save Config""" + if not self.check_enable_mode(): + self.enable() + self.send_command('save config') From 8db54815ed5531425dcfe50f0ed6fabbf1090b7a Mon Sep 17 00:00:00 2001 From: Jay Crotts Date: Mon, 22 Jan 2018 15:21:25 -0800 Subject: [PATCH 29/62] Add Save config for brocade Netiron --- netmiko/brocade/brocade_netiron.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/netmiko/brocade/brocade_netiron.py b/netmiko/brocade/brocade_netiron.py index 22e795f86..ddebef1b9 100644 --- a/netmiko/brocade/brocade_netiron.py +++ b/netmiko/brocade/brocade_netiron.py @@ -3,7 +3,12 @@ class BrocadeNetironBase(CiscoSSHConnection): - pass + + def save_config(self): + """Save Config for BrocadeNetironBase""" + if not self.check_enable_mode(): + self.enable() + self.send_command('write memory') class BrocadeNetironSSH(BrocadeNetironBase): From d7a227ae5f0f53b5c620864df08c7b883402e968 Mon Sep 17 00:00:00 2001 From: Jay Crotts Date: Mon, 22 Jan 2018 15:26:53 -0800 Subject: [PATCH 30/62] Add save_config for brocade VDX --- netmiko/brocade/brocade_nos_ssh.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/netmiko/brocade/brocade_nos_ssh.py b/netmiko/brocade/brocade_nos_ssh.py index 70a45842d..ef5c14c79 100644 --- a/netmiko/brocade/brocade_nos_ssh.py +++ b/netmiko/brocade/brocade_nos_ssh.py @@ -19,3 +19,8 @@ def special_login_handler(self, delay_factor=1): delay_factor = self.select_delay_factor(delay_factor) self.write_channel(self.RETURN) time.sleep(1 * delay_factor) + + def save_config(self): + """Save Config for Brocade VDX.""" + self.send_command('copy running-config startup-config', '[Y/N]') + self.send_command('y') From b3768c1ba09253fbf04e03fd1eb7bde7cca245e3 Mon Sep 17 00:00:00 2001 From: Jay Crotts Date: Mon, 22 Jan 2018 16:40:00 -0800 Subject: [PATCH 31/62] Add save_config for dell devices --- netmiko/dell/dell_force10_ssh.py | 5 ++++- netmiko/dell/dell_powerconnect.py | 4 ++++ netmiko/juniper/juniper_ssh.py | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/netmiko/dell/dell_force10_ssh.py b/netmiko/dell/dell_force10_ssh.py index 3646908fe..012cdc7ca 100644 --- a/netmiko/dell/dell_force10_ssh.py +++ b/netmiko/dell/dell_force10_ssh.py @@ -5,4 +5,7 @@ class DellForce10SSH(CiscoSSHConnection): """Dell Force10 Driver - supports DNOS9.""" - pass + + def save_config(self): + """Save Config on DellForce10SSH""" + self.send_command('copy running-configuration startup-configuration') diff --git a/netmiko/dell/dell_powerconnect.py b/netmiko/dell/dell_powerconnect.py index a464e3d3d..bdbd25483 100644 --- a/netmiko/dell/dell_powerconnect.py +++ b/netmiko/dell/dell_powerconnect.py @@ -43,6 +43,10 @@ def config_mode(self, config_command='config'): """Enter configuration mode.""" return super(DellPowerConnectSSH, self).config_mode(config_command=config_command) + def save_config(self): + """Save Config on DellPowerConnectBase""" + self.send_command('copy running-config startup-config') + class DellPowerConnectSSH(DellPowerConnectBase): """Dell PowerConnect Driver. diff --git a/netmiko/juniper/juniper_ssh.py b/netmiko/juniper/juniper_ssh.py index 7acc1fb04..6722e114f 100644 --- a/netmiko/juniper/juniper_ssh.py +++ b/netmiko/juniper/juniper_ssh.py @@ -191,6 +191,7 @@ def save_config(self): self.send_command('write memory') self.send_command(self.RESPONSE_RETURN) + class JuniperFileTransfer(BaseFileTransfer): """Juniper SCP File Transfer driver.""" def __init__(self, ssh_conn, source_file, dest_file, file_system="/var/tmp", direction='put'): From 6371841871a800afff2847508cf93a37d1931996 Mon Sep 17 00:00:00 2001 From: Jay Crotts Date: Mon, 22 Jan 2018 16:48:56 -0800 Subject: [PATCH 32/62] Add save_config for huawei --- netmiko/huawei/huawei_ssh.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/netmiko/huawei/huawei_ssh.py b/netmiko/huawei/huawei_ssh.py index b056b3e05..b5dedddb1 100644 --- a/netmiko/huawei/huawei_ssh.py +++ b/netmiko/huawei/huawei_ssh.py @@ -81,6 +81,10 @@ def set_base_prompt(self, pri_prompt_terminator='>', alt_prompt_terminator=']', return self.base_prompt + def save_config(self): + """ Save Config for HuaweiSSH""" + self.send_command('save') + class HuaweiVrpv8SSH(HuaweiSSH): From 0f70a956d8e24065f7cd7c0669dbe7e4794e18be Mon Sep 17 00:00:00 2001 From: Jay Crotts Date: Mon, 22 Jan 2018 16:53:45 -0800 Subject: [PATCH 33/62] Add save_config for mellanox_ssh --- netmiko/mellanox/mellanox_ssh.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/netmiko/mellanox/mellanox_ssh.py b/netmiko/mellanox/mellanox_ssh.py index a817b2f45..4ae18315c 100644 --- a/netmiko/mellanox/mellanox_ssh.py +++ b/netmiko/mellanox/mellanox_ssh.py @@ -47,3 +47,10 @@ def exit_config_mode(self, exit_config='exit', pattern='#'): raise ValueError("Failed to exit configuration mode") log.debug("exit_config_mode: {0}".format(output)) return output + + def save_config(self): + """Save Config on Mellanox devices Enters and Leaves Config Mode""" + if not self.check_config_mode(): + self.config_mode() + self.send_command('configuration write') + self.exit_config_mode() From ef69e69b83ee7d39bc71b58132c62d25ae2c14a1 Mon Sep 17 00:00:00 2001 From: Jay Crotts Date: Mon, 22 Jan 2018 17:09:34 -0800 Subject: [PATCH 34/62] Add save_config wrapper for paloalto --- netmiko/paloalto/paloalto_panos_ssh.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/netmiko/paloalto/paloalto_panos_ssh.py b/netmiko/paloalto/paloalto_panos_ssh.py index 8dc0b07e2..86e0bbbde 100644 --- a/netmiko/paloalto/paloalto_panos_ssh.py +++ b/netmiko/paloalto/paloalto_panos_ssh.py @@ -147,3 +147,9 @@ def send_command(self, *args, **kwargs): """Palo Alto requires an extra delay""" kwargs['delay_factor'] = kwargs.get('delay_factor', 2.5) return super(PaloAltoPanosSSH, self).send_command(*args, **kwargs) + + def save_config(self, force=False, partial=False, device_and_network=False, + policy_and_objects=False, vsys='', no_vsys=False, delay_factor=.1): + """Wrapper arround commit for API Consistency""" + return self.commit(self, force, partial, device_and_network, + policy_and_objects, vsys, delay_factor) From b686810493534ce6eec6878946c0fce6a65e9081 Mon Sep 17 00:00:00 2001 From: Jay Crotts Date: Tue, 23 Jan 2018 11:05:02 -0800 Subject: [PATCH 35/62] Add save_config Wrapper for vyos --- netmiko/vyos/vyos_ssh.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/netmiko/vyos/vyos_ssh.py b/netmiko/vyos/vyos_ssh.py index ce8807362..eb8bb1c11 100644 --- a/netmiko/vyos/vyos_ssh.py +++ b/netmiko/vyos/vyos_ssh.py @@ -96,3 +96,7 @@ def send_config_set(self, config_commands=None, exit_config_mode=False, delay_fa strip_prompt=strip_prompt, strip_command=strip_command, config_mode_command=config_mode_command) + + def save_config(self, comment='', delay_factor=.1): + """Save Config Wrapper for VyOS""" + return self.commit(self, comment, delay_factor) From 1d297fde51bf10d53e05f8d42a58a425275e3128 Mon Sep 17 00:00:00 2001 From: Jay Crotts Date: Tue, 23 Jan 2018 11:17:22 -0800 Subject: [PATCH 36/62] Add save_config for alcatel --- netmiko/alcatel/alcatel_aos_ssh.py | 4 ++++ netmiko/alcatel/alcatel_sros_ssh.py | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/netmiko/alcatel/alcatel_aos_ssh.py b/netmiko/alcatel/alcatel_aos_ssh.py index 4c9432f83..d744bb0c4 100644 --- a/netmiko/alcatel/alcatel_aos_ssh.py +++ b/netmiko/alcatel/alcatel_aos_ssh.py @@ -38,3 +38,7 @@ def config_mode(self, *args, **kwargs): def exit_config_mode(self, *args, **kwargs): """No config mode on AOS""" return '' + + def save_config(self): + """Save Config for Alcatel Aos""" + return self.send_command('write memory flash-synchro') diff --git a/netmiko/alcatel/alcatel_sros_ssh.py b/netmiko/alcatel/alcatel_sros_ssh.py index 0fcf40d91..f7e20e747 100644 --- a/netmiko/alcatel/alcatel_sros_ssh.py +++ b/netmiko/alcatel/alcatel_sros_ssh.py @@ -42,3 +42,7 @@ def check_config_mode(self, check_string='config', pattern='#'): """ Checks if the device is in configuration mode or not. """ return super(AlcatelSrosSSH, self).check_config_mode(check_string=check_string, pattern=pattern) + + def save_config(self): + """Not Implemented""" + raise NotImplementedError From 68da101f5a74e394c68f6fa12f2c10d4460dd5f3 Mon Sep 17 00:00:00 2001 From: Jay Crotts Date: Tue, 23 Jan 2018 11:23:18 -0800 Subject: [PATCH 37/62] Add output return statements --- netmiko/brocade/brocade_nos_ssh.py | 5 +++-- netmiko/cisco/cisco_asa_ssh.py | 6 +++--- netmiko/cisco/cisco_ios.py | 5 +++-- netmiko/cisco/cisco_nxos_ssh.py | 5 +++-- netmiko/cisco/cisco_s300.py | 5 +++-- netmiko/cisco/cisco_tp_tcce.py | 1 + netmiko/cisco/cisco_wlc_ssh.py | 5 +++-- netmiko/cisco/cisco_xr_ssh.py | 2 +- netmiko/dell/dell_force10_ssh.py | 2 +- netmiko/dell/dell_powerconnect.py | 2 +- netmiko/hp/hp_comware_ssh.py | 5 +++-- netmiko/hp/hp_procurve_ssh.py | 4 ++-- netmiko/huawei/huawei_ssh.py | 2 +- netmiko/juniper/juniper_ssh.py | 5 +++-- netmiko/mellanox/mellanox_ssh.py | 4 ++-- 15 files changed, 33 insertions(+), 25 deletions(-) diff --git a/netmiko/brocade/brocade_nos_ssh.py b/netmiko/brocade/brocade_nos_ssh.py index ef5c14c79..6907c4450 100644 --- a/netmiko/brocade/brocade_nos_ssh.py +++ b/netmiko/brocade/brocade_nos_ssh.py @@ -22,5 +22,6 @@ def special_login_handler(self, delay_factor=1): def save_config(self): """Save Config for Brocade VDX.""" - self.send_command('copy running-config startup-config', '[Y/N]') - self.send_command('y') + output = self.send_command('copy running-config startup-config', '[Y/N]') + output += self.send_command('y') + return output \ No newline at end of file diff --git a/netmiko/cisco/cisco_asa_ssh.py b/netmiko/cisco/cisco_asa_ssh.py index 9990bd5ce..5e87bbbe3 100644 --- a/netmiko/cisco/cisco_asa_ssh.py +++ b/netmiko/cisco/cisco_asa_ssh.py @@ -107,9 +107,9 @@ def save_config(self): """Saves Config Using Copy Run Start""" self.enable() self.config_mode() - self.send_command(command_string='write memory') - self.send_command_timing(command_string=self.RESPONSE_RETURN) - + output = self.send_command(command_string='write memory') + output += self.send_command_timing(command_string=self.RESPONSE_RETURN) + return output class CiscoAsaFileTransfer(CiscoFileTransfer): """Cisco ASA SCP File Transfer driver.""" diff --git a/netmiko/cisco/cisco_ios.py b/netmiko/cisco/cisco_ios.py index 571989d3c..ee4a8318c 100644 --- a/netmiko/cisco/cisco_ios.py +++ b/netmiko/cisco/cisco_ios.py @@ -24,8 +24,9 @@ def session_preparation(self): def save_config(self): """Saves Config Using Copy Run Start""" self.enable() - self.send_command(command_string='copy running-config startup-config') - self.send_command_timing(self.RESPONSE_RETURN) # enter to confirm + output = self.send_command(command_string='copy running-config startup-config') + output += self.send_command_timing(self.RESPONSE_RETURN) # enter to confirm + return output class CiscoIosSSH(CiscoIosBase): diff --git a/netmiko/cisco/cisco_nxos_ssh.py b/netmiko/cisco/cisco_nxos_ssh.py index 303ba5838..95354b9d8 100644 --- a/netmiko/cisco/cisco_nxos_ssh.py +++ b/netmiko/cisco/cisco_nxos_ssh.py @@ -27,8 +27,9 @@ def normalize_linefeeds(self, a_string): def save_config(self): """Saves Config Using Copy Run Start""" self.enable() - self.send_command('copy running-config startup-config') - self.send_command_timing(self.RESPONSE_RETURN) # enter to confirm + output = self.send_command('copy running-config startup-config') + output += self.send_command_timing(self.RESPONSE_RETURN) # enter to confirm + return output class CiscoNxosFileTransfer(CiscoFileTransfer): diff --git a/netmiko/cisco/cisco_s300.py b/netmiko/cisco/cisco_s300.py index c47d81982..b32effde8 100644 --- a/netmiko/cisco/cisco_s300.py +++ b/netmiko/cisco/cisco_s300.py @@ -25,5 +25,6 @@ def session_preparation(self): def save_config(self): """ Saves config """ self.enable() - self.send_command(command_string='write', expect_string='[Yes') - self.send_command('Yes') + output = self.send_command(command_string='write', expect_string='[Yes') + output += self.send_command('Yes') + return output diff --git a/netmiko/cisco/cisco_tp_tcce.py b/netmiko/cisco/cisco_tp_tcce.py index 30509bb0e..e779dac50 100644 --- a/netmiko/cisco/cisco_tp_tcce.py +++ b/netmiko/cisco/cisco_tp_tcce.py @@ -87,4 +87,5 @@ def send_command(self, *args, **kwargs): return output def save_config(self): + """Not Implemented""" raise NotImplementedError diff --git a/netmiko/cisco/cisco_wlc_ssh.py b/netmiko/cisco/cisco_wlc_ssh.py index e128dd503..6b656306f 100644 --- a/netmiko/cisco/cisco_wlc_ssh.py +++ b/netmiko/cisco/cisco_wlc_ssh.py @@ -162,5 +162,6 @@ def send_config_set(self, config_commands=None, exit_config_mode=True, delay_fac def save_config(self): """ Saves config """ self.exit_config_mode() # need to be in root prompt to save config on WLC - self.send_command(command_string='save config', expect_string='(y/n)') - self.send_command('y') + output = self.send_command(command_string='save config', expect_string='(y/n)') + output += self.send_command('y') + return output diff --git a/netmiko/cisco/cisco_xr_ssh.py b/netmiko/cisco/cisco_xr_ssh.py index 25788dc85..02c864493 100644 --- a/netmiko/cisco/cisco_xr_ssh.py +++ b/netmiko/cisco/cisco_xr_ssh.py @@ -128,4 +128,4 @@ def exit_config_mode(self, exit_config='end'): def save_config(self, confirm=False, confirm_delay=None, comment='', label='', delay_factor=1): """Saves current config, calls self.commit() if it exists""" - self.commit(self, confirm, confirm_delay, comment, label, delay_factor) + return self.commit(self, confirm, confirm_delay, comment, label, delay_factor) diff --git a/netmiko/dell/dell_force10_ssh.py b/netmiko/dell/dell_force10_ssh.py index 012cdc7ca..5326736ac 100644 --- a/netmiko/dell/dell_force10_ssh.py +++ b/netmiko/dell/dell_force10_ssh.py @@ -8,4 +8,4 @@ class DellForce10SSH(CiscoSSHConnection): def save_config(self): """Save Config on DellForce10SSH""" - self.send_command('copy running-configuration startup-configuration') + return self.send_command('copy running-configuration startup-configuration') diff --git a/netmiko/dell/dell_powerconnect.py b/netmiko/dell/dell_powerconnect.py index bdbd25483..8188b95e4 100644 --- a/netmiko/dell/dell_powerconnect.py +++ b/netmiko/dell/dell_powerconnect.py @@ -45,7 +45,7 @@ def config_mode(self, config_command='config'): def save_config(self): """Save Config on DellPowerConnectBase""" - self.send_command('copy running-config startup-config') + return self.send_command('copy running-config startup-config') class DellPowerConnectSSH(DellPowerConnectBase): diff --git a/netmiko/hp/hp_comware_ssh.py b/netmiko/hp/hp_comware_ssh.py index 151cc60e1..be2a1fd87 100644 --- a/netmiko/hp/hp_comware_ssh.py +++ b/netmiko/hp/hp_comware_ssh.py @@ -81,5 +81,6 @@ def save_config(self): """Save Config using write memory.""" if not self.check_enable_mode(): self.enable() - self.send_command('save', '[Y/N]') - self.send_command('y') + output = self.send_command('save', '[Y/N]') + output += self.send_command('y') + return output \ No newline at end of file diff --git a/netmiko/hp/hp_procurve_ssh.py b/netmiko/hp/hp_procurve_ssh.py index 866822e83..689f46256 100644 --- a/netmiko/hp/hp_procurve_ssh.py +++ b/netmiko/hp/hp_procurve_ssh.py @@ -76,6 +76,6 @@ def cleanup(self): def save_config(self): """Save Config using write memory.""" if self.check_config_mode(): - self.send_command('write memory') + return self.send_command('write memory') else: - self.send_config_set(['write memory']) + return self.send_config_set(['write memory']) diff --git a/netmiko/huawei/huawei_ssh.py b/netmiko/huawei/huawei_ssh.py index b5dedddb1..a96f279ed 100644 --- a/netmiko/huawei/huawei_ssh.py +++ b/netmiko/huawei/huawei_ssh.py @@ -83,7 +83,7 @@ def set_base_prompt(self, pri_prompt_terminator='>', alt_prompt_terminator=']', def save_config(self): """ Save Config for HuaweiSSH""" - self.send_command('save') + return self.send_command('save') class HuaweiVrpv8SSH(HuaweiSSH): diff --git a/netmiko/juniper/juniper_ssh.py b/netmiko/juniper/juniper_ssh.py index 6722e114f..0bc5532f4 100644 --- a/netmiko/juniper/juniper_ssh.py +++ b/netmiko/juniper/juniper_ssh.py @@ -188,8 +188,9 @@ def strip_context_items(self, a_string): def save_config(self): """Saves Config in Automatic or Manual Mode""" - self.send_command('write memory') - self.send_command(self.RESPONSE_RETURN) + output = self.send_command('write memory') + output += self.send_command(self.RESPONSE_RETURN) + return output class JuniperFileTransfer(BaseFileTransfer): diff --git a/netmiko/mellanox/mellanox_ssh.py b/netmiko/mellanox/mellanox_ssh.py index 4ae18315c..c73a1fe62 100644 --- a/netmiko/mellanox/mellanox_ssh.py +++ b/netmiko/mellanox/mellanox_ssh.py @@ -52,5 +52,5 @@ def save_config(self): """Save Config on Mellanox devices Enters and Leaves Config Mode""" if not self.check_config_mode(): self.config_mode() - self.send_command('configuration write') - self.exit_config_mode() + output = self.send_command('configuration write') + output += self.exit_config_mode() From 965addd05ffb6aaec8ee976148b9db1c745b484f Mon Sep 17 00:00:00 2001 From: Jay Crotts Date: Tue, 23 Jan 2018 11:28:45 -0800 Subject: [PATCH 38/62] Fix newlines --- netmiko/brocade/brocade_nos_ssh.py | 2 +- netmiko/cisco/cisco_asa_ssh.py | 1 + netmiko/hp/hp_comware_ssh.py | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/netmiko/brocade/brocade_nos_ssh.py b/netmiko/brocade/brocade_nos_ssh.py index 6907c4450..5b192b12c 100644 --- a/netmiko/brocade/brocade_nos_ssh.py +++ b/netmiko/brocade/brocade_nos_ssh.py @@ -24,4 +24,4 @@ def save_config(self): """Save Config for Brocade VDX.""" output = self.send_command('copy running-config startup-config', '[Y/N]') output += self.send_command('y') - return output \ No newline at end of file + return output diff --git a/netmiko/cisco/cisco_asa_ssh.py b/netmiko/cisco/cisco_asa_ssh.py index 5e87bbbe3..86013d122 100644 --- a/netmiko/cisco/cisco_asa_ssh.py +++ b/netmiko/cisco/cisco_asa_ssh.py @@ -111,6 +111,7 @@ def save_config(self): output += self.send_command_timing(command_string=self.RESPONSE_RETURN) return output + class CiscoAsaFileTransfer(CiscoFileTransfer): """Cisco ASA SCP File Transfer driver.""" pass diff --git a/netmiko/hp/hp_comware_ssh.py b/netmiko/hp/hp_comware_ssh.py index be2a1fd87..b2b023300 100644 --- a/netmiko/hp/hp_comware_ssh.py +++ b/netmiko/hp/hp_comware_ssh.py @@ -83,4 +83,4 @@ def save_config(self): self.enable() output = self.send_command('save', '[Y/N]') output += self.send_command('y') - return output \ No newline at end of file + return output From 6d764bc22008fae393a25680615c0c049f2ca973 Mon Sep 17 00:00:00 2001 From: Kirk Byers Date: Tue, 23 Jan 2018 19:26:15 -0800 Subject: [PATCH 39/62] Restructuring some extreme items --- netmiko/extreme/__init__.py | 4 ++-- netmiko/extreme/{extreme_ssh.py => extreme.py} | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) rename netmiko/extreme/{extreme_ssh.py => extreme.py} (95%) diff --git a/netmiko/extreme/__init__.py b/netmiko/extreme/__init__.py index d5ee5d119..94d19aecf 100644 --- a/netmiko/extreme/__init__.py +++ b/netmiko/extreme/__init__.py @@ -1,6 +1,6 @@ from __future__ import unicode_literals -from netmiko.extreme.extreme_ssh import ExtremeSSH -from netmiko.extreme.extreme_ssh import ExtremeTelnet +from netmiko.extreme.extreme import ExtremeSSH +from netmiko.extreme.extreme import ExtremeTelnet from netmiko.extreme.extreme_wing_ssh import ExtremeWingSSH __all__ = ['ExtremeSSH', 'ExtremeWingSSH', 'ExtremeTelnet'] diff --git a/netmiko/extreme/extreme_ssh.py b/netmiko/extreme/extreme.py similarity index 95% rename from netmiko/extreme/extreme_ssh.py rename to netmiko/extreme/extreme.py index 4f64d3d80..e219d08f6 100644 --- a/netmiko/extreme/extreme_ssh.py +++ b/netmiko/extreme/extreme.py @@ -5,7 +5,7 @@ from netmiko.cisco_base_connection import CiscoSSHConnection -class ExtremeSSH(CiscoSSHConnection): +class ExtremeBase(CiscoSSHConnection): """Extreme support. Designed for EXOS >= 15.0 @@ -65,7 +65,11 @@ def exit_config_mode(self, exit_config=''): return '' -class ExtremeTelnet(ExtremeSSH): +class ExtremeSSH(ExtremeBase): + pass + + +class ExtremeTelnet(ExtremeBase): def __init__(self, *args, **kwargs): default_enter = kwargs.get('default_enter') kwargs['default_enter'] = '\r\n' if default_enter is None else default_enter From fd46063a81b4efa1752650686e87441cd9112f4c Mon Sep 17 00:00:00 2001 From: Kirk Byers Date: Tue, 23 Jan 2018 19:30:59 -0800 Subject: [PATCH 40/62] Restructure files --- netmiko/extreme/__init__.py | 4 ++-- netmiko/extreme/{extreme.py => extreme_exos.py} | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename netmiko/extreme/{extreme.py => extreme_exos.py} (100%) diff --git a/netmiko/extreme/__init__.py b/netmiko/extreme/__init__.py index 94d19aecf..1074d9428 100644 --- a/netmiko/extreme/__init__.py +++ b/netmiko/extreme/__init__.py @@ -1,6 +1,6 @@ from __future__ import unicode_literals -from netmiko.extreme.extreme import ExtremeSSH -from netmiko.extreme.extreme import ExtremeTelnet +from netmiko.extreme.extreme_exos import ExtremeSSH +from netmiko.extreme.extreme_exos import ExtremeTelnet from netmiko.extreme.extreme_wing_ssh import ExtremeWingSSH __all__ = ['ExtremeSSH', 'ExtremeWingSSH', 'ExtremeTelnet'] diff --git a/netmiko/extreme/extreme.py b/netmiko/extreme/extreme_exos.py similarity index 100% rename from netmiko/extreme/extreme.py rename to netmiko/extreme/extreme_exos.py From 9d15f725b981d832ba68586724e8da6c1361e61d Mon Sep 17 00:00:00 2001 From: Vinzenz Sinapius Date: Fri, 26 Jan 2018 13:41:17 +0100 Subject: [PATCH 41/62] Fix TypeError --- netmiko/dell/dell_powerconnect.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/netmiko/dell/dell_powerconnect.py b/netmiko/dell/dell_powerconnect.py index a464e3d3d..751119834 100644 --- a/netmiko/dell/dell_powerconnect.py +++ b/netmiko/dell/dell_powerconnect.py @@ -27,7 +27,7 @@ def session_preparation(self): def set_base_prompt(self, pri_prompt_terminator='>', alt_prompt_terminator='#', delay_factor=1): """Sets self.base_prompt: used as delimiter for stripping of trailing prompt in output.""" - prompt = super(DellPowerConnectSSH, self).set_base_prompt( + prompt = super(CiscoSSHConnection, self).set_base_prompt( pri_prompt_terminator=pri_prompt_terminator, alt_prompt_terminator=alt_prompt_terminator, delay_factor=delay_factor) @@ -37,11 +37,11 @@ def set_base_prompt(self, pri_prompt_terminator='>', alt_prompt_terminator='#', def check_config_mode(self, check_string='(config)#'): """Checks if the device is in configuration mode""" - return super(DellPowerConnectSSH, self).check_config_mode(check_string=check_string) + return super(CiscoSSHConnection, self).check_config_mode(check_string=check_string) def config_mode(self, config_command='config'): """Enter configuration mode.""" - return super(DellPowerConnectSSH, self).config_mode(config_command=config_command) + return super(CiscoSSHConnection, self).config_mode(config_command=config_command) class DellPowerConnectSSH(DellPowerConnectBase): From 9f8d2252eceb6997c9507440ec6b8ed607a1bccd Mon Sep 17 00:00:00 2001 From: Vinzenz Sinapius Date: Fri, 26 Jan 2018 13:43:45 +0100 Subject: [PATCH 42/62] Extend username_pattern for DELL PowerConnect --- netmiko/cisco_base_connection.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netmiko/cisco_base_connection.py b/netmiko/cisco_base_connection.py index 567774d41..98d090d13 100644 --- a/netmiko/cisco_base_connection.py +++ b/netmiko/cisco_base_connection.py @@ -63,7 +63,7 @@ def serial_login(self, pri_prompt_terminator=r'#\s*$', alt_prompt_terminator=r'> username_pattern, pwd_pattern, delay_factor, max_loops) def telnet_login(self, pri_prompt_terminator=r'#\s*$', alt_prompt_terminator=r'>\s*$', - username_pattern=r"(?:[Uu]ser:|sername|ogin)", pwd_pattern=r"assword", + username_pattern=r"(?:[Uu]ser:|sername|ogin|User Name)", pwd_pattern=r"assword", delay_factor=1, max_loops=20): """Telnet login. Can be username/password or just password.""" delay_factor = self.select_delay_factor(delay_factor) From 33c2907d8ebb1b8fecfa1d5d559c9e662c8cf200 Mon Sep 17 00:00:00 2001 From: Vinzenz Sinapius Date: Fri, 26 Jan 2018 13:56:35 +0100 Subject: [PATCH 43/62] Fix line length --- netmiko/cisco_base_connection.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/netmiko/cisco_base_connection.py b/netmiko/cisco_base_connection.py index 98d090d13..25574a26a 100644 --- a/netmiko/cisco_base_connection.py +++ b/netmiko/cisco_base_connection.py @@ -63,7 +63,8 @@ def serial_login(self, pri_prompt_terminator=r'#\s*$', alt_prompt_terminator=r'> username_pattern, pwd_pattern, delay_factor, max_loops) def telnet_login(self, pri_prompt_terminator=r'#\s*$', alt_prompt_terminator=r'>\s*$', - username_pattern=r"(?:[Uu]ser:|sername|ogin|User Name)", pwd_pattern=r"assword", + username_pattern=r"(?:[Uu]ser:|sername|ogin|User Name)", + pwd_pattern=r"assword", delay_factor=1, max_loops=20): """Telnet login. Can be username/password or just password.""" delay_factor = self.select_delay_factor(delay_factor) From 35d7b217a1f2197b947fe2b0b2cb36684cbf2806 Mon Sep 17 00:00:00 2001 From: Vinzenz Sinapius Date: Fri, 26 Jan 2018 13:59:55 +0100 Subject: [PATCH 44/62] Delete trailing whitespace --- netmiko/cisco_base_connection.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netmiko/cisco_base_connection.py b/netmiko/cisco_base_connection.py index 25574a26a..24c5056b1 100644 --- a/netmiko/cisco_base_connection.py +++ b/netmiko/cisco_base_connection.py @@ -63,7 +63,7 @@ def serial_login(self, pri_prompt_terminator=r'#\s*$', alt_prompt_terminator=r'> username_pattern, pwd_pattern, delay_factor, max_loops) def telnet_login(self, pri_prompt_terminator=r'#\s*$', alt_prompt_terminator=r'>\s*$', - username_pattern=r"(?:[Uu]ser:|sername|ogin|User Name)", + username_pattern=r"(?:[Uu]ser:|sername|ogin|User Name)", pwd_pattern=r"assword", delay_factor=1, max_loops=20): """Telnet login. Can be username/password or just password.""" From 50abccc387c0a877eb603ca09e35faa4711a8770 Mon Sep 17 00:00:00 2001 From: Kirk Byers Date: Sun, 28 Jan 2018 07:45:11 -0800 Subject: [PATCH 45/62] Arista and Juniper SCP is not fully implemented --- netmiko/ssh_dispatcher.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/netmiko/ssh_dispatcher.py b/netmiko/ssh_dispatcher.py index 5969b89d5..d24d16caa 100644 --- a/netmiko/ssh_dispatcher.py +++ b/netmiko/ssh_dispatcher.py @@ -110,12 +110,12 @@ } FILE_TRANSFER_MAP = { - 'arista_eos': AristaFileTransfer, +# 'arista_eos': AristaFileTransfer, 'cisco_asa': CiscoAsaFileTransfer, 'cisco_ios': CiscoIosFileTransfer, 'cisco_xe': CiscoIosFileTransfer, 'cisco_nxos': CiscoNxosFileTransfer, - 'juniper_junos': JuniperFileTransfer, +# 'juniper_junos': JuniperFileTransfer, } # Also support keys that end in _ssh From d98a0653b000564ad22e1f9806b5676e2f13cbae Mon Sep 17 00:00:00 2001 From: Kirk Byers Date: Sun, 28 Jan 2018 10:01:03 -0800 Subject: [PATCH 46/62] Fix linter errors --- netmiko/ssh_dispatcher.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/netmiko/ssh_dispatcher.py b/netmiko/ssh_dispatcher.py index d24d16caa..de3b5b58e 100644 --- a/netmiko/ssh_dispatcher.py +++ b/netmiko/ssh_dispatcher.py @@ -5,7 +5,8 @@ from netmiko.accedian import AccedianSSH from netmiko.alcatel import AlcatelAosSSH from netmiko.alcatel import AlcatelSrosSSH -from netmiko.arista import AristaSSH, AristaFileTransfer +from netmiko.arista import AristaSSH +# from netmiko.arista import AristaFileTransfer from netmiko.aruba import ArubaSSH from netmiko.avaya import AvayaErsSSH from netmiko.avaya import AvayaVspSSH @@ -35,7 +36,8 @@ from netmiko.fortinet import FortinetSSH from netmiko.hp import HPProcurveSSH, HPComwareSSH from netmiko.huawei import HuaweiSSH, HuaweiVrpv8SSH -from netmiko.juniper import JuniperSSH, JuniperFileTransfer +from netmiko.juniper import JuniperSSH +# from netmiko.juniper import JuniperFileTransfer from netmiko.linux import LinuxSSH from netmiko.mellanox import MellanoxSSH from netmiko.mrv import MrvOptiswitchSSH @@ -110,12 +112,12 @@ } FILE_TRANSFER_MAP = { -# 'arista_eos': AristaFileTransfer, + # 'arista_eos': AristaFileTransfer, 'cisco_asa': CiscoAsaFileTransfer, 'cisco_ios': CiscoIosFileTransfer, 'cisco_xe': CiscoIosFileTransfer, 'cisco_nxos': CiscoNxosFileTransfer, -# 'juniper_junos': JuniperFileTransfer, + # 'juniper_junos': JuniperFileTransfer, } # Also support keys that end in _ssh From 164b6a6c4fe6f68262bd24f30b3bd8308b3adcff Mon Sep 17 00:00:00 2001 From: Kirk Byers Date: Sun, 28 Jan 2018 20:48:26 -0800 Subject: [PATCH 47/62] Updating save config --- netmiko/alcatel/alcatel_aos_ssh.py | 6 +++--- netmiko/arista/arista_ssh.py | 6 ------ netmiko/avaya/avaya_ers_ssh.py | 6 ++---- netmiko/avaya/avaya_vsp_ssh.py | 6 ++---- netmiko/base_connection.py | 4 ++++ netmiko/brocade/brocade_netiron.py | 9 +++------ netmiko/brocade/brocade_nos_ssh.py | 8 ++++---- netmiko/cisco/cisco_asa_ssh.py | 10 +++------- netmiko/cisco/cisco_ios.py | 7 ++----- netmiko/cisco/cisco_nxos_ssh.py | 7 ------- netmiko/cisco/cisco_s300.py | 8 ++------ netmiko/cisco/cisco_wlc_ssh.py | 7 ++----- netmiko/cisco/cisco_xr_ssh.py | 6 +++--- netmiko/cisco_base_connection.py | 16 ++++++++++++++++ netmiko/dell/dell_force10_ssh.py | 6 +++--- netmiko/dell/dell_powerconnect.py | 4 ---- 16 files changed, 49 insertions(+), 67 deletions(-) diff --git a/netmiko/alcatel/alcatel_aos_ssh.py b/netmiko/alcatel/alcatel_aos_ssh.py index d744bb0c4..9c2c58c1f 100644 --- a/netmiko/alcatel/alcatel_aos_ssh.py +++ b/netmiko/alcatel/alcatel_aos_ssh.py @@ -39,6 +39,6 @@ def exit_config_mode(self, *args, **kwargs): """No config mode on AOS""" return '' - def save_config(self): - """Save Config for Alcatel Aos""" - return self.send_command('write memory flash-synchro') + def save_config(self, cmd='write memory flash-synchro', confirm=False): + """Save Config""" + return super(AlcatelAosSSH, self).save_config(cmd=cmd, confirm=confirm) diff --git a/netmiko/arista/arista_ssh.py b/netmiko/arista/arista_ssh.py index a71f2a945..f0605db34 100644 --- a/netmiko/arista/arista_ssh.py +++ b/netmiko/arista/arista_ssh.py @@ -35,12 +35,6 @@ def check_config_mode(self, check_string=')#', pattern=''): log.debug("check_config_mode: {0}".format(repr(output))) return check_string in output - def save_config(self): - """Saves Running Config using default file name.""" - self.enable() - self.send_command('copy running-config startup-config') - self.send_command(self.RESPONSE_RETURN) - class AristaFileTransfer(CiscoFileTransfer): """Arista SCP File Transfer driver.""" diff --git a/netmiko/avaya/avaya_ers_ssh.py b/netmiko/avaya/avaya_ers_ssh.py index c81be1cb2..f234b78dc 100644 --- a/netmiko/avaya/avaya_ers_ssh.py +++ b/netmiko/avaya/avaya_ers_ssh.py @@ -37,8 +37,6 @@ def special_login_handler(self, delay_factor=1): time.sleep(1 * delay_factor) i += 1 - def save_config(self): + def save_config(self, cmd='save config', confirm=False): """Save Config""" - if not self.check_enable_mode(): - self.enable() - self.send_command('save config') + return super(AvayaErsSSH, self).save_config(cmd=cmd, confirm=confirm) diff --git a/netmiko/avaya/avaya_vsp_ssh.py b/netmiko/avaya/avaya_vsp_ssh.py index 2fcdd4b19..a5cade6c2 100644 --- a/netmiko/avaya/avaya_vsp_ssh.py +++ b/netmiko/avaya/avaya_vsp_ssh.py @@ -16,8 +16,6 @@ def session_preparation(self): time.sleep(.3 * self.global_delay_factor) self.clear_buffer() - def save_config(self): + def save_config(self, cmd='save config', confirm=False): """Save Config""" - if not self.check_enable_mode(): - self.enable() - self.send_command('save config') + return super(AvayaVspSSH, self).save_config(cmd=cmd, confirm=confirm) diff --git a/netmiko/base_connection.py b/netmiko/base_connection.py index 6c392cd51..33c62b15b 100644 --- a/netmiko/base_connection.py +++ b/netmiko/base_connection.py @@ -1219,6 +1219,10 @@ def commit(self): """Commit method for platforms that support this.""" raise AttributeError("Network device does not support 'commit()' method") + def save_config(self, cmd='', confirm=True, confirm_response=''): + """Not Implemented""" + raise NotImplementedError + class TelnetConnection(BaseConnection): pass diff --git a/netmiko/brocade/brocade_netiron.py b/netmiko/brocade/brocade_netiron.py index ddebef1b9..153879cdb 100644 --- a/netmiko/brocade/brocade_netiron.py +++ b/netmiko/brocade/brocade_netiron.py @@ -3,12 +3,9 @@ class BrocadeNetironBase(CiscoSSHConnection): - - def save_config(self): - """Save Config for BrocadeNetironBase""" - if not self.check_enable_mode(): - self.enable() - self.send_command('write memory') + def save_config(self, cmd='write memory', confirm=False): + """Save Config""" + return super(BrocadeNetironBase, self).save_config(cmd=cmd, confirm=confirm) class BrocadeNetironSSH(BrocadeNetironBase): diff --git a/netmiko/brocade/brocade_nos_ssh.py b/netmiko/brocade/brocade_nos_ssh.py index 5b192b12c..4eb315b31 100644 --- a/netmiko/brocade/brocade_nos_ssh.py +++ b/netmiko/brocade/brocade_nos_ssh.py @@ -20,8 +20,8 @@ def special_login_handler(self, delay_factor=1): self.write_channel(self.RETURN) time.sleep(1 * delay_factor) - def save_config(self): + def save_config(self, cmd='copy running-config startup-config', confirm=True, + confirm_response='y'): """Save Config for Brocade VDX.""" - output = self.send_command('copy running-config startup-config', '[Y/N]') - output += self.send_command('y') - return output + return super(BrocadeNosSSH, self).save_config(cmd=cmd, confirm=confirm, + confirm_response=confirm_response) diff --git a/netmiko/cisco/cisco_asa_ssh.py b/netmiko/cisco/cisco_asa_ssh.py index 86013d122..ce46bf6c2 100644 --- a/netmiko/cisco/cisco_asa_ssh.py +++ b/netmiko/cisco/cisco_asa_ssh.py @@ -103,13 +103,9 @@ def asa_login(self): self.write_channel("login" + self.RETURN) i += 1 - def save_config(self): - """Saves Config Using Copy Run Start""" - self.enable() - self.config_mode() - output = self.send_command(command_string='write memory') - output += self.send_command_timing(command_string=self.RESPONSE_RETURN) - return output + def save_config(self, cmd='write mem', confirm=False): + """Saves Config""" + return super(CiscoAsaSSH, self).save_config(cmd=cmd, confirm=confirm) class CiscoAsaFileTransfer(CiscoFileTransfer): diff --git a/netmiko/cisco/cisco_ios.py b/netmiko/cisco/cisco_ios.py index ee4a8318c..34d30c615 100644 --- a/netmiko/cisco/cisco_ios.py +++ b/netmiko/cisco/cisco_ios.py @@ -21,12 +21,9 @@ def session_preparation(self): time.sleep(.3 * self.global_delay_factor) self.clear_buffer() - def save_config(self): + def save_config(self, cmd='write mem', confirm=False): """Saves Config Using Copy Run Start""" - self.enable() - output = self.send_command(command_string='copy running-config startup-config') - output += self.send_command_timing(self.RESPONSE_RETURN) # enter to confirm - return output + return super(CiscoIosBase, self).save_config(cmd=cmd, confirm=confirm) class CiscoIosSSH(CiscoIosBase): diff --git a/netmiko/cisco/cisco_nxos_ssh.py b/netmiko/cisco/cisco_nxos_ssh.py index 95354b9d8..f4effc620 100644 --- a/netmiko/cisco/cisco_nxos_ssh.py +++ b/netmiko/cisco/cisco_nxos_ssh.py @@ -24,13 +24,6 @@ def normalize_linefeeds(self, a_string): newline = re.compile(r'(\r\r\n|\r\n)') return newline.sub(self.RESPONSE_RETURN, a_string).replace('\r', '') - def save_config(self): - """Saves Config Using Copy Run Start""" - self.enable() - output = self.send_command('copy running-config startup-config') - output += self.send_command_timing(self.RESPONSE_RETURN) # enter to confirm - return output - class CiscoNxosFileTransfer(CiscoFileTransfer): """Cisco NXOS SCP File Transfer driver.""" diff --git a/netmiko/cisco/cisco_s300.py b/netmiko/cisco/cisco_s300.py index b32effde8..f183f8a3b 100644 --- a/netmiko/cisco/cisco_s300.py +++ b/netmiko/cisco/cisco_s300.py @@ -22,9 +22,5 @@ def session_preparation(self): # Clear the read buffer time.sleep(.3 * self.global_delay_factor) - def save_config(self): - """ Saves config """ - self.enable() - output = self.send_command(command_string='write', expect_string='[Yes') - output += self.send_command('Yes') - return output + def save_config(self, cmd='write memory', confirm=True, confirm_response='Y'): + return super(CiscoS300SSH, self).save_config(cmd=cmd, confirm=confirm) diff --git a/netmiko/cisco/cisco_wlc_ssh.py b/netmiko/cisco/cisco_wlc_ssh.py index 6b656306f..658958857 100644 --- a/netmiko/cisco/cisco_wlc_ssh.py +++ b/netmiko/cisco/cisco_wlc_ssh.py @@ -160,8 +160,5 @@ def send_config_set(self, config_commands=None, exit_config_mode=True, delay_fac return output def save_config(self): - """ Saves config """ - self.exit_config_mode() # need to be in root prompt to save config on WLC - output = self.send_command(command_string='save config', expect_string='(y/n)') - output += self.send_command('y') - return output + """Not Implemented""" + raise NotImplementedError diff --git a/netmiko/cisco/cisco_xr_ssh.py b/netmiko/cisco/cisco_xr_ssh.py index 02c864493..2c2df3ba5 100644 --- a/netmiko/cisco/cisco_xr_ssh.py +++ b/netmiko/cisco/cisco_xr_ssh.py @@ -126,6 +126,6 @@ def exit_config_mode(self, exit_config='end'): raise ValueError("Failed to exit configuration mode") return output - def save_config(self, confirm=False, confirm_delay=None, comment='', label='', delay_factor=1): - """Saves current config, calls self.commit() if it exists""" - return self.commit(self, confirm, confirm_delay, comment, label, delay_factor) + def save_config(self): + """Not Implemented (use commit() method)""" + raise NotImplementedError diff --git a/netmiko/cisco_base_connection.py b/netmiko/cisco_base_connection.py index 567774d41..44725ecfc 100644 --- a/netmiko/cisco_base_connection.py +++ b/netmiko/cisco_base_connection.py @@ -162,6 +162,22 @@ def _autodetect_fs(self, cmd='dir', pattern=r'Directory of (.*)/'): raise ValueError("An error occurred in dynamically determining remote file " "system: {} {}".format(cmd, output)) + def save_config(self, cmd='copy running-config startup-config', confirm=False, + confirm_response=''): + """Saves Config.""" + self.enable() + if confirm: + output = self.send_command_timing(command_string=cmd) + if confirm_response: + output += self.send_command_timing(confirm_response) + else: + # Send enter by default + output += self.send_command_timing(self.RETURN) + else: + # Some devices are slow so match on trailing-prompt if you can + output = self.send_command(command_string=cmd) + return output + class CiscoSSHConnection(CiscoBaseConnection): pass diff --git a/netmiko/dell/dell_force10_ssh.py b/netmiko/dell/dell_force10_ssh.py index 5326736ac..0481b9ab1 100644 --- a/netmiko/dell/dell_force10_ssh.py +++ b/netmiko/dell/dell_force10_ssh.py @@ -6,6 +6,6 @@ class DellForce10SSH(CiscoSSHConnection): """Dell Force10 Driver - supports DNOS9.""" - def save_config(self): - """Save Config on DellForce10SSH""" - return self.send_command('copy running-configuration startup-configuration') + def save_config(self, cmd='copy running-configuration startup-configuration', confirm=False): + """Saves Config""" + return super(DellForce10SSH, self).save_config(cmd=cmd, confirm=confirm) diff --git a/netmiko/dell/dell_powerconnect.py b/netmiko/dell/dell_powerconnect.py index 8188b95e4..a464e3d3d 100644 --- a/netmiko/dell/dell_powerconnect.py +++ b/netmiko/dell/dell_powerconnect.py @@ -43,10 +43,6 @@ def config_mode(self, config_command='config'): """Enter configuration mode.""" return super(DellPowerConnectSSH, self).config_mode(config_command=config_command) - def save_config(self): - """Save Config on DellPowerConnectBase""" - return self.send_command('copy running-config startup-config') - class DellPowerConnectSSH(DellPowerConnectBase): """Dell PowerConnect Driver. From 2ec5c60e6b7da69890dba8e38f0dbb517c77514d Mon Sep 17 00:00:00 2001 From: Kirk Byers Date: Mon, 29 Jan 2018 21:18:35 -0800 Subject: [PATCH 48/62] Updating HP Comware/ProCurve --- netmiko/hp/hp_comware_ssh.py | 10 +++------- netmiko/hp/hp_procurve_ssh.py | 9 +++------ 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/netmiko/hp/hp_comware_ssh.py b/netmiko/hp/hp_comware_ssh.py index b2b023300..76d867084 100644 --- a/netmiko/hp/hp_comware_ssh.py +++ b/netmiko/hp/hp_comware_ssh.py @@ -77,10 +77,6 @@ def check_enable_mode(self, check_string=']'): """enable mode on Comware is system-view.""" return self.check_config_mode(check_string=check_string) - def save_config(self): - """Save Config using write memory.""" - if not self.check_enable_mode(): - self.enable() - output = self.send_command('save', '[Y/N]') - output += self.send_command('y') - return output + def save_config(self, cmd='save force', confirm=False): + """Save Config.""" + return super(HPComwareSSH, self).save_config(cmd=cmd, confirm=confirm) diff --git a/netmiko/hp/hp_procurve_ssh.py b/netmiko/hp/hp_procurve_ssh.py index 689f46256..fadaa6a59 100644 --- a/netmiko/hp/hp_procurve_ssh.py +++ b/netmiko/hp/hp_procurve_ssh.py @@ -73,9 +73,6 @@ def cleanup(self): break count += 1 - def save_config(self): - """Save Config using write memory.""" - if self.check_config_mode(): - return self.send_command('write memory') - else: - return self.send_config_set(['write memory']) + def save_config(self, cmd='write memory', confirm=False): + """Save Config.""" + return super(HPProcurveSSH, self).save_config(cmd=cmd, confirm=confirm) From 48f16e1a06049ad14d91f7f4ea9ab5470e47f7d1 Mon Sep 17 00:00:00 2001 From: Kirk Byers Date: Tue, 30 Jan 2018 11:54:54 -0800 Subject: [PATCH 49/62] Fixing some super class references --- netmiko/dell/dell_powerconnect.py | 12 ++++++------ netmiko/extreme/extreme_exos.py | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/netmiko/dell/dell_powerconnect.py b/netmiko/dell/dell_powerconnect.py index 751119834..f85ea22a4 100644 --- a/netmiko/dell/dell_powerconnect.py +++ b/netmiko/dell/dell_powerconnect.py @@ -27,21 +27,21 @@ def session_preparation(self): def set_base_prompt(self, pri_prompt_terminator='>', alt_prompt_terminator='#', delay_factor=1): """Sets self.base_prompt: used as delimiter for stripping of trailing prompt in output.""" - prompt = super(CiscoSSHConnection, self).set_base_prompt( - pri_prompt_terminator=pri_prompt_terminator, - alt_prompt_terminator=alt_prompt_terminator, - delay_factor=delay_factor) + prompt = super(DellPowerConnectBase, self).set_base_prompt( + pri_prompt_terminator=pri_prompt_terminator, + alt_prompt_terminator=alt_prompt_terminator, + delay_factor=delay_factor) prompt = prompt.strip() self.base_prompt = prompt return self.base_prompt def check_config_mode(self, check_string='(config)#'): """Checks if the device is in configuration mode""" - return super(CiscoSSHConnection, self).check_config_mode(check_string=check_string) + return super(DellPowerConnectBase, self).check_config_mode(check_string=check_string) def config_mode(self, config_command='config'): """Enter configuration mode.""" - return super(CiscoSSHConnection, self).config_mode(config_command=config_command) + return super(DellPowerConnectBase, self).config_mode(config_command=config_command) class DellPowerConnectSSH(DellPowerConnectBase): diff --git a/netmiko/extreme/extreme_exos.py b/netmiko/extreme/extreme_exos.py index e219d08f6..120b44cd6 100644 --- a/netmiko/extreme/extreme_exos.py +++ b/netmiko/extreme/extreme_exos.py @@ -33,7 +33,7 @@ def set_base_prompt(self, *args, **kwargs): * testhost.4 # * testhost.5 # """ - cur_base_prompt = super(ExtremeSSH, self).set_base_prompt(*args, **kwargs) + cur_base_prompt = super(ExtremeBase, self).set_base_prompt(*args, **kwargs) # Strip off any leading * or whitespace chars; strip off trailing period and digits match = re.search(r'[\*\s]*(.*)\.\d+', cur_base_prompt) if match: @@ -50,7 +50,7 @@ def send_command(self, *args, **kwargs): # refresh self.base_prompt self.set_base_prompt() - return super(ExtremeSSH, self).send_command(*args, **kwargs) + return super(ExtremeBase, self).send_command(*args, **kwargs) def config_mode(self, config_command=''): """No configuration mode on Extreme.""" @@ -58,7 +58,7 @@ def config_mode(self, config_command=''): def check_config_mode(self, check_string='#'): """Checks whether in configuration mode. Returns a boolean.""" - return super(ExtremeSSH, self).check_config_mode(check_string=check_string) + return super(ExtremeBase, self).check_config_mode(check_string=check_string) def exit_config_mode(self, exit_config=''): """No configuration mode on Extreme.""" From d83047a5ff74b06af8643b5c03a37ece0ff93d37 Mon Sep 17 00:00:00 2001 From: Kirk Byers Date: Thu, 1 Feb 2018 11:11:47 -0800 Subject: [PATCH 50/62] Update auto detect to handle Nokia rebranding --- netmiko/ssh_autodetect.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netmiko/ssh_autodetect.py b/netmiko/ssh_autodetect.py index 288386500..efd7c466c 100644 --- a/netmiko/ssh_autodetect.py +++ b/netmiko/ssh_autodetect.py @@ -56,7 +56,7 @@ "dispatch": "_autodetect_std", }, 'alcatel_sros': { - "cmd": "show version | match ALCATEL", + "cmd": "show version | match TiMOS", "search_patterns": ["TiMOS"], "priority": 99, "dispatch": "_autodetect_std", From 2093a7b0bb91dc6208d09185aa88251209f4c814 Mon Sep 17 00:00:00 2001 From: Kirk Byers Date: Sat, 3 Feb 2018 09:11:47 -0800 Subject: [PATCH 51/62] Restructuring save_config method --- netmiko/juniper/juniper_ssh.py | 9 ++++----- netmiko/mellanox/mellanox_ssh.py | 10 ++++++---- netmiko/paloalto/paloalto_panos_ssh.py | 8 +++----- netmiko/vyos/vyos_ssh.py | 6 +++--- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/netmiko/juniper/juniper_ssh.py b/netmiko/juniper/juniper_ssh.py index 0bc5532f4..00c9e8687 100644 --- a/netmiko/juniper/juniper_ssh.py +++ b/netmiko/juniper/juniper_ssh.py @@ -186,11 +186,10 @@ def strip_context_items(self, a_string): return self.RESPONSE_RETURN.join(response_list[:-1]) return a_string - def save_config(self): - """Saves Config in Automatic or Manual Mode""" - output = self.send_command('write memory') - output += self.send_command(self.RESPONSE_RETURN) - return output + def save_config(self, cmd='', confirm=True, confirm_response=''): + """Not Implemented""" + raise NotImplementedError + class JuniperFileTransfer(BaseFileTransfer): diff --git a/netmiko/mellanox/mellanox_ssh.py b/netmiko/mellanox/mellanox_ssh.py index c73a1fe62..3f9aa5f59 100644 --- a/netmiko/mellanox/mellanox_ssh.py +++ b/netmiko/mellanox/mellanox_ssh.py @@ -48,9 +48,11 @@ def exit_config_mode(self, exit_config='exit', pattern='#'): log.debug("exit_config_mode: {0}".format(output)) return output - def save_config(self): + def save_config(self, cmd='configuration write', confirm=False, + confirm_response=''): """Save Config on Mellanox devices Enters and Leaves Config Mode""" - if not self.check_config_mode(): - self.config_mode() - output = self.send_command('configuration write') + output = self.enable() + output += self.config_mode() + output += self.send_command(cmd) output += self.exit_config_mode() + return output diff --git a/netmiko/paloalto/paloalto_panos_ssh.py b/netmiko/paloalto/paloalto_panos_ssh.py index 86e0bbbde..3a49d519b 100644 --- a/netmiko/paloalto/paloalto_panos_ssh.py +++ b/netmiko/paloalto/paloalto_panos_ssh.py @@ -148,8 +148,6 @@ def send_command(self, *args, **kwargs): kwargs['delay_factor'] = kwargs.get('delay_factor', 2.5) return super(PaloAltoPanosSSH, self).send_command(*args, **kwargs) - def save_config(self, force=False, partial=False, device_and_network=False, - policy_and_objects=False, vsys='', no_vsys=False, delay_factor=.1): - """Wrapper arround commit for API Consistency""" - return self.commit(self, force, partial, device_and_network, - policy_and_objects, vsys, delay_factor) + def save_config(self, cmd='', confirm=True, confirm_response=''): + """Not Implemented""" + raise NotImplementedError diff --git a/netmiko/vyos/vyos_ssh.py b/netmiko/vyos/vyos_ssh.py index eb8bb1c11..f44b6e265 100644 --- a/netmiko/vyos/vyos_ssh.py +++ b/netmiko/vyos/vyos_ssh.py @@ -97,6 +97,6 @@ def send_config_set(self, config_commands=None, exit_config_mode=False, delay_fa strip_command=strip_command, config_mode_command=config_mode_command) - def save_config(self, comment='', delay_factor=.1): - """Save Config Wrapper for VyOS""" - return self.commit(self, comment, delay_factor) + def save_config(self, cmd='', confirm=True, confirm_response=''): + """Not Implemented""" + raise NotImplementedError From 781c5d62e296c5ae6831af7affc2a13880a79005 Mon Sep 17 00:00:00 2001 From: Kirk Byers Date: Sat, 3 Feb 2018 09:12:35 -0800 Subject: [PATCH 52/62] Fixing linter --- netmiko/juniper/juniper_ssh.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/netmiko/juniper/juniper_ssh.py b/netmiko/juniper/juniper_ssh.py index 00c9e8687..5cc89e61a 100644 --- a/netmiko/juniper/juniper_ssh.py +++ b/netmiko/juniper/juniper_ssh.py @@ -186,10 +186,9 @@ def strip_context_items(self, a_string): return self.RESPONSE_RETURN.join(response_list[:-1]) return a_string - def save_config(self, cmd='', confirm=True, confirm_response=''): - """Not Implemented""" - raise NotImplementedError - + def save_config(self, cmd='', confirm=True, confirm_response=''): + """Not Implemented""" + raise NotImplementedError class JuniperFileTransfer(BaseFileTransfer): From 5188d8b6f243e418e5baa07f7261336c8d48afaf Mon Sep 17 00:00:00 2001 From: Kirk Byers Date: Sat, 3 Feb 2018 14:06:25 -0800 Subject: [PATCH 53/62] Add Cisco WLC --- netmiko/cisco/cisco_wlc_ssh.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/netmiko/cisco/cisco_wlc_ssh.py b/netmiko/cisco/cisco_wlc_ssh.py index 658958857..2e65241bd 100644 --- a/netmiko/cisco/cisco_wlc_ssh.py +++ b/netmiko/cisco/cisco_wlc_ssh.py @@ -159,6 +159,6 @@ def send_config_set(self, config_commands=None, exit_config_mode=True, delay_fac log.debug("{}".format(output)) return output - def save_config(self): - """Not Implemented""" - raise NotImplementedError + def save_config(self, cmd='save config', confirm=True, confirm_response='y'): + return super(CiscoWlcSSH, self).save_config(cmd=cmd, confirm=confirm, + confirm_response=confirm_response) From 9ce35136ef128614d7f2a5a1bc2eee7158e04abb Mon Sep 17 00:00:00 2001 From: Kirk Byers Date: Sun, 4 Feb 2018 11:10:36 -0800 Subject: [PATCH 54/62] Finalizing save config --- netmiko/a10/a10_ssh.py | 4 ++++ netmiko/accedian/accedian_ssh.py | 4 ++++ netmiko/alcatel/alcatel_sros_ssh.py | 2 +- netmiko/calix/calix_b6_ssh.py | 4 ++++ netmiko/checkpoint/checkpoint_gaia_ssh.py | 4 ++++ netmiko/ciena/ciena_saos_ssh.py | 4 ++++ netmiko/coriant/coriant_ssh.py | 4 ++++ netmiko/eltex/eltex_ssh.py | 4 ++++ netmiko/enterasys/enterasys_ssh.py | 4 ++++ netmiko/extreme/extreme_exos.py | 5 +++++ netmiko/fortinet/fortinet_ssh.py | 4 ++++ netmiko/huawei/huawei_ssh.py | 8 ++++++-- netmiko/juniper/juniper_ssh.py | 4 ---- netmiko/linux/linux_ssh.py | 4 ++++ netmiko/mrv/mrv_ssh.py | 4 ++++ netmiko/paloalto/paloalto_panos_ssh.py | 4 ---- netmiko/quanta/quanta_mesh_ssh.py | 4 ++++ netmiko/ruckus/ruckus_fastiron.py | 4 ++++ netmiko/ubiquiti/edge_ssh.py | 5 +++++ 19 files changed, 69 insertions(+), 11 deletions(-) diff --git a/netmiko/a10/a10_ssh.py b/netmiko/a10/a10_ssh.py index a9bb43f48..dd9e752a0 100644 --- a/netmiko/a10/a10_ssh.py +++ b/netmiko/a10/a10_ssh.py @@ -19,3 +19,7 @@ def session_preparation(self): # Clear the read buffer time.sleep(.3 * self.global_delay_factor) self.clear_buffer() + + def save_config(self, cmd='', confirm=True, confirm_response=''): + """Not Implemented""" + raise NotImplementedError diff --git a/netmiko/accedian/accedian_ssh.py b/netmiko/accedian/accedian_ssh.py index 9d742601e..1ffabfa42 100644 --- a/netmiko/accedian/accedian_ssh.py +++ b/netmiko/accedian/accedian_ssh.py @@ -39,3 +39,7 @@ def set_base_prompt(self, pri_prompt_terminator=':', alt_prompt_terminator='#', alt_prompt_terminator=alt_prompt_terminator, delay_factor=delay_factor) return self.base_prompt + + def save_config(self, cmd='', confirm=True, confirm_response=''): + """Not Implemented""" + raise NotImplementedError diff --git a/netmiko/alcatel/alcatel_sros_ssh.py b/netmiko/alcatel/alcatel_sros_ssh.py index f7e20e747..21ec9cf0b 100644 --- a/netmiko/alcatel/alcatel_sros_ssh.py +++ b/netmiko/alcatel/alcatel_sros_ssh.py @@ -43,6 +43,6 @@ def check_config_mode(self, check_string='config', pattern='#'): return super(AlcatelSrosSSH, self).check_config_mode(check_string=check_string, pattern=pattern) - def save_config(self): + def save_config(self, cmd='', confirm=True, confirm_response=''): """Not Implemented""" raise NotImplementedError diff --git a/netmiko/calix/calix_b6_ssh.py b/netmiko/calix/calix_b6_ssh.py index f55228972..da000c8b7 100644 --- a/netmiko/calix/calix_b6_ssh.py +++ b/netmiko/calix/calix_b6_ssh.py @@ -88,3 +88,7 @@ def exit_config_mode(self, exit_config=None, pattern=''): if exit_config is None: exit_config = 'exit' + self.RETURN + 'end' return super(CalixB6SSH, self).exit_config_mode(exit_config=exit_config, pattern=pattern) + + def save_config(self, cmd='', confirm=True, confirm_response=''): + """Not Implemented""" + raise NotImplementedError diff --git a/netmiko/checkpoint/checkpoint_gaia_ssh.py b/netmiko/checkpoint/checkpoint_gaia_ssh.py index 9c19b47a1..48b5fdca6 100644 --- a/netmiko/checkpoint/checkpoint_gaia_ssh.py +++ b/netmiko/checkpoint/checkpoint_gaia_ssh.py @@ -28,3 +28,7 @@ def config_mode(self, config_command=''): def exit_config_mode(self, exit_config=''): """No config mode for Check Point devices.""" return '' + + def save_config(self, cmd='', confirm=True, confirm_response=''): + """Not Implemented""" + raise NotImplementedError diff --git a/netmiko/ciena/ciena_saos_ssh.py b/netmiko/ciena/ciena_saos_ssh.py index 06b91a4fe..6d04fd20c 100644 --- a/netmiko/ciena/ciena_saos_ssh.py +++ b/netmiko/ciena/ciena_saos_ssh.py @@ -17,3 +17,7 @@ def session_preparation(self): def enable(self, *args, **kwargs): pass + + def save_config(self, cmd='', confirm=True, confirm_response=''): + """Not Implemented""" + raise NotImplementedError diff --git a/netmiko/coriant/coriant_ssh.py b/netmiko/coriant/coriant_ssh.py index 11b602cd4..9fa901960 100644 --- a/netmiko/coriant/coriant_ssh.py +++ b/netmiko/coriant/coriant_ssh.py @@ -36,3 +36,7 @@ def set_base_prompt(self, pri_prompt_terminator=':', alt_prompt_terminator='>', alt_prompt_terminator=alt_prompt_terminator, delay_factor=delay_factor) return self.base_prompt + + def save_config(self, cmd='', confirm=True, confirm_response=''): + """Not Implemented""" + raise NotImplementedError diff --git a/netmiko/eltex/eltex_ssh.py b/netmiko/eltex/eltex_ssh.py index d6bc47964..8c3b1beff 100644 --- a/netmiko/eltex/eltex_ssh.py +++ b/netmiko/eltex/eltex_ssh.py @@ -15,3 +15,7 @@ def session_preparation(self): # Clear the read buffer time.sleep(.3 * self.global_delay_factor) self.clear_buffer() + + def save_config(self, cmd='', confirm=True, confirm_response=''): + """Not Implemented""" + raise NotImplementedError diff --git a/netmiko/enterasys/enterasys_ssh.py b/netmiko/enterasys/enterasys_ssh.py index 69e0d42a9..9a1b2c83b 100644 --- a/netmiko/enterasys/enterasys_ssh.py +++ b/netmiko/enterasys/enterasys_ssh.py @@ -14,3 +14,7 @@ def session_preparation(self): # Clear the read buffer time.sleep(.3 * self.global_delay_factor) self.clear_buffer() + + def save_config(self, cmd='', confirm=True, confirm_response=''): + """Not Implemented""" + raise NotImplementedError diff --git a/netmiko/extreme/extreme_exos.py b/netmiko/extreme/extreme_exos.py index e219d08f6..6b0ae601f 100644 --- a/netmiko/extreme/extreme_exos.py +++ b/netmiko/extreme/extreme_exos.py @@ -14,6 +14,7 @@ def session_preparation(self): self._test_channel_read() self.set_base_prompt() self.disable_paging(command="disable clipaging") + self.send_command_timing("disable cli prompting") # Clear the read buffer time.sleep(.3 * self.global_delay_factor) self.clear_buffer() @@ -64,6 +65,10 @@ def exit_config_mode(self, exit_config=''): """No configuration mode on Extreme.""" return '' + def save_config(self, cmd='save configuration primary', confirm=False): + """Saves configuration.""" + return super(CiscoIosBase, self).save_config(cmd=cmd, confirm=confirm) + class ExtremeSSH(ExtremeBase): pass diff --git a/netmiko/fortinet/fortinet_ssh.py b/netmiko/fortinet/fortinet_ssh.py index 79c0f8405..793d28311 100644 --- a/netmiko/fortinet/fortinet_ssh.py +++ b/netmiko/fortinet/fortinet_ssh.py @@ -68,3 +68,7 @@ def config_mode(self, config_command=''): def exit_config_mode(self, exit_config=''): """No config mode for Fortinet devices.""" return '' + + def save_config(self, cmd='', confirm=True, confirm_response=''): + """Not Implemented""" + raise NotImplementedError diff --git a/netmiko/huawei/huawei_ssh.py b/netmiko/huawei/huawei_ssh.py index a96f279ed..2c584a762 100644 --- a/netmiko/huawei/huawei_ssh.py +++ b/netmiko/huawei/huawei_ssh.py @@ -81,9 +81,9 @@ def set_base_prompt(self, pri_prompt_terminator='>', alt_prompt_terminator=']', return self.base_prompt - def save_config(self): + def save_config(self, cmd='save', confirm=False, confirm_response=''): """ Save Config for HuaweiSSH""" - return self.send_command('save') + return super(HuaweiSSH, self).save_config(cmd=cmd, confirm=confirm) class HuaweiVrpv8SSH(HuaweiSSH): @@ -116,3 +116,7 @@ def commit(self, comment='', delay_factor=1): if error_marker in output: raise ValueError('Commit failed with following errors:\n\n{}'.format(output)) return output + + def save_config(self, cmd='', confirm=True, confirm_response=''): + """Not Implemented""" + raise NotImplementedError diff --git a/netmiko/juniper/juniper_ssh.py b/netmiko/juniper/juniper_ssh.py index 5cc89e61a..b46f95d1e 100644 --- a/netmiko/juniper/juniper_ssh.py +++ b/netmiko/juniper/juniper_ssh.py @@ -186,10 +186,6 @@ def strip_context_items(self, a_string): return self.RESPONSE_RETURN.join(response_list[:-1]) return a_string - def save_config(self, cmd='', confirm=True, confirm_response=''): - """Not Implemented""" - raise NotImplementedError - class JuniperFileTransfer(BaseFileTransfer): """Juniper SCP File Transfer driver.""" diff --git a/netmiko/linux/linux_ssh.py b/netmiko/linux/linux_ssh.py index 9f34bcfe0..4f51110c0 100644 --- a/netmiko/linux/linux_ssh.py +++ b/netmiko/linux/linux_ssh.py @@ -85,3 +85,7 @@ def enable(self, cmd='sudo su', pattern='ssword', re_flags=re.IGNORECASE): def cleanup(self): """Try to Gracefully exit the SSH session.""" self.write_channel("exit" + self.RETURN) + + def save_config(self, cmd='', confirm=True, confirm_response=''): + """Not Implemented""" + raise NotImplementedError diff --git a/netmiko/mrv/mrv_ssh.py b/netmiko/mrv/mrv_ssh.py index ed72174ff..dddbe7412 100644 --- a/netmiko/mrv/mrv_ssh.py +++ b/netmiko/mrv/mrv_ssh.py @@ -29,3 +29,7 @@ def enable(self, cmd='enable', pattern=r'#', re_flags=re.IGNORECASE): "the 'secret' argument to ConnectHandler." raise ValueError(msg) return output + + def save_config(self, cmd='save config flash', confirm=False): + """Saves configuration.""" + return super(MrvOptiswitchSSH, self).save_config(cmd=cmd, confirm=confirm) diff --git a/netmiko/paloalto/paloalto_panos_ssh.py b/netmiko/paloalto/paloalto_panos_ssh.py index 3a49d519b..8dc0b07e2 100644 --- a/netmiko/paloalto/paloalto_panos_ssh.py +++ b/netmiko/paloalto/paloalto_panos_ssh.py @@ -147,7 +147,3 @@ def send_command(self, *args, **kwargs): """Palo Alto requires an extra delay""" kwargs['delay_factor'] = kwargs.get('delay_factor', 2.5) return super(PaloAltoPanosSSH, self).send_command(*args, **kwargs) - - def save_config(self, cmd='', confirm=True, confirm_response=''): - """Not Implemented""" - raise NotImplementedError diff --git a/netmiko/quanta/quanta_mesh_ssh.py b/netmiko/quanta/quanta_mesh_ssh.py index c1b64cae6..ddca0961e 100644 --- a/netmiko/quanta/quanta_mesh_ssh.py +++ b/netmiko/quanta/quanta_mesh_ssh.py @@ -10,3 +10,7 @@ def disable_paging(self, command="no pager", delay_factor=1): def config_mode(self, config_command='configure'): """Enter configuration mode.""" return super(QuantaMeshSSH, self).config_mode(config_command=config_command) + + def save_config(self, cmd='', confirm=True, confirm_response=''): + """Not Implemented""" + raise NotImplementedError diff --git a/netmiko/ruckus/ruckus_fastiron.py b/netmiko/ruckus/ruckus_fastiron.py index 377028bb7..79819c689 100644 --- a/netmiko/ruckus/ruckus_fastiron.py +++ b/netmiko/ruckus/ruckus_fastiron.py @@ -48,6 +48,10 @@ def enable(self, cmd='enable', pattern=r'(ssword|User Name)', re_flags=re.IGNORE "the 'secret' argument to ConnectHandler." raise ValueError(msg) + def save_config(self, cmd='write mem', confirm=False): + """Saves configuration.""" + return super(RuckusFastironBase, self).save_config(cmd=cmd, confirm=confirm) + class RuckusFastironTelnet(RuckusFastironBase): def __init__(self, *args, **kwargs): diff --git a/netmiko/ubiquiti/edge_ssh.py b/netmiko/ubiquiti/edge_ssh.py index 9bc275a17..af1e40270 100644 --- a/netmiko/ubiquiti/edge_ssh.py +++ b/netmiko/ubiquiti/edge_ssh.py @@ -25,3 +25,8 @@ def exit_config_mode(self, exit_config='exit'): def exit_enable_mode(self, exit_command='exit'): """Exit enable mode.""" return super(UbiquitiEdgeSSH, self).exit_enable_mode(exit_command=exit_command) + + def save_config(self, cmd='write memory', confirm=False): + """Saves configuration.""" + return super(UbiquitiEdgeSSH, self).save_config(cmd=cmd, confirm=confirm) + From edd744625672cdfc8ca62ad66ec35ff781e23f00 Mon Sep 17 00:00:00 2001 From: Kirk Byers Date: Sun, 4 Feb 2018 11:12:45 -0800 Subject: [PATCH 55/62] Linter cleanup --- netmiko/extreme/extreme_exos.py | 2 +- netmiko/ubiquiti/edge_ssh.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/netmiko/extreme/extreme_exos.py b/netmiko/extreme/extreme_exos.py index 6b0ae601f..afb8f5e9f 100644 --- a/netmiko/extreme/extreme_exos.py +++ b/netmiko/extreme/extreme_exos.py @@ -67,7 +67,7 @@ def exit_config_mode(self, exit_config=''): def save_config(self, cmd='save configuration primary', confirm=False): """Saves configuration.""" - return super(CiscoIosBase, self).save_config(cmd=cmd, confirm=confirm) + return super(ExtremeBase, self).save_config(cmd=cmd, confirm=confirm) class ExtremeSSH(ExtremeBase): diff --git a/netmiko/ubiquiti/edge_ssh.py b/netmiko/ubiquiti/edge_ssh.py index af1e40270..b4cf5631c 100644 --- a/netmiko/ubiquiti/edge_ssh.py +++ b/netmiko/ubiquiti/edge_ssh.py @@ -29,4 +29,3 @@ def exit_enable_mode(self, exit_command='exit'): def save_config(self, cmd='write memory', confirm=False): """Saves configuration.""" return super(UbiquitiEdgeSSH, self).save_config(cmd=cmd, confirm=confirm) - From a7680b469ace8f8e033ec6cb13418e97c399d0b2 Mon Sep 17 00:00:00 2001 From: Kirk Byers Date: Mon, 5 Feb 2018 10:05:03 -0800 Subject: [PATCH 56/62] Fixing minor regex issue in SCP code --- netmiko/cisco/cisco_nxos_ssh.py | 12 ------------ netmiko/scp_handler.py | 4 ++-- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/netmiko/cisco/cisco_nxos_ssh.py b/netmiko/cisco/cisco_nxos_ssh.py index f4effc620..0e75a7ff6 100644 --- a/netmiko/cisco/cisco_nxos_ssh.py +++ b/netmiko/cisco/cisco_nxos_ssh.py @@ -47,18 +47,6 @@ def __init__(self, ssh_conn, source_file, dest_file, file_system='bootflash:', d else: raise ValueError("Invalid direction specified") - def remote_space_available(self, search_pattern=r"(\d+) bytes free"): - """Return space available on remote device.""" - return super(CiscoNxosFileTransfer, self).remote_space_available( - search_pattern=search_pattern - ) - - def verify_space_available(self, search_pattern=r"(\d+) bytes free"): - """Verify sufficient space is available on destination file system (return boolean).""" - return super(CiscoNxosFileTransfer, self).verify_space_available( - search_pattern=search_pattern - ) - def check_file_exists(self, remote_cmd=""): """Check if the dest_file already exists on the file system (return boolean).""" raise NotImplementedError diff --git a/netmiko/scp_handler.py b/netmiko/scp_handler.py index 962a2016f..5e6c2ca53 100644 --- a/netmiko/scp_handler.py +++ b/netmiko/scp_handler.py @@ -91,7 +91,7 @@ def close_scp_chan(self): self.scp_conn.close() self.scp_conn = None - def remote_space_available(self, search_pattern=r"bytes total \((.*) bytes free\)"): + def remote_space_available(self, search_pattern=r"(\d+) bytes free"): """Return space available on remote device.""" remote_cmd = "dir {}".format(self.file_system) remote_output = self.ssh_ctl_chan.send_command_expect(remote_cmd) @@ -103,7 +103,7 @@ def local_space_available(self): destination_stats = os.statvfs(".") return destination_stats.f_bsize * destination_stats.f_bavail - def verify_space_available(self, search_pattern=r"bytes total \((.*) bytes free\)"): + def verify_space_available(self, search_pattern=r"(\d+) bytes free"): """Verify sufficient space is available on destination file system (return boolean).""" if self.direction == 'put': space_avail = self.remote_space_available(search_pattern=search_pattern) From 80b7ace34899dc2eba6a904d99c2756b59a7690c Mon Sep 17 00:00:00 2001 From: Kirk Byers Date: Mon, 5 Feb 2018 12:00:46 -0800 Subject: [PATCH 57/62] Updating vendor table --- README.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a421583eb..0568f19dc 100644 --- a/README.md +++ b/README.md @@ -37,15 +37,17 @@ Alcatel AOS6/AOS8 Avaya ERS Avaya VSP Brocade VDX -Brocade ICX/FastIron Brocade MLX/NetIron +Calix B6 Cisco WLC -Dell-Force10 DNOS9 +Dell-Force10 Dell PowerConnect Huawei Mellanox +NetApp cDOT Palo Alto PAN-OS Pluribus +Ruckus ICX/FastIron Ubiquiti EdgeSwitch Vyatta VyOS @@ -53,17 +55,20 @@ Vyatta VyOS A10 Accedian -Alcatel-Lucent SR-OS Aruba Ciena SAOS Cisco Telepresence -CheckPoint Gaia +Check Point GAiA +Coriant +Eltex Enterasys Extreme EXOS Extreme Wing F5 LTM Fortinet MRV Communications OptiSwitch +Nokia/Alcatel SR-OS +QuantaMesh ## Tutorials: From aa07469c22269dc86b5a81ded9eba9b67c66d73e Mon Sep 17 00:00:00 2001 From: Kirk Byers Date: Mon, 5 Feb 2018 12:03:37 -0800 Subject: [PATCH 58/62] Update the README --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0568f19dc..02c9ea805 100644 --- a/README.md +++ b/README.md @@ -6,14 +6,15 @@ Netmiko Multi-vendor library to simplify Paramiko SSH connections to network devices -Python 2.7, 3.4, 3.5 +Python 2.7, 3.5, 3.6 #### Requires: -Paramiko >= 1.13+ +Paramiko >= 2 scp >= 0.10.0 pyyaml -pytest (for unit tests) +pyserial +textfsm #### Supports: From ae135730428a1f602cc2a9cfd129fcd64d950394 Mon Sep 17 00:00:00 2001 From: Kirk Byers Date: Mon, 5 Feb 2018 12:05:42 -0800 Subject: [PATCH 59/62] Update the README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 02c9ea805..580c41c3f 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ NetApp cDOT Palo Alto PAN-OS Pluribus Ruckus ICX/FastIron -Ubiquiti EdgeSwitch +Ubiquiti EdgeSwitch Vyatta VyOS ###### Experimental From d14e72bcc22850ad73fcc60caa5b3515429d839d Mon Sep 17 00:00:00 2001 From: Kirk Byers Date: Tue, 6 Feb 2018 19:08:41 -0800 Subject: [PATCH 60/62] Updating autodetect; rolling version; creating Netmiko dispatcher --- netmiko/__init__.py | 5 +++-- netmiko/ssh_autodetect.py | 18 +++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/netmiko/__init__.py b/netmiko/__init__.py index e538b9be8..e3fa88cd4 100644 --- a/netmiko/__init__.py +++ b/netmiko/__init__.py @@ -20,12 +20,13 @@ # Alternate naming NetmikoTimeoutError = NetMikoTimeoutException NetmikoAuthError = NetMikoAuthenticationException +Netmiko = ConnectHandler -__version__ = '2.0.1' +__version__ = '2.0.2' __all__ = ('ConnectHandler', 'ssh_dispatcher', 'platforms', 'SCPConn', 'FileTransfer', 'NetMikoTimeoutException', 'NetMikoAuthenticationException', 'NetmikoTimeoutError', 'NetmikoAuthError', 'InLineTransfer', 'redispatch', - 'SSHDetect', 'BaseConnection') + 'SSHDetect', 'BaseConnection', 'Netmiko') # Cisco cntl-shift-six sequence CNTL_SHIFT_6 = chr(30) diff --git a/netmiko/ssh_autodetect.py b/netmiko/ssh_autodetect.py index efd7c466c..cfe4e06b4 100644 --- a/netmiko/ssh_autodetect.py +++ b/netmiko/ssh_autodetect.py @@ -56,19 +56,19 @@ "dispatch": "_autodetect_std", }, 'alcatel_sros': { - "cmd": "show version | match TiMOS", + "cmd": "show version", "search_patterns": ["TiMOS"], "priority": 99, "dispatch": "_autodetect_std", }, 'arista_eos': { - "cmd": "show version | inc rist", + "cmd": "show version", "search_patterns": ["Arista"], "priority": 99, "dispatch": "_autodetect_std", }, 'cisco_ios': { - "cmd": "show version | inc Cisco", + "cmd": "show version", "search_patterns": [ "Cisco IOS Software", "Cisco Internetwork Operating System Software" @@ -77,37 +77,37 @@ "dispatch": "_autodetect_std", }, 'cisco_asa': { - "cmd": "show version | inc Cisco", + "cmd": "show version", "search_patterns": ["Cisco Adaptive Security Appliance", "Cisco ASA"], "priority": 99, "dispatch": "_autodetect_std", }, 'cisco_nxos': { - "cmd": "show version | inc Cisco", + "cmd": "show version", "search_patterns": ["Cisco Nexus Operating System", "NX-OS"], "priority": 99, "dispatch": "_autodetect_std", }, 'cisco_xr': { - "cmd": "show version | inc Cisco", + "cmd": "show version", "search_patterns": ["Cisco IOS XR"], "priority": 99, "dispatch": "_autodetect_std", }, 'huawei': { - "cmd": "display version | inc Huawei", + "cmd": "display version", "search_patterns": ["Huawei Technologies", "Huawei Versatile Routing Platform Software"], "priority": 99, "dispatch": "_autodetect_std", }, 'juniper_junos': { - "cmd": "show version | match JUNOS", + "cmd": "show version", "search_patterns": ["JUNOS Software Release", "JUNOS .+ Software", "JUNOS OS Kernel"], "priority": 99, "dispatch": "_autodetect_std", }, 'dell_force10': { - "cmd": "show version | grep Type", + "cmd": "show version", "search_patterns": ["S4048-ON"], "priority": 99, "dispatch": "_autodetect_std", From 2778cc3b0c0055755bd7ba6da2b5a9f7da196870 Mon Sep 17 00:00:00 2001 From: Kirk Byers Date: Wed, 7 Feb 2018 11:15:42 -0800 Subject: [PATCH 61/62] Fixing autodetect issues --- netmiko/ssh_autodetect.py | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/netmiko/ssh_autodetect.py b/netmiko/ssh_autodetect.py index cfe4e06b4..37f814fb3 100644 --- a/netmiko/ssh_autodetect.py +++ b/netmiko/ssh_autodetect.py @@ -48,6 +48,7 @@ # 'dispatch' key is the SSHDetect method to call. dispatch key will be popped off dictionary # remaining keys indicate kwargs that will be passed to dispatch method. +# Note, the 'cmd' needs to avoid output paging. SSH_MAPPER_BASE = { 'alcatel_aos': { "cmd": "show system", @@ -56,19 +57,22 @@ "dispatch": "_autodetect_std", }, 'alcatel_sros': { - "cmd": "show version", - "search_patterns": ["TiMOS"], + "cmd": "show version | match TiMOS", + "search_patterns": [ + "Nokia", + "Alcatel", + ], "priority": 99, "dispatch": "_autodetect_std", }, 'arista_eos': { - "cmd": "show version", + "cmd": "show version | inc rist", "search_patterns": ["Arista"], "priority": 99, "dispatch": "_autodetect_std", }, 'cisco_ios': { - "cmd": "show version", + "cmd": "show version | inc Cisco", "search_patterns": [ "Cisco IOS Software", "Cisco Internetwork Operating System Software" @@ -77,37 +81,44 @@ "dispatch": "_autodetect_std", }, 'cisco_asa': { - "cmd": "show version", + "cmd": "show version | inc Cisco", "search_patterns": ["Cisco Adaptive Security Appliance", "Cisco ASA"], "priority": 99, "dispatch": "_autodetect_std", }, 'cisco_nxos': { - "cmd": "show version", + "cmd": "show version | inc Cisco", "search_patterns": ["Cisco Nexus Operating System", "NX-OS"], "priority": 99, "dispatch": "_autodetect_std", }, 'cisco_xr': { - "cmd": "show version", + "cmd": "show version | inc Cisco", "search_patterns": ["Cisco IOS XR"], "priority": 99, "dispatch": "_autodetect_std", }, 'huawei': { - "cmd": "display version", - "search_patterns": ["Huawei Technologies", "Huawei Versatile Routing Platform Software"], + "cmd": "display version | inc Huawei", + "search_patterns": [ + "Huawei Technologies", + "Huawei Versatile Routing Platform Software" + ], "priority": 99, "dispatch": "_autodetect_std", }, 'juniper_junos': { - "cmd": "show version", - "search_patterns": ["JUNOS Software Release", "JUNOS .+ Software", "JUNOS OS Kernel"], + "cmd": "show version | match JUNOS", + "search_patterns": [ + "JUNOS Software Release", + "JUNOS .+ Software", + "JUNOS OS Kernel", + ], "priority": 99, "dispatch": "_autodetect_std", }, 'dell_force10': { - "cmd": "show version", + "cmd": "show version | grep Type", "search_patterns": ["S4048-ON"], "priority": 99, "dispatch": "_autodetect_std", From fc5769dc39d61aa8095b50b74153af18b4635253 Mon Sep 17 00:00:00 2001 From: Kirk Byers Date: Fri, 9 Feb 2018 12:51:27 -0800 Subject: [PATCH 62/62] Minor linter fixes --- netmiko/ssh_autodetect.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/netmiko/ssh_autodetect.py b/netmiko/ssh_autodetect.py index 37f814fb3..89d0a4cf4 100644 --- a/netmiko/ssh_autodetect.py +++ b/netmiko/ssh_autodetect.py @@ -101,7 +101,7 @@ 'huawei': { "cmd": "display version | inc Huawei", "search_patterns": [ - "Huawei Technologies", + "Huawei Technologies", "Huawei Versatile Routing Platform Software" ], "priority": 99, @@ -110,8 +110,8 @@ 'juniper_junos': { "cmd": "show version | match JUNOS", "search_patterns": [ - "JUNOS Software Release", - "JUNOS .+ Software", + "JUNOS Software Release", + "JUNOS .+ Software", "JUNOS OS Kernel", ], "priority": 99,