Created
January 9, 2013 07:17
-
-
Save shaon/ed157afad1b814de294b to your computer and use it in GitHub Desktop.
have to keep it in the same directory with ea_cloud.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/expect | |
set timeout 2 | |
set user [lindex $argv 0] | |
set password [lindex $argv 1] | |
set host [lindex $argv 2] | |
set data_snap [lindex $argv 3] | |
set dummy_snap [lindex $argv 4] | |
set prompt "eucagrp0> " | |
##set cloneVol {volume select snap-2F283AE3 clone snap-tempo offline snap-reserve 0%} | |
if {[llength $argv] == 0} { | |
send_user "Usage: \.\/ea.exp username password hostname data_snap demo_snap\n" | |
exit 1 | |
} | |
spawn /usr/bin/ssh $user@$host | |
expect "no)? " { send -- "yes\r" } | |
expect "password: " { send -- "$password\r" } | |
proc runCmd { cmd } { | |
send -- "$cmd\r" | |
return | |
} | |
proc setCmd { val type } { | |
if {$type == "clone"} { | |
set cmd "volume select $val clone snap-temp offline snap-reserve 0%" | |
return $cmd | |
} | |
if {$type == "rename"} { | |
set cmd "volume rename snap-temp $val" | |
return $cmd | |
} | |
if {$type == "delete"} { | |
set cmd "volume delete $val" | |
return $cmd | |
} | |
if {$type == "online"} { | |
set cmd "volume select $val online" | |
return $cmd | |
} | |
if {$type == "offline"} { | |
set cmd "volume select $val offline" | |
return $cmd | |
} | |
} | |
set cmd_san [setCmd $data_snap "clone"] | |
expect $prompt { runCmd $cmd_san } | |
sleep 10 | |
set cmd_san [setCmd $dummy_snap "offline"] | |
expect $prompt { runCmd $cmd_san } | |
set cmd_san [setCmd $dummy_snap "delete"] | |
expect $prompt { runCmd $cmd_san } | |
sleep 5 | |
set cmd_san [setCmd $dummy_snap "rename"] | |
expect $prompt { runCmd $cmd_san } | |
set cmd_san [setCmd $dummy_snap "online"] | |
expect $prompt { runCmd $cmd_san } | |
expect "$ " | |
send -- "logout\r" | |
expect "# " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment