Giter Club home page Giter Club logo

switch-upgrade-tool's Introduction

switch-upgrade-tool

Network switch OS upgrade tool. Primarily used for Cisco IOS

Overview

In the default mode this tool will connect to a switch IP (or list of IP's) and gather all required information about the current OS version. It compares this to a simple config file, and displays if an OS upgrade is required. It also has copy, upgrade and reload modes, which can be used to fully automate the upgrade.

Usage

Execute /scripts/swupgrade.py

swupgrade.py (--host HOST | --list LIST) [--user USER] [--copy][--upgrade] [--reload] [--debug] [--help]

switch upgrade utility

optional arguments:
--host HOST switch IP address
--list LIST File containing list of switch IP addresses
--user USER Username to connect
--copy Copy upgrade files to devices
--upgrade Execute remote upgrade
--reload Reload switches post upgrade
--debug Debug logging
--help Show this help msg and exit

-- 2019 Liam Jordan

/backups/

Used during the copy, upgrade and reload phases. The switch config is saved to file automatically, the backups directory is the default save location.

/configs/

Used to store config files. The swimages.yml file is required, and contains information about possible upgrades. This should be updated with the OS version you want to use.

/images/

Used to store OS images. If you want to copy the image using the script, this is the default location. The file name should be the same as the image field in the swimages.yml file.

/iplists/

The default directory the script uses to look for an iplist file. Should be in the same format as example.ip.

switch-upgrade-tool's People

Contributors

lsjordan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

switch-upgrade-tool's Issues

Fix Reload Pending Bug

Address a bug where the --reload flag doesnt work, unless used at the same time as the --upgrade flag, due to the reload pending exception.

swupgrade.py --host 10.123.21.11 --user *** --copy --upgrade
Password:
[SUCCESS] - 10.123.21.11: [C2960+][lanlite][15.0(2)SE6] - upgrade to 15.2(4)E7 - file already on flash
[INFO] - [MAIN]: 10.123.21.11 - Preparing to upgrade...
[SUCCESS] - [MAIN]: 10.123.21.11 - Upgrade success

swupgrade.py --host 10.123.21.11 --user *** --copy --upgrade --reload
Password:
[ERROR] - 10.123.21.11: Not supported - RELOAD PENDING

swupgrade.py --host 10.123.21.11 --user *** --copy --upgrade --reload
Password:
[SUCCESS] - 10.123.21.11: [C2960+][lanlite][15.0(2)SE6] - upgrade to 15.2(4)E7 - file already on flash
[INFO] - [MAIN]: 10.123.21.11 - Preparing to upgrade...
[SUCCESS] - [MAIN]: 10.123.21.11 - Upgrade success
[INFO] - [MAIN]: 10.123.21.11 - Preparing to reload...
[SUCCESS] - [MAIN]: 10.123.21.11 - Reload success, reloading in 5 mins

Implement Multiprocessing

I have had a brief attempt at implementing some Multiprocessing streams to dramatically improve performance (SSH connections are inherently slow, and being able to run more than one switch at once will be a big performance gain).

There is a Multiprocessing branch with some example code that i don't really have the skills to implement, would appreciate any attempts or guidance.

  • Liam

Socket Timeout Bug

Address an issue where the control SSH connection expires if a file copy takes a long time.

[INFO] - [MAIN]: 10.5.21.11 - Preparing to copy file...
[SUCCESS] - [MAIN]: 10.5.21.11 - Copy success################] 100.0% - c2960s-universalk9-mz.152-2.E9.bin
[INFO] - [MAIN]: 10.5.21.12 - Preparing to copy file...
Traceback (most recent call last):
File "C:\Tools\switch-upgrade-tool\scripts\swupgrade.py", line 253, in
main(parse_arguments())
File "C:\Tools\switch-upgrade-tool\scripts\swupgrade.py", line 243, in main
success = copy_file(copy_list, log)
File "C:\Tools\switch-upgrade-tool\scripts\swupgrade.py", line 183, in copy_file
switch.save_config()
File "C:\Tools\switch-upgrade-tool\scripts\netdevices.py", line 209, in save_config
self.ssh().send_command("wr mem")
File "C:\tools\python\lib\site-packages\netmiko\base_connection.py", line 1139, in > send_command
prompt = self.find_prompt(delay_factor=delay_factor)
File "C:\tools\python\lib\site-packages\netmiko\base_connection.py", line 972, in find_prompt
self.write_channel(self.RETURN)
File "C:\tools\python\lib\site-packages\netmiko\base_connection.py", line 360, in write_channel
self._write_channel(out_data)
File "C:\tools\python\lib\site-packages\netmiko\base_connection.py", line 331, in _write_channel
self.remote_conn.sendall(write_bytes(out_data, encoding=self.encoding))
File "C:\tools\python\lib\site-packages\paramiko\channel.py", line 846, in sendall
sent = self.send(s)
File "C:\tools\python\lib\site-packages\paramiko\channel.py", line 801, in send
return self._send(s, m)
File "C:\tools\python\lib\site-packages\paramiko\channel.py", line 1180, in _send
raise socket.error("Socket is closed")
OSError: Socket is closed

Change variable names that clash with built in functions

    """print the information from check_upgrade to the user"""
    s_log = Logger(host)
    if type == "error":
        s_log.error(info, msg, msg_color)
    elif type == "info":
        s_log.info(info, msg, msg_color)
    elif type == "success":
        s_log.success(info, msg, msg_color)
    else:
        s.log.error("Something went wrong")```

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.