more on node status. supports aix
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@2239 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
e8f67622e6
commit
7e52eff678
@ -37,7 +37,7 @@ $::STATUS_DISCOVERING="discovering";
|
||||
$::STATUS_DEFINED="defined";
|
||||
$::STATUS_UNKNOWN="unknown";
|
||||
|
||||
#defined->[discovering]->installing->booting->->alive, defined->netbooting->booted->alive, alive/unreachable->booting->->alive, powering-off->unreachable, alive->unreachable
|
||||
#defined->[discovering]->installing->booting->booted->alive, defined->netbooting->booted->alive, alive/unreachable->booting->booted->alive, powering-off->unreachable, alive->unreachable
|
||||
%::NEXT_NODESTAT_VAL=(
|
||||
$::STATUS_DEFINED=>{$::STATUS_DISCOVERING=>1, $::STATUS_INSTALLING=>1, $::STATUS_NETBOOTING=>1, $::STATUS_POWERING_OFF=>1, $::STATUS_BOOTING=>1},
|
||||
$::STATUS_DISCOVERING=>{$::STATUS_INSTALLING=>1},
|
||||
|
@ -147,14 +147,13 @@ sub process_command {
|
||||
if ($subcommand ne 'off') {
|
||||
#get the current nodeset stat
|
||||
if (@allnodes>0) {
|
||||
my $chaintab = xCAT::Table->new('chain');
|
||||
my $tabdata=$chaintab->getNodesAttribs(\@allnodes,['node', 'currstate']);
|
||||
foreach my $node (@allnodes) {
|
||||
my $tmp1=$tabdata->{$node}->[0];
|
||||
if ($tmp1) {
|
||||
my $currstate=$tmp1->{currstate};
|
||||
if ($currstate =~ /^install/) { $nodestat{$node}=$::STATUS_INSTALLING;}
|
||||
elsif ($currstate =~ /^netboot/) { $nodestat{$node}=$::STATUS_NETBOOTING;}
|
||||
my $nsh={};
|
||||
my ($ret, $msg)=xCAT::Utils->getNodesetStates(\@allnodes, $nsh);
|
||||
if ($ret) { trace( $request, $msg );}
|
||||
else {
|
||||
foreach (keys %$nsh) {
|
||||
my $currstate=$nsh->{$_};
|
||||
$nodestat{$_}=xCAT_monitoring::monitorctrl->getNodeStatusFromNodesetState($currstate, "rpower");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -164,7 +163,18 @@ sub process_command {
|
||||
$check=1;
|
||||
my $noderange = $request->{node};
|
||||
my @allnodes=@$noderange;
|
||||
foreach (@allnodes) { $nodestat{$_}=$::STATUS_NETBOOTING;}
|
||||
#get the current nodeset stat
|
||||
if (@allnodes>0) {
|
||||
my $nsh={};
|
||||
my ($ret, $msg)=xCAT::Utils->getNodesetStates(\@allnodes, $nsh);
|
||||
if ($ret) { trace( $request, $msg );}
|
||||
else {
|
||||
foreach (keys %$nsh) {
|
||||
my $currstate=$nsh->{$_};
|
||||
$nodestat{$_}=xCAT_monitoring::monitorctrl->getNodeStatusFromNodesetState($currstate, "netboot");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (keys %nodestat) { print "node=$_,status=" . $nodestat{$_} ."\n"; } #Ling:remove
|
||||
|
@ -3,6 +3,7 @@ package xCAT::Postage;
|
||||
use xCAT::Table;
|
||||
use xCAT::MsgUtils;
|
||||
use xCAT::NodeRange;
|
||||
use xCAT::Utils;
|
||||
use Data::Dumper;
|
||||
use strict;
|
||||
BEGIN
|
||||
@ -286,44 +287,7 @@ sub makescript {
|
||||
#-----------------------------------------------------------------------------
|
||||
sub getnodesetstate {
|
||||
my $node=shift;
|
||||
my $state="undefined";
|
||||
|
||||
#get boot type (pxe or yaboot) for the node
|
||||
my $noderestab=xCAT::Table->new('noderes',-create=>0);
|
||||
my $ent=$noderestab->getNodeAttribs($node,[qw(netboot)]);
|
||||
if ($ent->{netboot}) {
|
||||
my $boottype=$ent->{netboot};
|
||||
|
||||
#get nodeset state from corresponding files
|
||||
my $bootfilename;
|
||||
if ($boottype eq "pxe") { $bootfilename="/tftpboot/pxelinux.cfg/$node";}
|
||||
elsif ($boottype eq "yaboot") { $bootfilename="/tftpboot/etc/$node";}
|
||||
else { $bootfilename="/tftpboot/pxelinux.cfg/$node"; }
|
||||
|
||||
if (-r $bootfilename) {
|
||||
my $fhand;
|
||||
open ($fhand, $bootfilename);
|
||||
my $headline = <$fhand>;
|
||||
close $fhand;
|
||||
$headline =~ s/^#//;
|
||||
chomp($headline);
|
||||
my @a=split(' ', $headline);
|
||||
$state = $a[0];
|
||||
} else {
|
||||
xCAT::MsgUtils->message('S', "getpostscripts: file $bootfilename cannot be accessed.");
|
||||
}
|
||||
} else {
|
||||
xCAT::MsgUtils->message('S', "getpostscripts: noderes.netboot for node $node not defined.");
|
||||
}
|
||||
|
||||
#get the nodeset state from the chain table as a backup.
|
||||
if ($state eq "undefined") {
|
||||
my $chaintab = xCAT::Table->new('chain');
|
||||
my $stref = $chaintab->getNodeAttribs($node,['currstate']);
|
||||
if ($stref and $stref->{currstate}) { $state=$stref->{currstate}; }
|
||||
}
|
||||
|
||||
return $state;
|
||||
return xCAT::Utils->get_nodeset_state($node);
|
||||
}
|
||||
|
||||
sub get_otherpkg_file_name {
|
||||
|
@ -263,7 +263,7 @@ nodelist => {
|
||||
descriptions => {
|
||||
node => 'The hostname of a node in the cluster.',
|
||||
groups => "A comma-delimited list of groups this node is a member of. Group names are arbitrary, except all nodes should be part of the 'all' group.",
|
||||
status => 'The current status of this node. This attribute will be set by xCAT software. Valid values: defined, booting, netbooting, booted, discovering, installing, alive, powering-off, unreachable. The default value is defined. The possible status change sequenses are: defined->[discovering]->installing->booting->alive, defined->netbooting->booted->alive, alive/unreachable->booting->alive, alive->powering-off->unreachable, alive->unreachable',
|
||||
status => 'The current status of this node. This attribute will be set by xCAT software. Valid values: defined, booting, netbooting, booted, discovering, installing, alive, powering-off, unreachable. The default value is defined. The possible status change sequenses are: defined->[discovering]->installing->booting->booted->alive, defined->netbooting->booted->alive, alive/unreachable->booting->booted->alive, alive->powering-off->unreachable, alive->unreachable',
|
||||
comments => 'Any user-written notes.',
|
||||
disable => "Set to 'yes' or '1' to comment out this row.",
|
||||
},
|
||||
|
@ -1,6 +1,11 @@
|
||||
#!/usr/bin/env perl
|
||||
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
|
||||
package xCAT::Utils;
|
||||
BEGIN
|
||||
{
|
||||
$::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat';
|
||||
}
|
||||
use lib "$::XCATROOT/lib/perl";
|
||||
require xCAT::Table;
|
||||
use POSIX qw(ceil);
|
||||
use Socket;
|
||||
@ -10,6 +15,7 @@ require Data::Dumper;
|
||||
require xCAT::NodeRange;
|
||||
require DBI;
|
||||
|
||||
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT_OK = qw(genpassword);
|
||||
|
||||
@ -590,7 +596,7 @@ sub add_cron_job
|
||||
#add new entries to the cron tab
|
||||
push(@newtabs, $newentry);
|
||||
my $tabname = "";
|
||||
if (xCAT::Utils::isLinux) { $tabname = "-"; }
|
||||
if (xCAT::Utils->isLinux()) { $tabname = "-"; }
|
||||
open(CRONTAB, "|/usr/bin/crontab $tabname")
|
||||
or return (1, "cannot open crontab.");
|
||||
foreach (@newtabs) { print CRONTAB $_ . "\n"; }
|
||||
@ -649,7 +655,7 @@ sub remove_cron_job
|
||||
|
||||
#refresh the cron
|
||||
my $tabname = "";
|
||||
if (xCAT::Utils::isLinux) { $tabname = "-"; }
|
||||
if (xCAT::Utils->isLinux()) { $tabname = "-"; }
|
||||
open(CRONTAB, "|/usr/bin/crontab $tabname")
|
||||
or return (1, "cannot open crontab.");
|
||||
foreach (@newtabs) { print CRONTAB $_ . "\n"; }
|
||||
@ -2462,4 +2468,146 @@ sub runxcatd
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
=head3 getNodesetStates
|
||||
get current nodeset stat for the given nodes
|
||||
Arguments:
|
||||
nodes -- a pointer to an array of nodes
|
||||
hashref -- A pointer to a hash that contains the nodeset status.
|
||||
Returns:
|
||||
(ret code, error message)
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
sub getNodesetStates{
|
||||
my $noderef=shift;
|
||||
if ($noderef =~ /xCAT::Utils/) {
|
||||
$noderef=shift;
|
||||
}
|
||||
my @nodes=@$noderef;
|
||||
my $hashref=shift;
|
||||
|
||||
if (@nodes>0) {
|
||||
my $tab = xCAT::Table->new('noderes');
|
||||
if (! $tab) { return (1, "Unable to open noderes table.");}
|
||||
|
||||
#initialize all nodes
|
||||
foreach (@nodes) { $hashref->{$_}="undefined";}
|
||||
|
||||
my @aixnodes=();
|
||||
my @pxenodes=();
|
||||
my @yabootnodes=();
|
||||
my $tabdata=$tab->getNodesAttribs(\@nodes,['node', 'netboot']);
|
||||
foreach my $node (@nodes) {
|
||||
my $nb="aixinstall";
|
||||
my $tmp1=$tabdata->{$node}->[0];
|
||||
if (($tmp1) && ($tmp1->{netboot})) { $nb=$tmp1->{netboot};}
|
||||
if ($nb eq "yaboot") {
|
||||
push(@yabootnodes,$node);
|
||||
} elsif ($nb eq "pxe") {
|
||||
push(@pxenodes,$node);
|
||||
} elsif ($nb eq "aixinstall") {
|
||||
push(@aixnodes,$node);
|
||||
}
|
||||
}
|
||||
|
||||
my @retarray;
|
||||
my $retcode=0;
|
||||
my $errormsg;
|
||||
# print "ya=@yabootnodes, pxe=@pxenodes, aix=@aixnodes\n";
|
||||
if (@yabootnodes > 0) {
|
||||
use xCAT_plugin::yaboot;
|
||||
@retarray=xCAT_plugin::yaboot::getNodesetStates(\@yabootnodes, $hashref);
|
||||
if ($retarray[0]) {
|
||||
$retcode=$retarray[0];
|
||||
$errormsg .= $retarray[1];
|
||||
xCAT::MsgUtils->message('E',$retarray[1]);}
|
||||
}
|
||||
if (@pxenodes > 0) {
|
||||
use xCAT_plugin::pxe;
|
||||
@retarray=xCAT_plugin::pxe::getNodesetStates(\@pxenodes, $hashref);
|
||||
if ($retarray[0]) {
|
||||
$retcode=$retarray[0];
|
||||
$errormsg .= $retarray[1];
|
||||
xCAT::MsgUtils->message('E',$retarray[1]);
|
||||
}
|
||||
}
|
||||
if (@aixnodes > 0) {
|
||||
use xCAT_plugin::aixinstall;
|
||||
@retarray=xCAT_plugin::aixinstall::getNodesetStates(\@aixnodes, $hashref);
|
||||
if ($retarray[0]) {
|
||||
$retcode=$retarray[0];
|
||||
$errormsg .= $retarray[1];
|
||||
xCAT::MsgUtils->message('E',$retarray[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return (0, "");
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
=head3 get_nodeset_state
|
||||
get current nodeset stat for the given node.
|
||||
Arguments:
|
||||
nodes -- node name.
|
||||
Returns:
|
||||
nodesetstate
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
sub get_nodeset_state {
|
||||
my $node=shift;
|
||||
if ($node =~ /xCAT::Utils/) {
|
||||
$node=shift;
|
||||
}
|
||||
|
||||
my $state="undefined";
|
||||
|
||||
#get boot type (pxe, yaboot or aixinstall) for the node
|
||||
my $noderestab=xCAT::Table->new('noderes',-create=>0);
|
||||
my $ent=$noderestab->getNodeAttribs($node,[qw(netboot)]);
|
||||
if ($ent && $ent->{netboot}) {
|
||||
my $boottype=$ent->{netboot};
|
||||
#get nodeset state from corresponding files
|
||||
if ($boottype eq "pxe") {
|
||||
use xCAT_plugin::pxe;
|
||||
my $tmp=xCAT_plugin::pxe::getstate($node);
|
||||
my @a=split(' ', $tmp);
|
||||
$state = $a[0];
|
||||
|
||||
}
|
||||
elsif ($boottype eq "yaboot") {
|
||||
use xCAT_plugin::yaboot;
|
||||
my $tmp=xCAT_plugin::yaboot::getstate($node);
|
||||
my @a=split(' ', $tmp);
|
||||
$state = $a[0];
|
||||
}
|
||||
elsif ($boottype eq "aixinstall") {
|
||||
use xCAT_plugin::aixinstall;
|
||||
$state=xCAT_plugin::aixinstall::getNodesetState($node);
|
||||
}
|
||||
}
|
||||
else { #default to AIX because AIX does not set noderes.netboot value
|
||||
use xCAT_plugin::aixinstall;
|
||||
$state=xCAT_plugin::aixinstall::getNodesetState($node);
|
||||
}
|
||||
|
||||
#get the nodeset state from the chain table as a backup.
|
||||
if ($state eq "undefined") {
|
||||
my $chaintab = xCAT::Table->new('chain');
|
||||
my $stref = $chaintab->getNodeAttribs($node,['currstate']);
|
||||
if ($stref and $stref->{currstate}) { $state=$stref->{currstate}; }
|
||||
}
|
||||
|
||||
return $state;
|
||||
}
|
||||
|
||||
|
||||
|
||||
1;
|
||||
|
@ -528,7 +528,30 @@ sub processMonitoringTableChanges {
|
||||
|
||||
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
=head3 getNodeStatusFromNodesetState
|
||||
This routine returns the node status string for the given nodeset string
|
||||
=cut
|
||||
#--------------------------------------------------------------------------------
|
||||
sub getNodeStatusFromNodesetState {
|
||||
my $nodeset=shift;
|
||||
if ($nodeset =~ /xCAT_monitoring::monitorctrl/) {
|
||||
$nodeset=shift;
|
||||
}
|
||||
my $action=shift;
|
||||
|
||||
my $status=$::STATUS_BOOTING;
|
||||
if ($nodeset =~ /^install/) { $status=$::STATUS_INSTALLING; } #linux
|
||||
elsif ($nodeset =~ /^netboot/) { $status=$::STATUS_NETBOOTING;} #linux
|
||||
elsif ($nodeset =~ /^boot/) { $status=$::STATUS_BOOTING;} #linux
|
||||
elsif ($nodeset =~ /^discover/) { $status=$::STATUS_DISCOVERING;} #linux
|
||||
elsif (($nodeset =~ /^diskless/) || ($nodeset =~ /^dataless/)) { $status=$::STATUS_NETBOOTING;} #aix
|
||||
elsif ($nodeset =~ /^standalone/) { #aix
|
||||
if ($action eq "rnetboot") { $status=$::STATUS_INSTALLING; }
|
||||
else { $status=$::STATUS_BOOTING; }
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
=head3 setNodeStatusAttributes
|
||||
|
@ -9,7 +9,11 @@
|
||||
#####################################################
|
||||
|
||||
package xCAT_plugin::aixinstall;
|
||||
|
||||
BEGIN
|
||||
{
|
||||
$::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat';
|
||||
}
|
||||
use lib "$::XCATROOT/lib/perl";
|
||||
use Sys::Hostname;
|
||||
use File::Basename;
|
||||
use xCAT::NodeRange;
|
||||
@ -4780,13 +4784,13 @@ sub nimnodeset_usage
|
||||
|
||||
=head3 is_me
|
||||
|
||||
returns 1 if the hostname is the node I'm running on
|
||||
returns 1 if the hostname is the node I am running on
|
||||
|
||||
Arguments:
|
||||
none
|
||||
Returns:
|
||||
1 - this is the node I'm running on
|
||||
0 - this is not the node I'm running on
|
||||
1 - this is the node I am running on
|
||||
0 - this is not the node I am running on
|
||||
Globals:
|
||||
none
|
||||
Error:
|
||||
@ -4820,4 +4824,81 @@ sub is_me
|
||||
}
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
=head3 getNodesetStates
|
||||
returns the nodeset state for the given nodes. The possible nodeset
|
||||
states are: diskless, dataless, standalone and undefined.
|
||||
Arguments:
|
||||
nodes --- a pointer to an array of nodes
|
||||
states -- a pointer to a hash table. This hash will be filled by this
|
||||
function node and key and the nodeset stat as the value.
|
||||
Returns:
|
||||
(return code, error message)
|
||||
=cut
|
||||
#-----------------------------------------------------------------------------
|
||||
sub getNodesetStates {
|
||||
my $noderef=shift;
|
||||
if ($noderef =~ /xCAT_plugin::aixinstall/) {
|
||||
$noderef=shift;
|
||||
}
|
||||
my @nodes=@$noderef;
|
||||
my $hashref=shift;
|
||||
|
||||
if (@nodes>0) {
|
||||
my $nttab = xCAT::Table->new('nodetype');
|
||||
my $nimtab = xCAT::Table->new('nimimage');
|
||||
if (! $nttab) { return (1, "Unable to open nodetype table.");}
|
||||
if (! $nimtab) { return (1, "Unable to open nimimage table.");}
|
||||
|
||||
my %nimimage=();
|
||||
my $nttabdata=$nttab->getNodesAttribs(\@nodes,['node', 'profile']);
|
||||
foreach my $node (@nodes) {
|
||||
my $tmp1=$nttabdata->{$node}->[0];
|
||||
if ($tmp1) {
|
||||
my $profile=$tmp1->{profile};
|
||||
if ( ! exists($nimimage{$profile})) {
|
||||
(my $tmp)=$nimtab->getAttribs({'imagename'=>$profile},'nimtype');
|
||||
if (defined($tmp)) { $nimimage{$profile} = $tmp->{nimtype}; }
|
||||
else { $nimimage{$profile}="undefined";}
|
||||
}
|
||||
$hashref->{$node}=$nimimage{$profile};
|
||||
} else {$hashref->{$node}="undefined";}
|
||||
}
|
||||
$nttab->close();
|
||||
$nimtab->close();
|
||||
}
|
||||
return (0, "");
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
=head3 getNodesetState
|
||||
get current nodeset stat for the given node.
|
||||
Arguments:
|
||||
nodes -- node name.
|
||||
Returns:
|
||||
nodesetstate
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
sub getNodesetState {
|
||||
my $node = shift;
|
||||
my $state="undefined";
|
||||
my $nttab = xCAT::Table->new('nodetype');
|
||||
my $nimtab = xCAT::Table->new('nimimage');
|
||||
if ($nttab && $nimtab) {
|
||||
my $tmp1 = $nttab->getNodeAttribs($node,['profile']);
|
||||
if ($tmp1 && $tmp1->{profile}) {
|
||||
my $profile=$tmp1->{profile};
|
||||
my $tmp2=$nimtab->getAttribs({'imagename'=>$profile},'nimtype');
|
||||
if (defined($tmp2)) { $state = $tmp2->{nimtype}; }
|
||||
}
|
||||
$nttab->close();
|
||||
$nimtab->close();
|
||||
}
|
||||
|
||||
return $state;
|
||||
}
|
||||
|
||||
1;
|
||||
|
@ -2669,14 +2669,12 @@ sub dompa {
|
||||
if ($args->[0] ne 'off') {
|
||||
#get the current nodeset stat
|
||||
if (@allnodes>0) {
|
||||
my $chaintab = xCAT::Table->new('chain');
|
||||
my $tabdata=$chaintab->getNodesAttribs(\@allnodes,['node', 'currstate']);
|
||||
foreach my $node (@allnodes) {
|
||||
my $tmp1=$tabdata->{$node}->[0];
|
||||
if ($tmp1) {
|
||||
my $currstate=$tmp1->{currstate};
|
||||
if ($currstate =~ /^install/) { $nodestat{$node}=$::STATUS_INSTALLING;}
|
||||
elsif ($currstate =~ /^netboot/) { $nodestat{$node}=$::STATUS_NETBOOTING;}
|
||||
my $nsh={};
|
||||
my ($ret, $msg)=xCAT::Utils->getNodesetStates(\@allnodes, $nsh);
|
||||
if (!$ret) {
|
||||
foreach (keys %$nsh) {
|
||||
my $currstate=$nsh->{$_};
|
||||
$nodestat{$_}=xCAT_monitoring::monitorctrl->getNodeStatusFromNodesetState($currstate, "rpower");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -231,8 +231,11 @@ sub nextdestiny {
|
||||
$chaintab->setNodeAttribs($node,$ref); #$ref is in a state to commit back to db
|
||||
|
||||
#collect node status for certain states
|
||||
if ($ref->{currstate} =~ /^boot/) {
|
||||
my $stat="booting";
|
||||
my $stat;
|
||||
if ($ref->{currstate} =~ /^boot/) { $stat=$::STATUS_BOOTING; }
|
||||
elsif ($ref->{currstate} =~ /^discover/) { $stat=$::STATUS_DISCOVERING; }
|
||||
|
||||
if ($stat) {
|
||||
if (exists($node_status{$stat})) {
|
||||
my $pa=$node_status{$stat};
|
||||
push(@$pa, $node);
|
||||
@ -249,7 +252,9 @@ sub nextdestiny {
|
||||
}
|
||||
|
||||
#setup the nodelist.status
|
||||
xCAT_monitoring::monitorctrl::setNodeStatusAttributes(\%node_status, 1);
|
||||
if (keys(%node_status) > 0) {
|
||||
xCAT_monitoring::monitorctrl::setNodeStatusAttributes(\%node_status, 1);
|
||||
}
|
||||
|
||||
if ($callnodeset) {
|
||||
$subreq->({command=>['nodeset'],
|
||||
|
@ -5567,14 +5567,12 @@ sub process_request {
|
||||
if ($extrargs->[0] ne 'off') {
|
||||
#get the current nodeset stat
|
||||
if (@allnodes>0) {
|
||||
my $chaintab = xCAT::Table->new('chain');
|
||||
my $tabdata=$chaintab->getNodesAttribs(\@allnodes,['node', 'currstate']);
|
||||
foreach my $node (@allnodes) {
|
||||
my $tmp1=$tabdata->{$node}->[0];
|
||||
if ($tmp1) {
|
||||
my $currstate=$tmp1->{currstate};
|
||||
if ($currstate =~ /^install/) { $nodestat{$node}=$::STATUS_INSTALLING;}
|
||||
elsif ($currstate =~ /^netboot/) { $nodestat{$node}=$::STATUS_NETBOOTING;}
|
||||
my $nsh={};
|
||||
my ($ret, $msg)=xCAT::Utils->getNodesetStates(\@allnodes, $nsh);
|
||||
if (!$ret) {
|
||||
foreach (keys %$nsh) {
|
||||
my $currstate=$nsh->{$_};
|
||||
$nodestat{$_}=xCAT_monitoring::monitorctrl->getNodeStatusFromNodesetState($currstate, "rpower");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -303,4 +303,35 @@ sub process_request {
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
=head3 getNodesetStates
|
||||
returns the nodeset state for the given nodes. The possible nodeset
|
||||
states are: netboot, install, boot and discover.
|
||||
Arguments:
|
||||
nodes --- a pointer to an array of nodes
|
||||
states -- a pointer to a hash table. This hash will be filled by this
|
||||
function node and key and the nodeset stat as the value.
|
||||
Returns:
|
||||
(return code, error message)
|
||||
=cut
|
||||
#-----------------------------------------------------------------------------
|
||||
sub getNodesetStates {
|
||||
my $noderef=shift;
|
||||
if ($noderef =~ /xCAT_plugin::pxe/) {
|
||||
$noderef=shift;
|
||||
}
|
||||
my @nodes=@$noderef;
|
||||
my $hashref=shift;
|
||||
|
||||
if (@nodes>0) {
|
||||
foreach my $node (@nodes) {
|
||||
my $tmp=getstate($node);
|
||||
my @a=split(' ', $tmp);
|
||||
$stat = $a[0];
|
||||
$hashref->{$node}=$stat;
|
||||
}
|
||||
}
|
||||
return (0, "");
|
||||
}
|
||||
|
||||
1;
|
||||
|
@ -233,7 +233,7 @@ sub updatenode {
|
||||
my $localhostname=hostname();
|
||||
|
||||
my $nodestring=join(',', @$nodes);
|
||||
print "postscripts=$postscripts, nodestring=$nodestring\n";
|
||||
#print "postscripts=$postscripts, nodestring=$nodestring\n";
|
||||
|
||||
if ($nodestring) {
|
||||
my $output;
|
||||
@ -241,8 +241,7 @@ sub updatenode {
|
||||
$output=`XCATBYPASS=Y $::XCATROOT/bin/xdsh $nodestring -e /install/postscripts/xcatdsklspost 1 $postscripts 2>&1`;
|
||||
}
|
||||
else {
|
||||
$output="This function is not supported on AIX.";
|
||||
#$output=`XCATBYPASS=Y $::XCATROOT/bin/xdsh $nodestring -e /install/postscripts/xcataixpost 1 $postscripts 2>&1`;
|
||||
$output=`XCATBYPASS=Y $::XCATROOT/bin/xdsh $nodestring -e /install/postscripts/xcataixpost 1 $postscripts 2>&1`;
|
||||
}
|
||||
my $rsp={};
|
||||
$rsp->{data}->[0]= "$output\n";
|
||||
|
@ -553,14 +553,12 @@ sub process_request {
|
||||
if ($subcommand ne 'off') {
|
||||
#get the current nodeset stat
|
||||
if (@allnodes>0) {
|
||||
my $chaintab = xCAT::Table->new('chain');
|
||||
my $tabdata=$chaintab->getNodesAttribs(\@allnodes,['node', 'currstate']);
|
||||
foreach my $node (@allnodes) {
|
||||
my $tmp1=$tabdata->{$node}->[0];
|
||||
if ($tmp1) {
|
||||
my $currstate=$tmp1->{currstate};
|
||||
if ($currstate =~ /^install/) { $nodestat{$node}=$::STATUS_INSTALLING;}
|
||||
elsif ($currstate =~ /^netboot/) { $nodestat{$node}=$::STATUS_NETBOOTING;}
|
||||
my $nsh={};
|
||||
my ($ret, $msg)=xCAT::Utils->getNodesetStates(\@allnodes, $nsh);
|
||||
if (!$ret) {
|
||||
foreach (keys %$nsh) {
|
||||
my $currstate=$nsh->{$_};
|
||||
$nodestat{$_}=xCAT_monitoring::monitorctrl->getNodeStatusFromNodesetState($currstate, "rpower");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -289,5 +289,35 @@ sub process_request {
|
||||
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
=head3 getNodesetStates
|
||||
returns the nodeset state for the given nodes. The possible nodeset
|
||||
states are: netboot, install, boot and discover.
|
||||
Arguments:
|
||||
nodes --- a pointer to an array of nodes
|
||||
states -- a pointer to a hash table. This hash will be filled by this
|
||||
function node and key and the nodeset stat as the value.
|
||||
Returns:
|
||||
(return code, error message)
|
||||
=cut
|
||||
#-----------------------------------------------------------------------------
|
||||
sub getNodesetStates {
|
||||
my $noderef=shift;
|
||||
if ($noderef =~ /xCAT_plugin::yaboot/) {
|
||||
$noderef=shift;
|
||||
}
|
||||
my @nodes=@$noderef;
|
||||
my $hashref=shift;
|
||||
|
||||
if (@nodes>0) {
|
||||
foreach my $node (@nodes) {
|
||||
my $tmp=getstate($node);
|
||||
my @a=split(' ', $tmp);
|
||||
$stat = $a[0];
|
||||
$hashref->{$node}=$stat;
|
||||
}
|
||||
}
|
||||
return (0, "");
|
||||
}
|
||||
|
||||
1;
|
||||
|
@ -121,38 +121,41 @@ if [[ $OSTYPE = linux* ]]; then
|
||||
fi
|
||||
exit 0
|
||||
else #AIX
|
||||
mkdir -p /xcatpost/post/otherpkgs/$OSVER/$ARCH
|
||||
rm -f -R /xcatpost/post/otherpkgs/$OSVER/$ARCH/*
|
||||
#mkdir -p /xcatpost/post/otherpkgs/$OSVER/$ARCH
|
||||
#rm -f -R /xcatpost/post/otherpkgs/$OSVER/$ARCH/*
|
||||
|
||||
# get the name of my service node/NIM master from the /etc/niminfo file
|
||||
if [ -f "/etc/niminfo" ]; then
|
||||
servnode=`grep NIM_MASTER_HOSTNAME /etc/niminfo|tr "=" " "|awk {'print $3'}`
|
||||
echo "servnode=$servnode"
|
||||
else
|
||||
echo "Could not find /etc/niminfo file"
|
||||
logger "otherpkgs: Could not find /etc/niminfo file"
|
||||
exit 1
|
||||
fi
|
||||
#if [ -f "/etc/niminfo" ]; then
|
||||
# servnode=`grep NIM_MASTER_HOSTNAME /etc/niminfo|tr "=" " "|awk {'print $3'}`
|
||||
# echo "servnode=$servnode"
|
||||
#else
|
||||
# echo "Could not find /etc/niminfo file"
|
||||
# logger "otherpkgs: Could not find /etc/niminfo file"
|
||||
# exit 1
|
||||
#fi
|
||||
|
||||
for x in `echo "$OTHERPKGS" | tr "," "\n"`
|
||||
do
|
||||
result=`rcp -r $servnode:/install/post/otherpkgs/$OSVER/$ARCH/$x* /xcatpost/post/otherpkgs/$OSVER/$ARCH/.`
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "$result"
|
||||
logger "otherpkgs: $result"
|
||||
fi
|
||||
done
|
||||
#for x in `echo "$OTHERPKGS" | tr "," "\n"`
|
||||
#do
|
||||
# result=`rcp -r $servnode:/install/post/otherpkgs/$OSVER/$ARCH/$x* /xcatpost/post/otherpkgs/$OSVER/$ARCH/.`
|
||||
# if [ $? -ne 0 ]; then
|
||||
# echo "$result"
|
||||
# logger "otherpkgs: $result"
|
||||
# fi
|
||||
#done
|
||||
|
||||
#on AIX use geninstall
|
||||
PKGS=`echo "$OTHERPKGS" | tr "," " "`
|
||||
cd /xcatpost/post/otherpkgs/$OSVER/$ARCH
|
||||
result=`geninstall -I aX -Y -d /xcatpost/post/otherpkgs/$OSVER/$ARCH $PKGS 2>&1`
|
||||
rc=$?
|
||||
if [ $rc -ne 0 ]; then
|
||||
echo "$result"
|
||||
logger "otherpkgs: $result"
|
||||
fi
|
||||
exit $rc
|
||||
#PKGS=`echo "$OTHERPKGS" | tr "," " "`
|
||||
#cd /xcatpost/post/otherpkgs/$OSVER/$ARCH
|
||||
#result=`geninstall -I aX -Y -d /xcatpost/post/otherpkgs/$OSVER/$ARCH $PKGS 2>&1`
|
||||
#rc=$?
|
||||
#if [ $rc -ne 0 ]; then
|
||||
# echo "$result"
|
||||
# logger "otherpkgs: $result"
|
||||
#fi
|
||||
#exit $rc
|
||||
|
||||
echo "Please use nimnodecust command to add additional packages to AIX nodes."
|
||||
logger "xCAT otherpkgs: Please use nimnodecust command to add addition packages to AIX nodes."
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
@ -87,7 +87,7 @@ if (&runcmd($chcmd) != 0) {
|
||||
if (-f $scriptname)
|
||||
{
|
||||
if (@ARGV>0) {
|
||||
my $scripts=$ARGV[0];
|
||||
my $scripts=$ARGV[1];
|
||||
my $POSTS=join('\n', split(',', $scripts));
|
||||
#print "scripts=$scripts\n";
|
||||
#remove all the postscripts
|
||||
@ -111,6 +111,16 @@ if (-f $scriptname)
|
||||
exit 1;
|
||||
}
|
||||
|
||||
if (@ARGV<1) {
|
||||
if (&updateflag != 0) {
|
||||
print "$::sdate xcataixpost: Failed to update the xCAT server.\n";
|
||||
print $::LOG_FILE "$::sdate xcataixpost: Failed to update the xCAT server..\n";
|
||||
close($::LOG_FILE);
|
||||
exit 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
close($::LOG_FILE);
|
||||
|
||||
exit 0;
|
||||
@ -156,6 +166,36 @@ sub getmypost {
|
||||
return 0;
|
||||
}
|
||||
|
||||
############################################################
|
||||
#
|
||||
# updateflag
|
||||
# Tells xCAT on the server that the post scripts is done.
|
||||
#
|
||||
############################################################
|
||||
sub updateflag {
|
||||
print "updateflag servicenode=$servnode\n";
|
||||
my $port = "3002";
|
||||
my $remote = IO::Socket::INET->new( Proto => "tcp", PeerAddr => $servnode, PeerPort => $port, );
|
||||
unless ($remote) {
|
||||
print "$::sdate xcataixpost: Cannot connect to host \'$servnode\'\n";
|
||||
print $::LOG_FILE "$::sdate xcataixpost: Cannot connect to host \'$servnode\'\n";
|
||||
return 1;
|
||||
}
|
||||
$remote->autoflush(1);
|
||||
|
||||
my $line;
|
||||
while (defined ($line = <$remote>)) {
|
||||
chomp $line;
|
||||
if ($line eq "ready") {
|
||||
print $remote "netbooted\n";
|
||||
} elsif ($line eq "done") {
|
||||
last;
|
||||
}
|
||||
}
|
||||
close $remote;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#####################################################
|
||||
#
|
||||
# run the command
|
||||
|
@ -5,7 +5,6 @@
|
||||
# Generic xCAT post script for diskless nodes
|
||||
#
|
||||
#####################################################
|
||||
|
||||
if [ ! `uname` == Linux ]; then
|
||||
MYDIR=`dirname $0`
|
||||
exec $MYDIR/xcatdsklspost.aix
|
||||
@ -83,17 +82,17 @@ fi
|
||||
#MYCONT=`cat /tmp/mypostscript`
|
||||
#echo "$MYCONT"
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
#notify the server that we are done with netbooting
|
||||
echo "updateflag.awk \$MASTER 3002 netbooted" >> /tmp/mypostscript
|
||||
fi
|
||||
|
||||
chmod +x /tmp/mypostscript
|
||||
if [ -x /tmp/mypostscript ];then
|
||||
/tmp/mypostscript
|
||||
fi
|
||||
rm -f /tmp/mypostscript
|
||||
|
||||
#notify the server that we are done with netbooting
|
||||
if [ $# -eq 0 ]; then
|
||||
updateflag.awk $MASTER 3002 netbooted
|
||||
fi
|
||||
|
||||
killall stunnel
|
||||
rm -rf /etc/stunnel
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user