From c36106056737afa8d90ffeea4169a402433596f3 Mon Sep 17 00:00:00 2001 From: Thomas Ryan Date: Mon, 27 May 2024 11:14:04 -0400 Subject: [PATCH] Releasing v24.5 --- docs/changelog/2024/may.rst | 59 ++++++++++ docs/changelog/index.rst | 1 + docs/changelog_plugins/2024/may.rst | 51 ++++++++ docs/changelog_plugins/index.rst | 1 + src/unicon/plugins/__init__.py | 2 +- .../iosxe/cat8k/service_implementation.py | 4 + .../iosxe/cat9k/service_implementation.py | 4 +- src/unicon/plugins/iosxe/cat9k/statements.py | 3 +- .../plugins/iosxe/connection_provider.py | 7 ++ .../iosxr/spitfire/service_implementation.py | 4 +- src/unicon/plugins/sros/patterns.py | 2 +- .../iosxe/iosxe_mock_data_cat9k_reload.yaml | 46 ++++++++ .../iosxe/iosxe_mock_data_sdwan.yaml | 111 +++++++++++++++++- .../tests/mock_data/sros/sros_mock_data.yaml | 10 +- .../plugins/tests/test_plugin_iosxe_cat9k.py | 30 +++++ .../plugins/tests/test_plugin_iosxe_sdwan.py | 26 +++- src/unicon/plugins/tests/test_plugin_sros.py | 6 + 17 files changed, 355 insertions(+), 12 deletions(-) create mode 100644 docs/changelog/2024/may.rst create mode 100644 docs/changelog_plugins/2024/may.rst diff --git a/docs/changelog/2024/may.rst b/docs/changelog/2024/may.rst new file mode 100644 index 00000000..1986ea03 --- /dev/null +++ b/docs/changelog/2024/may.rst @@ -0,0 +1,59 @@ +May 2024 +========== + +May 28 - Unicon v24.5 +------------------------ + + + +.. csv-table:: Module Versions + :header: "Modules", "Versions" + + ``unicon.plugins``, v24.5 + ``unicon``, v24.5 + +Install Instructions +^^^^^^^^^^^^^^^^^^^^ + +.. code-block:: bash + + bash$ pip install unicon.plugins + bash$ pip install unicon + +Upgrade Instructions +^^^^^^^^^^^^^^^^^^^^ + +.. code-block:: bash + + bash$ pip install --upgrade unicon.plugins + bash$ pip install --upgrade unicon + +Features and Bug Fixes: +^^^^^^^^^^^^^^^^^^^^^^^ + + + + +Changelogs +^^^^^^^^^^ +-------------------------------------------------------------------------------- + Fix +-------------------------------------------------------------------------------- + +* playback + * mock_helper + * Added show version | include operating mode to list of recorded commands + + +-------------------------------------------------------------------------------- + Fix +-------------------------------------------------------------------------------- + +* iosxe + * cat9k + * Modified summary.py + * Added reload_confirm_iosxe to reload_to_rommon_statement_list + * Added post time + * Added POST_SWITCHOVER_WAIT before enable + + diff --git a/docs/changelog/index.rst b/docs/changelog/index.rst index 6267ffc7..24e1f86a 100644 --- a/docs/changelog/index.rst +++ b/docs/changelog/index.rst @@ -4,6 +4,7 @@ Changelog .. toctree:: :maxdepth: 2 + 2024/may 2024/april 2024/march 2024/february diff --git a/docs/changelog_plugins/2024/may.rst b/docs/changelog_plugins/2024/may.rst new file mode 100644 index 00000000..aaa05730 --- /dev/null +++ b/docs/changelog_plugins/2024/may.rst @@ -0,0 +1,51 @@ +May 2024 +========== + +May 28 - Unicon.Plugins v24.5 +------------------------ + + + +.. csv-table:: Module Versions + :header: "Modules", "Versions" + + ``unicon.plugins``, v24.5 + ``unicon``, v24.5 + +Install Instructions +^^^^^^^^^^^^^^^^^^^^ + +.. code-block:: bash + + bash$ pip install unicon.plugins + bash$ pip install unicon + +Upgrade Instructions +^^^^^^^^^^^^^^^^^^^^ + +.. code-block:: bash + + bash$ pip install --upgrade unicon.plugins + bash$ pip install --upgrade unicon + +Features and Bug Fixes: +^^^^^^^^^^^^^^^^^^^^^^^ + + + + +Changelogs +^^^^^^^^^^ +-------------------------------------------------------------------------------- + Fix +-------------------------------------------------------------------------------- + +* sros + * Updated mdcli regex prompt to accommodate various output + +* iosxe + * CAT9K + * Updated regex in Rommon service + * Modified learn_tokens to go to enable mode before sending stop PnP disovery + + diff --git a/docs/changelog_plugins/index.rst b/docs/changelog_plugins/index.rst index 04171b38..5e79066b 100644 --- a/docs/changelog_plugins/index.rst +++ b/docs/changelog_plugins/index.rst @@ -4,6 +4,7 @@ Plugins Changelog .. toctree:: :maxdepth: 2 + 2024/may 2024/april 2024/march 2024/february diff --git a/src/unicon/plugins/__init__.py b/src/unicon/plugins/__init__.py index 3f8de17c..dc6b157f 100644 --- a/src/unicon/plugins/__init__.py +++ b/src/unicon/plugins/__init__.py @@ -1,4 +1,4 @@ -__version__ = '24.4' +__version__ = '24.5' supported_chassis = [ 'single_rp', diff --git a/src/unicon/plugins/iosxe/cat8k/service_implementation.py b/src/unicon/plugins/iosxe/cat8k/service_implementation.py index 5683ce8f..55f14090 100644 --- a/src/unicon/plugins/iosxe/cat8k/service_implementation.py +++ b/src/unicon/plugins/iosxe/cat8k/service_implementation.py @@ -115,6 +115,10 @@ def call_service(self, command=None, timeout=con.connection_timeout, context=self.context ) + + con.log.info(f'Waiting {con.settings.POST_SWITCHOVER_WAIT} seconds before going to enable mode') + sleep(con.settings.POST_SWITCHOVER_WAIT) + con.spawn.sendline() con.state_machine.go_to( 'enable', diff --git a/src/unicon/plugins/iosxe/cat9k/service_implementation.py b/src/unicon/plugins/iosxe/cat9k/service_implementation.py index 617a72e8..3b114338 100644 --- a/src/unicon/plugins/iosxe/cat9k/service_implementation.py +++ b/src/unicon/plugins/iosxe/cat9k/service_implementation.py @@ -125,10 +125,10 @@ def pre_service(self, *args, **kwargs): con.spawn, context=self.context) boot_info = con.execute('show boot') - m = re.search(r'Enable Break = (yes|no)|ENABLE_BREAK variable (= yes|does not exist)', boot_info) + m = re.search(r'Enable Break = (yes|no|0|1)|ENABLE_BREAK variable (= yes|does not exist)', boot_info) if m: break_enabled = m.group() - if 'yes' not in break_enabled: + if all(i not in break_enabled for i in ['yes', '1']): con.configure('boot enable-break') else: raise SubCommandFailure('Could not determine if break is enabled, cannot transition to rommon') diff --git a/src/unicon/plugins/iosxe/cat9k/statements.py b/src/unicon/plugins/iosxe/cat9k/statements.py index 9c327e02..affe2972 100644 --- a/src/unicon/plugins/iosxe/cat9k/statements.py +++ b/src/unicon/plugins/iosxe/cat9k/statements.py @@ -1,7 +1,7 @@ from unicon.eal.dialogs import Statement from unicon.plugins.generic.service_statements import ( - save_env, confirm_reset, reload_confirm, reload_confirm_ios) + save_env, confirm_reset, reload_confirm, reload_confirm_ios, reload_confirm_iosxe) from .patterns import IosXECat9kPatterns @@ -20,4 +20,5 @@ confirm_reset, reload_confirm, reload_confirm_ios, + reload_confirm_iosxe, boot_interrupt_stmt] diff --git a/src/unicon/plugins/iosxe/connection_provider.py b/src/unicon/plugins/iosxe/connection_provider.py index d9df63af..fd2afbf2 100644 --- a/src/unicon/plugins/iosxe/connection_provider.py +++ b/src/unicon/plugins/iosxe/connection_provider.py @@ -47,6 +47,13 @@ def learn_tokens(self): GenericPatterns().learn_os_prompt) con.state_machine.add_state(self.learn_tokens_state) + # Change to enable state before sending stop PnP disovery + con.state_machine.go_to('enable', + con.spawn, + context=con.context, + timeout=con.connection_timeout, + prompt_recovery=con.prompt_recovery) + # The first thing we need to is to send stop PnP discovery otherwise device will not execute any command. con.spawn.sendline('pnpa service discovery stop') # The device may reload after the command we get the dialog statements from reload service and try to handle that diff --git a/src/unicon/plugins/iosxr/spitfire/service_implementation.py b/src/unicon/plugins/iosxr/spitfire/service_implementation.py index 07b3bca0..5f195c5f 100644 --- a/src/unicon/plugins/iosxr/spitfire/service_implementation.py +++ b/src/unicon/plugins/iosxr/spitfire/service_implementation.py @@ -312,10 +312,10 @@ def call_service(self, line_type = line_type[1] if reload_creds: - context = self.context.copy() + context = con.active.context.copy() context.update(cred_list=reload_creds) else: - context = self.context + context = con.active.context if line_type != 'Console': raise Exception("Console is not used.") diff --git a/src/unicon/plugins/sros/patterns.py b/src/unicon/plugins/sros/patterns.py index e33a175e..72aad2ba 100644 --- a/src/unicon/plugins/sros/patterns.py +++ b/src/unicon/plugins/sros/patterns.py @@ -9,6 +9,6 @@ def __init__(self): super().__init__() self.continue_connect = r'Are you sure you want to continue connecting \(yes/no(/\[fingerprint\])?\)' self.permission_denied = r'^Permission denied, please try again\.\s?$' - self.mdcli_prompt = r'^(.*?)\[.*\][\r\n]+[AB]:.*@%N[#$]\s?$' + self.mdcli_prompt = r'^(.*?)(\[[^\]]*\])?[\r\n]+[AB]:.*@%N[#$]\s?$' self.classiccli_prompt = r'^(.*?)\*?[AB]:%N(>.*)?[#$]\s?$' self.discard_uncommitted = r'Discard uncommitted changes\? \[y,n\]' diff --git a/src/unicon/plugins/tests/mock_data/iosxe/iosxe_mock_data_cat9k_reload.yaml b/src/unicon/plugins/tests/mock_data/iosxe/iosxe_mock_data_cat9k_reload.yaml index ec1604ca..84c6fa26 100644 --- a/src/unicon/plugins/tests/mock_data/iosxe/iosxe_mock_data_cat9k_reload.yaml +++ b/src/unicon/plugins/tests/mock_data/iosxe/iosxe_mock_data_cat9k_reload.yaml @@ -87,6 +87,52 @@ cat9k_enable_reload_to_rommon_break2: "reload": new_state: cat9k_boot_to_rommon + +cat9k_enable_reload_to_rommon_break3: + prompt: "switch1#" + commands: + "show version | include operating mode": "" + "show boot": | + --------------------------- + Switch 1 + --------------------------- + Current Boot Variables: + BOOT variable does not exist + + Boot Variables on next reload: + BOOT variable does not exist + Manual Boot = yes + Enable Break = 1 + Boot Mode = DEVICE + iPXE Timeout = 0 + "config term": + new_state: cat9k_enable_reload_to_rommon_break_config + "reload": + new_state: cat9k_boot_to_rommon + + +cat9k_enable_reload_to_rommon_break4: + prompt: "switch1#" + commands: + "show version | include operating mode": "" + "show boot": | + --------------------------- + Switch 1 + --------------------------- + Current Boot Variables: + BOOT variable does not exist + + Boot Variables on next reload: + BOOT variable does not exist + Manual Boot = yes + Enable Break = 0 + Boot Mode = DEVICE + iPXE Timeout = 0 + "config term": + new_state: cat9k_enable_reload_to_rommon_break_config + "reload": + new_state: cat9k_boot_to_rommon + cat9k_enable_reload_to_rommon_break_config: prompt: "%N(config)#" commands: diff --git a/src/unicon/plugins/tests/mock_data/iosxe/iosxe_mock_data_sdwan.yaml b/src/unicon/plugins/tests/mock_data/iosxe/iosxe_mock_data_sdwan.yaml index e6ab4249..81930436 100644 --- a/src/unicon/plugins/tests/mock_data/iosxe/iosxe_mock_data_sdwan.yaml +++ b/src/unicon/plugins/tests/mock_data/iosxe/iosxe_mock_data_sdwan.yaml @@ -121,4 +121,113 @@ sdwan_config_commit_confirm: prompt: "Proceed? [yes,no]" commands: "yes": - new_state: sdwan_config2 \ No newline at end of file + new_state: sdwan_config2 + +sdwan_controller_mode: + prompt: "%N>" + commands: + "show version | include operating mode": "Router operating mode: Controller-Managed" + "enable": + new_state: sdwan_controller_mode_enable + +sdwan_controller_mode_enable: + prompt: "%N#" + commands: + <<: *sdwan_enable_cmds + "show version": | + Cisco IOS XE Software, Version BLD_V1715_THROTTLE_LATEST_20240501_033727_V17_15_0_32 + Cisco IOS Software [IOSXE], c8000aep Software (X86_64_LINUX_IOSD-UNIVERSALK9-M), Experimental Version 17.15.20240501:040851 [BLD_V1715_THROTTLE_LATEST_20240501_033727:/nobackup/mcpre/s2c-build-ws 102] + Copyright (c) 1986-2024 by Cisco Systems, Inc. + Compiled Tue 30-Apr-24 21:09 by mcpre + + + Cisco IOS-XE software, Copyright (c) 2005-2024 by cisco Systems, Inc. + All rights reserved. Certain components of Cisco IOS-XE software are + licensed under the GNU General Public License ("GPL") Version 2.0. The + software code licensed under GPL Version 2.0 is free software that comes + with ABSOLUTELY NO WARRANTY. You can redistribute and/or modify such + GPL code under the terms of GPL Version 2.0. For more details, see the + documentation or "License Notice" file accompanying the IOS-XE software, + or the applicable URL provided on the flyer accompanying the IOS-XE + software. + + + ROM: Encore_V14 + Encore uptime is 1 day, 14 hours, 52 minutes + Uptime for this control processor is 1 day, 14 hours, 53 minutes + System returned to ROM by Image Install + System image file is "bootflash:packages.conf" + Last reload reason: Image Install + + + + This product contains cryptographic features and is subject to United + States and local country laws governing import, export, transfer and + use. Delivery of Cisco cryptographic products does not imply + third-party authority to import, export, distribute or use encryption. + Importers, exporters, distributors and users are responsible for + compliance with U.S. and local country laws. By using this product you + agree to comply with applicable laws and regulations. If you are unable + to comply with U.S. and local laws, return this product immediately. + + A summary of U.S. laws governing Cisco cryptographic products may be found at: + http://www.cisco.com/wwl/export/crypto/tool/stqrg.html + + If you require further assistance please contact us by sending email to + export@cisco.com. + + License Mode: Controller-Managed + + Smart Licensing Status: Smart Licensing Using Policy + + cisco C8530-12X4QC (1EN) processor (revision 1EN) with 14594820K/6147K bytes of memory. + Processor board ID FLX273502YF + Router operating mode: Controller-Managed + 12 Ten Gigabit Ethernet interfaces + 3 Forty Gigabit Ethernet interfaces + 32768K bytes of non-volatile configuration memory. + 33554432K bytes of physical memory. + 464553984K bytes of NVMe SSD flash at bootflash:. + + Configuration register is 0x2102 + "show inventory": | + NAME: "Chassis", DESCR: "Cisco C8530-12X4QC Chassis" + PID: C8530-12X4QC , VID: V00 , SN: FLX273502YF + + NAME: "Fan Tray", DESCR: "Cisco C8500-FAN-1R Fan Tray" + PID: C8500-FAN-1R , VID: , SN: + + NAME: "module 0", DESCR: "Cisco C8530-12X4QC Modular Interface Processor" + PID: C8530-12X4QC , VID: , SN: + + NAME: "SPA subslot 0/0", DESCR: "8-port 10/1G SFP Ethernet Port Adapter" + PID: 8xSFP+ , VID: N/A , SN: JAE12345678 + + NAME: "subslot 0/0 transceiver 0", DESCR: "10GE SR" + PID: SFP-10G-SR-S , VID: V01 , SN: OPM25160UGU + + NAME: "subslot 0/0 transceiver 1", DESCR: "10GE SR" + PID: SFP-10G-SR , VID: V03 , SN: AGA15514DWD + + NAME: "subslot 0/0 transceiver 2", DESCR: "10GE SR" + PID: SFP-10G-SR-S , VID: V01 , SN: FNS26090JAL + + NAME: "subslot 0/0 transceiver 3", DESCR: "10GE SR" + PID: SFP-10G-SR-S , VID: V01 , SN: FNS26090L1M + + NAME: "subslot 0/0 transceiver 4", DESCR: "10GE SR" + PID: SFP-10G-SR-S , VID: V01 , SN: FNS26090JAW + + NAME: "SPA subslot 0/1", DESCR: "1-port 40/1-port 100/4-port 10 Gigabit QSFP Ethernet Port Adapter" + PID: 4xSFP+/1xQSFP , VID: N/A , SN: JAE12345678 + + NAME: "SPA subslot 0/2", DESCR: "3-port 40 / 1-port 100 Gigabit QSFP Ethernet Port Adapter" + PID: 3xQSFP , VID: N/A , SN: JAE12345678 + + NAME: "module R0", DESCR: "Cisco C8530-12X4QC Route Processor" + PID: C8530-12X4QC , VID: V00 , SN: JAE273709CU + + NAME: "module F0", DESCR: "Cisco C8530-12X4QC Embedded Services Processor" + PID: C8530-12X4QC , VID: , SN: + "uname -a": "" + "pnpa service discovery stop": "" \ No newline at end of file diff --git a/src/unicon/plugins/tests/mock_data/sros/sros_mock_data.yaml b/src/unicon/plugins/tests/mock_data/sros/sros_mock_data.yaml index 370035c8..853cbc95 100644 --- a/src/unicon/plugins/tests/mock_data/sros/sros_mock_data.yaml +++ b/src/unicon/plugins/tests/mock_data/sros/sros_mock_data.yaml @@ -42,6 +42,13 @@ mdcli_execute: new_state: mdcli_configure_global "environment console length 512": "" "environment console width 512": "" + "show port description": | + 1/1/c1 QSFP28 Connector + 1/1/c1/1 IMO1CRIP002:1/1/c22/1 C00235986 [I] + 1/1/c2 QSFP28 Connector + 1/1/c2/1 IMO1CRIP002:1/1/c23/1 C00235987 [I] + + 2024-03-18 17:25:17 WEST keys: 'ctrl-z': "" "//": @@ -189,4 +196,5 @@ classiccli_config_lag_access: new_state: classiccli_config_lag keys: "ctrl-z": - new_state: classiccli_execute \ No newline at end of file + new_state: classiccli_execute + diff --git a/src/unicon/plugins/tests/test_plugin_iosxe_cat9k.py b/src/unicon/plugins/tests/test_plugin_iosxe_cat9k.py index 90094279..cb17fe1c 100644 --- a/src/unicon/plugins/tests/test_plugin_iosxe_cat9k.py +++ b/src/unicon/plugins/tests/test_plugin_iosxe_cat9k.py @@ -445,6 +445,36 @@ def test_rommon_enable_break2(self): self.assertEqual(c.state_machine.current_state, 'rommon') c.disconnect() + def test_rommon_enable_break3(self): + c = Connection(hostname='switch', + start=['mock_device_cli --os iosxe --state cat9k_enable_reload_to_rommon_break3'], + os='iosxe', + platform='cat9k', + mit=True, + credentials=dict(default=dict(username='cisco', password='cisco'), + alt=dict(username='admin', password='lab')), + settings=dict(POST_DISCONNECT_WAIT_SEC=0, GRACEFUL_DISCONNECT_WAIT_SEC=0.2), + log_buffer=True) + c.connect() + c.rommon() + self.assertEqual(c.state_machine.current_state, 'rommon') + c.disconnect() + + def test_rommon_enable_break4(self): + c = Connection(hostname='switch', + start=['mock_device_cli --os iosxe --state cat9k_enable_reload_to_rommon_break4'], + os='iosxe', + platform='cat9k', + mit=True, + credentials=dict(default=dict(username='cisco', password='cisco'), + alt=dict(username='admin', password='lab')), + settings=dict(POST_DISCONNECT_WAIT_SEC=0, GRACEFUL_DISCONNECT_WAIT_SEC=0.2), + log_buffer=True) + c.connect() + c.rommon() + self.assertEqual(c.state_machine.current_state, 'rommon') + c.disconnect() + def test_reload_with_image(self): c = Connection(hostname='switch', start=['mock_device_cli --os iosxe --state cat9k_enable_reload_to_rommon'], diff --git a/src/unicon/plugins/tests/test_plugin_iosxe_sdwan.py b/src/unicon/plugins/tests/test_plugin_iosxe_sdwan.py index ae0c63a9..18f07bd9 100644 --- a/src/unicon/plugins/tests/test_plugin_iosxe_sdwan.py +++ b/src/unicon/plugins/tests/test_plugin_iosxe_sdwan.py @@ -76,9 +76,29 @@ def test_iosxe_sdwan_connect(self): finally: d.disconnect() - @classmethod - def tearDownClass(self): - self.md.stop() + def test_iosxe_sdwan_controller_mode_connect(self): + testbed = ''' + devices: + Router: + type: router + os: iosxe + platform: sdwan + credentials: + default: + username: cisco + password: cisco + connections: + defaults: + class: 'unicon.Unicon' + cli: + command: mock_device_cli --os iosxe --state sdwan_controller_mode + ''' + t = loader.load(testbed) + d = t.devices.Router + try: + d.connect() + finally: + d.disconnect() class TestIosXESDWANConfigure(unittest.TestCase): diff --git a/src/unicon/plugins/tests/test_plugin_sros.py b/src/unicon/plugins/tests/test_plugin_sros.py index 902c9b4c..a12343f4 100644 --- a/src/unicon/plugins/tests/test_plugin_sros.py +++ b/src/unicon/plugins/tests/test_plugin_sros.py @@ -29,6 +29,12 @@ def test_mdcli_execute(self): expect = self.md.mock_data['mdcli_execute']['commands'][cmd] self.assertEqual(self.joined(output), self.joined(expect)) + def test_mdcli_1_execute(self): + cmd = "show port description" + out = self.con.mdcli_execute(cmd) + expect = self.md.mock_data['mdcli_execute']['commands'][cmd] + self.assertEqual(self.joined(out), self.joined(expect)) + def test_mdcli_configure(self): cmd = 'router interface coreloop ipv4 primary address 1.1.1.1 prefix-length 32' output = self.con.mdcli_configure(cmd, mode='global')