I'm working with this great ZTP getting started repo
I'm having one issue and that is with the EEM upgrade function.
I have a C9300L-24P-4X running Cisco IOS XE Software, Version 16.12.02.
The script works beautifully until I try to install the software with the *deploy_eem_upgrade_script* function.
def deploy_eem_upgrade_script(image): install_command = 'install add file flash:' + image + ' activate commit' eem_commands = ['event manager applet upgrade', 'event none maxrun 600', 'action 1.0 cli command "enable"', 'action 2.0 cli command "%s" pattern "[y/n/q]"' % install_command, 'action 2.1 wait 10', 'action 2.2 cli command "n" pattern "proceed"', 'action 2.3 cli command "y"' ] results = configure(eem_commands) print("----->>> results of eem_commands:\n" + results) print '*** Successfully configured upgrade EEM script on device! ***'
Here is the error that I'm getting and its pretty consistent. I've played around with the EEM commands based on some EEM examples I've seen but so far no joy. I don't have a lot of EEM experience so I'm sure that is the problem.
*** Deploying EEM upgrade script *** Traceback (most recent call last): File "/bootflash/downloaded_script.py", line 206, in <module> main() File "/bootflash/downloaded_script.py", line 174, in main deploy_eem_upgrade_script(img_cat9k) File "/bootflash/downloaded_script.py", line 63, in deploy_eem_upgrade_script results = configure(eem_commands) File "/usr/lib/python2.7/site-packages/cli/__init__.py", line 185, in configure raise CLIConfigurationError(results) cli.CLIConfigurationError: ConfigError: There was a problem with 7 commands while configuring the device.
Here is the error in context:
--- System Configuration Dialog --- Would you like to enter the initial configuration dialog? [yes/no]: Loading http://192.168.1.25/ZTP_python.py Loading http://192.168.1.25/ZTP_python.py day0guestshell installed successfully Current state is: DEPLOYED day0guestshell activated successfully Current state is: ACTIVATED day0guestshell started successfully Current state is: RUNNING Guestshell enabled successfully HTTP server statistics: Accepted connections total: 0###### STARTING ZTP SCRIPT ###### *** Obtaining serial number of device.. *** *** Setting configuration file variable.. *** *** Config file: FOC.cfg *** ---->>>>> sh_version is Cisco IOS XE Software, Version 16.12.01 Cisco IOS Software [Gibraltar], Catalyst L3 Switch Software (CAT9K_IOSXE), Version 16.12.1, RELEASE SOFTWARE (fc4) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2019 by Cisco Systems, Inc. Compiled Tue 30-Jul-19 19:26 by mcpre Cisco IOS-XE software, Copyright (c) 2005-2019 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: IOS-XE ROMMON BOOTLDR: System Bootstrap, Version 16.12.2r, RELEASE SOFTWARE (P) Switch uptime is 2 minutes Uptime for this control processor is 3 minutes System returned to ROM by Image Install System image file is "flash: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 email@example.com. Technology Package License Information: ------------------------------------------------------------------------------ Technology-package Technology-package Current Type Next reboot ------------------------------------------------------------------------------ network-essentials Smart License network-essentials None Subscription Smart License None AIR License Level: AIR DNA Advantage Next reload AIR license Level: AIR DNA Advantage Smart Licensing Status: UNREGISTERED/EVAL MODE cisco C9300L-24P-4X (X86) processor with 1344464K/6147K bytes of memory. Processor board ID FOC2344L53F 1 Virtual Ethernet interface 24 Gigabit Ethernet interfaces 4 Ten Gigabit Ethernet interfaces 2048K bytes of non-volatile configuration memory. 8388608K bytes of physical memory. 1638400K bytes of Crash Files at crashinfo:. 11264000K bytes of Flash at flash:. 0K bytes of WebUI ODM Files at webui:. Base Ethernet MAC Address : 3c:51:0e:31:52:80 Motherboard Assembly Number : 73-19167-04 Motherboard Serial Number : FOC23443TLK Model Revision Number : F0 Motherboard Revision Number : C0 Model Number : C9300L-24P-4X System Serial Number : FOC2344L53F Switch Ports Model SW Version SW Image Mode ------ ----- ----- ---------- ---------- ---- * 1 29 C9300L-24P-4X 16.12.1 CAT9K_IOSXE INSTALL Configuration register is 0x102 *** Upgrade is required. Starting upgrade process.. *** *** Checking to see if cat9k_iosxe.16.12.02.SPA.bin exists on flash:/ *** *** The cat9k_iosxe.16.12.02.SPA.bin does NOT exist on flash:/ *** *** Successfully set "file prompt quiet" on switch *** ---->>>>> tansfere_file is copy http://192.168.1.25/cat9k_iosxe.16.12.02.SPA.bin flash:/ Transferring cat9k_iosxe.16.12.02.SPA.bin to flash:/ Verifying MD5 for flash:/cat9k_iosxe.16.12.02.SPA.bin *** MD5 hashes match!! *** *** Deploying EEM upgrade script *** Traceback (most recent call last): File "/bootflash/downloaded_script.py", line 206, in <module> main() File "/bootflash/downloaded_script.py", line 174, in main deploy_eem_upgrade_script(img_cat9k) File "/bootflash/downloaded_script.py", line 63, in deploy_eem_upgrade_script results = configure(eem_commands) File "/usr/lib/python2.7/site-packages/cli/__init__.py", line 185, in configure raise CLIConfigurationError(results) cli.CLIConfigurationError: ConfigError: There was a problem with 7 commands while configuring the device. Loading http://192.168.1.25/ZTP_python.py Loading http://192.168.1.25/ZTP_python.py HTTP server statistics: Accepted connections total: 7###### STARTING ZTP SCRIPT ###### *** Obtaining serial number of device.. *** *** Setting configuration file variable.. *** *** Config file: FOC2344L53F.cfg ***
Here is the working script in its current state:
On a more strategic note, is an EEM script the only way to go here? Are we limited by Python2 and the modules in the GuestShell?
Here is a log of the interactive session I'm trying to automate via EEM
Switch#install add file flash:cat9k_iosxe.16.12.01.SPA.bin activate commit install_add_activate_commit: START Mon Jan 18 19:53:16 UTC 2021 System configuration has been modified. Press Yes(y) to save the configuration and proceed. Press No(n) for proceeding without saving the configuration. Press Quit(q) to exit, you may save configuration and re-enter the command. [y/n/q]n *Jan 18 19:53:24.163: %INSTALL-5-INSTALL_START_INFO: Switch 1 R0/0: install_engine: Started install one-shot flash:cat9k_iosxe.16.12.01.SPA.bininstall_add_activate_commit: Adding PACKAGE install_add_activate_commit: Checking whether new add is allowed .... --- Starting initial file syncing --- Info: Finished copying flash:cat9k_iosxe.16.12.01.SPA.bin to the selected switch(es) Finished initial file syncing --- Starting Add --- Performing Add on all members  Add package(s) on switch 1  Finished Add on switch 1 Checking status of Add on  Add: Passed on  Finished Add Image added. Version: 220.127.116.11.544 install_add_activate_commit: Activating PACKAGE Following packages shall be activated: /flash/cat9k-wlc.16.12.01.SPA.pkg /flash/cat9k-webui.16.12.01.SPA.pkg /flash/cat9k-srdriver.16.12.01.SPA.pkg /flash/cat9k-sipspa.16.12.01.SPA.pkg /flash/cat9k-sipbase.16.12.01.SPA.pkg /flash/cat9k-rpboot.16.12.01.SPA.pkg /flash/cat9k-rpbase.16.12.01.SPA.pkg /flash/cat9k-guestshell.16.12.01.SPA.pkg /flash/cat9k-espbase.16.12.01.SPA.pkg /flash/cat9k-cc_srdriver.16.12.01.SPA.pkg This operation may require a reload of the system. Do you want to proceed? [y/n]