[f-nsp] Script to simplify software upgrade process

Piper, James James.Piper at railcorp.nsw.gov.au
Mon Mar 31 00:42:45 EDT 2008


 
Formatting got all messed up. Email me directly if you want a copy.

James

-----Original Message-----
From: foundry-nsp-bounces at puck.nether.net
[mailto:foundry-nsp-bounces at puck.nether.net] On Behalf Of Piper, James
Sent: Monday, 31 March 2008 15:31
To: foundry-nsp at puck.nether.net
Subject: [f-nsp] Script to simplify software upgrade process

Hi All,

I'm not sure if I missed something but I haven't found anything in the
documentation that gives a simple list of commands to execute in order
to perform a software upgrade from a TFTP server. In response I wrote
this simple script to parse a software release directory and generate a
file listing the exact commands in order to cut-and-paste onto the
switch. Be good if SNMP could be used instead. Hope it helps someone..

Regards,
James

# Copyright 2008 Rail Corporation of NSW # # This program is free
software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published
by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see
<http://www.gnu.org/licenses/>.

import re
from os import listdir
from sys import argv, exit

if len(argv)==3:
    tftp_server = argv[1]
    files_dir = argv[2]
else:
    tftp_server = '172.21.2.101'
    files_dir = '.'

files = listdir(files_dir)

# regex for matching files
mgt_monitor = re.compile('^xmb\d+.*\.bin') mgt_boot =
re.compile('^xmprm\d+.*\.bin') mgt_ironware =
re.compile('^xmr\d+.*\.bin') mgt_fpga =
re.compile('^mbridge_\d+.*\.xsvf')

int_monitor = re.compile('^xmlb\d+.*\.bin') int_boot =
re.compile('^xmlprm\d+.*\.bin') int_ironware =
re.compile('^xmlp\d+.*\.bin') int_pbif =
re.compile('^pbif(?!oc).*\.bin') int_xpp =
re.compile('^xpp(?!oc).*\.bin') int_xgmac = re.compile('^xgmac')

fabric_fpga = re.compile('^sbridge')

commands = {}

# commands are entered in order
for f in files:
	if mgt_monitor.match(f): 
		commands[0] = '! mgt_monitor\ncopy tftp flash %s %s
monitor\n' % (tftp_server, f)

	if mgt_boot.match(f): 
		commands[1] =  '! mgt_boot\ncopy tftp flash %s %s
boot\n' % (tftp_server, f)

	if mgt_ironware.match(f): 
		commands[2] =  '! mgt_ironware\ncopy tftp flash %s %s
primary\n' % (tftp_server, f)

	if mgt_fpga.match(f): 
		commands[3] =  '! mgt_fpga\ncopy tftp mbridge %s %s\n' %
(tftp_server, f)

	if int_monitor.match(f): 
		commands[4] =  '! int_monitor\ncopy tftp lp %s %s
monitor all\n' % (tftp_server, f)

	if int_boot.match(f): 
		commands[5] =  '! int_boot\ncopy tftp lp %s %s boot
all\n' % (tftp_server, f)

	if int_ironware.match(f): 
		commands[6] =  '! int_ironware\ncopy tftp lp %s %s
primary all\n' % (tftp_server, f)

	if int_pbif.match(f): 
		commands[7] =  '! int_pbif\ncopy tftp lp %s %s fpga-pbif
all\n' % (tftp_server, f)

	if int_xpp.match(f): 
		commands[8] =  '! int_xpp\ncopy tftp lp %s %s fpga-xpp
all\n' % (tftp_server, f)

	if int_xgmac.match(f): 
		commands[9] =  '! int_xgmac\ncopy tftp lp %s %s
fpga-xgmac all\n' % (tftp_server, f)

out  = open('upgrade.cfg','w')

# write out commands in order
for i in range(10):
	if commands.has_key(i): out.write( '%s' % (commands[i]) )

if not len(commands)==0:
    out.write('! reboot\nboot system flash primary')





This e-mail and any attachments may contain confidential information
that is intended solely for the use of the intended recipient and may be
subject to copyright. If you receive this e-mail in error, please notify
the sender immediately and delete the e-mail and its attachments from
your system. You must not disclose, copy or use any part of this e-mail
if you are not the intended recipient. Any opinion expressed in this
e-mail and any attachments is not an opinion of RailCorp unless stated
or apparent from its content. RailCorp is not responsible for any
unauthorised alterations to this e-mail or any attachments. RailCorp
will not incur any liability resulting directly or indirectly as a
result of the recipient accessing any of the attached files that may
contain a virus.
_______________________________________________
foundry-nsp mailing list
foundry-nsp at puck.nether.net
http://puck.nether.net/mailman/listinfo/foundry-nsp




This e-mail and any attachments may contain confidential information that is intended solely for the use of the intended recipient and may be subject to copyright. If you receive this e-mail in error, please notify the sender immediately and delete the e-mail and its attachments from your system. You must not disclose, copy or use any part of this e-mail if you are not the intended recipient. Any opinion expressed in this e-mail and any attachments is not an opinion of RailCorp unless stated or apparent from its content. RailCorp is not responsible for any unauthorised alterations to this e-mail or any attachments. RailCorp will not incur any liability resulting directly or indirectly as a result of the recipient accessing any of the attached files that may contain a virus.



More information about the foundry-nsp mailing list