]> andersk Git - moira.git/blobdiff - incremental/afs_utils.pl
Added user status information as argument #10 to the incremental program
[moira.git] / incremental / afs_utils.pl
index 0e1399e145aa525f966339e771824ef17751f92d..f64579b0f1dbb5be8bca5c7b02f4416bf9ccafd1 100644 (file)
@@ -1,3 +1,5 @@
+# $Header$
+
 $afsbin="/moira/bin";
 $vos="$afsbin/vos";
 $pts="$afsbin/pts";
@@ -16,6 +18,7 @@ $LOCK_UN=8;
      "CONTRIB", "contrib",
      "COURSE", "course",
      "HOMEDIR", "user",
+     "LEASE", "dept",
      "PROJECT", "project",
      "REF", "ref",
      "SW", "sw",
@@ -23,21 +26,6 @@ $LOCK_UN=8;
      "UROP", "urop",
      );
 
-# Function: afs_vname
-# Returns the canonical volume name for (locker,type,cell)
-sub afs_vname
-{
-    local($name,$type,$cell) = @_;
-
-    $vtype = eval "\$vtypes_$cell{$type}";
-    return "" unless $vtype;
-
-    $vname = $vtype . "." . $name;
-    $vname =~ s/[^-A-Za-z0-9_.]//g;            # strip out illegal characters
-    return $vname;
-}
-
-
 # File format:
 #    cell server partition total used alloc
 
@@ -72,8 +60,7 @@ sub afs_unlock
     close(SRV);
 }
 
-# Function: afs_find
-# Finds server/partition for allocation.
+# Find server/partition for allocation.
 #
 # Best fit algorithm used:
 #    max[ (2*free space) - (unused quota) ]
@@ -81,36 +68,35 @@ sub afs_unlock
 #
 # Note: This routine does not actually adjust the quota; the caller
 # should use afs_quota_adj();
+
 sub afs_find
 {
-    local($cell,$type,$quota) = @_;
-    local($i, $j, $vos, $a);
-    local(@max) = '';
+    local($cell,$type,$quota,@except) = @_;
+    local($j,$k);
+    local(@max) = ("", "", -10000000);
 
     &afs_lock;
     chop(@afs_data);
 
-    for $i ($[ .. $#afs_data) {
-       ($a, $asrv, $apart, $t, $total, $used, $alloc) =
-           split(/\s+/, $afs_data[$i]);
+  sloop:
+    for (@afs_data) {
+       local ($a, $asrv, $apart, $t, $total, $used, $alloc) = split(/\s+/,$_);
        next if ($a ne $cell || !$total || $type !~ /$t/);
+       for $j (@except) {
+           next sloop if ($j eq $asrv);
+       }
        $alloc = $used if ($alloc < $used);
        $j = 2*$total - $used - $alloc;
-       if (! @max || $j > $max[2]) {
-           ($total, $used) = &afs_partinfo($asrv, $apart, $cell);
-           next if ($?);
-           $afs_data[$i]=join(' ',$cell,$asrv,$apart,$t,$total,$used,$alloc);
-           @max = ($asrv,$apart,$j);
-       }
+       @max = ($asrv,$apart,$j) if (! @max || $j > $max[2]);
     }
 
     &afs_unlock;
     return(@max);
 }
 
-
-# Function: afs_quota_adj
-# Adjusts the quota allocation for a given server/partition
+#
+# Quota adjustments
+#
 sub afs_quota_adj
 {
     local($cell,$asrv,$apart,$adj) = @_;
@@ -131,20 +117,3 @@ sub afs_quota_adj
     &afs_unlock;
     return($found);
 }
-
-
-sub afs_partinfo
-{
-    local($as, $ap, $c) = @_;
-    local(@vos, $total, $used);
-
-    open(VOS,"$vos partinfo $as $ap -cell $c -noauth|");
-    chop(@vos = <VOS>);
-    close(VOS);
-    return "" if ($?);
-
-    @vos = split(/\s+/,$vos[0]);
-    $total = pop(@vos);
-    $used = $total-$vos[5];
-    return ($total,$used);
-}
This page took 0.044278 seconds and 4 git commands to generate.