fix bug 3556007: modifications related to Utils.pm
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@13581 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
564a5df5cb
commit
a732cb476d
@ -18,6 +18,7 @@ use POSIX qw(ceil);
|
||||
use File::Path;
|
||||
use Math::BigInt;
|
||||
use Socket;
|
||||
use xCAT::GlobalDef;
|
||||
use strict;
|
||||
use warnings "all";
|
||||
my $socket6support = eval { require Socket6 };
|
||||
@ -1972,4 +1973,44 @@ sub get_hdwr_ip
|
||||
|
||||
return $ip;
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
=head3 pingNodeStatus
|
||||
This function takes an array of nodes and returns their status using fping.
|
||||
Arguments:
|
||||
nodes-- an array of nodes.
|
||||
Returns:
|
||||
a hash that has the node status. The format is:
|
||||
{alive=>[node1, node3,...], unreachable=>[node4, node2...]}
|
||||
=cut
|
||||
#--------------------------------------------------------------------------------
|
||||
sub pingNodeStatus {
|
||||
my ($class, @mon_nodes)=@_;
|
||||
my %status=();
|
||||
my @active_nodes=();
|
||||
my @inactive_nodes=();
|
||||
if ((@mon_nodes)&& (@mon_nodes > 0)) {
|
||||
#get all the active nodes
|
||||
my $nodes= join(' ', @mon_nodes);
|
||||
my $temp=`fping -a $nodes 2> /dev/null`;
|
||||
chomp($temp);
|
||||
@active_nodes=split(/\n/, $temp);
|
||||
|
||||
#get all the inactive nodes by substracting the active nodes from all.
|
||||
my %temp2;
|
||||
if ((@active_nodes) && ( @active_nodes > 0)) {
|
||||
foreach(@active_nodes) { $temp2{$_}=1};
|
||||
foreach(@mon_nodes) {
|
||||
if (!$temp2{$_}) { push(@inactive_nodes, $_);}
|
||||
}
|
||||
}
|
||||
else {@inactive_nodes=@mon_nodes;}
|
||||
}
|
||||
|
||||
$status{$::STATUS_ACTIVE}=\@active_nodes;
|
||||
$status{$::STATUS_INACTIVE}=\@inactive_nodes;
|
||||
|
||||
return %status;
|
||||
}
|
||||
|
||||
1;
|
||||
|
@ -33,7 +33,7 @@ eval {
|
||||
};
|
||||
use warnings "all";
|
||||
require xCAT::InstUtils;
|
||||
require xCAT::NetworkUtils;
|
||||
#require xCAT::NetworkUtils;
|
||||
require xCAT::Schema;
|
||||
#require Data::Dumper;
|
||||
require xCAT::NodeRange;
|
||||
@ -94,7 +94,7 @@ our @EXPORT_OK = qw(genpassword runcmd3);
|
||||
# xCAT::Utils::getNodeIPaddress ====> xCAT::NetworkUtils::getNodeIPaddress
|
||||
# xCAT::Utils->thishostisnot ====> xCAT::NetworkUtils->thishostisnot
|
||||
# xCAT::Utils->gethost_ips ====> xCAT::NetworkUtils->gethost_ips
|
||||
# xCAT::Utils::get_subnet_aix ===> xCAT::NetworkUtils::get_subnet_aix
|
||||
# xCAT::Utils::get_subnet_aix ====> xCAT::NetworkUtils::get_subnet_aix
|
||||
# xCAT::Utils->determinehostname ====> xCAT::NetworkUtils->determinehostname
|
||||
# xCAT::Utils::toIP ====> xCAT::NetworkUtils::toIP
|
||||
# xCAT::Utils->validate_ip ====> xCAT::NetworkUtils->validate_ip
|
||||
@ -102,7 +102,7 @@ our @EXPORT_OK = qw(genpassword runcmd3);
|
||||
# xCAT::Utils->isIpaddr ====> xCAT::NetworkUtils->isIpaddr
|
||||
# xCAT::Utils::getNodeNetworkCfg ====> xCAT::NetworkUtils::getNodeNetworkCfg
|
||||
# xCAT::Utils::get_hdwr_ip ====> xCAT::NetworkUtils::get_hdwr_ip
|
||||
|
||||
# xCAT::Utils->pingNodeStatus ====> xCAT::NetworkUtils->pingNodeStatus
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
@ -2914,44 +2914,6 @@ sub isSELINUX
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
=head3 pingNodeStatus
|
||||
This function takes an array of nodes and returns their status using fping.
|
||||
Arguments:
|
||||
nodes-- an array of nodes.
|
||||
Returns:
|
||||
a hash that has the node status. The format is:
|
||||
{alive=>[node1, node3,...], unreachable=>[node4, node2...]}
|
||||
=cut
|
||||
#--------------------------------------------------------------------------------
|
||||
sub pingNodeStatus {
|
||||
my ($class, @mon_nodes)=@_;
|
||||
my %status=();
|
||||
my @active_nodes=();
|
||||
my @inactive_nodes=();
|
||||
if ((@mon_nodes)&& (@mon_nodes > 0)) {
|
||||
#get all the active nodes
|
||||
my $nodes= join(' ', @mon_nodes);
|
||||
my $temp=`fping -a $nodes 2> /dev/null`;
|
||||
chomp($temp);
|
||||
@active_nodes=split(/\n/, $temp);
|
||||
|
||||
#get all the inactive nodes by substracting the active nodes from all.
|
||||
my %temp2;
|
||||
if ((@active_nodes) && ( @active_nodes > 0)) {
|
||||
foreach(@active_nodes) { $temp2{$_}=1};
|
||||
foreach(@mon_nodes) {
|
||||
if (!$temp2{$_}) { push(@inactive_nodes, $_);}
|
||||
}
|
||||
}
|
||||
else {@inactive_nodes=@mon_nodes;}
|
||||
}
|
||||
|
||||
$status{$::STATUS_ACTIVE}=\@active_nodes;
|
||||
$status{$::STATUS_INACTIVE}=\@inactive_nodes;
|
||||
|
||||
return %status;
|
||||
}
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
=head3 noderangecontainsMN
|
||||
|
@ -13,6 +13,7 @@ use strict;
|
||||
use Getopt::Std;
|
||||
use POSIX qw(strftime);
|
||||
use xCAT::Utils;
|
||||
use xCAT::TableUtils;
|
||||
use xCAT::MsgUtils;
|
||||
use IO::File;
|
||||
|
||||
@ -97,7 +98,7 @@ if (!$batch) { #handle single event
|
||||
}
|
||||
}
|
||||
|
||||
my ($rc, $msg)=xCAT::Utils->logEventsToDatabase(\@a);
|
||||
my ($rc, $msg)=xCAT::TableUtils->logEventsToDatabase(\@a);
|
||||
if ($rc) {
|
||||
xCAT::MsgUtils->message('S', "logeventtoxcat:$msg. The condition is $condname. The response is $respname.\n");
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ use xCAT_monitoring::monitorctrl;
|
||||
use xCAT::MsgUtils;
|
||||
use xCAT::DBobjUtils;
|
||||
use xCAT::TableUtils;
|
||||
use xCAT::NetworkUtils;
|
||||
use Data::Dumper;
|
||||
1;
|
||||
|
||||
@ -78,7 +79,7 @@ sub start {
|
||||
my $inactive_nodes=[];
|
||||
if (($scope) && ($noderef)) {
|
||||
my @mon_nodes=@$noderef;
|
||||
my %nodes_status=xCAT::Utils->pingNodeStatus(@mon_nodes);
|
||||
my %nodes_status=xCAT::NetworkUtils->pingNodeStatus(@mon_nodes);
|
||||
$inactive_nodes=$nodes_status{$::STATUS_INACTIVE};
|
||||
if (@$inactive_nodes>0) {
|
||||
my $error="The following nodes cannot have nrpe started because they are inactive:\n @$inactive_nodes.";
|
||||
@ -141,7 +142,7 @@ sub stop {
|
||||
#go to nodes to start nrpe
|
||||
if (($scope) && ($noderef)) {
|
||||
my @mon_nodes=@$noderef;
|
||||
my %nodes_status=xCAT::Utils->pingNodeStatus(@mon_nodes);
|
||||
my %nodes_status=xCAT::NetworkUtils->pingNodeStatus(@mon_nodes);
|
||||
|
||||
my $active_nodes=$nodes_status{$::STATUS_ACTIVE};
|
||||
if (@$active_nodes > 0) {
|
||||
@ -706,7 +707,7 @@ cfg_file=/etc/nagios/objects/mychildren.cfg
|
||||
my $inactive_nodes=[];
|
||||
if ($scope) {
|
||||
#print "Configuring the nodes.\n";
|
||||
my %nodes_status=xCAT::Utils->pingNodeStatus(@mon_nodes);
|
||||
my %nodes_status=xCAT::NetworkUtils->pingNodeStatus(@mon_nodes);
|
||||
$inactive_nodes=$nodes_status{$::STATUS_INACTIVE};
|
||||
if (@$inactive_nodes>0) {
|
||||
my $error="The following nodes cannot be configured because they are inactive:\n @$inactive_nodes.";
|
||||
|
@ -6897,7 +6897,7 @@ sub updatespot
|
||||
|
||||
# if this has a shared_root resource then
|
||||
# it might need statelite setup
|
||||
my $sharedinstall=xCAT::Utils->get_site_attribute('sharedinstall');
|
||||
my $sharedinstall=xCAT::TableUtils->get_site_attribute('sharedinstall');
|
||||
chomp $sharedinstall;
|
||||
if ( $sharedinstall eq "sns" ) {
|
||||
my $rc=xCAT::InstUtils->dolitesetup($image, \%imghash, \@nodelist, $callback, $subreq);
|
||||
|
Loading…
Reference in New Issue
Block a user