From 0f52e5f000908d25de8f2f9cee04e57bf8bf3c97 Mon Sep 17 00:00:00 2001 From: wangxiaopeng Date: Tue, 19 Jan 2016 21:21:47 -0500 Subject: [PATCH] Enhance sycnfile format Support the new format 'file -> (noderange for permitted nodes) file' for syncfile. --- perl-xCAT/xCAT/DSHCLI.pm | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/perl-xCAT/xCAT/DSHCLI.pm b/perl-xCAT/xCAT/DSHCLI.pm index 4bbe3633e..870f919d5 100644 --- a/perl-xCAT/xCAT/DSHCLI.pm +++ b/perl-xCAT/xCAT/DSHCLI.pm @@ -20,6 +20,7 @@ require xCAT::DSHCore; use xCAT::MsgUtils; use xCAT::Utils; use xCAT::TableUtils; +use xCAT::NodeRange; use lib '/opt/xcat/xdsh'; our @dsh_available_contexts = (); our @dsh_valid_contexts = (); @@ -5068,12 +5069,29 @@ sub parse_rsync_input_file_on_MN } } else { # not processing EXECUTE, EXECUTEALWAYS or APPEND # otherwise it is just the synclist - if ($line =~ /(.+) -> (.+)/) - { - + # xCAT supports the syncfile format: + # file -> file + # file -> (noderange for permitted nodes) file + if ($line =~ /(.+) -> (.+)/ || $line =~ /(.+) -> +\((.+)\) +(.+)/) { $::process_line = 1; - my $src_file = $1; - my $dest_file = $2; + my $src_file; + my $dest_file; + my $dest_node; + my @dest_nodes; + if ($line =~ /(.+) -> +\((.+)\) +(.+)/) { + $src_file = $1; + $dest_node = $2; + $dest_file = $3; + } elsif ($line =~ /(.+) -> (.+)/) { + $src_file = $1; + $dest_file = $2; + } + + # get all the permitted nodes for the line + $dest_node =~ s/\s//g; + if ($dest_node) { + @dest_nodes = noderange($dest_node); + } $dest_file =~ s/[\s;]//g; my @srcfiles = (split ' ', $src_file); my $arraysize = scalar @srcfiles; # of source files on the line @@ -5102,6 +5120,10 @@ sub parse_rsync_input_file_on_MN foreach my $target_node (@dest_host) { + # skip the node if it's NOT in the permitted list + if ($dest_node && ! grep /^$target_node$/, @dest_nodes) { + next; + } $$options{'destDir_srcFile'}{$target_node} ||= {}; # for each file on the line