This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

Upgrade Cisco IOS (.BIN file) via TFTP - Cisco LAN Access Switches.ncm-template

This Configuration Change Template upgrades the operating system (IOS Version) on your Cisco IOS device. Supports all current Cisco LAN Access Switches including the 2950, 3550, 3560, 2960, 3750, 2975 series switches. This script when executed will prompt you for the IOS archive filename ending in .bin. This file is assumed to be located in the root of your NCM TFTP Directory (normally C:\TFTP-Root). If you have your IOS upgrades in a subdirectory of TFTP-Root provide the directory name when prompted for the IOS upgrade filename. I.E (IOSUPGRADES\c3550-ipbasek9-tar.122-44.SE6.bin)

  • Hi Greg,

    Thanks for posting this, it looks excellent.

    One thing though, i would recommend adding a line to rewrite the startup configuration, as it stands now it would erase the flash but not re-create the startup configuration. (that or just make a note that somebody should do this afterwards)

    Also, i have chosen to remove the creation of the boot string in ours, otherwise its excellent emoticons_happy.png

    Thanks,

    Ayden

    EDIT: Nevermind, i didnt realise it asked you afterwards anyway.... (new to NCM)

  • Hello, I am new to the Thwack and also to NCM. With the script above to upload a new IOS to a switch, when I attmept to run this to a test 3560 switch, i get the prompt to enter the IOS name ***.bin, this seems to be ok and doesnt throw any errors, but then i get the sstaus Complete and a Green Tick, i get an error.  Is there anything I need to change within the script itself before running does the switch have to have an IOS already in the flash directory, i am not sure if this script will remove the exisiting IOS to make room for the new IOS anyway I have attached the error i get:

    Error:Variable @End could not be matched. Possible causes of this are:

    Error:Variable @End could not be matched. Possible causes of this are:

      ^

    % Invalid input detected at '^' marker.

    1) It has not been declared.

    1) It has not been declared.

      ^

    % Invalid input detected at '^' marker.

    2) You are referencing an entity property which does not exist.

    2) You are referencing an entity property which does not exist.

      ^

    % Invalid input detected at '^' marker.

    3) You are missing a closing bracket in a prior native block.

    3) You are missing a closing bracket in a prior native block.

      ^

    % Invalid input detected at '^' marker.

  • I had a similar problem with the script ( a few actually) using it on our 3750's.

    To fix the @End error you just need to add a variable definition for end, put this:

    string @End = 'end'

    Just under the string @Exit = 'exit' line, it should fix that problem.

    Post back how you went with the script too, on our 3750's, it erases flash then immediately just logs out, finishing with a complete. The script output just shows all hte commands, but i know from looking at the device the IOS etc has not copied over.

    I have modified the script into 2 seperate scripts, one to erase flash, and one to do a copy of a bin file, this has proven to be much more reliable for me.

    Let me know how you go, I will upload them if you have no luck emoticons_happy.png

    Cheers,

    Ayden

  • Morning, thank you Auden, i done what you suggested, and although i dont get those error messages I am not getting what i think i should expect.  I take it this script will remove the exisitng IOS file from flash, but i am not sure if 'erase flash' does this, i ran the script and it didnt delete the old IOS from flash nor did it copy the new IOS up to flash. the script results show this.

    conf t

    Enter configuration commands, one per line.  End with CNTL/Z.

    file prompt quiet

    exit

    erase flash:

    copy tftp://192.168.168.4/c3560-ipservicesk9-mz.122-55.SE6.bin flash://c3560-ipservicesk9-mz.122-55.SE6.bin

    conf t

    Enter configuration commands, one per line.  End with CNTL/Z.

    boot system flash:c3560-ipservicesk9-mz.122-55.SE6.bin

    end

    thats it.

    any help would be apprecitaed or having a look at your scripts after you split them

    Peter

  • Hi Peter,

    I have actually had a few problems with the process, it seems that running the erase required a "Y" after it to confirm, hence why it wasnt doing it, on top of that, the console would time out while the flash erased and the rest of the script would fail to execute (despite being marked as successful)

    I have actually just deleted my scripts this morning due to all the problems, and gone with a more simple "archive" style upgrade using this one:

  • Greg and abeeson,

    Thank you this works great, I have recently had two uploads burn me with corrupted IOSs so I am running your script with this additional line:

    string @Verify = 'verify /md5 ' + @CopyImg2

    How can I show in my "Script Results" the text at the end of the dots? i.e .....Done!

    Thanks for the help.

  • hello all, sorry for a newbie question but this is my first crack at NCM.

    i have modified this script to also include a scheduled reboot. ( see below)

    however i was wondering what do i need to do so that it knows what is the StorageAddress ?do i replace  that with the actual IP of the TFTP server?  is there somewhere else that this gets defined?

    /*

    .CHANGE_TEMPLATE_DESCRIPTION

            This change script allows you erase the flash on Cisco IOS routers/switches and copy a new IOS .BIN image via tftp.

    .PLATFORM_DESCRIPTION

            This runs on Cisco IOS devices.

    .PARAMETER_LABEL @ContextNode

            NCM Node

    .PARAMETER_DESCRIPTION @ContextNode

            The node the template will operate on.  All templates require this by default. The target node is selected during the first part of the wizard so it will not be available for selection when defining values of variables.

    .PARAMETER_LABEL @IOS_FILENAME

            The File Name of the new IOS Version.

    .PARAMETER_DESCRIPTION @IOS_FILENAME

            This should be a valid Cisco IOS .BIN File. No spaces are allowed. A script will not be generated for a Cisco IOS Filename that includes a space.

    .PARAMETER_LABEL @ReloadTime

            Reload Time

    .PARAMETER_DESCRIPTION @ReloadTime

            Time that you wish the switch to reload in 24hr format HH:MM, i.e. 05:00 for 5am

    */

    script UpgradeIOS (

                             NCM.Nodes @ContextNode,

                             string @IOS_FILENAME )

    {

    string @FilePromptQuiet = 'file prompt quiet'

    string @NoFilePromptQuiet = 'no file prompt quiet'

    string @Exit = 'exit'

    string @EraseFlash = 'erase flash:'

    string @CopyImg = 'copy tftp://${StorageAddress}/' + @IOS_FILENAME

    string @CopyImg2 = ' flash://' + @IOS_FILENAME

    string @CopyImg3 = @CopyImg + @CopyImg2

    string @ConfT = 'conf t'

    string @BootSys = 'boot system flash:' + @IOS_FILENAME

    string @WriteMem = 'wr me'

    string @Reload = 'Reload at @ReloadTime'

    if (@IOS_FILENAME contains ' ')

    {}

    else

    {

      foreach ( @node in @ContextNode )

      {

        if ( @node.Vendor == 'Cisco' )

        {

            CLI

            {

    @ConfT

    @FilePromptQuiet

    @Exit

    @EraseFlash

    @CopyImg3

    @ConfT

    @BootSys

    @End

    @WriteMem

    @Reload

            }

        }

      }

    }

    }