2007-10-26 22:44:33 +00:00
|
|
|
#!/usr/bin/env perl
|
|
|
|
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
|
2008-01-03 15:55:47 +00:00
|
|
|
BEGIN
|
|
|
|
{
|
2008-05-13 14:03:46 +00:00
|
|
|
use Time::HiRes qw(sleep);
|
2008-01-03 15:55:47 +00:00
|
|
|
$::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat';
|
2008-05-13 14:03:46 +00:00
|
|
|
my $sleepint=int(rand(10));
|
|
|
|
print "Opening console in ".(2+(0.5*$sleepint))." seconds...\n";
|
|
|
|
sleep $sleepint;
|
2008-01-03 15:55:47 +00:00
|
|
|
}
|
|
|
|
$::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat';
|
|
|
|
use lib "$::XCATROOT/lib/perl";
|
2008-08-16 13:41:14 +00:00
|
|
|
$ENV{HOME}='/root/';
|
|
|
|
require xCAT::Client;
|
2007-10-26 22:44:33 +00:00
|
|
|
my $username = 'USERID';
|
|
|
|
my $password = 'PASSW0RD';
|
|
|
|
my $node = $ARGV[0];
|
2008-08-16 13:41:14 +00:00
|
|
|
my $bmc;
|
|
|
|
sub getans {
|
|
|
|
my $rsp = shift;
|
|
|
|
if ($rsp->{node}) {
|
|
|
|
$bmc = $rsp->{node}->[0]->{bmcaddr}->[0];
|
|
|
|
$username = $rsp->{node}->[0]->{bmcuser}->[0];
|
|
|
|
$password = $rsp->{node}->[0]->{bmcpass}->[0];
|
|
|
|
}
|
2007-10-26 22:44:33 +00:00
|
|
|
}
|
2008-08-16 13:41:14 +00:00
|
|
|
my $cmdref={
|
|
|
|
command=>"getipmicons",
|
|
|
|
arg=>"text",
|
|
|
|
noderange=>$ARGV[0]
|
|
|
|
};
|
|
|
|
xCAT::Client::submit_request($cmdref,\&getans);
|
|
|
|
until ($username and $password and $bmc) {
|
|
|
|
print "console not ready\n";
|
|
|
|
sleep 5+int(rand(10));
|
|
|
|
xCAT::Client::submit_request($cmdref,\&getans);
|
2007-10-26 22:44:33 +00:00
|
|
|
}
|
2008-08-16 13:41:14 +00:00
|
|
|
#require xCAT::Table;
|
|
|
|
#require xCAT::Utils;
|
|
|
|
#my $dba;
|
|
|
|
#my $ipmitab = xCAT::Table->new('ipmi');
|
|
|
|
#unless ($ipmitab) { die "Unable to open IPMI table"; }
|
|
|
|
#my $passtab = xCAT::Table->new('passwd');
|
|
|
|
#if ($passtab) {
|
|
|
|
# ($dba) = $passtab->getAttribs({key=>'ipmi'},qw(username password));
|
|
|
|
# if ($dba) {
|
|
|
|
# if ($dba->{username}) { $username = $dba->{username}; }
|
|
|
|
# if ($dba->{password}) { $password = $dba->{password}; }
|
|
|
|
# }
|
|
|
|
#}
|
|
|
|
|
|
|
|
#$dba = $ipmitab->getNodeAttribs($ARGV[0],[qw(bmc username password)]);
|
|
|
|
#if ($dba) {
|
|
|
|
# if ($dba->{bmc}) { $bmc = $dba->{bmc}; }
|
|
|
|
# if ($dba->{username}) { $username = $dba->{username}; }
|
|
|
|
# if ($dba->{password}) { $password = $dba->{password}; }
|
|
|
|
#}
|
|
|
|
#xCAT::Utils::close_all_dbhs;
|
2008-03-19 20:58:29 +00:00
|
|
|
#my $isintel = system "ipmitool -I lanplus -U $username -P $password -H $bmc chassis status > /dev/null 2>&1";
|
|
|
|
my $isintel = system "ipmitool -I lan -U $username -P $password -H $bmc mc info| grep 'Manufacturer ID : 343' > /dev/null 2>&1";
|
|
|
|
$isintel = not $isintel;
|
2008-03-17 16:02:49 +00:00
|
|
|
my $inteloption="";
|
|
|
|
if ($isintel) {
|
|
|
|
$inteloption=" -o intelplus";
|
|
|
|
}
|
|
|
|
system "ipmitool -I lanplus$inteloption -U $username -P $password -H $bmc sol deactivate"; #Stop any active session
|
|
|
|
exec "ipmitool -I lanplus$inteloption -U $username -P $password -H $bmc sol activate";
|
2007-10-26 22:44:33 +00:00
|
|
|
|
|
|
|
|