From e9329bb620b0cf53fb77cda7648a46870908435b Mon Sep 17 00:00:00 2001 From: jjhua Date: Wed, 2 Dec 2009 09:38:51 +0000 Subject: [PATCH] check in the files which are related to the direct attach support git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@4708 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/PPCinv.pm | 6 +++ perl-xCAT/xCAT/PPCpower.pm | 16 ++++++++ perl-xCAT/xCAT/PPCrflash.pm | 41 ++++++++++-------- xCAT-server/lib/perl/xCAT/PPC.pm | 64 ++++++++++++++++++++++++++++- xCAT-server/lib/xcat/plugins/bpa.pm | 7 +++- xCAT-server/lib/xcat/plugins/fsp.pm | 11 +++-- 6 files changed, 121 insertions(+), 24 deletions(-) diff --git a/perl-xCAT/xCAT/PPCinv.pm b/perl-xCAT/xCAT/PPCinv.pm index 5bfbf6a2f..a02a58b7d 100644 --- a/perl-xCAT/xCAT/PPCinv.pm +++ b/perl-xCAT/xCAT/PPCinv.pm @@ -5,6 +5,7 @@ use strict; use Getopt::Long; use xCAT::PPCcli qw(SUCCESS EXPECT_ERROR RC_ERROR NR_ERROR); use xCAT::Usage; +use xCAT::Directinv; ########################################## @@ -431,6 +432,11 @@ sub firmware { my $hwtype = @$exp[2]; my @result; + if($request->{direct_attach_support} == 1) { + my $res = xCAT::Directinv::firmware($request, $hash); + return( \$res ); + } + while (my ($mtms,$h) = each(%$hash) ) { while (my ($name,$d) = each(%$h) ) { diff --git a/perl-xCAT/xCAT/PPCpower.pm b/perl-xCAT/xCAT/PPCpower.pm index 0a3086991..05933aa1e 100644 --- a/perl-xCAT/xCAT/PPCpower.pm +++ b/perl-xCAT/xCAT/PPCpower.pm @@ -6,6 +6,7 @@ use Getopt::Long; use xCAT::PPCcli qw(SUCCESS EXPECT_ERROR RC_ERROR NR_ERROR); use xCAT::Usage; use xCAT::MsgUtils; +use xCAT::Directpower; ########################################################################## # Parse the command line for options and operands @@ -145,6 +146,11 @@ sub powercmd_boot { my @output = (); my $callback = $request->{'callback'}; + if($request->{direct_attach_support} == 1) { + my $res = xCAT::Directpower::powercmd_boot($request, $hash); + return( \$res ); + } + ###################################### # Power commands are grouped by CEC # not Hardware Control Point @@ -270,6 +276,11 @@ sub powercmd { my @result = (); my $callback = $request->{'callback'}; + if($request->{direct_attach_support} == 1) { + my $res = xCAT::Directpower::powercmd($request, $hash); + return( \$res ); + } + #################################### # Power commands are grouped by CEC # not Hardware Control Point @@ -369,6 +380,11 @@ sub state { my $convert = shift; my @result = (); + if($request->{direct_attach_support} == 1) { + my $res = xCAT::Directpower::state($request, $hash); + return( \$res ); + } + if ( !defined( $prefix )) { $prefix = ""; } diff --git a/perl-xCAT/xCAT/PPCrflash.pm b/perl-xCAT/xCAT/PPCrflash.pm index cc3906811..8568001d5 100644 --- a/perl-xCAT/xCAT/PPCrflash.pm +++ b/perl-xCAT/xCAT/PPCrflash.pm @@ -169,8 +169,8 @@ sub parse_args { if(noderange_validate($request) == -1) { return(usage()); } - - send_msg($request, 1, "It may take considerable time to complete, depending on the number of systems being updated and the workload on the target HMC. In particular, power subsystem updates may take an hour or more if there are many attached managed systems. Please waiting."); + + $request->{callback}->({data =>[ "It may take considerable time to complete, depending on the number of systems being updated and the workload on the target HMC. In particular, power subsystem updates may take an hour or more if there are many attached managed systems. Please waiting."]}); #################################### # No operands - add command name @@ -247,15 +247,15 @@ sub noderange_validate { #my $t = print_var($exargs, "exargs"); #print $t; if ( grep(/commit/,@$exargs) != 0 || grep(/recover/,@$exargs) != 0) { - send_msg( $request, 1, "When run \"rflash\" with the \"commit\" or \"recover\" operation, the noderange cannot be BPA and can only be CEC or LPAR."); - send_msg( $request, 1, "And then, it will do the operation for both managed systems and power subsystems."); + #send_msg( $request, 1, "When run \"rflash\" with the \"commit\" or \"recover\" operation, the noderange cannot be BPA and can only be CEC or LPAR."); + #send_msg( $request, 1, "And then, it will do the operation for both managed systems and power subsystems."); return -1; } } } if($f1 * $f2) { - send_msg( $request, 1, "The argument noderange of rflash can't be BPA and CEC(or LPAR) at the same time"); + #send_msg( $request, 1, "The argument noderange of rflash can't be BPA and CEC(or LPAR) at the same time"); return -1; } } @@ -264,7 +264,7 @@ sub noderange_validate { sub preprocess_for_rflash { my $request = shift; my $opt = shift; - + my $callback = $request->{callback}; my $packages_fw = "/install/packages_fw"; my $c = 0; my $packages_d; @@ -279,8 +279,9 @@ sub preprocess_for_rflash { if($packages_d ne $packages_fw ) { $$opt{p} = $packages_fw; if(! -d $packages_d) { - send_msg($request, 1, "The directory $packages_d doesn't exist!"); - $request = (); + #send_msg($request, 1, "The directory $packages_d doesn't exist!"); + $callback->({data=>["The directory $packages_d doesn't exist!"]}); + $request = (); return -1; } @@ -294,7 +295,8 @@ sub preprocess_for_rflash { # Make sure we have some files to process # if( !scalar( @dirlist ) ) { - send_msg($request, 1, "The directory $packages_d is empty !"); + #send_msg($request, 1, "The directory $packages_d is empty !"); + $callback->({data=>["The directory $packages_d is empty !"]}); $request = (); return -1; } @@ -303,7 +305,8 @@ sub preprocess_for_rflash { my @rpmlist = grep /\.rpm$/, @dirlist; my @xmllist = grep /\.xml$/, @dirlist; if( @rpmlist == 0 | @xmllist == 0) { - send_msg($request, 1, "There isn't any rpm and xml files in the directory $packages_d!"); + #send_msg($request, 1, "There isn't any rpm and xml files in the directory $packages_d!"); + $callback->({data=>["There isn't any rpm and xml files in the directory $packages_d!"]}); $request = (); return -1; } @@ -317,8 +320,9 @@ sub preprocess_for_rflash { xCAT::Utils->runcmd($cmd, 0); if ($::RUNCMD_RC != 0) { - send_msg($request, 1, "Failed to remove the old packages in $packages_fw."); - $request = (); + #send_msg($request, 1, "Failed to remove the old packages in $packages_fw."); + $callback->({data=>["Failed to remove the old packages in $packages_fw."]}); + $request = (); return -1; } @@ -328,7 +332,8 @@ sub preprocess_for_rflash { xCAT::Utils->runcmd("$cmd", 0); if ($::RUNCMD_RC != 0) { - send_msg($request, 1, "$cmd failed."); + #send_msg($request, 1, "$cmd failed."); + $callback->({data=>["$cmd failed."]}); $request = (); return; @@ -338,7 +343,8 @@ sub preprocess_for_rflash { xCAT::Utils->runcmd($cmd, 0); if ($::RUNCMD_RC != 0) { - send_msg($request, 1, "$cmd failed."); + #send_msg($request, 1, "$cmd failed."); + $callback->({data=>["$cmd failed."]}); $request = (); return -1; @@ -543,8 +549,8 @@ sub rflash { my @result; my $timeout = $request->{ppctimeout}; - $packages_dir = $request->{opt}->{p}; - $activate = $request->{opt}->{activate}; + $packages_dir = $request->{opt}->{p}; + $activate = $request->{opt}->{activate}; my $hmc; my $mtms; @@ -587,7 +593,7 @@ sub rflash { dpush(\@value,[$hmc, "mtms:$mtms"]); $mtms_t = "$mtms_t $mtms"; my $lflag = 0; - my $managed_system = $mtms; + my $managed_system = $mtms; if( defined( $housekeeping ) ) { #$hmc_has_work = 1; #$::work_flag = 1; @@ -776,6 +782,7 @@ sub rflash { # The above code isn't supported. my $cmd_hmc = "csmlicutil $tmp_file"; +# my $cmd_hmc = "ls"; print "before runxcmd, current_userid = $current_userid\n"; my $res = xCAT::Utils->runxcmd( { command => ['xdsh'], diff --git a/xCAT-server/lib/perl/xCAT/PPC.pm b/xCAT-server/lib/perl/xCAT/PPC.pm index ad8fbc898..ed01da379 100644 --- a/xCAT-server/lib/perl/xCAT/PPC.pm +++ b/xCAT-server/lib/perl/xCAT/PPC.pm @@ -18,6 +18,7 @@ use xCAT::DBobjUtils; use xCAT_monitoring::monitorctrl; use Thread qw(yield); + ########################################## # Globals ########################################## @@ -120,6 +121,21 @@ sub process_command { $start = Time::HiRes::gettimeofday(); } + #xCAT doesn't support direct attach by default + $request->{direct_attach_support} = 0; + ####################################### + # Direct-attached FSP handler + ######################################### + my $hwtype = $request->{hwtype}; + if ( $hwtype eq "fsp" or $hwtype eq "bpa") { + my $direct_attach_support = check_direct_attach($request); + if($direct_attach_support == 0 && + ($request->{command} =~ /^(rpower)$/ || $request->{command} =~ /^rinv$/ || $request->{command} =~ /^rflash$/)) { + #direct-attached fsp commands: such as rpower and so on. + $request->{direct_attach_support} = 1; + } + } + ####################################### # Group nodes based on command ####################################### @@ -642,7 +658,7 @@ sub preprocess_nodes { and ($request->{command} !~ /^renergy$/) and (( $request->{command} =~ /^(rscan|rspconfig)$/ ) or ($request->{hwtype} eq "fsp" or $request->{hwtype} eq "bpa" ) - or ($request->{command} eq 'lshwconn' and $request->{nodetype} eq 'hmc')) + or ($request->{command} eq 'lshwconn' and $request->{nodetype} eq 'hmc')) and ($request->{direct_attach_support} != 1) ) { my $result = resolve_hcp( $request, $noderange ); return( $result ); @@ -1104,6 +1120,31 @@ sub invoke_cmd { # Direct-attached FSP handler ######################################## if ( ($power ne "hmc") && ( $hwtype eq "fsp" or $hwtype eq "bpa")) { + + if($request->{direct_attach_support} == 1 ) { + # direct-attached fsp commands: such as rpower and so on. Using fsp-api. + + ######################################## + #Process specific command + ######################################### + print "in invoke cmd node: $nodes\n"; + my $result = runcmd( $request, $nodes ); + #print '------after runcmd----\n'; + #print Dumper($result); + my $r; + foreach $r ( @$$result ) { + my %output; + $output{node}->[0]->{name}->[0] = @$r[0]; + $output{node}->[0]->{data}->[0]->{contents}->[0] = @$r[1]; + $output{errorcode} = @$r[2]; + push @outhash, \%output; + } + my $out = $request->{pipe}; + print $out freeze( [@outhash] ); + print $out "\nENDOFFREEZE6sK4ci\n"; + return; + } + #################################### # Dynamically load FSP module #################################### @@ -1605,5 +1646,26 @@ sub updconf_in_asm return ([0, undef, \@data]); } + +sub check_direct_attach +{ + my $request = shift; + + my $fsp_api = "/opt/xcat/sbin/fsp-api"; + my $libfsp = "/usr/lib/libfsp.a"; +# my $libfsp = "/opt/xcat/lib/libfsp.a"; +# my $hw_svr = "/opt/csm/csmbin/hdwr_svr"; + + my $msg = (); +# if((-e $fsp_api) && (-x $fsp_api)&& (-e $libfsp) && (-e $hw_svr)) { + if((-e $fsp_api) && (-x $fsp_api)&& (-e $libfsp)) { + return 0; + } + + return -1; +} + + + 1; diff --git a/xCAT-server/lib/xcat/plugins/bpa.pm b/xCAT-server/lib/xcat/plugins/bpa.pm index d74501d9a..e4e4ab519 100644 --- a/xCAT-server/lib/xcat/plugins/bpa.pm +++ b/xCAT-server/lib/xcat/plugins/bpa.pm @@ -10,10 +10,13 @@ use xCAT::PPC; ########################################################################## sub handled_commands { return { - rspconfig => 'nodehm:mgt', + rspconfig => 'nodehm:mgt', mkhwconn => 'nodehm:mgt', rmhwconn => 'nodehm:mgt', - lshwconn => 'nodehm:mgt' + lshwconn => 'nodehm:mgt', + rinv => 'nodehm:mgt', + rflash => 'nodehm:mgt' + }; } diff --git a/xCAT-server/lib/xcat/plugins/fsp.pm b/xCAT-server/lib/xcat/plugins/fsp.pm index 4b21fba1c..2ac0d3afd 100644 --- a/xCAT-server/lib/xcat/plugins/fsp.pm +++ b/xCAT-server/lib/xcat/plugins/fsp.pm @@ -13,10 +13,13 @@ sub handled_commands { rpower => 'nodehm:power,mgt', reventlog => 'nodehm:mgt', rspconfig => 'nodehm:mgt', - mkhwconn => 'nodehm:mgt', - rmhwconn => 'nodehm:mgt', - lshwconn => 'nodehm:mgt', - renergy => 'nodehm:mgt' + mkhwconn => 'nodehm:mgt', + rmhwconn => 'nodehm:mgt', + lshwconn => 'nodehm:mgt', + renergy => 'nodehm:mgt' , + rinv => 'nodehm:mgt', + rflash => 'nodehm:mgt' + }; }