add xdsh -s flag support to update the servicenodes

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@3405 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
lissav 2009-05-19 14:59:17 +00:00
parent 26542beeda
commit ebe2afe1d1
3 changed files with 51 additions and 13 deletions

View File

@ -42,7 +42,7 @@ our @dsh_valid_env = (
'DSH_PATH', 'DSH_SYNTAX',
'DSH_TIMEOUT', 'DSH_REMOTE_PASSWORD',
'DSH_TO_USERID', 'DSH_FROM_USERID',
'DEVICETYPE',
'DEVICETYPE', 'RSYNCSN',
);
select(STDERR);
$| = 1;

View File

@ -171,6 +171,11 @@ if ($ENV{'DEVICETYPE'})
push(@{$cmdref->{env}}, "DEVICETYPE=$ENV{'DEVICETYPE'}");
}
if ($ENV{'RSYNCSN'})
{
push(@{$cmdref->{env}}, "RSYNCSN=$ENV{'RSYNCSN'}");
}
xCAT::Client::submit_request($cmdref, \&xCAT::Client::handle_response);
exit $xCAT::Client::EXITCODE;
@ -256,7 +261,7 @@ sub parse_args_xdsh
# find out who we are going to log on to the node as
my $to_userid;
if ($options{'user'}) # if -l option
if ($options{'user'}) # if -l option
{
$to_userid = $options{'user'};
}
@ -444,6 +449,10 @@ sub parse_args_xdcp
xCAT::DSHCLI->show_dsh_config;
exit 0;
}
if ($options{'rsyncSN'})
{
$ENV{'RSYNCSN'} = "yes"; # rsync file to SN
}
if ($options{'version'})
{
my $version = xCAT::Utils->Version();
@ -454,7 +463,7 @@ sub parse_args_xdcp
if (($options{'rootimg'}) && (!($options{'File'})))
{
xCAT::MsgUtils->message("E",
"To use -i flag you must supply the -F flag\n.");
"To use -i flag you must supply the -F flag\n.");
exit 1;
}
if ($options{'node-rcp'}) # if set on command line, use it

View File

@ -55,32 +55,61 @@ sub preprocess_request
my $cb = shift;
my %sn;
my $sn;
#if already preprocessed, go straight to request
if ($req->{_xcatpreprocessed}->[0] == 1 ) { return [$req]; }
if ($req->{_xcatpreprocessed}->[0] == 1) { return [$req]; }
my $nodes = $req->{node};
my $service = "xcat";
my @requests;
my $syncsn = 0;
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
}
}
# find service nodes for requested nodes
# build an individual request for each service node
if ($nodes)
{
$sn = xCAT::Utils->get_ServiceNode($nodes, $service, "MN");
if ($syncsn == 0)
{ # not syncing sn, do hierarchy
# build each request for each service node
# build each request for each service node
foreach my $snkey (keys %$sn)
{
my $reqcopy = {%$req};
$reqcopy->{node} = $sn->{$snkey};
$reqcopy->{'_xcatdest'} = $snkey;
$reqcopy->{_xcatpreprocessed}->[0] = 1;
push @requests, $reqcopy;
foreach my $snkey (keys %$sn)
{
my $reqcopy = {%$req};
$reqcopy->{node} = $sn->{$snkey};
$reqcopy->{'_xcatdest'} = $snkey;
$reqcopy->{_xcatpreprocessed}->[0] = 1;
push @requests, $reqcopy;
}
}
else
{ # syncing SN
# rebuild nodelist and noderange with service nodes
my @snodes;
my @snoderange;
foreach my $snkey (keys %$sn)
{
push @snodes, $snkey;
$snoderange[0] .= "$snkey,";
}
chop $snoderange[0];
$req->{node} = \@snodes;
$req->{noderange} = \@snoderange;
return [$req];
}
}
else
{ # running local on image ( -R option)
{ # running local on image
return [$req];
}
return \@requests;