Code drop for the Syncing file feature to support that sync file to the root image
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@3606 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
025a8454ad
commit
a9e38189f3
@ -4108,8 +4108,15 @@ sub parse_and_run_dcp
|
||||
}
|
||||
|
||||
# -s chosen or -F set rsync path
|
||||
( ($options{'rsyncSN'} || $options{'File'})
|
||||
&& ($options{'node-rcp'} = '/usr/bin/rsync'));
|
||||
if ($options{'rsyncSN'} || $options{'File'}) {
|
||||
if ($^O eq 'aix')
|
||||
{
|
||||
$options{'node-rcp'} = '/usr/local/bin/rsync';
|
||||
} elsif ($^O eq 'linux')
|
||||
{
|
||||
$options{'node-rcp'} = '/usr/bin/rsync';
|
||||
}
|
||||
}
|
||||
my $remotecopycommand = $options{'node-rcp'};
|
||||
if ($options{'node-rcp'}
|
||||
&& (!-f $options{'node-rcp'} || !-x $options{'node-rcp'}))
|
||||
@ -4323,7 +4330,11 @@ sub rsync_to_image
|
||||
|
||||
# for each file on the line
|
||||
my $synccmd = "";
|
||||
$synccmd = "/usr/bin/rsync -Lupotz ";
|
||||
if ($^O eq 'aix') {
|
||||
$synccmd = "/usr/local/bin/rsync -Lupotz ";
|
||||
} else {
|
||||
$synccmd = "/usr/bin/rsync -Lupotz ";
|
||||
}
|
||||
my $syncopt = "";
|
||||
foreach my $srcfile (@srcfiles)
|
||||
{
|
||||
@ -4334,6 +4345,7 @@ sub rsync_to_image
|
||||
$syncopt .= $imageupdatepath;
|
||||
$synccmd .= $syncopt;
|
||||
|
||||
xCAT::MsgUtils->message("S", "rsync2image: $synccmd\n");
|
||||
my @output = xCAT::Utils->runcmd($synccmd, 0);
|
||||
if ($::RUNCMD_RC != 0)
|
||||
{
|
||||
|
@ -11,7 +11,7 @@ use base xCAT::DSHRemoteShell;
|
||||
|
||||
if ($^O eq 'aix')
|
||||
{
|
||||
our $RSYNC_CMD = '/usr/bin/rsync';
|
||||
our $RSYNC_CMD = '/usr/local/bin/rsync';
|
||||
}
|
||||
|
||||
if ($^O eq 'linux')
|
||||
@ -70,7 +70,14 @@ sub remote_copy_command
|
||||
{
|
||||
|
||||
my $sync_opt;
|
||||
$sync_opt = '-Lupotz ';
|
||||
if ($^O eq 'aix')
|
||||
{
|
||||
$sync_opt = '--rsync-path /usr/local/bin/rsync ';
|
||||
} else {
|
||||
$sync_opt = '--rsync-path /usr/bin/rsync ';
|
||||
}
|
||||
|
||||
$sync_opt .= '-Lupotz ';
|
||||
$sync_opt .= $$config{'options'};
|
||||
|
||||
open RSCYCCMDFILE, "> /tmp/rsync_$$config{'dest-host'}"
|
||||
|
@ -4082,5 +4082,55 @@ sub getsynclistfile()
|
||||
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
=head3 getrootimage
|
||||
Get the directory of root image for a node;
|
||||
Note: This subroutine only works for diskless node
|
||||
|
||||
Arguments:
|
||||
$node
|
||||
Returns:
|
||||
string - directory of the root image
|
||||
undef - this is not a diskless node or the root image does not existed
|
||||
Globals:
|
||||
none
|
||||
Error:
|
||||
Example:
|
||||
my $node_syncfile=xCAT::Utils->getrootimage($node);
|
||||
|
||||
=cut
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
sub getrootimage()
|
||||
{
|
||||
my $node = shift;
|
||||
if (($node) && ($node =~ /xCAT::Utils/))
|
||||
{
|
||||
$node = shift;
|
||||
}
|
||||
# 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->getNodeAttribs($node, ['profile','os','arch']);
|
||||
my $profile = $nodetype_v->{'profile'};
|
||||
my $os = $nodetype_v->{'os'};
|
||||
my $arch = $nodetype_v->{'arch'};
|
||||
|
||||
if ($^O eq "linux") {
|
||||
my $rootdir = "/install/netboot/$os/$arch/$profile/rootimg/";
|
||||
if (-d $rootdir) {
|
||||
return $rootdir;
|
||||
} else {
|
||||
return undef;
|
||||
}
|
||||
} else {
|
||||
# For AIX
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
@ -4537,6 +4537,7 @@ sub mkdsklsnode
|
||||
my $nethash = shift;
|
||||
my $imaghash = shift;
|
||||
my $locs = shift;
|
||||
my $subreq = shift;
|
||||
|
||||
my %lochash = %{$locs};
|
||||
my %objhash = %{$nodehash};
|
||||
@ -4666,6 +4667,7 @@ ll~;
|
||||
#
|
||||
my $error=0;
|
||||
my @nodesfailed;
|
||||
my $node_syncfile = xCAT::Utils->getsynclistfile($nodes);
|
||||
foreach my $node (@nodelist)
|
||||
{
|
||||
my $image_name = $nodeosi{$node};
|
||||
@ -4897,6 +4899,23 @@ ll~;
|
||||
push(@nodesfailed, $node);
|
||||
next;
|
||||
}
|
||||
|
||||
# Update the files in /install/custom/netboot/AIX/syncfile to the root image
|
||||
# figure out the path of root image
|
||||
my $cmd = "/usr/sbin/lsnim -a location $imagehash{$image_name}{root} | /usr/bin/grep location 2>/dev/null";
|
||||
my $location = xCAT::Utils->runcmd("$cmd", -1);
|
||||
$location =~ s/\s*location = //;
|
||||
chomp($location);
|
||||
my $root_location = $location.'/'.$nim_name.'/';
|
||||
if (-d $root_location) {
|
||||
my $syncfile = $$node_syncfile{$node};
|
||||
xCAT::MsgUtils->message("S", "mkdsklsnode: $root_location, $syncfile");
|
||||
|
||||
my $arg = ["-i", "$root_location", "-F", "$syncfile"];
|
||||
my $env = ["RSYNCSN=yes", "DSH_RSYNC_FILE=$syncfile"];
|
||||
$subreq->({command=>['xdcp'], node=>[$node], arg=>$arg, env=>$env}, $callback);
|
||||
}
|
||||
|
||||
} # end - for each node
|
||||
|
||||
#
|
||||
|
@ -261,21 +261,47 @@ sub updatenode {
|
||||
# if not specifying -S, do the sync file operation
|
||||
unless ($::SKIPSYNCFILE) {
|
||||
my %syncfile_node = ();
|
||||
my %syncfile_rootimage = ();
|
||||
my $node_syncfile = xCAT::Utils->getsynclistfile($nodes);
|
||||
foreach my $node (@$nodes) {
|
||||
my $synclist = $$node_syncfile{$node};
|
||||
|
||||
if ($synclist) {
|
||||
push @{$syncfile_node{$synclist}}, $node;
|
||||
next;
|
||||
}
|
||||
|
||||
# Figure out the directory of the root image
|
||||
# one $synclist will only map to one root image, so
|
||||
# just find the root image one time
|
||||
# only for netboot node (diskless)
|
||||
if ($synclist && $synclist =~ /\/netboot\//) {
|
||||
if (! defined($syncfile_rootimage{$synclist})) {
|
||||
my $root_dir = xCAT::Utils->getrootimage($node);
|
||||
if (-d $root_dir) {
|
||||
$syncfile_rootimage{$synclist} = $root_dir;
|
||||
} else {
|
||||
$syncfile_rootimage{$synclist} = "no_root_image";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Sync files to the target nodes
|
||||
foreach my $synclist (keys %syncfile_node) {
|
||||
my $args = ["-F", "$synclist"];
|
||||
my $env = ["DSH_RSYNC_FILE=$synclist"];
|
||||
$subreq->({command=>['xdcp'], node=>$syncfile_node{$synclist}, arg=>$args, env=>$env}, $callback);
|
||||
}
|
||||
|
||||
# Sync files to the root image for the diskless nodes
|
||||
foreach my $synclist (keys %syncfile_rootimage) {
|
||||
if ($syncfile_rootimage{$synclist} eq "no_root_image") {
|
||||
next;
|
||||
}
|
||||
my $args = ["-i", $syncfile_rootimage{$synclist}, "-F", $synclist];
|
||||
my $env = ["DSH_RSYNC_FILE=$synclist"];
|
||||
$subreq->({command=>['xdcp'], arg=>$args, env=>$env}, $callback);
|
||||
}
|
||||
}
|
||||
|
||||
my $nodestring=join(',', @$nodes);
|
||||
|
@ -1,4 +1,8 @@
|
||||
#!/usr/bin/env perl
|
||||
BEGIN { $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : -d '/opt/xcat' ? '/opt/xcat' : '/usr'; }
|
||||
use lib "$::XCATROOT/lib/perl";
|
||||
use xCAT::Utils;
|
||||
|
||||
use File::Basename;
|
||||
use File::Path;
|
||||
use File::Copy;
|
||||
@ -190,6 +194,15 @@ elsif (-x "$pathtofiles/$profile.postinstall") {
|
||||
|
||||
mkinitrd();
|
||||
|
||||
# sync fils to the rootimage
|
||||
my $syncfile = xCAT::Utils->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";
|
||||
`$::XCATROOT/bin/xdcp -i "$installroot/netboot/$osver/$arch/$profile/rootimg" -F $syncfile`;
|
||||
}
|
||||
|
||||
|
||||
sub getlibs {
|
||||
my $file = shift;
|
||||
my $liblist = `chroot $installroot/netboot/$osver/$arch/$profile/rootimg ldd $file`;
|
||||
|
@ -1,4 +1,8 @@
|
||||
#!/usr/bin/env perl
|
||||
BEGIN { $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : -d '/opt/xcat' ? '/opt/xcat' : '/usr'; }
|
||||
use lib "$::XCATROOT/lib/perl";
|
||||
use xCAT::Utils;
|
||||
|
||||
use File::Basename;
|
||||
use File::Path;
|
||||
use File::Copy;
|
||||
@ -245,6 +249,14 @@ if (($postinstall_filename) && (-x $postinstall_filename)) {
|
||||
|
||||
mkinitrd();
|
||||
|
||||
# sync fils to the rootimage
|
||||
my $syncfile = xCAT::Utils->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";
|
||||
`$::XCATROOT/bin/xdcp -i "$installroot/netboot/$osver/$arch/$profile/rootimg" -F $syncfile`;
|
||||
}
|
||||
|
||||
|
||||
sub getlibs {
|
||||
my $file = shift;
|
||||
|
Loading…
Reference in New Issue
Block a user