X-Git-Url: https://secure.softndesign.org/git/?a=blobdiff_plain;f=simple-cdd%2Fadditional_scripts%2Fconfigure_switch.tcl;fp=simple-cdd%2Fadditional_scripts%2Fconfigure_switch.tcl;h=8e2af2fc091571923fe89273a9ffcf64c176af52;hb=b3f3562f417f2983a7e0d0c2d5b54bb3bd9e94ab;hp=0000000000000000000000000000000000000000;hpb=40346f7c7585854238262f7b8ca4b5a0e5c5f0b4;p=debian6500.git diff --git a/simple-cdd/additional_scripts/configure_switch.tcl b/simple-cdd/additional_scripts/configure_switch.tcl new file mode 100755 index 0000000..8e2af2f --- /dev/null +++ b/simple-cdd/additional_scripts/configure_switch.tcl @@ -0,0 +1,50 @@ +#!/usr/bin/expect + +# ============================================================================ +# +# Copyright (C) THALES. All rights reserved +# Author: Laurent Mazet +# +# Script de configuration du switchs +# +# 2013-10-10 V1.0 : Creation +# +# ============================================================================ + +set host [lrange $argv 0 0] +if { $host == "" } { + puts "usage: configure_switch.tcl \[swg1|swg2|swm\]" + exit 1 +} + +set tftpserver "" +if { $host == "swg1" } { set tftpserver "10.133.26.160" } +if { $host == "swg2" } { set tftpserver "10.133.26.160" } +if { $host == "swm" } { set tftpserver "10.133.28.160" } +if { $tftpserver == "" } { puts "unknown switch '$host'"; exit } + +set date [ exec date +%Y%m%d-%H:%m:%S ] +set backup "$host-$date.txt" + +spawn telnet $host + +set timeout 30 + +expect { + "Password:" { send "thales\r" } + incorrect { send_user "invalid password or account\n"; exit 1 } + timeout { send_user "connection to $host timed out\n"; exit 1 } + eof { send_user "connection to host failed\n"; exit 1 } +} +expect -exact ">" { send "enable\r" } +expect "Password:" { send "thales\r" } +expect "#" { send "copy running-config tftp://$tftpserver/$backup\r" } +expect -exact "?" { send "$tftpserver\r" } +expect -exact "?" { send "$backup\r" } +expect "#" { send "copy tftp://$tftpserver/$host.txt startup-config\r" } +expect -exact "?" { send "startup-config\r" } +#expect "#" { send_user " << reload or exit ? >> "; interact } +expect "#" { send "reload\r" } + +exit 0 +# vim:set tabstop=4 expandtab shiftwidth=4: