]> xenbits.xensource.com Git - people/liuw/osstest.git/commitdiff
cr-ensure-disk-space: Honour different config for published log expiry
authorIan Jackson <ian.jackson@eu.citrix.com>
Mon, 9 Mar 2015 16:25:22 +0000 (12:25 -0400)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Tue, 24 Mar 2015 18:57:00 +0000 (18:57 +0000)
Break out references to $c{Logs...} into new dircfg() function, and
look up $c{${cfgbase}...} first.  No functional change with existing
config.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
cr-ensure-disk-space

index 1064590f5c1f8cddf954e3bddb19a338ca49802a..0ee84c70415550d680807f2b6133f1238b3156e8 100755 (executable)
@@ -70,6 +70,11 @@ sub ontarget ($) {
     }
 }
 
+sub dircfg ($) {
+    my ($k) = @_;
+    return $c{"${cfgbase}${k}"} // $c{"Logs${k}"};
+}
+
 for (;;) {
     open P, "-|", ontarget "df --block-size=1M -P $pubdir" or die $!;
     $_= <P>;
@@ -78,8 +83,8 @@ for (;;) {
     m,^\S+\s+\d+\s+\d+\s+(\d+)\s+, or die "$_ ?";
     $!=0; $?=0; close P or die "$! $?";
     my $space= $1;
-    printf "space: %8d, wanted: %8d ", $space, $c{LogsMinSpaceMby};
-    last if $space >= $c{LogsMinSpaceMby};
+    printf "space: %8d, wanted: %8d ", $space, dircfg('MinSpaceMby');
+    last if $space >= dircfg('MinSpaceMby');
 
     if (!@flights) {
        open P, "-|", ontarget "ls -1 $pubdir" or die $!;
@@ -103,7 +108,7 @@ for (;;) {
 
     printf "(age %dd) ", $age / 86400;
 
-    die "age $age" if $age < $c{LogsMinExpireAge};
+    die "age $age" if $age < dircfg('MinExpireAge');
 
     printf "...";