From b5b49db02fdf3946253e144168f7225051544aad Mon Sep 17 00:00:00 2001 From: linggao Date: Tue, 30 Sep 2008 20:00:46 +0000 Subject: [PATCH] more on node status update git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@2267 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/GlobalDef.pm | 18 +++-- perl-xCAT/xCAT/Schema.pm | 36 ++++++++- .../lib/xcat/monitoring/monitorctrl.pm | 6 +- xCAT-server/lib/xcat/plugins/destiny.pm | 78 ++++++++++++------- 4 files changed, 100 insertions(+), 38 deletions(-) diff --git a/perl-xCAT/xCAT/GlobalDef.pm b/perl-xCAT/xCAT/GlobalDef.pm index b7d6ac58e..618762f19 100644 --- a/perl-xCAT/xCAT/GlobalDef.pm +++ b/perl-xCAT/xCAT/GlobalDef.pm @@ -34,20 +34,24 @@ $::STATUS_NETBOOTING="netbooting"; $::STATUS_BOOTED="booted"; $::STATUS_POWERING_OFF="powering-off"; $::STATUS_DISCOVERING="discovering"; +$::STATUS_CONFIGURING="configuring"; +$::STATUS_STANDING_BY="standingby"; +$::STATUS_SHELL="shell"; $::STATUS_DEFINED="defined"; $::STATUS_UNKNOWN="unknown"; -#defined->[discovering]->installing->installed->booting->alive, defined->netbooting->booted->alive, alive/unreachable->booting->alive, powering-off->unreachable, alive->unreachable +#defined->[discovering]->[configuring]->[standingby]->installing->[installed]->booting->alive, defined->[discovering]->[configuring]-[standingby]->netbooting->booted->alive, alive/unreachable->booting->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, $::STATUS_BOOTING=>1}, - $::STATUS_INSTALLING =>{$::STATUS_INSTALLED=>1, $::STATUS_DISCOVERING=>1}, + $::STATUS_DEFINED=>{$::STATUS_DISCOVERING=>1, $::STATUS_INSTALLING=>1, $::STATUS_NETBOOTING=>1, $::STATUS_POWERING_OFF=>1, $::STATUS_BOOTING=>1, $::STATUS_CONFIGURING=>1}, + $::STATUS_DISCOVERING=>{$::STATUS_INSTALLING=>1, $::STATUS_NETBOOTING=>1, $::STATUS_CONFIGURING=>1, $::STATUS_BOOTING=>1}, + $::STATUS_CONFIGURING=>{$::STATUS_INSTALLING=>1, $::STATUS_NETBOOTING=>1, $::STATUS_STANDING_BY=>1}, + $::STATUS_INSTALLING =>{$::STATUS_INSTALLED=>1, $::STATUS_BOOTING=>1}, $::STATUS_INSTALLED =>{$::STATUS_BOOTING=>1}, - $::STATUS_BOOTING=>{$::STATUS_BOOTED=>1,$::STATUS_ACTIVE=>1, $::STATUS_INACTIVE=>1}, + $::STATUS_BOOTING=>{$::STATUS_BOOTED=>1, $::STATUS_ACTIVE=>1, $::STATUS_INACTIVE=>1}, $::STATUS_NETBOOTING=>{$::STATUS_BOOTED=>1}, $::STATUS_BOOTED=>{$::STATUS_ACTIVE=>1, $::STATUS_INACTIVE=>1}, - $::STATUS_ACTIVE=>{$::STATUS_INACTIVE=>1, $::STATUS_DISCOVERING=>1, $::STATUS_INSTALLING=>1, $::STATUS_NETBOOTING=>1, $::STATUS_POWERING_OFF=>1, $::STATUS_BOOTING=>1}, - $::STATUS_INACTIVE=>{$::STATUS_ACTIVE=>1, $::STATUS_DISCOVERING=>1, $::STATUS_INSTALLING=>1, $::STATUS_NETBOOTING=>1, $::STATUS_POWERING_OFF=>1, $::STATUS_BOOTING=>1}, + $::STATUS_ACTIVE=>{$::STATUS_INACTIVE=>1, $::STATUS_DISCOVERING=>1, $::STATUS_CONFIGURING=>1, $::STATUS_INSTALLING=>1, $::STATUS_NETBOOTING=>1, $::STATUS_POWERING_OFF=>1, $::STATUS_BOOTING=>1}, + $::STATUS_INACTIVE=>{$::STATUS_ACTIVE=>1, $::STATUS_DISCOVERING=>1, $::STATUS_CONFIGURING=>1, $::STATUS_INSTALLING=>1, $::STATUS_NETBOOTING=>1, $::STATUS_POWERING_OFF=>1, $::STATUS_BOOTING=>1}, $::STATUS_POWERING_OFF=>{$::STATUS_INACTIVE=>1} ); diff --git a/perl-xCAT/xCAT/Schema.pm b/perl-xCAT/xCAT/Schema.pm index 8e467f8f3..c34bc6aec 100644 --- a/perl-xCAT/xCAT/Schema.pm +++ b/perl-xCAT/xCAT/Schema.pm @@ -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->installed->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, configuring, installing, alive, standingby, powering-off, unreachable. The default value is defined. The possible status change sequenses are: defined->[discovering]->[configuring]->[standingby]->installing->[installed]->booting->alive, defined->[discovering]->[configuring]->[standingby]->netbooting->booted->alive, alive/unreachable->booting->alive, alive->powering-off->unreachable, alive->unreachable', appstatus => "A comma-delimited list monitored applications that are active on the node. For example 'sshd,rmcd,gmond", comments => 'Any user-written notes.', disable => "Set to 'yes' or '1' to comment out this row.", @@ -554,6 +554,17 @@ nimimage => { disable => "Set to 'yes' or '1' to comment out this row.", }, }, +performance => { + cols => [qw(timestamp node attrname attrvalue)], + keys => [qw(timestamp node attrname)], + table_desc => 'Describes the system performance every interval unit of time.', + descriptions => { + timestamp => 'The time at which the metric was captured.', + node => 'The node name.', + attrname => 'The metric name.', + attrvalue => 'The metric value.' + }, + }, ); # end of tabspec definition @@ -1381,6 +1392,29 @@ push(@{$defspec{group}->{'attrs'}}, @nodeattrs); }, ); +######################### +# performance table # +######################### +@{$defspec{performance}->{'attrs'}} = ( + + {attr_name => 'timestamp', + tabentry => 'performance.timestamp', + access_tabentry => 'performance.timestamp=attr:timestamp', + }, + {attr_name => 'node', + tabentry => 'performance.node', + access_tabentry => 'performance.timestamp=attr:timestamp', + }, + {attr_name => 'attrname', + tabentry => 'performance.netname', + access_tabentry => 'performance.timestamp=attr:timestamp', + }, + {attr_name => 'attrvalue', + tabentry => 'performance.attrvalue', + access_tabentry => 'performance.timestamp=attr:timestamp', + }, + ); + # Build a corresponding hash for the attribute names to make # definition access easier foreach (keys %xCAT::Schema::defspec) { diff --git a/xCAT-server/lib/xcat/monitoring/monitorctrl.pm b/xCAT-server/lib/xcat/monitoring/monitorctrl.pm index 014dfc42f..e797091d7 100644 --- a/xCAT-server/lib/xcat/monitoring/monitorctrl.pm +++ b/xCAT-server/lib/xcat/monitoring/monitorctrl.pm @@ -540,11 +540,13 @@ sub getNodeStatusFromNodesetState { } my $action=shift; - my $status=$::STATUS_BOOTING; + my $status=$::STATUS_BOOTING; #boot, reboot, runimage 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 =~ /^runcmd/) { $status=$::STATUS_CONFIGURING;} #linux + elsif ($nodeset =~ /^standby/) { $status=$::STATUS_STANDING_BY;} #linux + elsif ($nodeset =~ /^shell/) { $status=$::STATUS_SHELL;} #linux elsif (($nodeset =~ /^diskless/) || ($nodeset =~ /^dataless/)) { $status=$::STATUS_NETBOOTING;} #aix elsif ($nodeset =~ /^standalone/) { #aix if ($action eq "rnetboot") { $status=$::STATUS_INSTALLING; } diff --git a/xCAT-server/lib/xcat/plugins/destiny.pm b/xCAT-server/lib/xcat/plugins/destiny.pm index 0f7c3ed38..22adf43c7 100644 --- a/xCAT-server/lib/xcat/plugins/destiny.pm +++ b/xCAT-server/lib/xcat/plugins/destiny.pm @@ -34,13 +34,13 @@ sub process_request { $callback = shift; $subreq = shift; if ($request->{command}->[0] eq 'getdestiny') { - getdestiny(); + getdestiny(0); } if ($request->{command}->[0] eq 'nextdestiny') { - nextdestiny($request); + nextdestiny(0); #it is called within dodestiny } if ($request->{command}->[0] eq 'setdestiny') { - setdestiny($request); + setdestiny($request, 0); } } @@ -59,12 +59,14 @@ sub relay_response { sub setdestiny { my $req=shift; + my $flag=shift; + $chaintab = xCAT::Table->new('chain',-create=>1); my @nodes=@{$req->{node}}; my $state = $req->{arg}->[0]; my %nstates; if ($state eq "next") { - return nextdestiny(); + return nextdestiny($flag + 1); #this is special case where updateflag is called } elsif ($state eq "iscsiboot") { my $iscsitab=xCAT::Table->new('iscsi'); unless ($iscsitab) { @@ -172,11 +174,12 @@ sub setdestiny { } $chaintab->setNodeAttribs($_,{currstate=>$lstate}); } - return getdestiny(); + return getdestiny($flag + 1); } sub nextdestiny { + my $flag=shift; my $callnodeset=0; if (scalar(@_)) { $callnodeset=1; @@ -207,7 +210,6 @@ sub nextdestiny { my $node; $chaintab = xCAT::Table->new('chain'); my $chainents = $chaintab->getNodesAttribs(\@nodes,[qw(currstate currchain chain)]); - my %node_status=(); foreach $node (@nodes) { unless($chaintab) { syslog("local1|err","ERROR: $node requested destiny update, no chain table"); @@ -230,32 +232,12 @@ sub nextdestiny { } $chaintab->setNodeAttribs($node,$ref); #$ref is in a state to commit back to db - #collect node status for certain states - 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); - } - else { - $node_status{$stat}=[$node]; - } - } - my %requ; $requ{node}=[$node]; $requ{arg}=[$ref->{currstate}]; - setdestiny(\%requ); + setdestiny(\%requ, $flag+1); } - #setup the nodelist.status - if (keys(%node_status) > 0) { - xCAT_monitoring::monitorctrl::setNodeStatusAttributes(\%node_status, 1); - } - if ($callnodeset) { $subreq->({command=>['nodeset'], node=> \@nodes, @@ -266,6 +248,12 @@ sub nextdestiny { sub getdestiny { + my $flag=shift; + # flag value: + # 0--getdestiny is called by dodestiny + # 1--called by nextdestiny in dodestiny. The node calls nextdestiny before boot and runcmd. + # 2--called by nodeset command + # 3--called by updateflag after the node finished installation and before booting my @args; my @nodes; if ($request->{node}) { @@ -295,6 +283,8 @@ sub getdestiny { my $bpents = $bptab->getNodesAttribs(\@nodes,[qw(kernel initrd kcmdline xcatmaster)]); my $sitetab= xCAT::Table->new('site'); (my $sent) = $sitetab->getAttribs({key=>'master'},'value'); + + my %node_status=(); foreach $node (@nodes) { unless ($chaintab) { #Without destiny, have the node wait with ssh hopefully open at least $callback->({node=>[{name=>[$node],data=>['standby'],destiny=>[ 'standby' ]}]}); @@ -302,8 +292,21 @@ sub getdestiny { } my $ref = $chainents->{$node}->[0]; #$chaintab->getNodeAttribs($node,[qw(currstate chain)]); unless ($ref) { + #collect node status for certain states + if (($flag==0) || ($flag==3)) { + my $stat=xCAT_monitoring::monitorctrl->getNodeStatusFromNodesetState("standby", "getdestiny"); + #print "node=$node, stat=$stat\n"; + if ($stat) { + if (exists($node_status{$stat})) { + my $pa=$node_status{$stat}; + push(@$pa, $node); + } + else { $node_status{$stat}=[$node]; } + } + } + $callback->({node=>[{name=>[$node],data=>['standby'],destiny=>[ 'standby' ]}]}); - return; + next; } unless ($ref->{currstate}) { #Has a record, but not yet in a state... my @chain = split /,/,$ref->{chain}; @@ -335,8 +338,27 @@ sub getdestiny { $response{imgserver} = xCAT::Utils->my_ip_facing($node); } + #collect node status for certain states + if (($flag==0) || ($flag==3)) { + my $stat=xCAT_monitoring::monitorctrl->getNodeStatusFromNodesetState($response{destiny}->[0], "getdestiny"); + #print "node=$node, stat=$stat\n"; + if ($stat) { + if (exists($node_status{$stat})) { + my $pa=$node_status{$stat}; + push(@$pa, $node); + } + else { $node_status{$stat}=[$node]; } + } + } + $callback->({node=>[\%response]}); } + + #setup the nodelist.status + if (($flag==0) || ($flag==3)) { + #print "save status\n"; + if (keys(%node_status) > 0) { xCAT_monitoring::monitorctrl::setNodeStatusAttributes(\%node_status, 1); } + } }