diff --git a/perl-xCAT/xCAT/DSHCLI.pm b/perl-xCAT/xCAT/DSHCLI.pm index 130e6ce31..24b5b4988 100644 --- a/perl-xCAT/xCAT/DSHCLI.pm +++ b/perl-xCAT/xCAT/DSHCLI.pm @@ -42,7 +42,7 @@ our @dsh_valid_env = ( 'DSH_PATH', 'DSH_SYNTAX', 'DSH_TIMEOUT', 'DSH_REMOTE_PASSWORD', 'DSH_TO_USERID', 'DSH_FROM_USERID', - 'DEVICETYPE', 'RSYNCSN', + 'DEVICETYPE', 'RSYNCSN','DSH_RSYNC_FILE', ); select(STDERR); $| = 1; diff --git a/xCAT-client/bin/xdsh b/xCAT-client/bin/xdsh index 2c8e8dd85..32856ae29 100644 --- a/xCAT-client/bin/xdsh +++ b/xCAT-client/bin/xdsh @@ -171,6 +171,10 @@ if ($ENV{'DEVICETYPE'}) push(@{$cmdref->{env}}, "DEVICETYPE=$ENV{'DEVICETYPE'}"); } +if ($ENV{'DSH_RSYNC_FILE'}) +{ + push(@{$cmdref->{env}}, "DSH_RSYNC_FILE=$ENV{'DSH_RSYNC_FILE'}"); +} if ($ENV{'RSYNCSN'}) { push(@{$cmdref->{env}}, "RSYNCSN=$ENV{'RSYNCSN'}"); @@ -453,6 +457,10 @@ sub parse_args_xdcp { $ENV{'RSYNCSN'} = "yes"; # rsync file to SN } + if ($options{'File'}) + { + $ENV{'DSH_RSYNC_FILE'} = $options{'File'} ; # rsync file + } if ($options{'version'}) { my $version = xCAT::Utils->Version(); diff --git a/xCAT-server/lib/xcat/plugins/xdsh.pm b/xCAT-server/lib/xcat/plugins/xdsh.pm index d3248ef9e..97b78c684 100644 --- a/xCAT-server/lib/xcat/plugins/xdsh.pm +++ b/xCAT-server/lib/xcat/plugins/xdsh.pm @@ -61,14 +61,18 @@ sub preprocess_request my $nodes = $req->{node}; my $service = "xcat"; my @requests; - my $syncsn = 0; + my $syncsn = 0; + my $syncsnfile = "NONE"; foreach my $envar (@{$req->{env}}) { my ($var, $value) = split(/=/, $envar, 2); if ($var eq "RSYNCSN") { # syncing SN, will change $syncsn = 1; # nodelist to the list of SN - last; # for those nodes + } + if ($var eq "DSH_RSYNC_FILE") + { # if hierarchy,need to put file on the SN + $syncsnfile = $value; # sync file to SN } } @@ -78,9 +82,28 @@ sub preprocess_request { $sn = xCAT::Utils->get_ServiceNode($nodes, $service, "MN"); if ($syncsn == 0) - { # not syncing sn, do hierarchy - # build each request for each service node + { # not syncing sn, do hierarchy + # build each request for each service node + foreach my $snkey (keys %$sn) + { + if ($syncsnfile ne "NONE") + { # need to send rsync file to SN + my $addreq; + $addreq->{node}->[0] = $snkey; + $addreq->{noderange}->[0] = $snkey; + $addreq->{arg}->[0] = $syncsnfile; + $addreq->{arg}->[1] = $syncsnfile; + $addreq->{command}->[0] = $req->{command}->[0]; + $addreq->{cwd}->[0] = $req->{cwd}->[0]; + push @requests, $addreq; + } + else + { + last; + } + + } foreach my $snkey (keys %$sn) { my $reqcopy = {%$req};