2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-05-29 09:13:08 +00:00
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@11749 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
zhaoertao 2012-03-05 10:25:08 +00:00
parent c428cd60d2
commit d6d8739cdf
11 changed files with 92 additions and 19 deletions

View File

@ -131,11 +131,26 @@ sub rbootseq {
#print Dumper($d);
if (!($$d[4] =~ /^lpar$/)) {
if (!($$d[4] =~ /^(lpar|blade)$/)) {
push @output, [$node_name, "\'boot\' command not supported for CEC or BPA", -1 ];
return (\@output);
}
# add checking the power state of the cec
my $power_state = xCAT::FSPUtils::fsp_api_action ($node_name, $d, "cec_state", $tooltype);
unless (@$power_state and @$power_state =~ /operating|standby/) {
my $machine;
my $state;
if ($$d[4] eq 'blade') {
$machine = "blade";
$state = "on";
} else {
$machine = "CEC";
$state = "power on";
}
push @output, [$node_name, "\'boot\' command can only support while the $machine is in the \'$state\' state, -1"];
return (\@output);
}
if( $opt->{net} ) {
my $mactab = xCAT::Table->new( 'mac');
unless($mactab) {

View File

@ -157,7 +157,7 @@ sub mkhwconn_parse_args
next;
} else
{
unless ( $nodetype =~ /^(fsp|bpa|frame|cec|hmc)$/)
unless ( $nodetype =~ /^(fsp|bpa|frame|cec|hmc|blade)$/)
{
return ( usage("Node type is incorrect. \n"));
}
@ -369,7 +369,7 @@ sub lshwconn_parse_args
return( ["Failed to get nodehm.mgt value for node $node.\n"]);
}
if ( $ttype ne 'fsp' and $ttype ne 'cec'
and $ttype ne 'bpa' and $ttype ne 'frame')
and $ttype ne 'bpa' and $ttype ne 'frame' and $ttype ne 'blade')
{
return( ["Node type $ttype is not supported for this command in FSPAPI\n"]);
}

View File

@ -142,7 +142,7 @@ sub firmware {
#####################################
# Command only supported on FSP/BPA/LPARs
#####################################
if ( @$d[4] !~ /^(cec|frame|fsp|bpa|lpar)$/ ) {
if ( @$d[4] !~ /^(cec|frame|fsp|bpa|lpar|blade)$/ ) {
push @result,
[$name,"Information only available for CEC/FSP/Frame/BPA/LPAR",RC_ERROR];
next;

View File

@ -209,13 +209,14 @@ sub powercmd {
$newnames .="$node_name,";
$newd = $d;
$lpar_flag = 1;
} elsif ($$d[4] =~ /^(fsp|cec)$/) {
} elsif ($$d[4] =~ /^(fsp|cec|blade)$/) {
if($action =~ /^on$/) { $action = "cec_on_autostart"; }
if($action =~ /^off$/) { $action = "cec_off"; }
if($action =~ /^resetsp$/) { $action = "reboot_service_processor"; }
if($action =~ /^lowpower$/) { $action = "cec_on_low_power"; }
if($action =~ /^reboot$/) {$action = "cec_reboot";}
if($action !~ /^cec_on_autostart$/ && $action !~ /^cec_off$/ && $action !~ /^cec_on_low_power$/ && $action !~ /^onstandby$/ && $action !~ /^reboot_service_processor$/ ) {
push @output, [$node_name, "\'$action\' command not supported for CEC", -1 ];
push @output, [$node_name, "\'$action\' command not supported for $$d[4]", -1 ];
next;
}
$newids = $$d[0];
@ -409,9 +410,18 @@ sub state {
##############################
# Convert state to on/off
##############################
if ($type eq 'blade') {
if ($value =~ /^(power-on-transition|power off|off)$/) {
$value = "off";
} else {
$value = "on";
}
}
if ( defined( $convert )) {
$value = power_status( $value );
}
push @result, [$name,"$prefix$value",$Rc];
}
}

View File

@ -28,7 +28,7 @@ my %hcptab = (
bpa => "ppcdirect",
frame => "ppcdirect",
cec => "ppcdirect",
blade => "mpa",
);
###########################################
@ -41,7 +41,7 @@ my %defaultgrp = (
bpa => "bpa",
frame => "frame",
cec => "cec",
blade => "blade",
);
my %globlehwtype = (
fsp => $::NODETYPE_FSP,
@ -848,7 +848,8 @@ my %default_passwd_accounts = (
bpa => \%power_accounts,
frame => \%power_accounts,
cec => \%power_accounts,
blade => { USERID => 'PASSW0RD',},
blade => { USERID => 'PASSW0RD',
HMC => 'PASSW0RD'},
ipmi => { USERID => 'PASSW0RD',},
ivm => { padmin => 'padmin',},
vmware => { root => '',},

View File

@ -421,7 +421,7 @@ mp => {
},
mpa => {
cols => [qw(mpa username password comments disable)],
keys => [qw(mpa)],
keys => [qw(mpa username)],
nodecol => "mpa",
table_desc => 'Contains info about each Management Module and how to access it.',
descriptions => {

View File

@ -2346,9 +2346,9 @@ sub getNodeSpecAttribs {
my %options = ();
my @attribs = ();
my @keys = ();
if (ref $_[0]) {
if (ref $_[0] eq 'HASH') {
%options = %{shift()};
@attribs = @_;
@attribs = @{shift()};
foreach my $key (keys %options) {
if (!grep(/^$key$/, @attribs)) {
push @attribs, $key;

View File

@ -111,6 +111,8 @@ my %usage = (
rspconfig <noderange> [sshcfg|snmpcfg|pd1|pd2|network|swnet|ntp|textid|frame]
rspconfig <singlenode> [textid=name]
rspconfig <singlenode> [frame=number]
rspconfig <singlenode> [USERID=passwd]
rspconfig <singlenode> [HMC=passwd]
rspconfig <noderange> [sshcfg=<enable|disable>|
snmpcfg=<enable|disable>|
pd1=<nonred|redwoperf|redwperf>|

View File

@ -3897,7 +3897,7 @@ sub process_request {
my $pass=$bladepass;
my $ent;
if (defined($mpatab)) {
($ent)=$mpatab->getNodeSpecAttribs($mpa, {username=>"USERID"},['username','password']);#zet modify here
($ent)=$mpatab->getNodeSpecAttribs($mpa, {username=>"USERID"},qw(username password));
if (defined($ent->{password})) { $pass = $ent->{password}; }
if (defined($ent->{username})) { $user = $ent->{username}; }
}
@ -3952,12 +3952,12 @@ sub telnetcmds {
my @unhandled;
my %handled = ();
my $result;
my @tcmds = qw(snmpcfg sshcfg network swnet pd1 pd2 textid network_reset rscanfsp initnetwork solcfg);
my @tcmds = qw(snmpcfg sshcfg network swnet pd1 pd2 textid network_reset rscanfsp initnetwork solcfg USERID HMC);
# most of these commands should be able to be done
# through SNMP, but they produce various errors.
foreach my $cmd (@_) {
if ($cmd =~ /^swnet|pd1|pd2|sshcfg|rscanfsp|=/) {
if ($cmd =~ /^swnet|pd1|pd2|sshcfg|rscanfsp|USERID|HMC|=/) {
if (($cmd =~ /^textid/) and ($nodeid > 0)) {
push @unhandled,$cmd;
next;
@ -4031,6 +4031,7 @@ sub telnetcmds {
elsif (/^rscanfsp$/) { $result = rscanfsp($t,$mpa,$handled{$_},$mm); }
elsif (/^solcfg$/) { $result = solcfg($t,$handled{$_},$mm); }
elsif (/^network_reset$/) { $result = network($t,$handled{$_},$mpa,$mm,$node,$nodeid,1); }
elsif (/^(USERID|HMC)$/) {$result = passwd($t, $mpa, $1, $handled{$_}, $mm);}
push @data, "$_: @$result";
$Rc |= shift(@$result);
push @cfgtext,@$result;
@ -4165,6 +4166,31 @@ sub mmtextid {
return([0,"textid: $value"]);
}
sub passwd {
my $t = shift;
my $mpa = shift;
my $user = shift;
my $pass = shift;
my $mm = shift;
my $cmd = "users -n $user -p $pass -T system:$mm";
print "===>$cmd\n";
if (!$pass) {
return ([1, "No param specified"]);
}
my @data = $t->cmd($cmd);
if (!grep(/OK/i, @data)) {
return ([1, @data]);
}
my $mpatab = xCAT::Table->new('mpa');
if ($mpatab) {
$mpatab->setAttribs({mpa=>$mpa,username=>$user},{password=>$pass});
} else {
return ([1, "Update password for $user in 'mpa' table failed"]);
}
return ([0, "Success"]);
}
sub pd {

View File

@ -259,7 +259,7 @@ sub getfspcon {
$rsp = {node=>[{name=>[$node]}]};
$rsp->{node}->[0]->{fsp_ip}->[0]=$fsp_ip;
$rsp->{node}->[0]->{id}->[0]=$id;
$rsp->{node}->[0]->{type}->[0]=$type; #zet
$rsp->{node}->[0]->{type}->[0]=$type;
$callback->($rsp);
return $rsp
}

View File

@ -38,6 +38,7 @@ BEGIN
my $sleepint=int(rand(10));
use lib "$::XCATROOT/lib/perl";
require xCAT::Client;
require xCAT::Utils;
use strict;
#use Getopt::Long;
#use xCAT::Table;
@ -56,6 +57,7 @@ my $verbose = 0;
my $node;
my $ips;
my $id;
my $hwtype;
##########################################
# Database errors
@ -166,6 +168,17 @@ sub invoke_cmd {
my $node = shift;
my $fsp_ip = shift;
my $id = shift;
my $hwtype = shift;
my $machine;
my $state;
if ($hwtype eq 'blade') {
$machine = "blade";
$state = "on";
} else {
$machine = "CEC";
$state = "power on";
}
#my @attribs = qw(id parent hcp);
#my %tabs = ();
@ -240,7 +253,12 @@ sub invoke_cmd {
#if(!defined($fsp_ip)) {
# return "Failed to get the $fsp_name\'s ip";
#}
my $power_state_cmd = "$fsp_api -a cec_state -t $type:$fsp_ip:$id:$node: 2>&1";
my $res = xCAT::Utils->runcmd($power_state_cmd, -1);
unless ($res and $res =~ /operating|standby/) {
return("The command 'rcons' is only support while the $machine is in the '$state' state");
}
my $cmd = "$fsp_api -a $action -t $type:$fsp_ip:$id:$node:\r";
#print "cmd: $cmd\n";
my $running_failed_code = "Reason code: 0x1000000";
@ -294,6 +312,7 @@ sub getans {
if ($rsp->{node}) {
$ips = $rsp->{node}->[0]->{fsp_ip}->[0];
$id = $rsp->{node}->[0]->{id}->[0];
$hwtype = $rsp->{node}->[0]->{type}->[0];
}
}
@ -315,7 +334,7 @@ release_lock(); #done with xcatd, can run with near impunity
$node = $ARGV[0];
my $result = invoke_cmd($node, $ips, $id);
my $result = invoke_cmd($node, $ips, $id, $hwtype);
if ( $result ne "0" ) {
print STDERR "$node: $result\n";
exit(1);