01-09-2025 10:10 AM
I'm working on a homebuilt ZTP environment. I have it set up to download a Python script from my DNS server and start configuration as well as download the appropriate software image. That part is working well. What I can't figure out is how to install the new software. When I try using the single line command to install and reload the switch, I get a message stating "Interactive command cannot execute in non-interactive context". Has anyone successfully done this apart from DNAC? Another option could be something like DHCP option 125, but if I can do this via CLI, I'd prefer that. I've seen one suggestion to use the EEM, but that seems kind of hackish. I was hoping by now there was a better way.
Thank you
Solved! Go to Solution.
01-09-2025 10:34 AM
I’ve heard this a few times and no real work around. I would use a eem script such as
eem = '''event manager applet upgrade
event none maxrun 300
action 1.0 cli command "enable"
action 2.0 cli command "request platform software package install switch all file flash: cat9k_iosxe.16.06.03.SPA.bin auto-copy" '''
cli.configurep(eem)
install_cmd = "event manager run upgrade"
cli.executep (install_cmd)
01-09-2025 10:34 AM
I’ve heard this a few times and no real work around. I would use a eem script such as
eem = '''event manager applet upgrade
event none maxrun 300
action 1.0 cli command "enable"
action 2.0 cli command "request platform software package install switch all file flash: cat9k_iosxe.16.06.03.SPA.bin auto-copy" '''
cli.configurep(eem)
install_cmd = "event manager run upgrade"
cli.executep (install_cmd)
01-09-2025 02:19 PM
Thanks for the reply. I was hoping for a solution truly using the CLI, but that appears to not be possible. Your solution works, and I will go with that. I had to alter slightly because I don't have the same install syntax. Below is what I'm using. One little note for those wanting to use this. The code will execute and the image will install in the background. So in my case, my provisioning will compete, and allow me to log into the switch before the install is done. Within a couple minutes, the switch will reload though. Don't assume it failed just because you can log in after provisioning.
Thanks for the help!
LITE = 'cat9k_lite_iosxe.17.12.04.SPA.bin'
FULL = 'cat9k_iosxe.17.12.04.SPA.bin'
def create_upgrade_applet(model):
print('Creating Applet')
if '9200' in model:
eem = f'''event manager applet upgrade
event none maxrun 300
action 1.0 cli command "enable"
action 2.0 cli command "install add file flash:{LITE} activate commit prompt-level none" '''
cli.configurep(eem)
else:
eem = f'''event manager applet upgrade
event none maxrun 300
action 1.0 cli command "enable"
action 2.0 cli command "install add file flash:{FULL} activate commit prompt-level none" '''
cli.configurep(eem)
def install_image():
print('Running applet')
install_cmd = "event manager run upgrade"
cli.executep (install_cmd)
create_upgrade_applet(model)
install_image()
01-10-2025 03:14 AM
Awesome!
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide