From 8a8c5a943ded374787e1f874d0fce59bc24e6e2a Mon Sep 17 00:00:00 2001 From: Casandra Qiu Date: Tue, 28 Feb 2017 17:08:05 -0500 Subject: [PATCH] use mgt=ipmi instead of openbmc --- xCAT-server/lib/xcat/plugins/openbmc.pm | 35 ++++++++++++++++--------- xCAT-server/share/xcat/cons/openbmc | 7 +---- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index fc4fb6678..84b32ab3c 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -31,6 +31,16 @@ use xCAT::SvrUtils; use File::Basename; use Data::Dumper; use JSON; +use Getopt::Long; +use File::Path; +use Term::ANSIColor; +use Time::Local; +use strict; +use Class::Struct; +use XML::Simple; +use Storable qw(dclone); +use SNMP; +use xCAT::PasswordUtils; $::OPENBMC_DEVEL = $ENV{'OPENBMC_DEVEL'}; @@ -249,22 +259,23 @@ sub process_request { } - #Assume the openbmc user/password is defined in the passwd - my $passtab = xCAT::Table->new('passwd'); - if ($passtab) { - ($dba) = $passtab->getAttribs({key=>'openbmc'},qw(username password)); - if ($dba) { - if ($dba->{username}) { $username = $dba->{username}; } - if ($dba->{password}) { $password = $dba->{password}; } - } - } - + my $ipmitab = xCAT::Table->new('ipmi'); + my $ipmihash = $ipmitab->getNodesAttribs($noderange, [ 'bmc', 'username', 'password' ]); + my $authdata = xCAT::PasswordUtils::getIPMIAuth(noderange => $noderange, ipmihash => $ipmihash); foreach (@$noderange) { my $node = $_; my $nodeip = $node; - push @donargs, [ $node,$nodeip,$username, $password]; - my $output = "openbmc, get $username and $password from passwd table for $nodeip"; + my $nodeuser = $authdata->{$node}->{username}; + my $nodepass = $authdata->{$node}->{password}; + my $nodeip = $node; + my $ent; + if (defined($ipmitab)) { + $ent = $ipmihash->{$node}->[0]; + if (ref($ent) and defined $ent->{bmc}) { $nodeip = $ent->{bmc}; } + } + push @donargs, [ $node,$nodeip,$nodeuser, $nodepass]; + my $output = "openbmc, get $username and $password from ipmi table for $nodeip"; xCAT::SvrUtils::sendmsg($output, $callback, $node, %allerrornodes); } diff --git a/xCAT-server/share/xcat/cons/openbmc b/xCAT-server/share/xcat/cons/openbmc index a83038a81..87a2a7a7b 100755 --- a/xCAT-server/share/xcat/cons/openbmc +++ b/xCAT-server/share/xcat/cons/openbmc @@ -91,10 +91,5 @@ if ($ENV{SSHCONSOLEPORT}) { $sshport= $ENV{SSHCONSOLEPORT}; } -#sshpass command needs to install before can run that -if (-x '/usr/bin/sshpass') { - exec "/usr/bin/sshpass -p $password ssh -p $sshport -l $username $nodeip"; -} else { - print "Please install sshpass first. \n"; -} +exec "ssh -p $sshport -l $username $nodeip";