move the getsynclistfile() from Utils.pm to SvrUtils.pm; move the syncfiles() from Postage.pm to syncfiles.pm
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@3853 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
c81d0dbf6f
commit
227f6bdcf4
@ -17,7 +17,7 @@ require xCAT::NodeRange;
|
||||
require DBI;
|
||||
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT_OK = qw(genpassword getsynclistfile);
|
||||
our @EXPORT_OK = qw(genpassword);
|
||||
|
||||
my $utildata; #data to persist locally
|
||||
#--------------------------------------------------------------------------------
|
||||
@ -4171,175 +4171,6 @@ sub checkCredFiles
|
||||
|
||||
}
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
=head3 getsynclistfile
|
||||
Get the synclist file for the nodes;
|
||||
The arguments $os,$arch,$profile,$insttype are only available when no $nodes is specified
|
||||
|
||||
Arguments:
|
||||
$nodes
|
||||
$os
|
||||
$arch
|
||||
$profile
|
||||
$insttype - installation type (can be install or netboot)
|
||||
Returns:
|
||||
When specified $nodes: reference of a hash of node=>synclist
|
||||
Otherwise: full path of the synclist file
|
||||
Globals:
|
||||
none
|
||||
Error:
|
||||
Example:
|
||||
my $node_syncfile=xCAT::Utils->getsynclistfile($nodes);
|
||||
my $syncfile=xCAT::Utils->getsynclistfile(undef, 'sles11', 'ppc64', 'compute', 'netboot');
|
||||
Comments:
|
||||
none
|
||||
|
||||
=cut
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
sub getsynclistfile()
|
||||
{
|
||||
my $nodes = shift;
|
||||
if (($nodes) && ($nodes =~ /xCAT::Utils/))
|
||||
{
|
||||
$nodes = shift;
|
||||
}
|
||||
|
||||
my ($os, $arch, $profile, $inst_type) = @_;
|
||||
|
||||
# for aix node, use the node figure out the profile, then use the value of
|
||||
# profile (osimage name) to get the synclist file path (osimage.synclists)
|
||||
if (isAIX()) {
|
||||
my %node_syncfile = ();
|
||||
my %osimage_syncfile = ();
|
||||
my @profiles = ();
|
||||
|
||||
# get the profile attributes for the nodes
|
||||
my $nodetype_t = xCAT::Table->new('nodetype');
|
||||
unless ($nodetype_t) {
|
||||
return ;
|
||||
}
|
||||
my $nodetype_v = $nodetype_t->getNodesAttribs($nodes, ['profile']);
|
||||
|
||||
# the vaule of profile for AIX node is the osimage name
|
||||
foreach my $node (@$nodes) {
|
||||
my $profile = $nodetype_v->{$node}->[0]->{'profile'};
|
||||
$node_syncfile{$node} = $profile;
|
||||
|
||||
if (! grep /$profile/, @profiles) {
|
||||
push @profiles, $profile;
|
||||
}
|
||||
}
|
||||
|
||||
# get the syncfiles base on the osimage
|
||||
my $osimage_t = xCAT::Table->new('osimage');
|
||||
unless ($osimage_t) {
|
||||
return ;
|
||||
}
|
||||
foreach my $osimage (@profiles) {
|
||||
my $synclist = $osimage_t->getAttribs({imagename=>"$osimage"}, 'synclists');
|
||||
if (-r $synclist->{'synclists'}) {
|
||||
$osimage_syncfile{$osimage} = $synclist->{'synclists'};
|
||||
} else {
|
||||
$osimage_syncfile{$osimage} = undef;
|
||||
}
|
||||
}
|
||||
|
||||
# set the syncfiles to the nodes
|
||||
foreach my $node (@$nodes) {
|
||||
$node_syncfile{$node} = $osimage_syncfile{$node_syncfile{$node}};
|
||||
}
|
||||
|
||||
return \%node_syncfile;
|
||||
}
|
||||
|
||||
# if does not specify the $node param, default consider for genimage command
|
||||
if ($nodes) {
|
||||
my %node_syncfile = ();
|
||||
|
||||
my %node_insttype = ();
|
||||
my %insttype_node = ();
|
||||
# get the nodes installation type
|
||||
xCAT::SvrUtils->getNodesetStates($nodes, \%insttype_node);
|
||||
# convert the hash to the node=>type
|
||||
foreach my $type (keys %insttype_node) {
|
||||
foreach my $node (@{$insttype_node{$type}}) {
|
||||
$node_insttype{$node} = $type;
|
||||
}
|
||||
}
|
||||
|
||||
# get the os,arch,profile attributes for the nodes
|
||||
my $nodetype_t = xCAT::Table->new('nodetype');
|
||||
unless ($nodetype_t) {
|
||||
return ;
|
||||
}
|
||||
my $nodetype_v = $nodetype_t->getNodesAttribs($nodes, ['profile','os','arch']);
|
||||
|
||||
foreach my $node (@$nodes) {
|
||||
$inst_type = $node_insttype{$node};
|
||||
if ($inst_type eq "netboot" || $inst_type eq "diskless") {
|
||||
$inst_type = "netboot";
|
||||
} else {
|
||||
$inst_type = "install";
|
||||
}
|
||||
|
||||
$profile = $nodetype_v->{$node}->[0]->{'profile'};
|
||||
$os = $nodetype_v->{$node}->[0]->{'os'};
|
||||
$arch = $nodetype_v->{$node}->[0]->{'arch'};
|
||||
|
||||
my $platform = "";
|
||||
if ($os) {
|
||||
if ($os =~ /rh.*/) { $platform = "rh"; }
|
||||
elsif ($os =~ /centos.*/) { $platform = "centos"; }
|
||||
elsif ($os =~ /fedora.*/) { $platform = "fedora"; }
|
||||
elsif ($os =~ /sles.*/) { $platform = "sles"; }
|
||||
elsif ($os =~ /AIX.*/) { $platform = "AIX"; }
|
||||
}
|
||||
|
||||
my $base = "/install/custom/$inst_type/$platform";
|
||||
if (-r "$base/$profile.$os.$arch.synclist") {
|
||||
$node_syncfile{$node} = "$base/$profile.$os.$arch.synclist";
|
||||
} elsif (-r "$base/$profile.$arch.synclist") {
|
||||
$node_syncfile{$node} = "$base/$profile.$arch.synclist";
|
||||
} elsif (-r "$base/$profile.$os.synclist") {
|
||||
$node_syncfile{$node} = "$base/$profile.$os.synclist";
|
||||
} elsif (-r "$base/$profile.synclist") {
|
||||
$node_syncfile{$node} = "$base/$profile.synclist";
|
||||
}
|
||||
}
|
||||
|
||||
return \%node_syncfile;
|
||||
} else {
|
||||
my $platform = "";
|
||||
if ($os) {
|
||||
if ($os =~ /rh.*/) { $platform = "rh"; }
|
||||
elsif ($os =~ /centos.*/) { $platform = "centos"; }
|
||||
elsif ($os =~ /fedora.*/) { $platform = "fedora"; }
|
||||
elsif ($os =~ /sles.*/) { $platform = "sles"; }
|
||||
elsif ($os =~ /AIX.*/) { $platform = "AIX"; }
|
||||
}
|
||||
|
||||
my $base = "/install/custom/$inst_type/$platform";
|
||||
if (-r "$base/$profile.$os.$arch.synclist") {
|
||||
return "$base/$profile.$os.$arch.synclist";
|
||||
} elsif (-r "$base/$profile.$arch.synclist") {
|
||||
return "$base/$profile.$arch.synclist";
|
||||
} elsif (-r "$base/$profile.$os.synclist") {
|
||||
return "$base/$profile.$os.synclist";
|
||||
} elsif (-r "$base/$profile.synclist") {
|
||||
return "$base/$profile.synclist";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
=head3 acquire_lock
|
||||
Get a lock on an arbirtrary named resource. For now, this is only across the scope of one service node/master node, an argument may be added later if/when 'global' locks are supported. This call will block until the lock is free.
|
||||
|
@ -408,44 +408,5 @@ sub get_otherpkg_file_name {
|
||||
return "";
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head3 syncfiles
|
||||
|
||||
Use the xdcp command to sync files from Management node/Service node to the Compute node
|
||||
|
||||
Arguments:
|
||||
Returns: 0 - failed; 1 - succeeded;
|
||||
Example:
|
||||
xCAT::Postage->syncfiles($node, $callback);
|
||||
|
||||
Comments:
|
||||
|
||||
=cut
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
sub syncfiles {
|
||||
my $node = shift;
|
||||
if ($node =~ /xCAT::Postage/) {
|
||||
$node = shift;
|
||||
}
|
||||
my $callback = shift;
|
||||
my $subreq = shift;
|
||||
|
||||
#get the sync file base on the node type
|
||||
my $synclist = xCAT::Utils->getsynclistfile([$node]);
|
||||
if (!$synclist) {
|
||||
xCAT::MsgUtils->message("S", "Cannot find synclist file for the $node");
|
||||
return 0;
|
||||
}
|
||||
|
||||
# call the xdcp plugin to handle the syncfile operation
|
||||
my $args = ["-F", "$$synclist{$node}"];
|
||||
my $env = ["DSH_RSYNC_FILE=$$synclist{$node}"];
|
||||
$subreq->({command=>['xdcp'], node=>[$node], arg=>$args, env=>$env}, $callback);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
@ -8,6 +8,7 @@ BEGIN
|
||||
}
|
||||
use lib "$::XCATROOT/lib/perl";
|
||||
require xCAT::Table;
|
||||
require xCAT::Utils;
|
||||
|
||||
use strict;
|
||||
|
||||
@ -176,5 +177,173 @@ sub get_nodeset_state
|
||||
return $state;
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
=head3 getsynclistfile
|
||||
Get the synclist file for the nodes;
|
||||
The arguments $os,$arch,$profile,$insttype are only available when no $nodes is specified
|
||||
|
||||
Arguments:
|
||||
$nodes
|
||||
$os
|
||||
$arch
|
||||
$profile
|
||||
$insttype - installation type (can be install or netboot)
|
||||
Returns:
|
||||
When specified $nodes: reference of a hash of node=>synclist
|
||||
Otherwise: full path of the synclist file
|
||||
Globals:
|
||||
none
|
||||
Error:
|
||||
Example:
|
||||
my $node_syncfile=xCAT::SvrUtils->getsynclistfile($nodes);
|
||||
my $syncfile=xCAT::SvrUtils->getsynclistfile(undef, 'sles11', 'ppc64', 'compute', 'netboot');
|
||||
Comments:
|
||||
none
|
||||
|
||||
=cut
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
sub getsynclistfile()
|
||||
{
|
||||
my $nodes = shift;
|
||||
if (($nodes) && ($nodes =~ /xCAT::SvrUtils/))
|
||||
{
|
||||
$nodes = shift;
|
||||
}
|
||||
|
||||
my ($os, $arch, $profile, $inst_type) = @_;
|
||||
|
||||
# for aix node, use the node figure out the profile, then use the value of
|
||||
# profile (osimage name) to get the synclist file path (osimage.synclists)
|
||||
if (xCAT::Utils->isAIX()) {
|
||||
my %node_syncfile = ();
|
||||
my %osimage_syncfile = ();
|
||||
my @profiles = ();
|
||||
|
||||
# get the profile attributes for the nodes
|
||||
my $nodetype_t = xCAT::Table->new('nodetype');
|
||||
unless ($nodetype_t) {
|
||||
return ;
|
||||
}
|
||||
my $nodetype_v = $nodetype_t->getNodesAttribs($nodes, ['profile']);
|
||||
|
||||
# the vaule of profile for AIX node is the osimage name
|
||||
foreach my $node (@$nodes) {
|
||||
my $profile = $nodetype_v->{$node}->[0]->{'profile'};
|
||||
$node_syncfile{$node} = $profile;
|
||||
|
||||
if (! grep /$profile/, @profiles) {
|
||||
push @profiles, $profile;
|
||||
}
|
||||
}
|
||||
|
||||
# get the syncfiles base on the osimage
|
||||
my $osimage_t = xCAT::Table->new('osimage');
|
||||
unless ($osimage_t) {
|
||||
return ;
|
||||
}
|
||||
foreach my $osimage (@profiles) {
|
||||
my $synclist = $osimage_t->getAttribs({imagename=>"$osimage"}, 'synclists');
|
||||
if (-r $synclist->{'synclists'}) {
|
||||
$osimage_syncfile{$osimage} = $synclist->{'synclists'};
|
||||
} else {
|
||||
$osimage_syncfile{$osimage} = undef;
|
||||
}
|
||||
}
|
||||
|
||||
# set the syncfiles to the nodes
|
||||
foreach my $node (@$nodes) {
|
||||
$node_syncfile{$node} = $osimage_syncfile{$node_syncfile{$node}};
|
||||
}
|
||||
|
||||
return \%node_syncfile;
|
||||
}
|
||||
|
||||
# if does not specify the $node param, default consider for genimage command
|
||||
if ($nodes) {
|
||||
my %node_syncfile = ();
|
||||
|
||||
my %node_insttype = ();
|
||||
my %insttype_node = ();
|
||||
# get the nodes installation type
|
||||
xCAT::SvrUtils->getNodesetStates($nodes, \%insttype_node);
|
||||
# convert the hash to the node=>type
|
||||
foreach my $type (keys %insttype_node) {
|
||||
foreach my $node (@{$insttype_node{$type}}) {
|
||||
$node_insttype{$node} = $type;
|
||||
}
|
||||
}
|
||||
|
||||
# get the os,arch,profile attributes for the nodes
|
||||
my $nodetype_t = xCAT::Table->new('nodetype');
|
||||
unless ($nodetype_t) {
|
||||
return ;
|
||||
}
|
||||
my $nodetype_v = $nodetype_t->getNodesAttribs($nodes, ['profile','os','arch']);
|
||||
|
||||
foreach my $node (@$nodes) {
|
||||
$inst_type = $node_insttype{$node};
|
||||
if ($inst_type eq "netboot" || $inst_type eq "diskless") {
|
||||
$inst_type = "netboot";
|
||||
} else {
|
||||
$inst_type = "install";
|
||||
}
|
||||
|
||||
$profile = $nodetype_v->{$node}->[0]->{'profile'};
|
||||
$os = $nodetype_v->{$node}->[0]->{'os'};
|
||||
$arch = $nodetype_v->{$node}->[0]->{'arch'};
|
||||
|
||||
my $platform = "";
|
||||
if ($os) {
|
||||
if ($os =~ /rh.*/) { $platform = "rh"; }
|
||||
elsif ($os =~ /centos.*/) { $platform = "centos"; }
|
||||
elsif ($os =~ /fedora.*/) { $platform = "fedora"; }
|
||||
elsif ($os =~ /sles.*/) { $platform = "sles"; }
|
||||
elsif ($os =~ /AIX.*/) { $platform = "AIX"; }
|
||||
}
|
||||
|
||||
my $base = "/install/custom/$inst_type/$platform";
|
||||
if (-r "$base/$profile.$os.$arch.synclist") {
|
||||
$node_syncfile{$node} = "$base/$profile.$os.$arch.synclist";
|
||||
} elsif (-r "$base/$profile.$arch.synclist") {
|
||||
$node_syncfile{$node} = "$base/$profile.$arch.synclist";
|
||||
} elsif (-r "$base/$profile.$os.synclist") {
|
||||
$node_syncfile{$node} = "$base/$profile.$os.synclist";
|
||||
} elsif (-r "$base/$profile.synclist") {
|
||||
$node_syncfile{$node} = "$base/$profile.synclist";
|
||||
}
|
||||
}
|
||||
|
||||
return \%node_syncfile;
|
||||
} else {
|
||||
my $platform = "";
|
||||
if ($os) {
|
||||
if ($os =~ /rh.*/) { $platform = "rh"; }
|
||||
elsif ($os =~ /centos.*/) { $platform = "centos"; }
|
||||
elsif ($os =~ /fedora.*/) { $platform = "fedora"; }
|
||||
elsif ($os =~ /sles.*/) { $platform = "sles"; }
|
||||
elsif ($os =~ /AIX.*/) { $platform = "AIX"; }
|
||||
}
|
||||
|
||||
my $base = "/install/custom/$inst_type/$platform";
|
||||
if (-r "$base/$profile.$os.$arch.synclist") {
|
||||
return "$base/$profile.$os.$arch.synclist";
|
||||
} elsif (-r "$base/$profile.$arch.synclist") {
|
||||
return "$base/$profile.$arch.synclist";
|
||||
} elsif (-r "$base/$profile.$os.synclist") {
|
||||
return "$base/$profile.$os.synclist";
|
||||
} elsif (-r "$base/$profile.synclist") {
|
||||
return "$base/$profile.synclist";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
@ -4667,7 +4667,7 @@ ll~;
|
||||
#
|
||||
my $error=0;
|
||||
my @nodesfailed;
|
||||
my $node_syncfile = xCAT::Utils->getsynclistfile($nodes);
|
||||
my $node_syncfile = xCAT::SvrUtils->getsynclistfile($nodes);
|
||||
foreach my $node (@nodelist)
|
||||
{
|
||||
my $image_name = $nodeosi{$node};
|
||||
|
@ -5,7 +5,8 @@ use File::Path;
|
||||
use File::Copy;
|
||||
use Cwd;
|
||||
use File::Temp;
|
||||
use xCAT::Utils qw(genpassword getsynclistfile);
|
||||
use xCAT::Utils qw(genpassword);
|
||||
use xCAT::SvrUtils;
|
||||
Getopt::Long::Configure("bundling");
|
||||
Getopt::Long::Configure("pass_through");
|
||||
|
||||
@ -135,7 +136,7 @@ sub process_request {
|
||||
}
|
||||
|
||||
# sync fils configured in the synclist to the rootimage
|
||||
my $syncfile = xCAT::Utils->getsynclistfile(undef, $osver, $arch, $profile, "netboot");
|
||||
my $syncfile = xCAT::SvrUtils->getsynclistfile(undef, $osver, $arch, $profile, "netboot");
|
||||
if (defined ($syncfile) && -f $syncfile
|
||||
&& -d "$installroot/netboot/$osver/$arch/$profile/rootimg") {
|
||||
print "sync files from $syncfile to the $installroot/netboot/$osver/$arch/$profile/rootimg\n";
|
||||
|
@ -57,6 +57,49 @@ sub process_request
|
||||
}
|
||||
|
||||
require xCAT::Postage;
|
||||
xCAT::Postage->syncfiles($client,$callback,$subreq);
|
||||
&syncfiles($client,$callback,$subreq);
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head3 syncfiles
|
||||
|
||||
Use the xdcp command to sync files from Management node/Service node t
|
||||
o the Compute node
|
||||
|
||||
Arguments:
|
||||
Returns: 0 - failed; 1 - succeeded;
|
||||
Example:
|
||||
syncfiles($node, $callback);
|
||||
|
||||
Comments:
|
||||
|
||||
=cut
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
sub syncfiles {
|
||||
my $node = shift;
|
||||
if ($node =~ /xCAT::Postage/) {
|
||||
$node = shift;
|
||||
}
|
||||
my $callback = shift;
|
||||
my $subreq = shift;
|
||||
|
||||
#get the sync file base on the node type
|
||||
my $synclist = xCAT::SvrUtils->getsynclistfile([$node]);
|
||||
if (!$synclist) {
|
||||
xCAT::MsgUtils->message("S", "Cannot find synclist file for the $node");
|
||||
return 0;
|
||||
}
|
||||
|
||||
# call the xdcp plugin to handle the syncfile operation
|
||||
my $args = ["-F", "$$synclist{$node}"];
|
||||
my $env = ["DSH_RSYNC_FILE=$$synclist{$node}"];
|
||||
$subreq->({command=>['xdcp'], node=>[$node], arg=>$args, env=>$env}, $callback);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
1;
|
||||
|
@ -295,7 +295,7 @@ sub updatenode {
|
||||
if ($request->{FileSyncing} && $request->{FileSyncing} eq "yes") {
|
||||
my %syncfile_node = ();
|
||||
my %syncfile_rootimage = ();
|
||||
my $node_syncfile = xCAT::Utils->getsynclistfile($nodes);
|
||||
my $node_syncfile = xCAT::SvrUtils->getsynclistfile($nodes);
|
||||
foreach my $node (@$nodes) {
|
||||
my $synclist = $$node_syncfile{$node};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user