2 # Copyright (c) 1996, Carnegie Mellon University
5 # See CMU_copyright.ph for use and distribution information
7 #: * vos.pm - Wrappers around VOS commands (volume maintenance)
8 #: * This module provides wrappers around the various volserver and VLDB
9 #: * commands, giving them a nice perl-based interface. Someday, they might
10 #: * talk to the servers directly instead of using 'vos', but not anytime
15 use OpenAFS
::CMU_copyright
;
16 use OpenAFS
::util
qw(:DEFAULT :afs_internal);
23 @EXPORT = qw(&AFS_vos_create &AFS_vos_listvldb
24 &AFS_vos_remove &AFS_vos_delentry
25 &AFS_vos_rename &AFS_vos_syncserv
26 &AFS_vos_move &AFS_vos_syncvldb
27 &AFS_vos_examine &AFS_vos_lock
28 &AFS_vos_addsite &AFS_vos_unlock
29 &AFS_vos_remsite &AFS_vos_unlockvldb
30 &AFS_vos_release &AFS_vos_changeaddr
31 &AFS_vos_backup &AFS_vos_listpart
32 &AFS_vos_backupsys &AFS_vos_partinfo
33 &AFS_vos_dump &AFS_vos_listvol
34 &AFS_vos_restore &AFS_vos_zap
37 $vos_err_parse = [ 'Error in vos (.*) command', '-(.*)' ];
40 #: AFS_vos_create($vol, $server, $part, [$quota], [$cell])
41 #: Create a volume with name $vol
42 #: The server name ($server) may be a hostname or IP address
43 #: The partition may be a partition name (/vicepx), letter (x), or number (24)
44 #: If specified, use $quota for the initial quota instead of 5000 blocks.
45 #: If specified, work in $cell instead of the default cell.
46 #: On success, return the volume ID.
48 $AFS_Help{vos_create
} = '$vol, $server, $part, [$quota], [$cell] => $volid';
50 my($vol, $server, $part, $quota, $cell) = @_;
53 @args = ('create', '-name', $vol, '-server', $server, '-part', $part);
54 push(@args, '-maxquota', $quota) if ($quota ne '');
55 push(@args, '-noauth') if ($AFS_Parms{'authlvl'} == 0);
56 push(@args, '-localauth') if ($AFS_Parms{'authlvl'} == 2);
57 push(@args, '-verbose') if ($AFS_Parms{'vostrace'} > 1);
58 push(@args, '-cell', $cell ?
$cell : $AFS_Parms{'cell'});
59 &wrapper
('vos', \
@args,
61 ['^Volume (\d+) created on partition \/vicep\S+ of \S+', \
$id ],
62 $AFS_Parms{'vostrace'} ?
([ '', '?']) : () ]);
67 #: AFS_vos_remove($vol, $server, $part, [$cell])
68 #: Remove the volume $vol from the server and partition specified by $server and
69 #: $part. If appropriate, also remove the corresponding VLDB entry.
70 #: If specified, work in $cell instead of the default cell.
71 #: On success, return 1.
73 $AFS_Help{vos_remove
} = '$vol, $server, $part, [$cell] => Success?';
75 my($vol, $server, $part, $cell) = @_;
78 @args = ('remove', '-id', $vol, '-server', $server, '-part', $part);
79 push(@args, '-noauth') if ($AFS_Parms{'authlvl'} == 0);
80 push(@args, '-localauth') if ($AFS_Parms{'authlvl'} == 2);
81 push(@args, '-verbose') if ($AFS_Parms{'vostrace'} > 1);
82 push(@args, '-cell', $cell ?
$cell : $AFS_Parms{'cell'});
83 &wrapper
('vos', \
@args,
85 $AFS_Parms{'vostrace'} ?
([ '', '?']) : () ]);
90 #: AFS_vos_rename($old, $new, [$cell])
91 #: Rename the volume $old to have the name $new.
92 #: If specified, work in $cell instead of the default cell.
93 #: On success, return 1.
95 $AFS_Help{vos_rename
} = '$old, $new, [$cell] => Success?';
97 my($old, $new, $cell) = @_;
100 @args = ('rename', '-oldname', $old, '-newname', $new);
101 push(@args, '-noauth') if ($AFS_Parms{'authlvl'} == 0);
102 push(@args, '-localauth') if ($AFS_Parms{'authlvl'} == 2);
103 push(@args, '-verbose') if ($AFS_Parms{'vostrace'} > 1);
104 push(@args, '-cell', $cell ?
$cell : $AFS_Parms{'cell'});
105 &wrapper
('vos', \
@args,
107 $AFS_Parms{'vostrace'} ?
([ '', '?']) : () ]);
112 #: AFS_vos_move($vol, $fromsrv, $frompart, $tosrv, $topart, [$cell])
113 #: Move the volume specified by $vol.
114 #: The source location is specified by $fromsrv and $frompart.
115 #: The destination location is specified by $tosrv and $topart.
116 #: If specified, work in $cell instead of the default cell.
117 #: On success, return 1.
120 $AFS_Help{vos_move
} = '$vol, $fromsrv, $frompart, $tosrv, $topart, [$cell] => Success?';
122 my($vol, $fromsrv, $frompart, $tosrv, $topart, $cell) = @_;
125 @args = ('move', '-id', $vol,
126 '-fromserver', $fromsrv, '-frompartition', $frompart,
127 '-toserver', $tosrv, '-topartition', $topart);
128 push(@args, '-noauth') if ($AFS_Parms{'authlvl'} == 0);
129 push(@args, '-localauth') if ($AFS_Parms{'authlvl'} == 2);
130 push(@args, '-verbose') if ($AFS_Parms{'vostrace'} > 1);
131 push(@args, '-cell', $cell ?
$cell : $AFS_Parms{'cell'});
132 &wrapper
('vos', \
@args,
134 $AFS_Parms{'vostrace'} ?
([ '', '?']) : () ]);
139 #: AFS_vos_examine($vol, [$cell])
140 #: Examine the volume $vol, and return information about it.
141 #: If specified, operate in cell $cell instead of the default cell.
142 #: On success, return an associative array with some or all of the following:
143 #: - name Name of this volume
144 #: - id ID of this volume
145 #: - kind Kind of volume (RW, RO, or BK)
146 #: - inuse Disk space in use
147 #: - state On-line or Off-line
148 #: - maxquota Maximum disk usage quota
149 #: - minquota Minimum disk usage quota (optional)
150 #: - stamp_create Time when volume was originally created
151 #: - stamp_update Time volume was last modified
152 #: - stamp_backup Time backup volume was cloned, or 'Never'
153 #: - stamp_copy Time this copy of volume was made
154 #: - backup_flag State of automatic backups: empty or 'disabled'
155 #: - dayuse Number of accesses in the past day
156 #: - rwid ID of read-write volume (even if this is RO or BK)
157 #: - roid ID of read-only volume (even if this is RW or BK)
158 #: - bkid ID of backup volume (even if this is RW or RO)
159 #: - rwserv Name of server where read/write volume is
160 #: - rwpart Name of partition where read/write volume is
161 #: - rosites Reference to a list of read-only sites. Each site, in turn,
162 #: is a reference to a two-element list (server, part).
164 $AFS_Help{vos_examine
} = '$vol, [$cell] => %info';
165 sub AFS_vos_examine
{
166 my($vol, $cell) = @_;
167 my(%result, @args, @rosites);
169 @args = ('examine', '-id', $vol);
170 push(@args, '-noauth') if ($AFS_Parms{'authlvl'} == 0);
171 push(@args, '-localauth') if ($AFS_Parms{'authlvl'} == 2);
172 push(@args, '-verbose') if ($AFS_Parms{'vostrace'} > 2);
173 push(@args, '-cell', $cell ?
$cell : $AFS_Parms{'cell'});
174 %result = &wrapper
('vos', \
@args,
176 ['^(\S+)\s*(\d+)\s*(RW|RO|BK)\s*(\d+)\s*K\s*([-\w]+)', 'name', 'id', 'kind', 'inuse', 'state'],
177 ['MaxQuota\s*(\d+)\s*K', 'maxquota' ],
178 ['MinQuota\s*(\d+)\s*K', 'minquota' ],
179 ['Creation\s*(.*\S+)', 'stamp_create' ],
180 ['Last Update\s*(.*\S+)', 'stamp_update' ],
181 ['Backup\s+([^\d\s].*\S+)', 'stamp_backup' ],
182 ['Copy\s*(.*\S+)', 'stamp_copy' ],
183 ['Automatic backups are (disabled) for this volume', 'backup_flag' ],
184 ['(\d+) accesses in the past day', 'dayuse' ],
185 ['RWrite\:\s*(\d+)', 'rwid' ],
186 ['ROnly\:\s*(\d+)', 'roid' ],
187 ['Backup\:\s*(\d+)', 'bkid' ],
188 ['server (\S+) partition /vicep(\S+) RW Site', 'rwserv', 'rwpart'],
189 ['server (\S+) partition /vicep(\S+) RO Site', sub {
190 push(@rosites, [$_[0], $_[1]]);
192 ($AFS_Parms{'vostrace'} > 2) ?
([ '', '?']) : () ]);
194 $result{'rosites'} = \
@rosites if (@rosites);
200 #: AFS_vos_addsite($vol, $server, $part, [$cell])
201 #: Add a replication site for volume $vol
202 #: The server name ($server) may be a hostname or IP address
203 #: The partition may be a partition name (/vicepx), letter (x), or number (24)
204 #: If specified, work in $cell instead of the default cell.
205 #: On success, return 1.
207 $AFS_Help{vos_addsite
} = '$vol, $server, $part, [$cell] => Success?';
208 sub AFS_vos_addsite
{
209 my($vol, $server, $part, $cell) = @_;
212 @args = ('addsite', '-id', $vol, '-server', $server, '-part', $part);
213 push(@args, '-noauth') if ($AFS_Parms{'authlvl'} == 0);
214 push(@args, '-localauth') if ($AFS_Parms{'authlvl'} == 2);
215 push(@args, '-verbose') if ($AFS_Parms{'vostrace'} > 1);
216 push(@args, '-cell', $cell ?
$cell : $AFS_Parms{'cell'});
217 &wrapper
('vos', \
@args,
219 $AFS_Parms{'vostrace'} ?
([ '', '?']) : () ]);
224 #: AFS_vos_remsite($vol, $server, $part, [$cell])
225 #: Remove a replication site for volume $vol
226 #: The server name ($server) may be a hostname or IP address
227 #: The partition may be a partition name (/vicepx), letter (x), or number (24)
228 #: If specified, work in $cell instead of the default cell.
229 #: On success, return 1.
231 $AFS_Help{vos_remsite
} = '$vol, $server, $part, [$cell] => Success?';
232 sub AFS_vos_remsite
{
233 my($vol, $server, $part, $cell) = @_;
236 @args = ('remsite', '-id', $vol, '-server', $server, '-part', $part);
237 push(@args, '-noauth') if ($AFS_Parms{'authlvl'} == 0);
238 push(@args, '-localauth') if ($AFS_Parms{'authlvl'} == 2);
239 push(@args, '-verbose') if ($AFS_Parms{'vostrace'} > 1);
240 push(@args, '-cell', $cell ?
$cell : $AFS_Parms{'cell'});
241 &wrapper
('vos', \
@args,
243 $AFS_Parms{'vostrace'} ?
([ '', '?']) : () ]);
248 #: AFS_vos_release($vol, [$cell], [$force])
249 #: Release the volume $vol.
250 #: If $force is specified and non-zero, use the "-f" switch.
251 #: If specified, work in $cell instead of the default cell.
252 #: On success, return 1.
254 $AFS_Help{vos_release
} = '$vol, [$cell], [$force] => Success?';
255 sub AFS_vos_release
{
256 my($vol, $cell, $force) = @_;
259 @args = ('release', '-id', $vol);
260 push(@args, '-f') if ($force);
261 push(@args, '-noauth') if ($AFS_Parms{'authlvl'} == 0);
262 push(@args, '-localauth') if ($AFS_Parms{'authlvl'} == 2);
263 push(@args, '-verbose') if ($AFS_Parms{'vostrace'} > 1);
264 push(@args, '-cell', $cell ?
$cell : $AFS_Parms{'cell'});
265 &wrapper
('vos', \
@args,
267 $AFS_Parms{'vostrace'} ?
([ '', '?']) : () ]);
272 #: AFS_vos_backup($vol, [$cell])
273 #: Make a backup of the volume $vol.
274 #: If specified, work in $cell instead of the default cell.
275 #: On success, return 1.
277 $AFS_Help{vos_backup
} = '$vol, [$cell] => Success?';
279 my($vol, $cell) = @_;
282 @args = ('backup', '-id', $vol);
283 push(@args, '-noauth') if ($AFS_Parms{'authlvl'} == 0);
284 push(@args, '-localauth') if ($AFS_Parms{'authlvl'} == 2);
285 push(@args, '-verbose') if ($AFS_Parms{'vostrace'} > 1);
286 push(@args, '-cell', $cell ?
$cell : $AFS_Parms{'cell'});
287 &wrapper
('vos', \
@args,
289 $AFS_Parms{'vostrace'} ?
([ '', '?']) : () ]);
294 #: AFS_vos_backupsys([$prefix], [$server, [$part]], [$exclude], [$cell])
295 #: Do en masse backups of AFS volumes.
296 #: If specified, match only volumes whose names begin with $prefix
297 #: If specified, limit work to the $server and, if given, $part.
298 #: If $exclude is specified and non-zero, backup only volumes NOT matched.
299 #: If specified, work in $cell instead of the default cell.
300 #: On success, return 1.
302 $AFS_Help{vos_backupsys
} = '[$prefix], [$server, [$part]], [$exclude], [$cell] => Success?';
303 sub AFS_vos_backupsys
{
304 my($prefix, $server, $part, $exclude, $cell) = @_;
307 @args = ('backupsys');
308 push(@args, '-prefix', $prefix) if ($prefix);
309 push(@args, '-server', $server) if ($server);
310 push(@args, '-partition', $part) if ($server && $part);
311 push(@args, '-exclude') if ($exclude);
312 push(@args, '-noauth') if ($AFS_Parms{'authlvl'} == 0);
313 push(@args, '-localauth') if ($AFS_Parms{'authlvl'} == 2);
314 push(@args, '-verbose') if ($AFS_Parms{'vostrace'} > 1);
315 push(@args, '-cell', $cell ?
$cell : $AFS_Parms{'cell'});
316 &wrapper
('vos', \
@args,
318 $AFS_Parms{'vostrace'} ?
([ '', '?']) : () ]);
323 #: AFS_vos_dump($vol, [$time], [$file], [$cell])
324 #: Dump the volume $vol
325 #: If specified, do an incremental dump since $time instead of a full dump.
326 #: If specified, dump to $file instead of STDOUT
327 #: If specified, work in $cell instead of the default cell.
328 #: On success, return 1.
330 $AFS_Help{vos_dump
} = '$vol, [$time], [$file], [$cell] => Success?';
332 my($vol, $time, $file, $cell) = @_;
335 @args = ('dump', '-id', $vol);
336 push(@args, '-time', ($time ?
$time : 0));
337 push(@args, '-file', $file) if ($file);
338 push(@args, '-noauth') if ($AFS_Parms{'authlvl'} == 0);
339 push(@args, '-localauth') if ($AFS_Parms{'authlvl'} == 2);
340 push(@args, '-verbose') if ($AFS_Parms{'vostrace'} > 1);
341 push(@args, '-cell', $cell ?
$cell : $AFS_Parms{'cell'});
342 &wrapper
('vos', \
@args,
344 $AFS_Parms{'vostrace'} ?
([ '', '?']) : () ],
345 { pass_stdout
=> !$file });
350 #: AFS_vos_restore($vol, $server, $part, [$file], [$id], [$owmode], [$cell])
351 #: Restore the volume $vol to partition $part on server $server.
352 #: If specified, restore from $file instead of STDIN
353 #: If specified, use the volume ID $id
354 #: If specified, $owmode must be 'abort', 'full', or 'incremental', and
355 #: indicates what to do if the volume exists.
356 #: If specified, work in $cell instead of the default cell.
357 #: On success, return 1.
359 $AFS_Help{vos_restore
} = '$vol, $server, $part, [$file], [$id], [$owmode], [$cell] => Success?';
360 sub AFS_vos_restore
{
361 my($vol, $server, $part, $file, $id, $owmode, $cell) = @_;
364 @args = ('restore', '-name', $vol, '-server', $server, '-partition', $part);
365 push(@args, '-file', $file) if ($file);
366 push(@args, '-id', $id) if ($id);
367 push(@args, '-overwrite', $owmode) if ($owmode);
368 push(@args, '-noauth') if ($AFS_Parms{'authlvl'} == 0);
369 push(@args, '-localauth') if ($AFS_Parms{'authlvl'} == 2);
370 push(@args, '-verbose') if ($AFS_Parms{'vostrace'} > 1);
371 push(@args, '-cell', $cell ?
$cell : $AFS_Parms{'cell'});
372 &wrapper
('vos', \
@args,
374 $AFS_Parms{'vostrace'} ?
([ '', '?']) : () ]);
379 #: AFS_vos_listvldb([$vol], [$server, [$part]], [$locked], [$cell])
380 #: Get a list of volumes in the VLDB.
381 #: If specified, list only the volume $vol
382 #: If specified, list only volumes on the server $server.
383 #: If specified with $server, list only volumes on the partition $part.
384 #: If $locked is specified and nonzero, list only locked VLDB entries
385 #: If specified, work in $cell instead of the default cell.
386 #: On success, return an associative array whose keys are names of volumes
387 #: on the specified server, and each of whose values is an associative
388 #: array describing the corresponding volume, containing some or all of
390 #: - name Name of this volume (same as key)
391 #: - rwid ID of read-write volume (even if this is RO or BK)
392 #: - roid ID of read-only volume (even if this is RW or BK)
393 #: - bkid ID of backup volume (even if this is RW or RO)
394 #: - locked Empty or LOCKED to indicate VLDB entry is locked
395 #: - rwserv Name of server where read/write volume is
396 #: - rwpart Name of partition where read/write volume is
397 #: - rosites Reference to a list of read-only sites. Each site, in turn,
398 #: is a reference to a two-element list (server, part).
400 $AFS_Help{vos_listvldb
} = '[$vol], [$server, [$part]], [$locked], [$cell] => %vols';
401 sub AFS_vos_listvldb
{
402 my($vol, $server, $part, $locked, $cell) = @_;
403 my(%finres, %vlist, @rosites);
405 @args = ('listvldb');
406 push(@args, '-name', $vol) if ($vol);
407 push(@args, '-server', $server) if ($server);
408 push(@args, '-partition', $part) if ($part && $server);
409 push(@args, '-locked') if ($locked);
410 push(@args, '-noauth') if ($AFS_Parms{'authlvl'} == 0);
411 push(@args, '-localauth') if ($AFS_Parms{'authlvl'} == 2);
412 push(@args, '-verbose') if ($AFS_Parms{'vostrace'} > 2);
413 push(@args, '-cell', $cell ?
$cell : $AFS_Parms{'cell'});
414 %finres = &wrapper
('vos', \
@args,
416 ['^(VLDB|Total) entries', '.'],
418 my(%vinfo) = %OpenAFS::wrapper
::result
;
421 $vinfo{rosites
} = [@rosites] if (@rosites);
422 $vlist{$vinfo{name
}} = \
%vinfo;
425 %OpenAFS::wrapper
::result
= ();
429 ['RWrite\:\s*(\d+)', 'rwid' ],
430 ['ROnly\:\s*(\d+)', 'roid' ],
431 ['Backup\:\s*(\d+)', 'bkid' ],
432 ['Volume is currently (LOCKED)', 'locked' ],
433 ['server (\S+) partition /vicep(\S+) RW Site', 'rwserv', 'rwpart'],
434 ['server (\S+) partition /vicep(\S+) RO Site', sub {
435 push(@rosites, [$_[0], $_[1]]);
437 ($AFS_Parms{'vostrace'} > 2) ?
([ '', '?']) : () ]);
440 $finres{rosites
} = [@rosites] if (@rosites);
441 $vlist{$finres{name
}} = \
%finres;
448 #: AFS_vos_delentry($vol, [$cell])
449 #: Delete the VLDB entry for the volume $vol
450 #: If specified, work in $cell instead of the default cell.
451 #: On success, return 1.
453 $AFS_Help{vos_delentry
} = '$vol, [$cell] => Success?';
454 sub AFS_vos_delentry
{
455 my($vol, $cell) = @_;
458 @args = ('delentry', '-id', $vol);
459 push(@args, '-noauth') if ($AFS_Parms{'authlvl'} == 0);
460 push(@args, '-localauth') if ($AFS_Parms{'authlvl'} == 2);
461 push(@args, '-verbose') if ($AFS_Parms{'vostrace'} > 1);
462 push(@args, '-cell', $cell ?
$cell : $AFS_Parms{'cell'});
463 &wrapper
('vos', \
@args,
465 $AFS_Parms{'vostrace'} ?
([ '', '?']) : () ]);
470 #: AFS_vos_syncserv($server, [$part], [$cell], [$force])
471 #: Synchronize the server $server with the VLDB
472 #: If specified, synchronize only partition $part
473 #: If specified, work in $cell instead of the default cell
474 #: If $force is specified, force updates to occur
475 #: On success, return 1.
477 $AFS_Help{vos_syncserv
} = '$server, [$part], [$cell], [$force] => Success?';
478 sub AFS_vos_syncserv
{
479 my($server, $part, $cell, $force) = @_;
482 @args = ('syncserv', '-server', $server);
483 push(@args, '-partition', $part) if ($part);
484 push(@args, '-force') if ($force);
485 push(@args, '-noauth') if ($AFS_Parms{'authlvl'} == 0);
486 push(@args, '-localauth') if ($AFS_Parms{'authlvl'} == 2);
487 push(@args, '-verbose') if ($AFS_Parms{'vostrace'} > 1);
488 push(@args, '-cell', $cell ?
$cell : $AFS_Parms{'cell'});
489 &wrapper
('vos', \
@args,
491 $AFS_Parms{'vostrace'} ?
([ '', '?']) : () ]);
496 #: AFS_vos_syncvldb($server, [$part], [$cell], [$force])
497 #: Synchronize the VLDB with server $server
498 #: If specified, synchronize only partition $part
499 #: If specified, work in $cell instead of the default cell
500 #: If $force is specified, force updates to occur
501 #: On success, return 1.
503 $AFS_Help{vos_syncvldb
} = '$server, [$part], [$cell], [$force] => Success?';
504 sub AFS_vos_syncvldb
{
505 my($server, $part, $cell, $force) = @_;
508 @args = ('syncvldb', '-server', $server);
509 push(@args, '-partition', $part) if ($part);
510 push(@args, '-force') if ($force);
511 push(@args, '-noauth') if ($AFS_Parms{'authlvl'} == 0);
512 push(@args, '-localauth') if ($AFS_Parms{'authlvl'} == 2);
513 push(@args, '-verbose') if ($AFS_Parms{'vostrace'} > 1);
514 push(@args, '-cell', $cell ?
$cell : $AFS_Parms{'cell'});
515 &wrapper
('vos', \
@args,
517 $AFS_Parms{'vostrace'} ?
([ '', '?']) : () ]);
522 #: AFS_vos_lock($vol, [$cell])
523 #: Lock the VLDB entry for volume $vol.
524 #: If specified, work in $cell instead of the default cell.
525 #: On success, return 1.
527 $AFS_Help{vos_lock
} = '$vol, [$cell] => Success?';
529 my($vol, $cell) = @_;
532 @args = ('lock', '-id', $vol);
533 push(@args, '-noauth') if ($AFS_Parms{'authlvl'} == 0);
534 push(@args, '-localauth') if ($AFS_Parms{'authlvl'} == 2);
535 push(@args, '-verbose') if ($AFS_Parms{'vostrace'} > 1);
536 push(@args, '-cell', $cell ?
$cell : $AFS_Parms{'cell'});
537 &wrapper
('vos', \
@args,
539 $AFS_Parms{'vostrace'} ?
([ '', '?']) : () ]);
544 #: AFS_vos_unlock($vol, [$cell])
545 #: Unlock the VLDB entry for volume $vol.
546 #: If specified, work in $cell instead of the default cell.
547 #: On success, return 1.
549 $AFS_Help{vos_unlock
} = '$vol, [$cell] => Success?';
551 my($vol, $cell) = @_;
554 @args = ('unlock', '-id', $vol);
555 push(@args, '-noauth') if ($AFS_Parms{'authlvl'} == 0);
556 push(@args, '-localauth') if ($AFS_Parms{'authlvl'} == 2);
557 push(@args, '-verbose') if ($AFS_Parms{'vostrace'} > 1);
558 push(@args, '-cell', $cell ?
$cell : $AFS_Parms{'cell'});
559 &wrapper
('vos', \
@args,
561 $AFS_Parms{'vostrace'} ?
([ '', '?']) : () ]);
566 #: AFS_vos_unlockvldb([$server, [$part]], [$cell])
567 #: Unlock some or all VLDB entries
568 #: If specified, unlock only entries for volumes on server $server
569 #: If specified with $server, unlock only entries for volumes on
570 #: partition $part, instead of entries for volumes on all partitions
571 #: If specified, work in $cell instead of the default cell.
572 #: On success, return 1.
574 $AFS_Help{vos_unlockvldb
} = '[$server, [$part]], [$cell] => Success?';
575 sub AFS_vos_unlockvldb
{
576 my($server, $part, $cell) = @_;
579 @args = ('unlockvldb');
580 push(@args, '-server', $server) if ($server);
581 push(@args, '-partition', $part) if ($server && $part);
582 push(@args, '-noauth') if ($AFS_Parms{'authlvl'} == 0);
583 push(@args, '-localauth') if ($AFS_Parms{'authlvl'} == 2);
584 push(@args, '-verbose') if ($AFS_Parms{'vostrace'} > 1);
585 push(@args, '-cell', $cell ?
$cell : $AFS_Parms{'cell'});
586 &wrapper
('vos', \
@args,
588 $AFS_Parms{'vostrace'} ?
([ '', '?']) : () ]);
593 #: AFS_vos_changeaddr($old, $new, [$cell])
594 #: Change the IP address of server $old to $new.
595 #: If specified, work in $cell instead of the default cell.
596 #: On success, return 1.
598 $AFS_Help{vos_changeaddr
} = '$old, $new, [$cell] => Success?';
599 sub AFS_vos_changeaddr
{
600 my($old, $new, $cell) = @_;
603 @args = ('changeaddr', '-oldaddr', $old, '-newaddr', $new);
604 push(@args, '-noauth') if ($AFS_Parms{'authlvl'} == 0);
605 push(@args, '-localauth') if ($AFS_Parms{'authlvl'} == 2);
606 push(@args, '-verbose') if ($AFS_Parms{'vostrace'} > 1);
607 push(@args, '-cell', $cell ?
$cell : $AFS_Parms{'cell'});
608 &wrapper
('vos', \
@args,
610 $AFS_Parms{'vostrace'} ?
([ '', '?']) : () ]);
615 #: AFS_vos_listpart($server, [$cell])
616 #: Retrieve a list of partitions on server $server
617 #: If specified, work in $cell instead of the default cell.
618 #: On success, return a list of partition letters
620 $AFS_Help{vos_listpart
} = '$server, [$cell] => @parts';
621 sub AFS_vos_listpart
{
622 my($server, $cell) = @_;
625 @args = ('listpart', '-server', $server);
626 push(@args, '-noauth') if ($AFS_Parms{'authlvl'} == 0);
627 push(@args, '-localauth') if ($AFS_Parms{'authlvl'} == 2);
628 push(@args, '-verbose') if ($AFS_Parms{'vostrace'} > 2);
629 push(@args, '-cell', $cell ?
$cell : $AFS_Parms{'cell'});
630 &wrapper
('vos', \
@args,
632 [ '^(.*\/vicep.*)$', #',
638 } split(' ', $_[0]));
640 ($AFS_Parms{'vostrace'} > 2) ?
([ '', '?']) : () ]);
645 #: AFS_vos_partinfo($server, [$part], [$cell])
646 #: Get information about partitions on server $server.
647 #: If specified, only get info about partition $part.
648 #: If specified, work in $cell instead of the default cell.
649 #: On success, return an associative array whose keys are partition letters,
650 #: and each of whose values is a reference to a 2-element list, consisting
651 #: of the total size of the partition and the amount of space used.
653 $AFS_Help{vos_partinfo
} = '$server, [$part], [$cell] => %info';
654 sub AFS_vos_partinfo
{
655 my($server, $part, $cell) = @_;
658 @args = ('partinfo', '-server', $server);
659 push(@args, '-partition', $part) if ($part);
660 push(@args, '-noauth') if ($AFS_Parms{'authlvl'} == 0);
661 push(@args, '-localauth') if ($AFS_Parms{'authlvl'} == 2);
662 push(@args, '-verbose') if ($AFS_Parms{'vostrace'} > 2);
663 push(@args, '-cell', $cell ?
$cell : $AFS_Parms{'cell'});
664 &wrapper
('vos', \
@args,
666 [ '^Free space on partition /vicep(.+)\: (\d+) K blocks out of total (\d+)',
668 $parts{$_[0]} = [ $_[1], $_[2] ];
670 ($AFS_Parms{'vostrace'} > 2) ?
([ '', '?']) : () ]);
675 #: AFS_vos_listvol($server, [$part], [$cell])
676 #: Get a list of volumes on the server $server.
677 #: If specified, list only volumes on the partition $part.
678 #: If specified, work in $cell instead of the default cell.
679 #: On success, return an associative array whose keys are names of volumes
680 #: on the specified server, and each of whose values is an associative
681 #: array describing the corresponding volume, containing some or all of
683 #: - name Name of this volume (same as key)
684 #: - id ID of this volume
685 #: - kind Kind of volume (RW, RO, or BK)
686 #: - inuse Disk space in use
687 #: - maxquota Maximum disk usage quota
688 #: - minquota Minimum disk usage quota (optional)
689 #: - stamp_create Time when volume was originally created
690 #: - stamp_update Time volume was last modified
691 #: - stamp_backup Time backup volume was cloned, or 'Never'
692 #: - stamp_copy Time this copy of volume was made
693 #: - backup_flag State of automatic backups: empty or 'disabled'
694 #: - dayuse Number of accesses in the past day
695 #: - serv Server where this volume is located
696 #: - part Partition where this volume is located
698 $AFS_Help{vos_listvol
} = '$server, [$part], [$cell] => %vols';
699 sub AFS_vos_listvol
{
700 my($server, $part, $cell) = @_;
703 @args = ('listvol', '-server', $server, '-long');
704 push(@args, '-partition', $part) if ($part);
705 push(@args, '-noauth') if ($AFS_Parms{'authlvl'} == 0);
706 push(@args, '-localauth') if ($AFS_Parms{'authlvl'} == 2);
707 push(@args, '-verbose') if ($AFS_Parms{'vostrace'} > 2);
708 push(@args, '-cell', $cell ?
$cell : $AFS_Parms{'cell'});
709 %finres = &wrapper
('vos', \
@args,
711 ['^\S+\s*\d+\s*(RW|RO|BK)', sub {
712 my(%vinfo) = %OpenAFS::wrapper
::result
;
715 $vlist{$vinfo{name
}} = \
%vinfo;
716 %OpenAFS::wrapper
::result
= ();
719 ['^(\S+)\s*(\d+)\s*(RW|RO|BK)\s*(\d+)\s*K', 'name', 'id', 'kind', 'inuse'],
720 ['(\S+)\s*\/vicep(\S+)\:', 'serv', 'part' ],
721 ['MaxQuota\s*(\d+)\s*K', 'maxquota' ],
722 ['MinQuota\s*(\d+)\s*K', 'minquota' ],
723 ['Creation\s*(.*\S+)', 'stamp_create' ],
724 ['Last Update\s*(.*\S+)', 'stamp_update' ],
725 ['Backup\s+([^\d\s].*\S+)', 'stamp_backup' ],
726 ['Copy\s*(.*\S+)', 'stamp_copy' ],
727 ['Automatic backups are (disabled) for this volume', 'backup_flag' ],
728 ['(\d+) accesses in the past day', 'dayuse' ],
729 ($AFS_Parms{'vostrace'} > 2) ?
([ '', '?']) : () ]);
732 $vlist{$finres{name
}} = \
%finres;
737 #: AFS_vos_zap($vol, $server, $part, [$cell], [$force])
738 #: Remove the volume $vol from the server and partition specified by $server and
739 #: $part. Don't bother messing with the VLDB.
740 #: If specified, work in $cell instead of the default cell.
741 #: If $force is specified, force the zap to happen
742 #: On success, return 1.
744 $AFS_Help{vos_zap
} = '$vol, $server, $part, [$cell], [$force] => Success?';
746 my($vol, $server, $part, $cell, $force) = @_;
749 @args = ('zap', '-id', $vol, '-server', $server, '-part', $part);
750 push(@args, '-force') if ($force);
751 push(@args, '-noauth') if ($AFS_Parms{'authlvl'} == 0);
752 push(@args, '-localauth') if ($AFS_Parms{'authlvl'} == 2);
753 push(@args, '-verbose') if ($AFS_Parms{'vostrace'} > 1);
754 push(@args, '-cell', $cell ?
$cell : $AFS_Parms{'cell'});
755 &wrapper
('vos', \
@args,
757 $AFS_Parms{'vostrace'} ?
([ '', '?']) : () ]);
762 #: AFS_vos_status($server, [$cell])
763 #: Get information about outstanding transactions on $server
764 #: If specified, work in $cell instead of the default cell
765 #: On success, return a list of transactions, each of which is a reference
766 #: to an associative array containing some or all of these elements:
767 #: - transid Transaction ID
768 #: - stamp_create Time the transaction was created
770 #: - part Partition letter
771 #: - action Action or procedure
772 #: - flags Volume attach flags
773 #: If there are no transactions, the list will be empty.
775 $AFS_Help{vos_status
} = '$server, [$cell] => @trans';
777 my($server, $cell) = @_;
780 @args = ('status', '-server', $server);
781 push(@args, '-noauth') if ($AFS_Parms{'authlvl'} == 0);
782 push(@args, '-localauth') if ($AFS_Parms{'authlvl'} == 2);
783 push(@args, '-verbose') if ($AFS_Parms{'vostrace'} > 2);
784 push(@args, '-cell', $cell ?
$cell : $AFS_Parms{'cell'});
785 &wrapper
('vos', \
@args,
788 my(%trinfo) = %OpenAFS::wrapper
::result
;
790 if ($trinfo{transid
}) {
791 push(@trlist, \
%trinfo);
792 %OpenAFS::wrapper
::result
= ();
795 ['^transaction\:\s*(\d+)\s*created: (.*\S+)', 'transid', 'stamp_create'],
796 ['^attachFlags:\s*(.*\S+)', 'flags'],
797 ['^volume:\s*(\d+)\s*partition\: \/vicep(\S+)\s*procedure\:\s*(\S+)',
798 'volid', 'part', 'action'],
799 ($AFS_Parms{'vostrace'} > 2) ?
([ '', '?']) : () ]);