diff mbox series

[OSSTEST,5/6] ts-logs-capture: try_fetch_logs: Honour $fs_ and $out_prefix

Message ID 20200327181526.19412-5-ian.jackson@eu.citrix.com (mailing list archive)
State New, archived
Headers show
Series [OSSTEST,1/6] TestSupport: export guest_find_lv | expand

Commit Message

Ian Jackson March 27, 2020, 6:15 p.m. UTC
This allows us to add some stuff to add to each pattern, and each
filename.  This will be useful in a moment.

None of the call sites pass this yet.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 ts-logs-capture | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/ts-logs-capture b/ts-logs-capture
index 418155ce..6be77676 100755
--- a/ts-logs-capture
+++ b/ts-logs-capture
@@ -68,11 +68,13 @@  END
     @guests = grep { defined $_->{Domid} } @allguests;
 }
 
-sub try_fetch_logs ($$) {
-    my ($lho, $logfilepats) = @_;
+sub try_fetch_logs ($$;$$) {
+    my ($lho, $logfilepats, $fs_prefix,$out_prefix) = @_;
+    $fs_prefix //= '';
+    $out_prefix //= '';
     my $ok= 0;
     foreach my $logfilepat (@$logfilepats) {
-        my $logfileslist= $logfilepat;
+        my $logfileslist= $fs_prefix.$logfilepat;
         if ($logfileslist =~ m/[*?]/) {
             if (!eval {
                 $logfileslist=
@@ -91,8 +93,9 @@  END
         }
         foreach my $logfile (split / /, $logfileslist) {
             my $llogfile= $logfile;
+	    $llogfile =~ s,^\Q$fs_prefix\E,,;
             $llogfile =~ s,/,-,g;
-            $llogfile= hostnamepath($lho)."--$llogfile";
+            $llogfile= hostnamepath($lho)."-$out_prefix-$llogfile";
             logm("fetching $logfile to $llogfile");
             if (!eval {
                 target_getfile_root($lho,60, $logfile,"$stash/$llogfile");