From e80a1e76426c040a383baaa6e41b7c2fbbb8abe3 Mon Sep 17 00:00:00 2001 From: Kirk Byers Date: Sat, 30 Jul 2022 10:45:47 -0700 Subject: [PATCH 1/7] Fixing generator issue with send_config_set --- netmiko/base_connection.py | 5 ++++- tests/test_netmiko_config.py | 30 ++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/netmiko/base_connection.py b/netmiko/base_connection.py index 44d4fed07..d19f7755e 100644 --- a/netmiko/base_connection.py +++ b/netmiko/base_connection.py @@ -33,6 +33,7 @@ from threading import Lock import functools import logging +import itertools import paramiko import serial @@ -2129,8 +2130,10 @@ def send_config_set( # Set bypass_commands="" to force no-bypass (usually for testing) bypass_detected = False if bypass_commands: + # Make a copy of the iterator + config_commands, config_commands_tmp = itertools.tee(config_commands, 2) bypass_detected = any( - [True for cmd in config_commands if re.search(bypass_commands, cmd)] + [True for cmd in config_commands_tmp if re.search(bypass_commands, cmd)] ) if bypass_detected: cmd_verify = False diff --git a/tests/test_netmiko_config.py b/tests/test_netmiko_config.py index 5c5449333..b0ad71059 100755 --- a/tests/test_netmiko_config.py +++ b/tests/test_netmiko_config.py @@ -91,6 +91,36 @@ def test_config_set(net_connect, commands, expected_responses): assert config_commands[-1] in config_commands_output +def test_config_set_generator(net_connect, commands, expected_responses): + """Test sending configuration commands as a generator.""" + + config_commands = commands["config"] + # Make a generator out of the config commands (to verify no issues with generators) + config_commands = (cmd for cmd in config_commands) + support_commit = commands.get("support_commit") + config_verify = commands["config_verification"] + + # Set to initial value and testing sending command as a string + net_connect.send_config_set(config_commands[0]) + if support_commit: + net_connect.commit() + cmd_response = expected_responses.get("cmd_response_init") + config_commands_output = net_connect.send_command(config_verify) + if cmd_response: + assert cmd_response in config_commands_output + else: + assert config_commands[0] in config_commands_output + net_connect.send_config_set(config_commands) + if support_commit: + net_connect.commit() + cmd_response = expected_responses.get("cmd_response_final") + config_commands_output = net_connect.send_command_expect(config_verify) + if cmd_response: + assert cmd_response in config_commands_output + else: + assert config_commands[-1] in config_commands_output + + def test_config_set_longcommand(net_connect, commands, expected_responses): """Test sending configuration commands using long commands""" config_commands = commands.get("config_long_command") From 9b02748f3f1ebdca1849349d2f829da06324733e Mon Sep 17 00:00:00 2001 From: Kirk Byers Date: Sun, 7 Aug 2022 11:09:18 -0700 Subject: [PATCH 2/7] Updating session log test files --- tests/SLOG/cisco881_slog.log | 1 + tests/SLOG/cisco881_slog_append.log | 14 +----------- tests/SLOG/cisco881_slog_append_compare.log | 3 +++ tests/SLOG/cisco881_slog_compare.log | 2 ++ tests/SLOG/cisco881_slog_wr.log | 24 +++++++++++++++------ 5 files changed, 25 insertions(+), 19 deletions(-) diff --git a/tests/SLOG/cisco881_slog.log b/tests/SLOG/cisco881_slog.log index 2e5125e58..d5b8cbca6 100644 --- a/tests/SLOG/cisco881_slog.log +++ b/tests/SLOG/cisco881_slog.log @@ -1,3 +1,4 @@ + cisco1>terminal width 511 cisco1>terminal length 0 cisco1> diff --git a/tests/SLOG/cisco881_slog_append.log b/tests/SLOG/cisco881_slog_append.log index d12914df3..40fa67d00 100644 --- a/tests/SLOG/cisco881_slog_append.log +++ b/tests/SLOG/cisco881_slog_append.log @@ -1,5 +1,6 @@ Initial file contents +cisco1> cisco1>terminal width 511 cisco1>terminal length 0 cisco1> @@ -14,16 +15,3 @@ FastEthernet4 10.220.88.20 YES NVRAM up up Vlan1 unassigned YES unset down down cisco1> cisco1>exit -cisco1>terminal width 511 -cisco1>terminal length 0 -cisco1> -cisco1> -Testing password and secret replacement -This is my password ******** -This is my secret ******** -cisco1>terminal width 511 -cisco1>terminal length 0 -cisco1> -cisco1> -Testing unicode -😁😁 \ No newline at end of file diff --git a/tests/SLOG/cisco881_slog_append_compare.log b/tests/SLOG/cisco881_slog_append_compare.log index 2e5125e58..40fa67d00 100644 --- a/tests/SLOG/cisco881_slog_append_compare.log +++ b/tests/SLOG/cisco881_slog_append_compare.log @@ -1,3 +1,6 @@ +Initial file contents + +cisco1> cisco1>terminal width 511 cisco1>terminal length 0 cisco1> diff --git a/tests/SLOG/cisco881_slog_compare.log b/tests/SLOG/cisco881_slog_compare.log index 2e5125e58..1e00df96e 100644 --- a/tests/SLOG/cisco881_slog_compare.log +++ b/tests/SLOG/cisco881_slog_compare.log @@ -1,3 +1,5 @@ + +cisco1> cisco1>terminal width 511 cisco1>terminal length 0 cisco1> diff --git a/tests/SLOG/cisco881_slog_wr.log b/tests/SLOG/cisco881_slog_wr.log index ab3382ce1..121bc85fc 100644 --- a/tests/SLOG/cisco881_slog_wr.log +++ b/tests/SLOG/cisco881_slog_wr.log @@ -1,4 +1,6 @@ + terminal width 511 +cisco1> cisco1>terminal width 511 cisco1>terminal length 0 terminal length 0 @@ -6,12 +8,22 @@ cisco1> cisco1> -cisco1>enable -enable -Password: ******** +cisco1>show foooooooo +show foooooooo + ^ +% Invalid input detected at '^' marker. -cisco1# +cisco1> -cisco1# +cisco1>show ip interface brief +show ip interface brief +Interface IP-Address OK? Method Status Protocol +FastEthernet0 unassigned YES unset down down +FastEthernet1 unassigned YES unset down down +FastEthernet2 unassigned YES unset down down +FastEthernet3 unassigned YES unset down down +FastEthernet4 10.220.88.20 YES NVRAM up up +Vlan1 unassigned YES unset down down +cisco1> -cisco1#exit +cisco1>exit From 38f522c71d02e1e46e43ae550e170826ae6ef6be Mon Sep 17 00:00:00 2001 From: Kirk Byers Date: Sun, 7 Aug 2022 11:10:55 -0700 Subject: [PATCH 3/7] Slog file --- tests/SLOG/cisco881_slog_compare.log | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/SLOG/cisco881_slog_compare.log b/tests/SLOG/cisco881_slog_compare.log index 1e00df96e..2e5125e58 100644 --- a/tests/SLOG/cisco881_slog_compare.log +++ b/tests/SLOG/cisco881_slog_compare.log @@ -1,5 +1,3 @@ - -cisco1> cisco1>terminal width 511 cisco1>terminal length 0 cisco1> From ab6ff64691e97cf8c68aa7b7426556cc161dbd98 Mon Sep 17 00:00:00 2001 From: Kirk Byers Date: Sun, 7 Aug 2022 11:23:26 -0700 Subject: [PATCH 4/7] Fixing SLOG test issues --- tests/SLOG/cisco881_slog.log | 1 - tests/SLOG/cisco881_slog_append.log | 15 ++++++++++++- tests/SLOG/cisco881_slog_append_compare.log | 3 --- tests/SLOG/cisco881_slog_wr.log | 24 ++++++--------------- tests/SLOG/netmiko.log | 14 ++++++------ 5 files changed, 28 insertions(+), 29 deletions(-) diff --git a/tests/SLOG/cisco881_slog.log b/tests/SLOG/cisco881_slog.log index d5b8cbca6..2e5125e58 100644 --- a/tests/SLOG/cisco881_slog.log +++ b/tests/SLOG/cisco881_slog.log @@ -1,4 +1,3 @@ - cisco1>terminal width 511 cisco1>terminal length 0 cisco1> diff --git a/tests/SLOG/cisco881_slog_append.log b/tests/SLOG/cisco881_slog_append.log index 40fa67d00..215ba1dd0 100644 --- a/tests/SLOG/cisco881_slog_append.log +++ b/tests/SLOG/cisco881_slog_append.log @@ -1,6 +1,5 @@ Initial file contents -cisco1> cisco1>terminal width 511 cisco1>terminal length 0 cisco1> @@ -15,3 +14,17 @@ FastEthernet4 10.220.88.20 YES NVRAM up up Vlan1 unassigned YES unset down down cisco1> cisco1>exit +cisco1>terminal width 511 +cisco1>terminal length 0 +cisco1> +cisco1> +Testing password and secret replacement +This is my password ******** +This is my secret ******** + +cisco1>terminal width 511 +cisco1>terminal length 0 +cisco1> +cisco1> +Testing unicode +😁😁 \ No newline at end of file diff --git a/tests/SLOG/cisco881_slog_append_compare.log b/tests/SLOG/cisco881_slog_append_compare.log index 40fa67d00..2e5125e58 100644 --- a/tests/SLOG/cisco881_slog_append_compare.log +++ b/tests/SLOG/cisco881_slog_append_compare.log @@ -1,6 +1,3 @@ -Initial file contents - -cisco1> cisco1>terminal width 511 cisco1>terminal length 0 cisco1> diff --git a/tests/SLOG/cisco881_slog_wr.log b/tests/SLOG/cisco881_slog_wr.log index 121bc85fc..ab3382ce1 100644 --- a/tests/SLOG/cisco881_slog_wr.log +++ b/tests/SLOG/cisco881_slog_wr.log @@ -1,6 +1,4 @@ - terminal width 511 -cisco1> cisco1>terminal width 511 cisco1>terminal length 0 terminal length 0 @@ -8,22 +6,12 @@ cisco1> cisco1> -cisco1>show foooooooo -show foooooooo - ^ -% Invalid input detected at '^' marker. +cisco1>enable +enable +Password: ******** -cisco1> +cisco1# -cisco1>show ip interface brief -show ip interface brief -Interface IP-Address OK? Method Status Protocol -FastEthernet0 unassigned YES unset down down -FastEthernet1 unassigned YES unset down down -FastEthernet2 unassigned YES unset down down -FastEthernet3 unassigned YES unset down down -FastEthernet4 10.220.88.20 YES NVRAM up up -Vlan1 unassigned YES unset down down -cisco1> +cisco1# -cisco1>exit +cisco1#exit diff --git a/tests/SLOG/netmiko.log b/tests/SLOG/netmiko.log index 79adf1d71..4b7b5ffd1 100644 --- a/tests/SLOG/netmiko.log +++ b/tests/SLOG/netmiko.log @@ -35,17 +35,19 @@ cisco1# write_channel: b'exit\n' write_channel: b'terminal width 511\n' read_channel: -read_channel: cisco1>terminal width +read_channel: +cisco1>terminal width read_channel: 511 cisco1> -Pattern found: (terminal width 511) cisco1>terminal width 511 +Pattern found: (terminal width 511) +cisco1>terminal width 511 In disable_paging Command: terminal length 0 write_channel: b'terminal length 0\n' read_channel: -read_channel: terminal length -read_channel: 0 +read_channel: terminal lengt +read_channel: h 0 cisco1> Pattern found: (terminal\ length\ 0) cisco1>terminal length 0 @@ -65,8 +67,8 @@ read_channel: [find_prompt()]: prompt is cisco1> write_channel: b'terminal width 511\n' read_channel: -read_channel: cisco1>terminal width -read_channel: 511 +read_channel: cisco1>terminal widt +read_channel: h 511 cisco1> Pattern found: (terminal width 511) cisco1>terminal width 511 In disable_paging From 766285dd7b71e39d84e1faffc5b50054792ac570 Mon Sep 17 00:00:00 2001 From: Kirk Byers Date: Mon, 8 Aug 2022 11:44:04 -0700 Subject: [PATCH 5/7] Update genie/pyats reqs and update session log test files --- requirements-genie.txt | 4 ++-- tests/SLOG/cisco881_slog.log | 1 + tests/SLOG/netmiko.log | 12 +++++++----- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/requirements-genie.txt b/requirements-genie.txt index 97ad60ce4..259345278 100644 --- a/requirements-genie.txt +++ b/requirements-genie.txt @@ -1,2 +1,2 @@ -pyats==22.5 -genie==22.5 +pyats==22.7.1 +genie==22.7 diff --git a/tests/SLOG/cisco881_slog.log b/tests/SLOG/cisco881_slog.log index 2e5125e58..d5b8cbca6 100644 --- a/tests/SLOG/cisco881_slog.log +++ b/tests/SLOG/cisco881_slog.log @@ -1,3 +1,4 @@ + cisco1>terminal width 511 cisco1>terminal length 0 cisco1> diff --git a/tests/SLOG/netmiko.log b/tests/SLOG/netmiko.log index 4b7b5ffd1..5efa47834 100644 --- a/tests/SLOG/netmiko.log +++ b/tests/SLOG/netmiko.log @@ -67,10 +67,12 @@ read_channel: [find_prompt()]: prompt is cisco1> write_channel: b'terminal width 511\n' read_channel: -read_channel: cisco1>terminal widt -read_channel: h 511 +read_channel: +cisco1>terminal width +read_channel: 511 cisco1> -Pattern found: (terminal width 511) cisco1>terminal width 511 +Pattern found: (terminal width 511) +cisco1>terminal width 511 In disable_paging Command: terminal length 0 @@ -104,8 +106,8 @@ read_channel: [find_prompt()]: prompt is cisco1> write_channel: b'show ip interface brief\n' read_channel: -read_channel: show ip interf -read_channel: ace brief +read_channel: show ip interfa +read_channel: ce brief Interface IP-Address OK? Method Status Protocol FastEthernet0 unassigned YES unset down down FastEthernet1 unassigned YES unset down down From 42b3df5444476bdb07813a516f83e24810ee703c Mon Sep 17 00:00:00 2001 From: Kirk Byers Date: Mon, 8 Aug 2022 11:44:37 -0700 Subject: [PATCH 6/7] Add test for generators and send_config_set --- tests/test_netmiko_config.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/test_netmiko_config.py b/tests/test_netmiko_config.py index b0ad71059..490c69e78 100755 --- a/tests/test_netmiko_config.py +++ b/tests/test_netmiko_config.py @@ -96,7 +96,7 @@ def test_config_set_generator(net_connect, commands, expected_responses): config_commands = commands["config"] # Make a generator out of the config commands (to verify no issues with generators) - config_commands = (cmd for cmd in config_commands) + config_commands_gen = (cmd for cmd in config_commands) support_commit = commands.get("support_commit") config_verify = commands["config_verification"] @@ -110,7 +110,9 @@ def test_config_set_generator(net_connect, commands, expected_responses): assert cmd_response in config_commands_output else: assert config_commands[0] in config_commands_output - net_connect.send_config_set(config_commands) + + # Send the config commands as a generator + net_connect.send_config_set(config_commands_gen) if support_commit: net_connect.commit() cmd_response = expected_responses.get("cmd_response_final") From f359e91c419db3d6bfb8cfbb9a20cc3e289ab381 Mon Sep 17 00:00:00 2001 From: Kirk Byers Date: Mon, 8 Aug 2022 12:26:43 -0700 Subject: [PATCH 7/7] Fixing typehints issue with generator and itertools --- netmiko/audiocode/audiocode_ssh.py | 6 +++--- netmiko/base_connection.py | 3 ++- netmiko/cdot/cdot_cros_ssh.py | 4 ++-- netmiko/cisco/cisco_viptela.py | 4 ++-- netmiko/cisco/cisco_wlc_ssh.py | 4 ++-- netmiko/cisco/cisco_xr.py | 4 ++-- netmiko/cloudgenix/cloudgenix_ion.py | 4 ++-- netmiko/ericsson/ericsson_ipos.py | 4 ++-- netmiko/hp/hp_comware.py | 4 ++-- netmiko/huawei/huawei.py | 4 ++-- netmiko/linux/linux_ssh.py | 4 ++-- netmiko/nokia/nokia_srl.py | 4 ++-- netmiko/nokia/nokia_sros.py | 4 ++-- netmiko/vyos/vyos_ssh.py | 4 ++-- netmiko/zyxel/zyxel_ssh.py | 4 ++-- 15 files changed, 31 insertions(+), 30 deletions(-) diff --git a/netmiko/audiocode/audiocode_ssh.py b/netmiko/audiocode/audiocode_ssh.py index 875df8356..06ec4780e 100644 --- a/netmiko/audiocode/audiocode_ssh.py +++ b/netmiko/audiocode/audiocode_ssh.py @@ -1,4 +1,4 @@ -from typing import Any, Optional, Sequence, TextIO, Union, List +from typing import Any, Optional, Sequence, Iterator, TextIO, Union, List import time import re from netmiko.base_connection import BaseConnection @@ -119,7 +119,7 @@ def exit_enable_mode(self, exit_command: str = "disable") -> str: def send_config_set( self, - config_commands: Union[str, Sequence[str], TextIO, None] = None, + config_commands: Union[str, Sequence[str], Iterator[str], TextIO, None] = None, *, exit_config_mode: bool = True, read_timeout: Optional[float] = None, @@ -359,7 +359,7 @@ def find_prompt( def send_config_set( self, - config_commands: Union[str, Sequence[str], TextIO, None] = None, + config_commands: Union[str, Sequence[str], Iterator[str], TextIO, None] = None, *, exit_config_mode: bool = True, read_timeout: Optional[float] = None, diff --git a/netmiko/base_connection.py b/netmiko/base_connection.py index d19f7755e..5a17e95b8 100644 --- a/netmiko/base_connection.py +++ b/netmiko/base_connection.py @@ -16,6 +16,7 @@ cast, Type, Sequence, + Iterator, TextIO, Union, Tuple, @@ -2033,7 +2034,7 @@ def send_config_from_file( def send_config_set( self, - config_commands: Union[str, Sequence[str], TextIO, None] = None, + config_commands: Union[str, Sequence[str], Iterator[str], TextIO, None] = None, *, exit_config_mode: bool = True, read_timeout: Optional[float] = None, diff --git a/netmiko/cdot/cdot_cros_ssh.py b/netmiko/cdot/cdot_cros_ssh.py index 9f1da9d0b..09a318206 100644 --- a/netmiko/cdot/cdot_cros_ssh.py +++ b/netmiko/cdot/cdot_cros_ssh.py @@ -7,7 +7,7 @@ # # Purpose: Provide basic SSH connection to CROS based router products -from typing import Optional, Union, Sequence, TextIO, Any +from typing import Optional, Union, Sequence, Iterator, TextIO, Any import time import warnings from netmiko.no_enable import NoEnable @@ -29,7 +29,7 @@ def session_preparation(self) -> None: def send_config_set( self, - config_commands: Union[str, Sequence[str], TextIO, None] = None, + config_commands: Union[str, Sequence[str], Iterator[str], TextIO, None] = None, exit_config_mode: bool = False, **kwargs: Any, ) -> str: diff --git a/netmiko/cisco/cisco_viptela.py b/netmiko/cisco/cisco_viptela.py index 45eae20fd..86b058976 100644 --- a/netmiko/cisco/cisco_viptela.py +++ b/netmiko/cisco/cisco_viptela.py @@ -1,5 +1,5 @@ """Subclass specific to Cisco Viptela.""" -from typing import Union, Sequence, TextIO, Any +from typing import Union, Sequence, Iterator, TextIO, Any import re from netmiko.cisco_base_connection import CiscoSSHConnection @@ -38,7 +38,7 @@ def config_mode( def send_config_set( self, - config_commands: Union[str, Sequence[str], TextIO, None] = None, + config_commands: Union[str, Sequence[str], Iterator[str], TextIO, None] = None, exit_config_mode: bool = False, **kwargs: Any, ) -> str: diff --git a/netmiko/cisco/cisco_wlc_ssh.py b/netmiko/cisco/cisco_wlc_ssh.py index 31eabdc37..8b184e0d4 100644 --- a/netmiko/cisco/cisco_wlc_ssh.py +++ b/netmiko/cisco/cisco_wlc_ssh.py @@ -1,5 +1,5 @@ """Netmiko Cisco WLC support.""" -from typing import Any, Union, Sequence, TextIO +from typing import Any, Union, Sequence, Iterator, TextIO import time import re import socket @@ -225,7 +225,7 @@ def exit_config_mode(self, exit_config: str = "exit", pattern: str = "") -> str: def send_config_set( self, - config_commands: Union[str, Sequence[str], TextIO, None] = None, + config_commands: Union[str, Sequence[str], Iterator[str], TextIO, None] = None, exit_config_mode: bool = False, enter_config_mode: bool = False, **kwargs: Any, diff --git a/netmiko/cisco/cisco_xr.py b/netmiko/cisco/cisco_xr.py index b5e5e5f42..c864ad98c 100644 --- a/netmiko/cisco/cisco_xr.py +++ b/netmiko/cisco/cisco_xr.py @@ -1,4 +1,4 @@ -from typing import Optional, Any, Union, Sequence, TextIO +from typing import Optional, Any, Union, Sequence, Iterator, TextIO import re import warnings from netmiko.base_connection import DELAY_FACTOR_DEPR_SIMPLE_MSG @@ -43,7 +43,7 @@ def set_base_prompt( def send_config_set( self, - config_commands: Union[str, Sequence[str], TextIO, None] = None, + config_commands: Union[str, Sequence[str], Iterator[str], TextIO, None] = None, exit_config_mode: bool = False, **kwargs: Any, ) -> str: diff --git a/netmiko/cloudgenix/cloudgenix_ion.py b/netmiko/cloudgenix/cloudgenix_ion.py index 0f188a877..232951e3f 100644 --- a/netmiko/cloudgenix/cloudgenix_ion.py +++ b/netmiko/cloudgenix/cloudgenix_ion.py @@ -1,4 +1,4 @@ -from typing import Any, Union, Sequence, TextIO, Optional +from typing import Any, Union, Sequence, Iterator, TextIO, Optional from netmiko.no_config import NoConfig from netmiko.cisco_base_connection import CiscoSSHConnection @@ -37,7 +37,7 @@ def save_config(self, *args: Any, **kwargs: Any) -> str: def send_config_set( self, - config_commands: Union[str, Sequence[str], TextIO, None] = None, + config_commands: Union[str, Sequence[str], Iterator[str], TextIO, None] = None, exit_config_mode: bool = False, **kwargs: Any ) -> str: diff --git a/netmiko/ericsson/ericsson_ipos.py b/netmiko/ericsson/ericsson_ipos.py index aac21a32a..5921c7afb 100644 --- a/netmiko/ericsson/ericsson_ipos.py +++ b/netmiko/ericsson/ericsson_ipos.py @@ -1,7 +1,7 @@ """ Ericsson Ipos looks like it was RedBack equipment. """ -from typing import Optional, Any, Union, Sequence, TextIO +from typing import Optional, Any, Union, Sequence, Iterator, TextIO import re import warnings @@ -54,7 +54,7 @@ def exit_config_mode(self, exit_config: str = "end", pattern: str = "#") -> str: def send_config_set( self, - config_commands: Union[str, Sequence[str], TextIO, None] = None, + config_commands: Union[str, Sequence[str], Iterator[str], TextIO, None] = None, exit_config_mode: bool = False, **kwargs: Any, ) -> str: diff --git a/netmiko/hp/hp_comware.py b/netmiko/hp/hp_comware.py index c7726397b..b6e7b8174 100644 --- a/netmiko/hp/hp_comware.py +++ b/netmiko/hp/hp_comware.py @@ -1,5 +1,5 @@ import re -from typing import Union, Sequence, TextIO, Any, Optional +from typing import Union, Sequence, Iterator, TextIO, Any, Optional from netmiko.cisco_base_connection import CiscoSSHConnection @@ -44,7 +44,7 @@ def check_config_mode( def send_config_set( self, - config_commands: Union[str, Sequence[str], TextIO, None] = None, + config_commands: Union[str, Sequence[str], Iterator[str], TextIO, None] = None, exit_config_mode: bool = True, read_timeout: Optional[float] = None, delay_factor: Optional[float] = None, diff --git a/netmiko/huawei/huawei.py b/netmiko/huawei/huawei.py index f80cd1a42..625ce1ae5 100644 --- a/netmiko/huawei/huawei.py +++ b/netmiko/huawei/huawei.py @@ -1,4 +1,4 @@ -from typing import Optional, Any, Union, Sequence, TextIO +from typing import Optional, Any, Union, Sequence, Iterator, TextIO import time import re import warnings @@ -196,7 +196,7 @@ def telnet_login( class HuaweiVrpv8SSH(HuaweiSSH): def send_config_set( self, - config_commands: Union[str, Sequence[str], TextIO, None] = None, + config_commands: Union[str, Sequence[str], Iterator[str], TextIO, None] = None, exit_config_mode: bool = False, **kwargs: Any, ) -> str: diff --git a/netmiko/linux/linux_ssh.py b/netmiko/linux/linux_ssh.py index b782c6499..56ee22df6 100644 --- a/netmiko/linux/linux_ssh.py +++ b/netmiko/linux/linux_ssh.py @@ -1,4 +1,4 @@ -from typing import Any, Optional, TYPE_CHECKING, Union, Sequence, TextIO +from typing import Any, Optional, TYPE_CHECKING, Union, Sequence, Iterator, TextIO import os import re @@ -61,7 +61,7 @@ def set_base_prompt( def send_config_set( self, - config_commands: Union[str, Sequence[str], TextIO, None] = None, + config_commands: Union[str, Sequence[str], Iterator[str], TextIO, None] = None, exit_config_mode: bool = True, **kwargs: Any, ) -> str: diff --git a/netmiko/nokia/nokia_srl.py b/netmiko/nokia/nokia_srl.py index a3bee5330..781467aeb 100644 --- a/netmiko/nokia/nokia_srl.py +++ b/netmiko/nokia/nokia_srl.py @@ -7,7 +7,7 @@ # https://github.com/ktbyers/netmiko/blob/develop/LICENSE import re -from typing import Any, Optional, Sequence, TextIO, Union +from typing import Any, Optional, Sequence, Iterator, TextIO, Union from netmiko import log from netmiko.no_enable import NoEnable from netmiko.base_connection import BaseConnection @@ -122,7 +122,7 @@ def exit_config_mode(self, exit_config: str = "", pattern: str = "") -> str: def send_config_set( self, - config_commands: Union[str, Sequence[str], TextIO, None] = None, + config_commands: Union[str, Sequence[str], Iterator[str], TextIO, None] = None, exit_config_mode: bool = False, **kwargs: Any, ) -> str: diff --git a/netmiko/nokia/nokia_sros.py b/netmiko/nokia/nokia_sros.py index ce8899b8b..5ddda2b9b 100644 --- a/netmiko/nokia/nokia_sros.py +++ b/netmiko/nokia/nokia_sros.py @@ -9,7 +9,7 @@ import re import os import time -from typing import Any, Optional, Union, Sequence, TextIO, Callable +from typing import Any, Optional, Union, Sequence, Iterator, TextIO, Callable from netmiko import log from netmiko.base_connection import BaseConnection @@ -174,7 +174,7 @@ def save_config(self, *args: Any, **kwargs: Any) -> str: def send_config_set( self, - config_commands: Union[str, Sequence[str], TextIO, None] = None, + config_commands: Union[str, Sequence[str], Iterator[str], TextIO, None] = None, exit_config_mode: bool = None, **kwargs: Any, ) -> str: diff --git a/netmiko/vyos/vyos_ssh.py b/netmiko/vyos/vyos_ssh.py index 37420124b..727650669 100644 --- a/netmiko/vyos/vyos_ssh.py +++ b/netmiko/vyos/vyos_ssh.py @@ -1,4 +1,4 @@ -from typing import Optional, Union, Sequence, TextIO, Any +from typing import Optional, Union, Sequence, Iterator, TextIO, Any import time import warnings import re @@ -123,7 +123,7 @@ def set_base_prompt( def send_config_set( self, - config_commands: Union[str, Sequence[str], TextIO, None] = None, + config_commands: Union[str, Sequence[str], Iterator[str], TextIO, None] = None, exit_config_mode: bool = False, **kwargs: Any, ) -> str: diff --git a/netmiko/zyxel/zyxel_ssh.py b/netmiko/zyxel/zyxel_ssh.py index 79fb4292c..7ac0005dc 100644 --- a/netmiko/zyxel/zyxel_ssh.py +++ b/netmiko/zyxel/zyxel_ssh.py @@ -1,4 +1,4 @@ -from typing import Any, Sequence, TextIO, Union +from typing import Any, Sequence, Iterator, TextIO, Union from netmiko.cisco_base_connection import CiscoSSHConnection from netmiko.no_enable import NoEnable from netmiko.no_config import NoConfig @@ -11,7 +11,7 @@ def disable_paging(self, *args: Any, **kwargs: Any) -> str: def send_config_set( self, - config_commands: Union[str, Sequence[str], TextIO, None] = None, + config_commands: Union[str, Sequence[str], Iterator[str], TextIO, None] = None, exit_config_mode: bool = False, enter_config_mode: bool = False, **kwargs: Any