mirror of
https://github.com/xcat2/xcat-core.git
synced 2025-05-22 03:32:04 +00:00
Merge pull request #1358 from xuweibj/I980
Fix issue 980, add status powering-on
This commit is contained in:
commit
1d3d27bece
@ -48,6 +48,7 @@ $::STATUS_INSTALLED="installed";
|
||||
$::STATUS_BOOTING="booting";
|
||||
$::STATUS_NETBOOTING="netbooting";
|
||||
$::STATUS_BOOTED="booted";
|
||||
$::STATUS_POWERING_ON="powering-on";
|
||||
$::STATUS_POWERING_OFF="powering-off";
|
||||
$::STATUS_DISCOVERING="discovering";
|
||||
$::STATUS_CONFIGURING="configuring";
|
||||
@ -65,6 +66,7 @@ $::STATUS_BMCREADY="bmcready";
|
||||
$::STATUS_BOOTING=>1,
|
||||
$::STATUS_NETBOOTING=>1,
|
||||
$::STATUS_BOOTED=>1,
|
||||
$::STATUS_POWERING_ON=>1,
|
||||
$::STATUS_POWERING_OFF=>1,
|
||||
$::STATUS_DISCOVERING=>1,
|
||||
$::STATUS_CONFIGURING=>1,
|
||||
@ -82,7 +84,7 @@ $::STATUS_BMCREADY="bmcready";
|
||||
|
||||
#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_CONFIGURING=>1},
|
||||
$::STATUS_DEFINED=>{$::STATUS_DISCOVERING=>1, $::STATUS_INSTALLING=>1, $::STATUS_NETBOOTING=>1, $::STATUS_POWERING_OFF=>1, $::STATUS_POWERING_ON=>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},
|
||||
@ -90,9 +92,10 @@ $::STATUS_BMCREADY="bmcready";
|
||||
$::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_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}
|
||||
$::STATUS_ACTIVE=>{$::STATUS_INACTIVE=>1, $::STATUS_DISCOVERING=>1, $::STATUS_CONFIGURING=>1, $::STATUS_INSTALLING=>1, $::STATUS_NETBOOTING=>1, $::STATUS_POWERING_OFF=>1, $::STATUS_POWERING_ON=>1},
|
||||
$::STATUS_INACTIVE=>{$::STATUS_ACTIVE=>1, $::STATUS_DISCOVERING=>1, $::STATUS_CONFIGURING=>1, $::STATUS_INSTALLING=>1, $::STATUS_NETBOOTING=>1, $::STATUS_POWERING_OFF=>1, $::STATUS_POWERING_ON=>1},
|
||||
$::STATUS_POWERING_OFF=>{$::STATUS_INACTIVE=>1},
|
||||
$::STATUS_POWERING_ON=>{$::STATUS_BOOTED=>1}
|
||||
);
|
||||
|
||||
|
||||
|
@ -3000,6 +3000,9 @@ sub power {
|
||||
}
|
||||
}
|
||||
my $errstr;
|
||||
my $newstat;
|
||||
my %newnodestatus=();
|
||||
|
||||
if ($subcommand eq 'on') {
|
||||
unless ($dom) {
|
||||
if ($use_xhrm) {
|
||||
@ -3012,6 +3015,9 @@ sub power {
|
||||
#this worked before I started doing the offline xml store because every rpower on tried to rebuild
|
||||
($dom, $errstr) = makedom($node, $cdloc);
|
||||
if ($errstr) { return (1, $errstr); }
|
||||
else {
|
||||
$newstat = $::STATUS_POWERING_ON;
|
||||
}
|
||||
} elsif (not $dom->is_active()) {
|
||||
$dom->create();
|
||||
} else {
|
||||
@ -3023,6 +3029,7 @@ sub power {
|
||||
$updatetable->{kvm_nodedata}->{$node}->{xml} = $newxml;
|
||||
if ($dom->is_active()) {
|
||||
$dom->destroy();
|
||||
$newstat=$::STATUS_POWERING_OFF;
|
||||
}
|
||||
undef $dom;
|
||||
} else { $retstring .= "$status_noop"; }
|
||||
@ -3031,6 +3038,7 @@ sub power {
|
||||
my $newxml = $dom->get_xml_description();
|
||||
$updatetable->{kvm_nodedata}->{$node}->{xml} = $newxml;
|
||||
$dom->shutdown();
|
||||
$newstat=$::STATUS_POWERING_OFF;
|
||||
} else { $retstring .= "$status_noop"; }
|
||||
} elsif ($subcommand eq 'reset') {
|
||||
if ($dom && $dom->is_active()) {
|
||||
@ -3043,6 +3051,7 @@ sub power {
|
||||
$updatetable->{kvm_nodedata}->{$node}->{xml} = $newxml;
|
||||
my $persist = $dom->is_persistent();
|
||||
$dom->destroy();
|
||||
$newstat=$::STATUS_POWERING_OFF;
|
||||
if ($persist) { $dom->undefine(); }
|
||||
undef $dom;
|
||||
if ($use_xhrm) {
|
||||
@ -3050,6 +3059,10 @@ sub power {
|
||||
}
|
||||
($dom, $errstr) = makedom($node, $cdloc, $newxml);
|
||||
if ($errstr) { return (1, $errstr); }
|
||||
else {
|
||||
$newstat=$::STATUS_POWERING_ON;
|
||||
}
|
||||
|
||||
} else { #no changes, just restart the domain TODO when possible, stupid lack of feature...
|
||||
}
|
||||
$retstring .= "reset";
|
||||
@ -3060,6 +3073,10 @@ sub power {
|
||||
}
|
||||
}
|
||||
|
||||
$newnodestatus{$newstat}=[$node];
|
||||
xCAT::Utils->filter_nostatusupdate(\%newnodestatus);
|
||||
xCAT_monitoring::monitorctrl::setNodeStatusAttributes(\%newnodestatus, 1);
|
||||
|
||||
unless ($retstring =~ /reset/) {
|
||||
$retstring = $retstring . getpowstate($dom);
|
||||
}
|
||||
@ -3774,35 +3791,6 @@ sub process_request {
|
||||
}
|
||||
|
||||
#print "oldstatus:" . Dumper(\%oldnodestatus);
|
||||
|
||||
#set the new status to the nodelist.status
|
||||
my %newnodestatus = ();
|
||||
my $newstat;
|
||||
if (($subcommand eq 'off') || ($subcommand eq 'softoff')) {
|
||||
my $newstat = $::STATUS_POWERING_OFF;
|
||||
$newnodestatus{$newstat} = \@allnodes;
|
||||
} else {
|
||||
|
||||
#get the current nodeset stat
|
||||
if (@allnodes > 0) {
|
||||
my $nsh = {};
|
||||
my ($ret, $msg) = xCAT::SvrUtils->getNodesetStates(\@allnodes, $nsh);
|
||||
if (!$ret) {
|
||||
foreach (keys %$nsh) {
|
||||
my $newstat = xCAT_monitoring::monitorctrl->getNodeStatusFromNodesetState($_, "rpower");
|
||||
$newnodestatus{$newstat} = $nsh->{$_};
|
||||
}
|
||||
} else {
|
||||
$callback->({ data => $msg });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#donot update node provision status (installing or netbooting) here
|
||||
xCAT::Utils->filter_nostatusupdate(\%newnodestatus);
|
||||
|
||||
#print "newstatus" . Dumper(\%newnodestatus);
|
||||
xCAT_monitoring::monitorctrl::setNodeStatusAttributes(\%newnodestatus, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user