From: Ian Jackson Date: Mon, 9 Mar 2015 16:25:22 +0000 (-0400) Subject: cr-ensure-disk-space: Honour different config for published log expiry X-Git-Tag: wip.libvirt-v3-base~256 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=41e9bf013e5f7c1390322aa18e122015f7e6f9fb;p=people%2Fliuw%2Fosstest.git cr-ensure-disk-space: Honour different config for published log expiry 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 --- diff --git a/cr-ensure-disk-space b/cr-ensure-disk-space index 1064590..0ee84c7 100755 --- a/cr-ensure-disk-space +++ b/cr-ensure-disk-space @@ -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 $!; $_=

; @@ -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 "...";