removed dependencies on the xCAT-server package from perl-xCAT package
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@2952 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
524405e55b
commit
529660fe6a
@ -2915,172 +2915,6 @@ 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)
|
||||
{
|
||||
require 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)
|
||||
{
|
||||
require 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)
|
||||
{
|
||||
require 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")
|
||||
{
|
||||
require xCAT_plugin::pxe;
|
||||
my $tmp = xCAT_plugin::pxe::getstate($node);
|
||||
my @a = split(' ', $tmp);
|
||||
$state = $a[0];
|
||||
|
||||
}
|
||||
elsif ($boottype eq "yaboot")
|
||||
{
|
||||
require xCAT_plugin::yaboot;
|
||||
my $tmp = xCAT_plugin::yaboot::getstate($node);
|
||||
my @a = split(' ', $tmp);
|
||||
$state = $a[0];
|
||||
}
|
||||
elsif ($boottype eq "aixinstall")
|
||||
{
|
||||
require xCAT_plugin::aixinstall;
|
||||
$state = xCAT_plugin::aixinstall::getNodesetState($node);
|
||||
}
|
||||
}
|
||||
else
|
||||
{ #default to AIX because AIX does not set noderes.netboot value
|
||||
require 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;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
|
@ -5,6 +5,7 @@ use strict;
|
||||
use lib "/opt/xcat/lib/perl";
|
||||
use xCAT::Table;
|
||||
use xCAT::Utils;
|
||||
use xCAT::SvrUtils;
|
||||
use xCAT::Usage;
|
||||
use POSIX "WNOHANG";
|
||||
use Storable qw(freeze thaw);
|
||||
@ -141,7 +142,7 @@ sub process_command {
|
||||
#get the current nodeset stat
|
||||
if (@allnodes>0) {
|
||||
my $nsh={};
|
||||
my ($ret, $msg)=xCAT::Utils->getNodesetStates(\@allnodes, $nsh);
|
||||
my ($ret, $msg)=xCAT::SvrUtils->getNodesetStates(\@allnodes, $nsh);
|
||||
if ($ret) { trace( $request, $msg );}
|
||||
else {
|
||||
foreach (keys %$nsh) {
|
||||
@ -159,7 +160,7 @@ sub process_command {
|
||||
#get the current nodeset stat
|
||||
if (@allnodes>0) {
|
||||
my $nsh={};
|
||||
my ($ret, $msg)=xCAT::Utils->getNodesetStates(\@allnodes, $nsh);
|
||||
my ($ret, $msg)=xCAT::SvrUtils->getNodesetStates(\@allnodes, $nsh);
|
||||
if ($ret) { trace( $request, $msg );}
|
||||
else {
|
||||
foreach (keys %$nsh) {
|
@ -4,6 +4,7 @@ use xCAT::Table;
|
||||
use xCAT::MsgUtils;
|
||||
use xCAT::NodeRange;
|
||||
use xCAT::Utils;
|
||||
use xCAT::SvrUtils;
|
||||
use Data::Dumper;
|
||||
use strict;
|
||||
BEGIN
|
||||
@ -323,7 +324,7 @@ sub makescript {
|
||||
#-----------------------------------------------------------------------------
|
||||
sub getnodesetstate {
|
||||
my $node=shift;
|
||||
return xCAT::Utils->get_nodeset_state($node);
|
||||
return xCAT::SvrUtils->get_nodeset_state($node);
|
||||
}
|
||||
|
||||
sub get_otherpkg_file_name {
|
183
xCAT-server/lib/perl/xCAT/SvrUtils.pm
Normal file
183
xCAT-server/lib/perl/xCAT/SvrUtils.pm
Normal file
@ -0,0 +1,183 @@
|
||||
#!/usr/bin/env perl
|
||||
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
|
||||
package xCAT::SvrUtils;
|
||||
|
||||
BEGIN
|
||||
{
|
||||
$::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat';
|
||||
}
|
||||
use lib "$::XCATROOT/lib/perl";
|
||||
require xCAT::Table;
|
||||
|
||||
use strict;
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
=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)
|
||||
{
|
||||
require 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)
|
||||
{
|
||||
require 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)
|
||||
{
|
||||
require 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")
|
||||
{
|
||||
require xCAT_plugin::pxe;
|
||||
my $tmp = xCAT_plugin::pxe::getstate($node);
|
||||
my @a = split(' ', $tmp);
|
||||
$state = $a[0];
|
||||
|
||||
}
|
||||
elsif ($boottype eq "yaboot")
|
||||
{
|
||||
require xCAT_plugin::yaboot;
|
||||
my $tmp = xCAT_plugin::yaboot::getstate($node);
|
||||
my @a = split(' ', $tmp);
|
||||
$state = $a[0];
|
||||
}
|
||||
elsif ($boottype eq "aixinstall")
|
||||
{
|
||||
require xCAT_plugin::aixinstall;
|
||||
$state = xCAT_plugin::aixinstall::getNodesetState($node);
|
||||
}
|
||||
}
|
||||
else
|
||||
{ #default to AIX because AIX does not set noderes.netboot value
|
||||
require 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;
|
@ -34,6 +34,7 @@ use IO::Handle;
|
||||
use Time::HiRes qw(gettimeofday sleep);
|
||||
use xCAT::DBobjUtils;
|
||||
use Getopt::Long;
|
||||
use xCAT::SvrUtils;
|
||||
|
||||
sub handled_commands {
|
||||
return {
|
||||
@ -2832,7 +2833,7 @@ sub dompa {
|
||||
|
||||
#get the current nodeset stat
|
||||
if (@allnodes>0) {
|
||||
my ($ret, $msg)=xCAT::Utils->getNodesetStates(\@allnodes, $nsh);
|
||||
my ($ret, $msg)=xCAT::SvrUtils->getNodesetStates(\@allnodes, $nsh);
|
||||
if ($ret) { xCAT::MsgUtils->message('S', "Cannot update node status: $msg\n"); }
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ use xCAT::SPD qw/decode_spd/;
|
||||
use POSIX qw(ceil floor);
|
||||
use Storable qw(store_fd retrieve_fd thaw freeze);
|
||||
use xCAT::Utils;
|
||||
use xCAT::SvrUtils;
|
||||
use xCAT::Usage;
|
||||
use Thread qw(yield);
|
||||
use LWP 5.64;
|
||||
@ -5893,7 +5894,7 @@ sub process_request {
|
||||
#get the current nodeset stat
|
||||
if (@allnodes>0) {
|
||||
my $nsh={};
|
||||
my ($ret, $msg)=xCAT::Utils->getNodesetStates(\@allnodes, $nsh);
|
||||
my ($ret, $msg)=xCAT::SvrUtils->getNodesetStates(\@allnodes, $nsh);
|
||||
if (!$ret) {
|
||||
foreach (keys %$nsh) {
|
||||
my $currstate=$nsh->{$_};
|
||||
|
@ -35,6 +35,7 @@ use IO::Handle;
|
||||
use Time::HiRes qw(gettimeofday sleep);
|
||||
use xCAT::DBobjUtils;
|
||||
use Getopt::Long;
|
||||
use xCAT::SvrUtils;
|
||||
|
||||
my %runningstates;
|
||||
my $vmmaxp=64;
|
||||
@ -906,7 +907,7 @@ sub process_request {
|
||||
#get the current nodeset stat
|
||||
if (@allnodes>0) {
|
||||
my $nsh={};
|
||||
my ($ret, $msg)=xCAT::Utils->getNodesetStates(\@allnodes, $nsh);
|
||||
my ($ret, $msg)=xCAT::SvrUtils->getNodesetStates(\@allnodes, $nsh);
|
||||
if (!$ret) {
|
||||
foreach (keys %$nsh) {
|
||||
my $currstate=$nsh->{$_};
|
||||
|
@ -34,6 +34,7 @@ use IO::Handle;
|
||||
use Time::HiRes qw(gettimeofday sleep);
|
||||
use xCAT::DBobjUtils;
|
||||
use Getopt::Long;
|
||||
use xCAT::SvrUtils;
|
||||
|
||||
my %runningstates;
|
||||
my $vmmaxp=64;
|
||||
@ -766,7 +767,7 @@ sub process_request {
|
||||
#get the current nodeset stat
|
||||
if (@allnodes>0) {
|
||||
my $nsh={};
|
||||
my ($ret, $msg)=xCAT::Utils->getNodesetStates(\@allnodes, $nsh);
|
||||
my ($ret, $msg)=xCAT::SvrUtils->getNodesetStates(\@allnodes, $nsh);
|
||||
if (!$ret) {
|
||||
foreach (keys %$nsh) {
|
||||
my $currstate=$nsh->{$_};
|
||||
|
@ -48,6 +48,7 @@ mkdir -p $RPM_BUILD_ROOT/opt/xcat/xdsh/Context
|
||||
mkdir -p $RPM_BUILD_ROOT/%{prefix}/lib/perl/xCAT_monitoring/samples
|
||||
mkdir -p $RPM_BUILD_ROOT/%{prefix}/lib/perl/xCAT_monitoring/pcp
|
||||
mkdir -p $RPM_BUILD_ROOT/%{prefix}/lib/perl/xCAT_schema/samples
|
||||
mkdir -p $RPM_BUILD_ROOT/%{prefix}/lib/perl/xCAT
|
||||
|
||||
%ifos linux
|
||||
cp -a share/xcat/install/* $RPM_BUILD_ROOT/%{prefix}/share/xcat/install/
|
||||
@ -88,6 +89,9 @@ ln -sf /%{prefix}/share/xcat/cons/hmc $RPM_BUILD_ROOT/%{prefix}/share/xcat/cons/
|
||||
cp lib/xcat/plugins/* $RPM_BUILD_ROOT/%{prefix}/lib/perl/xCAT_plugin
|
||||
chmod 644 $RPM_BUILD_ROOT/%{prefix}/lib/perl/xCAT_plugin/*
|
||||
|
||||
cp lib/perl/xCAT/* $RPM_BUILD_ROOT/%{prefix}/lib/perl/xCAT
|
||||
chmod 644 $RPM_BUILD_ROOT/%{prefix}/lib/perl/xCAT/*
|
||||
|
||||
# For now, don't ship these plugins - to avoid AIX dependency on SNMP.
|
||||
%ifnos linux
|
||||
rm $RPM_BUILD_ROOT/%{prefix}/lib/perl/xCAT_plugin/blade.pm
|
||||
|
Loading…
Reference in New Issue
Block a user