Remote Lights-Out Mgmt (iLO 2, iLO, RILOE II) Forum
Showing results for 
Search instead for 
Do you mean 

VC Manager command tool

Occasional Advisor

VC Manager command tool

Here's a command which lets us run a VC command without knowing which is the active VC

server02:/ root# util_execute_vcmgr_cmd chassis02-vc1 hpadmin password "show server -output=script2,no-headers"
enc0:1;1Z34AB1234;1;ProLiant BL685c G5;OK;Off;project_dev_tool_profile
enc0:2;1Z34AB1234;2;ProLiant BL685c G5;OK;Off;
enc0:3;1Z34AB1234;3;ProLiant BL685c G5;OK;Off;project_dev_odb4
enc0:4;1Z34AB1234;4;ProLiant BL685c G5;OK;Off;project_dev_odb3
server02:/ root# util_execute_vcmgr_cmd chassis02-vc2 hpadmin password "show server -output=script2,no-headers"
enc0:1;1Z34AB1234;1;ProLiant BL685c G5;OK;Off;project_dev_tool_profile
enc0:2;1Z34AB1234;2;ProLiant BL685c G5;OK;Off;
enc0:3;1Z34AB1234;3;ProLiant BL685c G5;OK;Off;project_dev_odb4
enc0:4;1Z34AB1234;4;ProLiant BL685c G5;OK;Off;project_dev_odb3


#!/usr/local/bin/expect
# Program : util_execute_vcmgr_cmd
# Version : 1.2
# Author : Mark Ashley
# Initial Date : 12th Feb 2009
# Modify Date : 26th Feb 2009
# Purpose : Connect to a HP Blade Chassis VC and run a command

set real_noisy 0
set noisy $real_noisy
# exp_internal 0
log_user $real_noisy

set whoami "[exec /usr/ucb/whoami]"
set myhostname "[exec /bin/hostname]"
set osname "[exec uname -s]"
set shell "tcsh"
set sshcmd "/bin/ssh"
set remote_prompt "\-\>$"
set local_prompt "(%|#|\\\$) $"
set remhost [lindex $argv 0]
set user [lindex $argv 1]
set passwd [lindex $argv 2]
set command [lindex $argv 3]
# log_file -noappend /var/tmp/vcmgr_cmd.$remhost.log

proc login_to_remote_host {} {
global whoami
global remhost
global user
global passwd
global local_prompt
global remote_prompt
global command
global shell_id
global sshcmd

send "$sshcmd $remhost -oStrictHostKeyChecking=no -l $user \"$command\"\r"
expect "*"
set timeout 10
set after_password 0
while 1 {
expect {
-re "Password: " {
send "$passwd\r"
expect "\r\n"
set after_password 1
}
-re ".*Virtual Connect Manager not found at this IP address." {
set after_password 0
}
"continue connecting \(yes/no\)" {
send "yes\r"
}
-re "Last login.+" {
send "\r"
}
timeout {
return
}
-re "password:" {
send "$passwd\r"
}
-re "Please use IP Address: (.*)\r\n" {
set newhost $expect_out(1,string)
log_user 0
set noisy 0
exec kill -INT $shell_id
# send_user "Switching to actual host $newhost\r\n"
expect -re $local_prompt
send "$sshcmd $newhost -oStrictHostKeyChecking=no -l $user \"$command\"\r"
expect -re "Password: " {
send "$passwd\r"
expect "\r\n"
set after_password 1
}
}
-re $local_prompt {
set after_password 0
send_user "\r\n"
exit
}
"publickey,password,keyboard-interactive" {
send_error "\rpassword for $remhost is wrong\r\n"
sleep 1
exit
}
-re ".*\r" {
if ($after_password) { send_user $expect_out(buffer) }
}
}
}
}
set shell_id [spawn $shell -l]
send "stty raw -echo\r"
expect "*"
send "uname -s\r"
expect "$osname\n"
expect -re $local_prompt
login_to_remote_host
expect -re $local_prompt
send_user "\r\n\n"