From e98cd07abe131d297ab09370ba546013dad3e625 Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Sat, 16 Aug 2008 13:41:14 +0000 Subject: [PATCH] -Fix xen cons error output formatting -Change ipmi cons method to not query tables directly. This dramatically decreases DB load. git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@2032 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/ipmi.pm | 21 ++++++++++ xCAT-server/share/xcat/cons/ipmi | 61 +++++++++++++++++++--------- xCAT-server/share/xcat/cons/xen | 2 +- 3 files changed, 63 insertions(+), 21 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/ipmi.pm b/xCAT-server/lib/xcat/plugins/ipmi.pm index 050e411fc..3253c47a1 100644 --- a/xCAT-server/lib/xcat/plugins/ipmi.pm +++ b/xCAT-server/lib/xcat/plugins/ipmi.pm @@ -24,6 +24,7 @@ our @EXPORT = qw( sub handled_commands { return { rpower => 'nodehm:power,mgt', + getipmicons => 'ipmi', rspconfig => 'nodehm:mgt', rvitals => 'nodehm:mgt', rinv => 'nodehm:mgt', @@ -4694,6 +4695,18 @@ sub preprocess_request { } +sub getipmicons { + my $argr=shift; + #$argr is [$node,$nodeip,$nodeuser,$nodepass]; + my $cb = shift; + my $ipmicons={node=>[{name=>[$argr->[0]]}]}; + $ipmicons->{node}->[0]->{bmcaddr}->[0]=$argr->[1]; + $ipmicons->{node}->[0]->{bmcuser}->[0]=$argr->[2]; + $ipmicons->{node}->[0]->{bmcpass}->[0]=$argr->[3]; + $cb->($ipmicons); +} + + sub process_request { @@ -4750,6 +4763,14 @@ sub process_request { } push @donargs,[$node,$nodeip,$nodeuser,$nodepass]; } + if ($request->{command}->[0] eq "getipmicons") { + foreach (@donargs) { + getipmicons($_,$callback); + } + return; + } + + my $children = 0; $SIG{CHLD} = sub {my $kpid; do { $kpid = waitpid(-1, WNOHANG); if ($kpid > 0) { delete $bmc_comm_pids{$kpid}; $children--; } } while $kpid > 0; }; my $sub_fds = new IO::Select; diff --git a/xCAT-server/share/xcat/cons/ipmi b/xCAT-server/share/xcat/cons/ipmi index 94f357486..adeadae45 100755 --- a/xCAT-server/share/xcat/cons/ipmi +++ b/xCAT-server/share/xcat/cons/ipmi @@ -10,31 +10,52 @@ BEGIN } $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat'; use lib "$::XCATROOT/lib/perl"; -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'); +$ENV{HOME}='/root/'; +require xCAT::Client; my $username = 'USERID'; my $password = 'PASSW0RD'; my $node = $ARGV[0]; -my $bmc = $node; -if ($passtab) { - ($dba) = $passtab->getAttribs({key=>'ipmi'},qw(username password)); - if ($dba) { - if ($dba->{username}) { $username = $dba->{username}; } - if ($dba->{password}) { $password = $dba->{password}; } - } +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]; + } } +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); +} +#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; +#$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; #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; diff --git a/xCAT-server/share/xcat/cons/xen b/xCAT-server/share/xcat/cons/xen index 7b8d7db74..283f8915e 100755 --- a/xCAT-server/share/xcat/cons/xen +++ b/xCAT-server/share/xcat/cons/xen @@ -35,7 +35,7 @@ sub getans { } xCAT::Client::submit_request($cmdref,\&getans); until ($dsthost and $speed and $dstty) { - print "console not ready"; + print "console not ready\n"; sleep 5+int(rand(10)); xCAT::Client::submit_request($cmdref,\&getans); }