Cisco UCS box already included CIMC, the we can write some script to change boot order by CIMC automatically. it is useful for PXE installation.
#!/usr/bin/expect
if {$argc<4} {
puts stderr "Usage: $argv0 ip login passwaord option(pxe/hdd)"
exit 1
}
set timeout 600
set IP [lindex $argv 0]
set LOGIN [lindex $argv 1]
set PASSWORD [lindex $argv 2]
set OPTION [lindex $argv 3]
set flag 1
spawn ssh -t -p 22 $IP -l $LOGIN
while {$flag > 0} {
expect {
"\(yes\/no\)\?" { send "yes\r" }
"assword:" { send "$PASSWORD\r"; set flag 0}
timeout exit
}
}
expect "#" { send "scope bios\r" }
if { $OPTION == "pxe"} {
expect "#" { send "set boot-order pxe,hdd,cdrom,fdd,efi\r" }
} else {
expect "#" { send "set boot-order hdd,pxe,cdrom,fdd,efi\r" }
}
expect "#" { send "commit\r" }
expect "#" { send "top\r" }
expect "#" { send "scope chassis\r" }
expect "#" { send "power cycle\r" }
expect "want to continue?" { send "y\r" }
expect "#" { send "exit\r" }
expect "#" { send "exit\r" }
|
阅读(746) | 评论(0) | 转发(0) |