diff --git a/docs/changelog/2024/october.rst b/docs/changelog/2024/october.rst new file mode 100644 index 00000000..fe00ac57 --- /dev/null +++ b/docs/changelog/2024/october.rst @@ -0,0 +1,32 @@ +October 2024 +========== + +October 29 - Unicon v24.10 +------------------------ + + + +.. csv-table:: Module Versions + :header: "Modules", "Versions" + + ``unicon.plugins``, v24.10 + ``unicon``, v24.10 + + + + +Changelogs +^^^^^^^^^^ +-------------------------------------------------------------------------------- + Fix +-------------------------------------------------------------------------------- + +* generic + * service_implementations/Configure + * update the pattern for update_hostname in the configure service. + +* iosxr/spitfire + * patterns + * remove the config and enable pattern + + diff --git a/docs/changelog/index.rst b/docs/changelog/index.rst index e194bba5..67187602 100644 --- a/docs/changelog/index.rst +++ b/docs/changelog/index.rst @@ -4,6 +4,7 @@ Changelog .. toctree:: :maxdepth: 2 + 2024/october 2024/September 2024/august 2024/july diff --git a/docs/changelog_plugins/2024/october.rst b/docs/changelog_plugins/2024/october.rst new file mode 100644 index 00000000..6772e328 --- /dev/null +++ b/docs/changelog_plugins/2024/october.rst @@ -0,0 +1,36 @@ +October 2024 +========== + +October 29 - Unicon.Plugins v24.10 +------------------------ + + + +.. csv-table:: Module Versions + :header: "Modules", "Versions" + + ``unicon.plugins``, v24.10 + ``unicon``, v24.10 + + + + +Changelogs +^^^^^^^^^^ +-------------------------------------------------------------------------------- + Fix +-------------------------------------------------------------------------------- + +* pid tokens + * Updated PID tokens to support NCS devices + + +-------------------------------------------------------------------------------- + Add +-------------------------------------------------------------------------------- + +* apic plugin + * Modified the regex patterns in the post_service method in Execute to remove extra junk values and retain the newline character in the output. + * Added a configure class to eliminate extra junk values from the output. + + diff --git a/docs/changelog_plugins/index.rst b/docs/changelog_plugins/index.rst index 9023e664..d4aea656 100644 --- a/docs/changelog_plugins/index.rst +++ b/docs/changelog_plugins/index.rst @@ -4,6 +4,7 @@ Plugins Changelog .. toctree:: :maxdepth: 2 + 2024/october 2024/September 2024/august 2024/july diff --git a/src/unicon/plugins/__init__.py b/src/unicon/plugins/__init__.py index 3127f04c..cd70af54 100644 --- a/src/unicon/plugins/__init__.py +++ b/src/unicon/plugins/__init__.py @@ -1,4 +1,4 @@ -__version__ = '24.9' +__version__ = '24.10' supported_chassis = [ 'single_rp', diff --git a/src/unicon/plugins/apic/connection.py b/src/unicon/plugins/apic/connection.py index 78446015..1d2a4077 100644 --- a/src/unicon/plugins/apic/connection.py +++ b/src/unicon/plugins/apic/connection.py @@ -1,7 +1,7 @@ from unicon.plugins.generic import GenericSingleRpConnection from unicon.plugins.generic.connection_provider import GenericSingleRpConnectionProvider -from unicon.plugins.generic import ServiceList, service_implementation as svc +from unicon.plugins.generic import ServiceList from unicon.eal.dialogs import Statement from . import service_implementation as aci_svc @@ -44,7 +44,7 @@ class AciApicServiceList(ServiceList): def __init__(self): super().__init__() self.execute = aci_svc.Execute - self.configure = svc.Configure + self.configure = aci_svc.Configure self.reload = aci_svc.Reload diff --git a/src/unicon/plugins/apic/service_implementation.py b/src/unicon/plugins/apic/service_implementation.py index f5af6aef..0d10911d 100644 --- a/src/unicon/plugins/apic/service_implementation.py +++ b/src/unicon/plugins/apic/service_implementation.py @@ -6,7 +6,8 @@ from time import sleep from unicon.logs import UniconStreamHandler, UNICON_LOG_FORMAT from unicon.bases.routers.services import BaseService -from unicon.plugins.generic.service_implementation import Execute as GenericExecute +from unicon.plugins.generic.service_implementation import (Execute as GenericExecute, + Configure as GenericConfigure) from unicon.plugins.generic import GenericUtils from unicon.core.errors import SubCommandFailure from unicon.eal.dialogs import Dialog @@ -16,6 +17,16 @@ utils = GenericUtils() +def clean_command_output(output): + """ Function to clean command output by removing unwanted characters """ + output = utils.remove_ansi_escape_codes(output) + output = re.sub('.\x08', '', output) + output = re.sub(r'%\s+\r ', '', output) + output = re.sub(r'\x00+', '', output) + output = re.sub(r'[\r%]+', '', output) + return output + + class Execute(GenericExecute): """ Execute Service implementation @@ -27,7 +38,6 @@ class Execute(GenericExecute): command: exec command reply: Additional Dialog patterns for interactive exec commands. timeout : Timeout value in sec, Default Value is 60 sec - lines: number of lines to capture when paging is active. Default: 100 Returns: True on Success, raise SubCommandFailure on failure @@ -46,15 +56,39 @@ def __init__(self, connection, context, **kwargs): def post_service(self, *args, clean_output=True, **kwargs): super().post_service(*args, **kwargs) - if clean_output: - if isinstance(self.result, str): - output = self.result - output = utils.remove_ansi_escape_codes(output) - output = re.sub('.\x08', '', output) - output = re.sub(r'\x00+', '', output) - output = re.sub(r'%(\s+\r )?', '', output) - output = re.sub(r'[\r\n]+', '', output) - self.result = output + if clean_output and isinstance(self.result, str): + self.result = clean_command_output(self.result) + + +class Configure(GenericConfigure): + """ Configure Service implementation + + Service to execute configuration commands on the device and return the + console output. The `reply` option can be passed for interactive configuration commands. + + Arguments: + commands : list/single config command + reply: Addition Dialogs for interactive config commands. + timeout : Timeout value in sec, Default Value is 30 sec + + Returns: + True on Success, raises SubCommandFailure on failure + + Example: + .. code-block:: python + output = rtr.configure('no logging console') + cmd =['hostname si-tvt-7200-28-41', 'no logging console'] + output = dev.configure(cmd) + """ + def __init__(self, connection, context, **kwargs): + # Connection object will have all the received details + super().__init__(connection, context, **kwargs) + + def post_service(self, *args, clean_output=True, **kwargs): + super().post_service(*args, **kwargs) + + if clean_output and isinstance(self.result, str): + self.result = clean_command_output(self.result) class Reload(BaseService): diff --git a/src/unicon/plugins/generic/service_implementation.py b/src/unicon/plugins/generic/service_implementation.py index 83f890f0..f2d86a55 100644 --- a/src/unicon/plugins/generic/service_implementation.py +++ b/src/unicon/plugins/generic/service_implementation.py @@ -1034,9 +1034,9 @@ def process_dialog_on_handle(self, handle, dialog, timeout): def update_hostname_if_needed(self, cmd_list): for cmd in cmd_list: - m = re.match(r'^\s*hostname (\S+)', cmd) + m = re.match(r'^\s*(hostname|switchname) (\S+)', cmd) if m: - self.connection.hostname = m.group(1) + self.connection.hostname = m.group(2) return diff --git a/src/unicon/plugins/iosxr/spitfire/patterns.py b/src/unicon/plugins/iosxr/spitfire/patterns.py index d2fc8d62..5a44e429 100644 --- a/src/unicon/plugins/iosxr/spitfire/patterns.py +++ b/src/unicon/plugins/iosxr/spitfire/patterns.py @@ -7,10 +7,6 @@ def __init__(self): super().__init__() # Always have the first match group (.*?) as this is the data # returned as the cli output . - self.enable_prompt = \ - r'^(.*?)RP/\d+/RP[01]/CPU\d+:(%N|ios)\s*#\s*?$' - self.config_prompt = \ - r'^(.*?)RP/\d+/RP[01]/CPU\d+:(%N|ios)\s*\(config.*\)\s*#\s*?$' self.bmc_prompt = \ r'^(.*?)root@spitfire-arm:.+?#\s*?$' self.xr_bash_prompt = \ diff --git a/src/unicon/plugins/pid_tokens.csv b/src/unicon/plugins/pid_tokens.csv index 48ab70cb..4ef5b87b 100644 --- a/src/unicon/plugins/pid_tokens.csv +++ b/src/unicon/plugins/pid_tokens.csv @@ -1,14 +1,18 @@ pid,os,platform,model,submodel 2501FRAD-FX,ios,c2k,c2500, 2501LANFRAD-FX,ios,c2k,c2500, +8102-64H,iosxr,spitfire,8100, 8201,iosxr,spitfire,8200, +8201-24H8FH,iosxr,spitfire,8200, 8201-32FH,iosxr,spitfire,8200, +8201-32FH-O,sonic,spitfire,8200, 8202,iosxr,spitfire,8200, 8202-32FH-M,iosxr,spitfire,8200, 8804,iosxr,spitfire,8800, 8808,iosxr,spitfire,8800, 8812,iosxr,spitfire,8800, 8818,iosxr,spitfire,8800, +AS2511-RJ,ios,c2500,c2511, ASR-9001,iosxr,asr9k,asr9000, ASR-9001-S,iosxr,asr9k,asr9000, ASR-9006-SYS,iosxr,asr9k,asr9000, @@ -20,18 +24,19 @@ ASR-9906,iosxr,asr9k,asr9900, ASR-9910,iosxr,asr9k,asr9900, ASR-9912,iosxr,asr9k,asr9900, ASR-9922,iosxr,asr9k,asr9900, -ASR1001,iosxe,asr1k,asr1000, -ASR1001-2XOC3POS,iosxe,asr1k,asr1000, -ASR1001-4X1GE,iosxe,asr1k,asr1000, -ASR1001-4XT3,iosxe,asr1k,asr1000, -ASR1001-8XCHT1E1,iosxe,asr1k,asr1000, -ASR1001-HDD,iosxe,asr1k,asr1000, -ASR1002,iosxe,asr1k,asr1000, -ASR1002-F,iosxe,asr1k,asr1000, -ASR1004,iosxe,asr1k,asr1000, -ASR1006,iosxe,asr1k,asr1000, -ASR1006-X,iosxe,asr1k,asr1000, -ASR1013,iosxe,asr1k,asr1000, +ASR1001,iosxe,asr1k,asr1001, +ASR1001-2XOC3POS,iosxe,asr1k,asr1001, +ASR1001-4X1GE,iosxe,asr1k,asr1001, +ASR1001-4XT3,iosxe,asr1k,asr1001, +ASR1001-8XCHT1E1,iosxe,asr1k,asr1001, +ASR1001-HDD,iosxe,asr1k,asr1001, +ASR1002,iosxe,asr1k,asr1002, +ASR1002-F,iosxe,asr1k,asr1002, +ASR1004,iosxe,asr1k,asr1004, +ASR1006,iosxe,asr1k,asr1006, +ASR1006-X,iosxe,asr1k,asr1006, +ASR1009-X,iosxe,asr1k,asr1009, +ASR1013,iosxe,asr1k,asr1013, C1000-16FP-2G-L,iosxe,cat1k,c1000, C1000-16P-2G-L,iosxe,cat1k,c1000, C1000-16P-E-2G-L,iosxe,cat1k,c1000, @@ -730,6 +735,15 @@ N3K-C36180YC-R,nxos,n3k,n3600, N3K-C3636C-R,nxos,n3k,n3600, N4K-4001I-XPX,nxos,n4k,n4000, N4K-4005I-XPX,nxos,n4k,n4000, +N540-12Z20G-SYS-A,iosxr,ncs500,ncs540, +N540-24Q8L2DD-SYS,iosxr,ncs500,ncs540, +N540-24Z8Q2C-M,iosxr,ncs500,ncs540, +N540-28Z4C-SYS-A,iosxr,ncs500,ncs540, +N540-ACC-SYS,iosxr,ncs500,ncs540, +N540-FH-CSR-SYS,iosxr,ncs500,ncs540, +N540X-4Z14G2Q-A,iosxr,ncs500,ncs540x, +N540X-8Z16G-SYS-A,iosxr,ncs500,ncs540x, +N540X-ACC-SYS,iosxr,ncs500,ncs540x, N5K-C5010P-BF,nxos,n5k,n5000, N5K-C5020P-BF,nxos,n5k,n5000, N5K-C5548P,nxos,n5k,n5500, @@ -809,9 +823,12 @@ NCS-5502-SE,iosxr,ncs5k,ncs5500, NCS-5504,iosxr,ncs5k,ncs5500, NCS-5508,iosxr,ncs5k,ncs5500, NCS-5516,iosxr,ncs5k,ncs5500, -NCS-55A1-24Q6H-S,iosxr,ncs5k,ncs5500, -NCS-55A1-36H-SE-S,iosxr,ncs5k,ncs5500, -NCS-55A1-48Q6H,iosxr,ncs5k,ncs5500, +NCS-55A1-24Q6H-S,iosxr,ncs5k,ncs55a1, +NCS-55A1-36H-S,iosxr,ncs5k,ncs55a1, +NCS-55A1-36H-SE-S,iosxr,ncs5k,ncs55a1, +NCS-55A1-48Q6H,iosxr,ncs5k,ncs55a1, +NCS-57C3-MOD-SYS,iosxr,ncs5k,ncs5700, +NCS-57C3-MODS-SYS,iosxr,ncs5k,ncs5700, NCS-6008,iosxr,ncs6k,ncs6000, NCS-F-CHASS,iosxr,ncs6k,ncs6000, NCS1001-K9,iosxr,ncs1k,ncs1000, @@ -826,11 +843,11 @@ NCS4009-SA-AC,iosxr,ncs4k,ncs4000, NCS4009-SA-DC,iosxr,ncs4k,ncs4000, NCS4016-SA-AC,iosxr,ncs4k,ncs4000, NCS4016-SA-DC,iosxr,ncs4k,ncs4000, -NCS4201-SA,iosxr,ncs4k,ncs4200, -NCS4202-SA,iosxr,ncs4k,ncs4200, -NCS4206-SA,iosxr,ncs4k,ncs4200, -NCS4216-F2B-SA,iosxr,ncs4k,ncs4200, -NCS4216-SA,iosxr,ncs4k,ncs4200, +NCS4201-SA,iosxe,ncs4k,ncs4200, +NCS4202-SA,iosxe,ncs4k,ncs4200, +NCS4206-SA,iosxe,ncs4k,ncs4200, +NCS4216-F2B-SA,iosxe,ncs4k,ncs4200, +NCS4216-SA,iosxe,ncs4k,ncs4200, NCS4KF-SA-DC,iosxr,ncs4k,ncs4000, Nexus1000V,nxos,n1k,n1000, Nexus1000Vh,nxos,n1k,n1000, @@ -1424,4 +1441,4 @@ WS-C6509-NEB-A,iosxe,cat6k,c6500, WS-C6509-V-E,iosxe,cat6k,c6500, WS-C6513,iosxe,cat6k,c6500, WS-C6513-E,iosxe,cat6k,c6500, -WS-X3011-CH,iosxe,cat3k,c3000, +WS-X3011-CH,iosxe,cat3k,c3000, \ No newline at end of file diff --git a/src/unicon/plugins/tests/mock/mock_device_nxos.py b/src/unicon/plugins/tests/mock/mock_device_nxos.py index f04cc418..add4332e 100644 --- a/src/unicon/plugins/tests/mock/mock_device_nxos.py +++ b/src/unicon/plugins/tests/mock/mock_device_nxos.py @@ -65,6 +65,11 @@ def exec(self, transport, cmd): self.set_state(self.transport_handles[transport], 'scp_password') return True + def config(self, transport, cmd): + m = re.match(r'\s*(hostname|switchname) (\S+)', cmd) + if m: + self.hostname = m.group(2) + return True class MockDeviceTcpWrapperNXOS(MockDeviceTcpWrapper): diff --git a/src/unicon/plugins/tests/mock_data/apic/apic_mock_data.yaml b/src/unicon/plugins/tests/mock_data/apic/apic_mock_data.yaml index c8177a99..f83bfbd9 100644 --- a/src/unicon/plugins/tests/mock_data/apic/apic_mock_data.yaml +++ b/src/unicon/plugins/tests/mock_data/apic/apic_mock_data.yaml @@ -93,6 +93,7 @@ apic_config: commands: "tenant test": new_state: apic_config_tenant + "switch-group": "\x1b[K\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1b[1C\x1b[?1l\x1b>\x1b[?2004l\r\r\nError: Invalid argument ''. Please check syntax in command reference guide\r\n\x1b[1m\x00\x00\x00\x00\x00\x00\x00\x00\x1b[7m\x00\x00\x00\x00\x00\x00\x00\x00%\x1b[m\x00\x00\x00\x00\x00\x00\x00\x00\x1b[1m\x00\x00\x00\x00\x00\x00\x00\x00\x1b[0m\x00\x00\x00\x00\x00\x00\x00\x00 \r \r\r\x1b[0m\x00\x00\x00\x00\x00\x00\x00\x00\x1b[m\x00\x00\x00\x00\x00\x00\x00\x00\x1b[m\x00\x00\x00\x00\x00\x00\x00\x00\x1b[J\x00" "end": new_state: apic_exec diff --git a/src/unicon/plugins/tests/mock_data/iosxr/iosxr_mock_data.yaml b/src/unicon/plugins/tests/mock_data/iosxr/iosxr_mock_data.yaml index dc94c119..eba670f2 100644 --- a/src/unicon/plugins/tests/mock_data/iosxr/iosxr_mock_data.yaml +++ b/src/unicon/plugins/tests/mock_data/iosxr/iosxr_mock_data.yaml @@ -363,7 +363,7 @@ enable: - |2 ^ % Invalid input detected at '^' marker." - + "not a real command partial": response: - |2 @@ -438,8 +438,8 @@ admin: ----------------------------------------------------------------------------- 0/RSP0/CPU0 A9K-RSP-4G(Active) IOS XR RUN PWR,NSHUT,MON 0/RSP1/CPU0 A9K-RSP-4G(Standby) IOS XR RUN PWR,NSHUT,MON - 0/FT0/SP FAN TRAY READY - 0/FT1/SP FAN TRAY READY + 0/FT0/SP FAN TRAY READY + 0/FT1/SP FAN TRAY READY 0/0/CPU0 A9K-MOD80-SE IOS XR RUN PWR,NSHUT,MON 0/0/0 A9K-MPA-20X1GE OK PWR,NSHUT,MON 0/0/1 A9K-MPA-20X1GE OK PWR,NSHUT,MON @@ -451,6 +451,8 @@ admin: config: prompt: "RP/0/RP0/CPU0:%N(config)#" commands: &config_cmds + "hostname R2": + new_state: config_r2 "end": new_state: enable "exit": @@ -491,6 +493,26 @@ config: "redundancy": new_state: config_redundancy +commit_prompt_r2: + prompt: "Uncommitted changes found, commit them before exiting(yes/no/cancel)? [cancel]:" + commands: + "yes": + new_state: config_r2 + +config_r2: + prompt: "RP/0/RP0/CPU0:R2(config)#" + commands: + <<: *config_cmds + commit: + new_state: commit_prompt_r2 + end: + new_state: enable_r2 + +enable_r2: + prompt: "RP/0/RP0/CPU0:R2#" + commands: + <<: *enable_cmds + config_redundancy: prompt: "RP/0/RP0/CPU0:%N(config)#" commands: @@ -688,7 +710,7 @@ enable1: "clear logg": new_state: half_confirm_prompt - + admin1: prompt: "sysadmin-vm:0_RP0#" @@ -712,8 +734,8 @@ admin1: ----------------------------------------------------------------------------- 0/RSP0/CPU0 A9K-RSP-4G(Active) IOS XR RUN PWR,NSHUT,MON 0/RSP1/CPU0 A9K-RSP-4G(Standby) IOS XR RUN PWR,NSHUT,MON - 0/FT0/SP FAN TRAY READY - 0/FT1/SP FAN TRAY READY + 0/FT0/SP FAN TRAY READY + 0/FT1/SP FAN TRAY READY 0/0/CPU0 A9K-MOD80-SE IOS XR RUN PWR,NSHUT,MON 0/0/0 A9K-MPA-20X1GE OK PWR,NSHUT,MON 0/0/1 A9K-MPA-20X1GE OK PWR,NSHUT,MON @@ -990,17 +1012,17 @@ asr9k_enable: Process Redundancy Partner (0/RSP1/CPU0) is in BACKUP role Backup node in 0/RSP1/CPU0 is ready Backup node in 0/RSP1/CPU0 is NSR-not-configured - - Group Primary Backup Status - --------- --------- --------- --------- - v6-routing 0/RSP0/CPU0 0/RSP1/CPU0 Ready - mcast-routing 0/RSP0/CPU0 0/RSP1/CPU0 Ready - netmgmt 0/RSP0/CPU0 0/RSP1/CPU0 Ready - v4-routing 0/RSP0/CPU0 0/RSP1/CPU0 Ready - central-services 0/RSP0/CPU0 0/RSP1/CPU0 Ready - dsc 0/RSP0/CPU0 0/RSP1/CPU0 Ready - dlrsc 0/RSP0/CPU0 0/RSP1/CPU0 Ready - + + Group Primary Backup Status + --------- --------- --------- --------- + v6-routing 0/RSP0/CPU0 0/RSP1/CPU0 Ready + mcast-routing 0/RSP0/CPU0 0/RSP1/CPU0 Ready + netmgmt 0/RSP0/CPU0 0/RSP1/CPU0 Ready + v4-routing 0/RSP0/CPU0 0/RSP1/CPU0 Ready + central-services 0/RSP0/CPU0 0/RSP1/CPU0 Ready + dsc 0/RSP0/CPU0 0/RSP1/CPU0 Ready + dlrsc 0/RSP0/CPU0 0/RSP1/CPU0 Ready + Reload and boot info ---------------------- A9K-RSP440-SE reloaded Thu May 21 17:12:33 2020: 1 hour, 41 minutes ago @@ -1010,7 +1032,7 @@ asr9k_enable: Standby node last went not ready Thu May 21 18:05:59 2020: 47 minutes ago Standby node last went ready Thu May 21 18:06:59 2020: 46 minutes ago There have been 2 switch-overs since reload - + Active node reload "Cause: User Initiated reload" Standby node reload "Cause: User Initiated reload" @@ -1031,11 +1053,11 @@ asr9k_config: "commmit": "" "line console": new_state: - asr9k_line_console + asr9k_line_console asr9k_config_line: prompt: "RP/0/RSP1/CPU0:PE1(config-line)#" - commands: + commands: "exec-timeout 0 0": "" "clock timezone UTC 0 0": "" "commit": "" @@ -1066,7 +1088,7 @@ asr9k_admin: "exit": new_state: asr9k_enable -# --- iosxrv ----- +# --- iosxrv ----- iosxrv_enable: prompt: "RP/0/0/CPU0:iosxrv-1#" commands: diff --git a/src/unicon/plugins/tests/mock_data/iosxr/iosxr_spitfire_mock_data.yaml b/src/unicon/plugins/tests/mock_data/iosxr/iosxr_spitfire_mock_data.yaml index 96d4ed91..00c22599 100644 --- a/src/unicon/plugins/tests/mock_data/iosxr/iosxr_spitfire_mock_data.yaml +++ b/src/unicon/plugins/tests/mock_data/iosxr/iosxr_spitfire_mock_data.yaml @@ -26,7 +26,7 @@ spitfire_pw: spitfire_enable: prompt: RP/0/RP0/CPU0:%N# - commands: + commands: &spitfire_enable_cmds "ctrl": new_state: spitfire_bmc "terminal length 0": "" @@ -442,7 +442,9 @@ spitfire_xr_env: spitfire_config: prompt: "RP/0/RP0/CPU0:%N(config)#" - commands: &config_cmds + commands: &spitfire_config_cmds + "hostname R2": + new_state: spitfire_config_r2 "end": new_state: spitfire_enable "hostname Router": "" @@ -635,3 +637,26 @@ spitfire_showtech_syslog: - 4:5,0.5,0.1 - 5:8,5,3 - 8:,3 + + +spitfire_commit_prompt_r2: + prompt: "Uncommitted changes found, commit them before exiting(yes/no/cancel)? [cancel]:" + commands: + "yes": + new_state: spitfire_config_r2 + + +spitfire_enable_r2: + prompt: "RP/0/RP0/CPU0:R2#" + commands: + <<: *spitfire_enable_cmds + + +spitfire_config_r2: + prompt: "RP/0/RP0/CPU0:R2(config)#" + commands: + <<: *spitfire_config_cmds + commit: + new_state: spitfire_commit_prompt_r2 + end: + new_state: spitfire_enable_r2 diff --git a/src/unicon/plugins/tests/test_plugin_apic.py b/src/unicon/plugins/tests/test_plugin_apic.py index ac1f1fde..9b1390d9 100644 --- a/src/unicon/plugins/tests/test_plugin_apic.py +++ b/src/unicon/plugins/tests/test_plugin_apic.py @@ -8,6 +8,7 @@ __author__ = "karmoham" import unittest +import sys from unittest.mock import patch from pyats.topology import loader @@ -136,6 +137,19 @@ def test_execute_output(self): c.execute("show firmware upgrade status") c.disconnect() + def test_configure_output(self): + c = Connection(hostname='APC', + start=[APIC_MOCK_DEVICE_CLI], + os='apic', + username='cisco', + tacacs_password='cisco') + c.connect() + output = c.configure("switch-group") + expected_output = "switch-group\n\n\nError: Invalid argument ''. Please check syntax in command reference guide\n \n \n\n\n" + self.assertEqual(output, expected_output) + c.disconnect() + + @patch.object(unicon.settings.Settings, 'POST_DISCONNECT_WAIT_SEC', 0) @patch.object(unicon.settings.Settings, 'GRACEFUL_DISCONNECT_WAIT_SEC', 0.2) class TestAciSSH(unittest.TestCase): diff --git a/src/unicon/plugins/tests/test_plugin_iosxr.py b/src/unicon/plugins/tests/test_plugin_iosxr.py index 013a82d7..521880fd 100644 --- a/src/unicon/plugins/tests/test_plugin_iosxr.py +++ b/src/unicon/plugins/tests/test_plugin_iosxr.py @@ -210,6 +210,12 @@ def test_failed_config_error_message2(self): with self.assertRaisesRegex(unicon.core.errors.SubCommandFailure, "% Invalid config"): self._conn.configure("test failed2") + def test_update_hostname(self): + self.assertEqual('Router', self._conn.hostname) + self._conn.configure('hostname R2') + self.assertEqual('R2', self._conn.hostname) + + class TestIosXrPluginAdminService(unittest.TestCase): def test_admin(self): diff --git a/src/unicon/plugins/tests/test_plugin_iosxr_spitfire.py b/src/unicon/plugins/tests/test_plugin_iosxr_spitfire.py index 03d503d0..df88d38d 100644 --- a/src/unicon/plugins/tests/test_plugin_iosxr_spitfire.py +++ b/src/unicon/plugins/tests/test_plugin_iosxr_spitfire.py @@ -486,7 +486,11 @@ def test_failed_config(self): self._conn.execute("test failed") self._conn.spawn.timeout = 60 self._conn.enable() - + + def test_learn_hostname(self): + self.assertEqual('Router', self._conn.hostname) + self._conn.configure('hostname R2') + self.assertEqual('R2', self._conn.hostname) class TestIosXrSpitfireSyslogHandler(unittest.TestCase): """Tests for syslog message handling.""" diff --git a/src/unicon/plugins/tests/test_plugin_nxos.py b/src/unicon/plugins/tests/test_plugin_nxos.py index 36be94aa..a8dda123 100644 --- a/src/unicon/plugins/tests/test_plugin_nxos.py +++ b/src/unicon/plugins/tests/test_plugin_nxos.py @@ -718,7 +718,9 @@ def test_config_locked(self): c.configure('') c.disconnect() - + + def test_configure_update_hostname(self): + self.dev.configure('switchname Router') class TestNxosConfigureDual(unittest.TestCase): @classmethod diff --git a/src/unicon/plugins/tests/test_utils.py b/src/unicon/plugins/tests/test_utils.py index 0fa99966..4bc00a26 100644 --- a/src/unicon/plugins/tests/test_utils.py +++ b/src/unicon/plugins/tests/test_utils.py @@ -106,7 +106,7 @@ def test_iosxe_learn_tokens_from_show_version_pid_number(self): self.assertEqual(self.dev.os, 'iosxe') self.assertEqual(self.dev.version, '15.2') self.assertEqual(self.dev.platform, 'asr1k') - self.assertEqual(self.dev.model, 'asr1000') + self.assertEqual(self.dev.model, 'asr1006') self.assertEqual(self.dev.pid, 'ASR1006') finally: self.dev.disconnect() @@ -407,7 +407,7 @@ def test_pid_token_lookup(self): 'pid': 'ASR1001-2XOC3POS', 'os': 'iosxe', 'platform': 'asr1k', - 'model': 'asr1000' + 'model': 'asr1001' }, tokens) @@ -486,7 +486,7 @@ def test_learn_token_HA(self): self.assertEqual(dev.os, 'iosxe') self.assertEqual(dev.version, '16.7') self.assertEqual(dev.platform, 'asr1k') - self.assertEqual(dev.model, 'asr1000') + self.assertEqual(dev.model, 'asr1006') self.assertEqual(dev.pid, 'ASR1006')