cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
135
Views
2
Helpful
3
Replies

Upgrading IOS XE during PnP with Guestshell

mradams33
Level 1
Level 1

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

1 Accepted Solution

Accepted Solutions

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)

Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io

View solution in original post

3 Replies 3

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)

Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io

mradams33
Level 1
Level 1

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()
 

Awesome!

Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io