From c3fa764ef974705825cee67b1d0c7d0b4b150068 Mon Sep 17 00:00:00 2001 From: Kilian Cavalotti Date: Mon, 11 Dec 2017 22:36:03 -0800 Subject: [PATCH] Add support for the "file -> (noderange) file" syntax in synclist with ServiceNodes (#4445) * Add support for "file - (noderange) file" in synclist when using hierarchical mode. Fixes #4425 This patch ensures that: 1. the synclist is correctly parsed when running on a Service Node 2. all files are synchronized to SNs in hierarchical mode * Better test condition for #4425, addresses issue in https://github.com/xcat2/xcat-core/pull/4445#issuecomment-349472901 --- perl-xCAT/xCAT/DSHCLI.pm | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/perl-xCAT/xCAT/DSHCLI.pm b/perl-xCAT/xCAT/DSHCLI.pm index 7e22de2d3..0ed458e18 100644 --- a/perl-xCAT/xCAT/DSHCLI.pm +++ b/perl-xCAT/xCAT/DSHCLI.pm @@ -5198,8 +5198,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) { + # skip the node if it's NOT in the permitted list and if + # it's not a SN doing a hierarchical mode transfer + if ($dest_node && !(grep /^$target_node$/, @dest_nodes) + && ($rsyncSN != 1) ) { next; } $$options{'destDir_srcFile'}{$target_node} ||= {}; @@ -5655,11 +5657,30 @@ sub parse_rsync_input_file_on_SN } 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; # remove blanks # see if destination is a directory @@ -5688,6 +5709,10 @@ sub parse_rsync_input_file_on_SN 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