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 #: - maxquota Maximum disk usage quota
148 #: - minquota Minimum disk usage quota (optional)
149 #: - stamp_create Time when volume was originally created
150 #: - stamp_update Time volume was last modified
151 #: - stamp_backup Time backup volume was cloned, or 'Never'
152 #: - stamp_copy Time this copy of volume was made
153 #: - backup_flag State of automatic backups: empty or 'disabled'
154 #: - dayuse Number of accesses in the past day
155 #: - rwid ID of read-write volume (even if this is RO or BK)
156 #: - roid ID of read-only volume (even if this is RW or BK)
157 #: - bkid ID of backup volume (even if this is RW or RO)
158 #: - rwserv Name of server where read/write volume is
159 #: - rwpart Name of partition where read/write volume is
160 #: - rosites Reference to a list of read-only sites. Each site, in turn,
161 #: is a reference to a two-element list (server, part).
163 $AFS_Help{vos_examine} = '$vol, [$cell] => %info';
164 sub AFS_vos_examine {
165 my($vol, $cell) = @_;
166 my(%result, @args, @rosites);
168 @args = ('examine', '-id', $vol);
169 push(@args, '-noauth') if ($AFS_Parms{'authlvl'} == 0);
170 push(@args, '-localauth') if ($AFS_Parms{'authlvl'} == 2);
171 push(@args, '-verbose') if ($AFS_Parms{'vostrace'} > 2);
172 push(@args, '-cell', $cell ? $cell : $AFS_Parms{'cell'});
173 %result = &wrapper('vos', \@args,
175 ['^(\S+)\s*(\d+)\s*(RW|RO|BK)\s*(\d+)\s*K', 'name', 'id', 'kind', 'inuse'],
176 ['MaxQuota\s*(\d+)\s*K', 'maxquota' ],
177 ['MinQuota\s*(\d+)\s*K', 'minquota' ],
178 ['Creation\s*(.*\S+)', 'stamp_create' ],
179 ['Last Update\s*(.*\S+)', 'stamp_update' ],
180 ['Backup\s+([^\d\s].*\S+)', 'stamp_backup' ],
181 ['Copy\s*(.*\S+)', 'stamp_copy' ],
182 ['Automatic backups are (disabled) for this volume', 'backup_flag' ],
183 ['(\d+) accesses in the past day', 'dayuse' ],
184 ['RWrite\:\s*(\d+)', 'rwid' ],
185 ['ROnly\:\s*(\d+)', 'roid' ],
186 ['Backup\:\s*(\d+)', 'bkid' ],
187 ['server (\S+) partition /vicep(\S+) RW Site', 'rwserv', 'rwpart'],
188 ['server (\S+) partition /vicep(\S+) RO Site', sub {
189 push(@rosites, [$_[0], $_[1]]);
191 ($AFS_Parms{'vostrace'} > 2) ? ([ '', '?']) : () ]);
193 $result{'rosites'} = \@rosites if (@rosites);
199 #: AFS_vos_addsite($vol, $server, $part, [$cell])
200 #: Add a replication site for volume $vol
201 #: The server name ($server) may be a hostname or IP address
202 #: The partition may be a partition name (/vicepx), letter (x), or number (24)
203 #: If specified, work in $cell instead of the default cell.
204 #: On success, return 1.
206 $AFS_Help{vos_addsite} = '$vol, $server, $part, [$cell] => Success?';
207 sub AFS_vos_addsite {
208 my($vol, $server, $part, $cell) = @_;
211 @args = ('addsite', '-id', $vol, '-server', $server, '-part', $part);
212 push(@args, '-noauth') if ($AFS_Parms{'authlvl'} == 0);
213 push(@args, '-localauth') if ($AFS_Parms{'authlvl'} == 2);
214 push(@args, '-verbose') if ($AFS_Parms{'vostrace'} > 1);
215 push(@args, '-cell', $cell ? $cell : $AFS_Parms{'cell'});
216 &wrapper('vos', \@args,
218 $AFS_Parms{'vostrace'} ? ([ '', '?']) : () ]);
223 #: AFS_vos_remsite($vol, $server, $part, [$cell])
224 #: Remove a replication site for volume $vol
225 #: The server name ($server) may be a hostname or IP address
226 #: The partition may be a partition name (/vicepx), letter (x), or number (24)
227 #: If specified, work in $cell instead of the default cell.
228 #: On success, return 1.
230 $AFS_Help{vos_remsite} = '$vol, $server, $part, [$cell] => Success?';
231 sub AFS_vos_remsite {
232 my($vol, $server, $part, $cell) = @_;
235 @args = ('remsite', '-id', $vol, '-server', $server, '-part', $part);
236 push(@args, '-noauth') if ($AFS_Parms{'authlvl'} == 0);
237 push(@args, '-localauth') if ($AFS_Parms{'authlvl'} == 2);
238 push(@args, '-verbose') if ($AFS_Parms{'vostrace'} > 1);
239 push(@args, '-cell', $cell ? $cell : $AFS_Parms{'cell'});
240 &wrapper('vos', \@args,
242 $AFS_Parms{'vostrace'} ? ([ '', '?']) : () ]);
247 #: AFS_vos_release($vol, [$cell], [$force])
248 #: Release the volume $vol.
249 #: If $force is specified and non-zero, use the "-f" switch.
250 #: If specified, work in $cell instead of the default cell.
251 #: On success, return 1.
253 $AFS_Help{vos_release} = '$vol, [$cell], [$force] => Success?';
254 sub AFS_vos_release {
255 my($vol, $cell, $force) = @_;
258 @args = ('release', '-id', $vol);
259 push(@args, '-f') if ($force);
260 push(@args, '-noauth') if ($AFS_Parms{'authlvl'} == 0);
261 push(@args, '-localauth') if ($AFS_Parms{'authlvl'} == 2);
262 push(@args, '-verbose') if ($AFS_Parms{'vostrace'} > 1);
263 push(@args, '-cell', $cell ? $cell : $AFS_Parms{'cell'});
264 &wrapper('vos', \@args,
266 $AFS_Parms{'vostrace'} ? ([ '', '?']) : () ]);
271 #: AFS_vos_backup($vol, [$cell])
272 #: Make a backup of the volume $vol.
273 #: If specified, work in $cell instead of the default cell.
274 #: On success, return 1.
276 $AFS_Help{vos_backup} = '$vol, [$cell] => Success?';
278 my($vol, $cell) = @_;
281 @args = ('backup', '-id', $vol);
282 push(@args, '-noauth') if ($AFS_Parms{'authlvl'} == 0);
283 push(@args, '-localauth') if ($AFS_Parms{'authlvl'} == 2);
284 push(@args, '-verbose') if ($AFS_Parms{'vostrace'} > 1);
285 push(@args, '-cell', $cell ? $cell : $AFS_Parms{'cell'});
286 &wrapper('vos', \@args,
288 $AFS_Parms{'vostrace'} ? ([ '', '?']) : () ]);
293 #: AFS_vos_backupsys([$prefix], [$server, [$part]], [$exclude], [$cell])
294 #: Do en masse backups of AFS volumes.
295 #: If specified, match only volumes whose names begin with $prefix
296 #: If specified, limit work to the $server and, if given, $part.
297 #: If $exclude is specified and non-zero, backup only volumes NOT matched.
298 #: If specified, work in $cell instead of the default cell.
299 #: On success, return 1.
301 $AFS_Help{vos_backupsys} = '[$prefix], [$server, [$part]], [$exclude], [$cell] => Success?';
302 sub AFS_vos_backupsys {
303 my($prefix, $server, $part, $exclude, $cell) = @_;
306 @args = ('backupsys');
307 push(@args, '-prefix', $prefix) if ($prefix);
308 push(@args, '-server', $server) if ($server);
309 push(@args, '-partition', $part) if ($server && $part);
310 push(@args, '-exclude') if ($exclude);
311 push(@args, '-noauth') if ($AFS_Parms{'authlvl'} == 0);
312 push(@args, '-localauth') if ($AFS_Parms{'authlvl'} == 2);
313 push(@args, '-verbose') if ($AFS_Parms{'vostrace'} > 1);
314 push(@args, '-cell', $cell ? $cell : $AFS_Parms{'cell'});
315 &wrapper('vos', \@args,
317 $AFS_Parms{'vostrace'} ? ([ '', '?']) : () ]);
322 #: AFS_vos_dump($vol, [$time], [$file], [$cell])
323 #: Dump the volume $vol
324 #: If specified, do an incremental dump since $time instead of a full dump.
325 #: If specified, dump to $file instead of STDOUT
326 #: If specified, work in $cell instead of the default cell.
327 #: On success, return 1.
329 $AFS_Help{vos_dump} = '$vol, [$time], [$file], [$cell] => Success?';
331 my($vol, $time, $file, $cell) = @_;
334 @args = ('dump', '-id', $vol);
335 push(@args, '-time', ($time ? $time : 0));
336 push(@args, '-file', $file) if ($file);
337 push(@args, '-noauth') if ($AFS_Parms{'authlvl'} == 0);
338 push(@args, '-localauth') if ($AFS_Parms{'authlvl'} == 2);
339 push(@args, '-verbose') if ($AFS_Parms{'vostrace'} > 1);
340 push(@args, '-cell', $cell ? $cell : $AFS_Parms{'cell'});
341 &wrapper('vos', \@args,
343 $AFS_Parms{'vostrace'} ? ([ '', '?']) : () ],
344 { pass_stdout => !$file });
349 #: AFS_vos_restore($vol, $server, $part, [$file], [$id], [$owmode], [$cell])
350 #: Restore the volume $vol to partition $part on server $server.
351 #: If specified, restore from $file instead of STDIN
352 #: If specified, use the volume ID $id
353 #: If specified, $owmode must be 'abort', 'full', or 'incremental', and
354 #: indicates what to do if the volume exists.
355 #: If specified, work in $cell instead of the default cell.
356 #: On success, return 1.
358 $AFS_Help{vos_restore} = '$vol, $server, $part, [$file], [$id], [$owmode], [$cell] => Success?';
359 sub AFS_vos_restore {
360 my($vol, $server, $part, $file, $id, $owmode, $cell) = @_;
363 @args = ('restore', '-name', $vol, '-server', $server, '-partition', $part);
364 push(@args, '-file', $file) if ($file);
365 push(@args, '-id', $id) if ($id);
366 push(@args, '-overwrite', $owmode) if ($owmode);
367 push(@args, '-noauth') if ($AFS_Parms{'authlvl'} == 0);
368 push(@args, '-localauth') if ($AFS_Parms{'authlvl'} == 2);
369 push(@args, '-verbose') if ($AFS_Parms{'vostrace'} > 1);
370 push(@args, '-cell', $cell ? $cell : $AFS_Parms{'cell'});
371 &wrapper('vos', \@args,
373 $AFS_Parms{'vostrace'} ? ([ '', '?']) : () ]);
378 #: AFS_vos_listvldb([$vol], [$server, [$part]], [$locked], [$cell])
379 #: Get a list of volumes in the VLDB.
380 #: If specified, list only the volume $vol
381 #: If specified, list only volumes on the server $server.
382 #: If specified with $server, list only volumes on the partition $part.
383 #: If $locked is specified and nonzero, list only locked VLDB entries
384 #: If specified, work in $cell instead of the default cell.
385 #: On success, return an associative array whose keys are names of volumes
386 #: on the specified server, and each of whose values is an associative
387 #: array describing the corresponding volume, containing some or all of
389 #: - name Name of this volume (same as key)
390 #: - rwid ID of read-write volume (even if this is RO or BK)
391 #: - roid ID of read-only volume (even if this is RW or BK)
392 #: - bkid ID of backup volume (even if this is RW or RO)
393 #: - locked Empty or LOCKED to indicate VLDB entry is locked
394 #: - rwserv Name of server where read/write volume is
395 #: - rwpart Name of partition where read/write volume is
396 #: - rosites Reference to a list of read-only sites. Each site, in turn,
397 #: is a reference to a two-element list (server, part).
399 $AFS_Help{vos_listvldb} = '[$vol], [$server, [$part]], [$locked], [$cell] => %vols';
400 sub AFS_vos_listvldb {
401 my($vol, $server, $part, $locked, $cell) = @_;
402 my(%finres, %vlist, @rosites);
404 @args = ('listvldb');
405 push(@args, '-name', $vol) if ($vol);
406 push(@args, '-server', $server) if ($server);
407 push(@args, '-partition', $part) if ($part && $server);
408 push(@args, '-locked') if ($locked);
409 push(@args, '-noauth') if ($AFS_Parms{'authlvl'} == 0);
410 push(@args, '-localauth') if ($AFS_Parms{'authlvl'} == 2);
411 push(@args, '-verbose') if ($AFS_Parms{'vostrace'} > 2);
412 push(@args, '-cell', $cell ? $cell : $AFS_Parms{'cell'});
413 %finres = &wrapper('vos', \@args,
415 ['^(VLDB|Total) entries', '.'],
417 my(%vinfo) = %OpenAFS::wrapper::result;
420 $vinfo{rosites} = [@rosites] if (@rosites);
421 $vlist{$vinfo{name}} = \%vinfo;
424 %OpenAFS::wrapper::result = ();
428 ['RWrite\:\s*(\d+)', 'rwid' ],
429 ['ROnly\:\s*(\d+)', 'roid' ],
430 ['Backup\:\s*(\d+)', 'bkid' ],
431 ['Volume is currently (LOCKED)', 'locked' ],
432 ['server (\S+) partition /vicep(\S+) RW Site', 'rwserv', 'rwpart'],
433 ['server (\S+) partition /vicep(\S+) RO Site', sub {
434 push(@rosites, [$_[0], $_[1]]);
436 ($AFS_Parms{'vostrace'} > 2) ? ([ '', '?']) : () ]);
439 $finres{rosites} = [@rosites] if (@rosites);
440 $vlist{$finres{name}} = \%finres;
447 #: AFS_vos_delentry($vol, [$cell])
448 #: Delete the VLDB entry for the volume $vol
449 #: If specified, work in $cell instead of the default cell.
450 #: On success, return 1.
452 $AFS_Help{vos_delentry} = '$vol, [$cell] => Success?';
453 sub AFS_vos_delentry {
454 my($vol, $cell) = @_;
457 @args = ('delentry', '-id', $vol);
458 push(@args, '-noauth') if ($AFS_Parms{'authlvl'} == 0);
459 push(@args, '-localauth') if ($AFS_Parms{'authlvl'} == 2);
460 push(@args, '-verbose') if ($AFS_Parms{'vostrace'} > 1);
461 push(@args, '-cell', $cell ? $cell : $AFS_Parms{'cell'});
462 &wrapper('vos', \@args,
464 $AFS_Parms{'vostrace'} ? ([ '', '?']) : () ]);
469 #: AFS_vos_syncserv($server, [$part], [$cell], [$force])
470 #: Synchronize the server $server with the VLDB
471 #: If specified, synchronize only partition $part
472 #: If specified, work in $cell instead of the default cell
473 #: If $force is specified, force updates to occur
474 #: On success, return 1.
476 $AFS_Help{vos_syncserv} = '$server, [$part], [$cell], [$force] => Success?';
477 sub AFS_vos_syncserv {
478 my($server, $part, $cell, $force) = @_;
481 @args = ('syncserv', '-server', $server);
482 push(@args, '-partition', $part) if ($part);
483 push(@args, '-force') if ($force);
484 push(@args, '-noauth') if ($AFS_Parms{'authlvl'} == 0);
485 push(@args, '-localauth') if ($AFS_Parms{'authlvl'} == 2);
486 push(@args, '-verbose') if ($AFS_Parms{'vostrace'} > 1);
487 push(@args, '-cell', $cell ? $cell : $AFS_Parms{'cell'});
488 &wrapper('vos', \@args,
490 $AFS_Parms{'vostrace'} ? ([ '', '?']) : () ]);
495 #: AFS_vos_syncvldb($server, [$part], [$cell], [$force])
496 #: Synchronize the VLDB with server $server
497 #: If specified, synchronize only partition $part
498 #: If specified, work in $cell instead of the default cell
499 #: If $force is specified, force updates to occur
500 #: On success, return 1.
502 $AFS_Help{vos_syncvldb} = '$server, [$part], [$cell], [$force] => Success?';
503 sub AFS_vos_syncvldb {
504 my($server, $part, $cell, $force) = @_;
507 @args = ('syncvldb', '-server', $server);
508 push(@args, '-partition', $part) if ($part);
509 push(@args, '-force') if ($force);
510 push(@args, '-noauth') if ($AFS_Parms{'authlvl'} == 0);
511 push(@args, '-localauth') if ($AFS_Parms{'authlvl'} == 2);
512 push(@args, '-verbose') if ($AFS_Parms{'vostrace'} > 1);
513 push(@args, '-cell', $cell ? $cell : $AFS_Parms{'cell'});
514 &wrapper('vos', \@args,
516 $AFS_Parms{'vostrace'} ? ([ '', '?']) : () ]);
521 #: AFS_vos_lock($vol, [$cell])
522 #: Lock the VLDB entry for volume $vol.
523 #: If specified, work in $cell instead of the default cell.
524 #: On success, return 1.
526 $AFS_Help{vos_lock} = '$vol, [$cell] => Success?';
528 my($vol, $cell) = @_;
531 @args = ('lock', '-id', $vol);
532 push(@args, '-noauth') if ($AFS_Parms{'authlvl'} == 0);
533 push(@args, '-localauth') if ($AFS_Parms{'authlvl'} == 2);
534 push(@args, '-verbose') if ($AFS_Parms{'vostrace'} > 1);
535 push(@args, '-cell', $cell ? $cell : $AFS_Parms{'cell'});
536 &wrapper('vos', \@args,
538 $AFS_Parms{'vostrace'} ? ([ '', '?']) : () ]);
543 #: AFS_vos_unlock($vol, [$cell])
544 #: Unlock the VLDB entry for volume $vol.
545 #: If specified, work in $cell instead of the default cell.
546 #: On success, return 1.
548 $AFS_Help{vos_unlock} = '$vol, [$cell] => Success?';
550 my($vol, $cell) = @_;
553 @args = ('unlock', '-id', $vol);
554 push(@args, '-noauth') if ($AFS_Parms{'authlvl'} == 0);
555 push(@args, '-localauth') if ($AFS_Parms{'authlvl'} == 2);
556 push(@args, '-verbose') if ($AFS_Parms{'vostrace'} > 1);
557 push(@args, '-cell', $cell ? $cell : $AFS_Parms{'cell'});
558 &wrapper('vos', \@args,
560 $AFS_Parms{'vostrace'} ? ([ '', '?']) : () ]);
565 #: AFS_vos_unlockvldb([$server, [$part]], [$cell])
566 #: Unlock some or all VLDB entries
567 #: If specified, unlock only entries for volumes on server $server
568 #: If specified with $server, unlock only entries for volumes on
569 #: partition $part, instead of entries for volumes on all partitions
570 #: If specified, work in $cell instead of the default cell.
571 #: On success, return 1.
573 $AFS_Help{vos_unlockvldb} = '[$server, [$part]], [$cell] => Success?';
574 sub AFS_vos_unlockvldb {
575 my($server, $part, $cell) = @_;
578 @args = ('unlockvldb');
579 push(@args, '-server', $server) if ($server);
580 push(@args, '-partition', $part) if ($server && $part);
581 push(@args, '-noauth') if ($AFS_Parms{'authlvl'} == 0);
582 push(@args, '-localauth') if ($AFS_Parms{'authlvl'} == 2);
583 push(@args, '-verbose') if ($AFS_Parms{'vostrace'} > 1);
584 push(@args, '-cell', $cell ? $cell : $AFS_Parms{'cell'});
585 &wrapper('vos', \@args,
587 $AFS_Parms{'vostrace'} ? ([ '', '?']) : () ]);
592 #: AFS_vos_changeaddr($old, $new, [$cell])
593 #: Change the IP address of server $old to $new.
594 #: If specified, work in $cell instead of the default cell.
595 #: On success, return 1.
597 $AFS_Help{vos_changeaddr} = '$old, $new, [$cell] => Success?';
598 sub AFS_vos_changeaddr {
599 my($old, $new, $cell) = @_;
602 @args = ('changeaddr', '-oldaddr', $old, '-newaddr', $new);
603 push(@args, '-noauth') if ($AFS_Parms{'authlvl'} == 0);
604 push(@args, '-localauth') if ($AFS_Parms{'authlvl'} == 2);
605 push(@args, '-verbose') if ($AFS_Parms{'vostrace'} > 1);
606 push(@args, '-cell', $cell ? $cell : $AFS_Parms{'cell'});
607 &wrapper('vos', \@args,
609 $AFS_Parms{'vostrace'} ? ([ '', '?']) : () ]);
614 #: AFS_vos_listpart($server, [$cell])
615 #: Retrieve a list of partitions on server $server
616 #: If specified, work in $cell instead of the default cell.
617 #: On success, return a list of partition letters
619 $AFS_Help{vos_listpart} = '$server, [$cell] => @parts';
620 sub AFS_vos_listpart {
621 my($server, $cell) = @_;
624 @args = ('listpart', '-server', $server);
625 push(@args, '-noauth') if ($AFS_Parms{'authlvl'} == 0);
626 push(@args, '-localauth') if ($AFS_Parms{'authlvl'} == 2);
627 push(@args, '-verbose') if ($AFS_Parms{'vostrace'} > 2);
628 push(@args, '-cell', $cell ? $cell : $AFS_Parms{'cell'});
629 &wrapper('vos', \@args,
631 [ '^(.*\/vicep.*)$', #',
637 } split(' ', $_[0]));
639 ($AFS_Parms{'vostrace'} > 2) ? ([ '', '?']) : () ]);
644 #: AFS_vos_partinfo($server, [$part], [$cell])
645 #: Get information about partitions on server $server.
646 #: If specified, only get info about partition $part.
647 #: If specified, work in $cell instead of the default cell.
648 #: On success, return an associative array whose keys are partition letters,
649 #: and each of whose values is a reference to a 2-element list, consisting
650 #: of the total size of the partition and the amount of space used.
652 $AFS_Help{vos_partinfo} = '$server, [$part], [$cell] => %info';
653 sub AFS_vos_partinfo {
654 my($server, $part, $cell) = @_;
657 @args = ('partinfo', '-server', $server);
658 push(@args, '-partition', $part) if ($part);
659 push(@args, '-noauth') if ($AFS_Parms{'authlvl'} == 0);
660 push(@args, '-localauth') if ($AFS_Parms{'authlvl'} == 2);
661 push(@args, '-verbose') if ($AFS_Parms{'vostrace'} > 2);
662 push(@args, '-cell', $cell ? $cell : $AFS_Parms{'cell'});
663 &wrapper('vos', \@args,
665 [ '^Free space on partition /vicep(.+)\: (\d+) K blocks out of total (\d+)',
667 $parts{$_[0]} = [ $_[1], $_[2] ];
669 ($AFS_Parms{'vostrace'} > 2) ? ([ '', '?']) : () ]);
674 #: AFS_vos_listvol($server, [$part], [$cell])
675 #: Get a list of volumes on the server $server.
676 #: If specified, list only volumes on the partition $part.
677 #: If specified, work in $cell instead of the default cell.
678 #: On success, return an associative array whose keys are names of volumes
679 #: on the specified server, and each of whose values is an associative
680 #: array describing the corresponding volume, containing some or all of
682 #: - name Name of this volume (same as key)
683 #: - id ID of this volume
684 #: - kind Kind of volume (RW, RO, or BK)
685 #: - inuse Disk space in use
686 #: - maxquota Maximum disk usage quota
687 #: - minquota Minimum disk usage quota (optional)
688 #: - stamp_create Time when volume was originally created
689 #: - stamp_update Time volume was last modified
690 #: - stamp_backup Time backup volume was cloned, or 'Never'
691 #: - stamp_copy Time this copy of volume was made
692 #: - backup_flag State of automatic backups: empty or 'disabled'
693 #: - dayuse Number of accesses in the past day
694 #: - serv Server where this volume is located
695 #: - part Partition where this volume is located
697 $AFS_Help{vos_listvol} = '$server, [$part], [$cell] => %vols';
698 sub AFS_vos_listvol {
699 my($server, $part, $cell) = @_;
702 @args = ('listvol', '-server', $server, '-long');
703 push(@args, '-partition', $part) if ($part);
704 push(@args, '-noauth') if ($AFS_Parms{'authlvl'} == 0);
705 push(@args, '-localauth') if ($AFS_Parms{'authlvl'} == 2);
706 push(@args, '-verbose') if ($AFS_Parms{'vostrace'} > 2);
707 push(@args, '-cell', $cell ? $cell : $AFS_Parms{'cell'});
708 %finres = &wrapper('vos', \@args,
710 ['^\S+\s*\d+\s*(RW|RO|BK)', sub {
711 my(%vinfo) = %OpenAFS::wrapper::result;
714 $vlist{$vinfo{name}} = \%vinfo;
715 %OpenAFS::wrapper::result = ();
718 ['^(\S+)\s*(\d+)\s*(RW|RO|BK)\s*(\d+)\s*K', 'name', 'id', 'kind', 'inuse'],
719 ['(\S+)\s*\/vicep(\S+)\:', 'serv', 'part' ],
720 ['MaxQuota\s*(\d+)\s*K', 'maxquota' ],
721 ['MinQuota\s*(\d+)\s*K', 'minquota' ],
722 ['Creation\s*(.*\S+)', 'stamp_create' ],
723 ['Last Update\s*(.*\S+)', 'stamp_update' ],
724 ['Backup\s+([^\d\s].*\S+)', 'stamp_backup' ],
725 ['Copy\s*(.*\S+)', 'stamp_copy' ],
726 ['Automatic backups are (disabled) for this volume', 'backup_flag' ],
727 ['(\d+) accesses in the past day', 'dayuse' ],
728 ($AFS_Parms{'vostrace'} > 2) ? ([ '', '?']) : () ]);
731 $vlist{$finres{name}} = \%finres;
736 #: AFS_vos_zap($vol, $server, $part, [$cell], [$force])
737 #: Remove the volume $vol from the server and partition specified by $server and
738 #: $part. Don't bother messing with the VLDB.
739 #: If specified, work in $cell instead of the default cell.
740 #: If $force is specified, force the zap to happen
741 #: On success, return 1.
743 $AFS_Help{vos_zap} = '$vol, $server, $part, [$cell], [$force] => Success?';
745 my($vol, $server, $part, $cell, $force) = @_;
748 @args = ('zap', '-id', $vol, '-server', $server, '-part', $part);
749 push(@args, '-force') if ($force);
750 push(@args, '-noauth') if ($AFS_Parms{'authlvl'} == 0);
751 push(@args, '-localauth') if ($AFS_Parms{'authlvl'} == 2);
752 push(@args, '-verbose') if ($AFS_Parms{'vostrace'} > 1);
753 push(@args, '-cell', $cell ? $cell : $AFS_Parms{'cell'});
754 &wrapper('vos', \@args,
756 $AFS_Parms{'vostrace'} ? ([ '', '?']) : () ]);
761 #: AFS_vos_status($server, [$cell])
762 #: Get information about outstanding transactions on $server
763 #: If specified, work in $cell instead of the default cell
764 #: On success, return a list of transactions, each of which is a reference
765 #: to an associative array containing some or all of these elements:
766 #: - transid Transaction ID
767 #: - stamp_create Time the transaction was created
769 #: - part Partition letter
770 #: - action Action or procedure
771 #: - flags Volume attach flags
772 #: If there are no transactions, the list will be empty.
774 $AFS_Help{vos_status} = '$server, [$cell] => @trans';
776 my($server, $cell) = @_;
779 @args = ('status', '-server', $server);
780 push(@args, '-noauth') if ($AFS_Parms{'authlvl'} == 0);
781 push(@args, '-localauth') if ($AFS_Parms{'authlvl'} == 2);
782 push(@args, '-verbose') if ($AFS_Parms{'vostrace'} > 2);
783 push(@args, '-cell', $cell ? $cell : $AFS_Parms{'cell'});
784 &wrapper('vos', \@args,
787 my(%trinfo) = %OpenAFS::wrapper::result;
789 if ($trinfo{transid}) {
790 push(@trlist, \%trinfo);
791 %OpenAFS::wrapper::result = ();
794 ['^transaction\:\s*(\d+)\s*created: (.*\S+)', 'transid', 'stamp_create'],
795 ['^attachFlags:\s*(.*\S+)', 'flags'],
796 ['^volume:\s*(\d+)\s*partition\: \/vicep(\S+)\s*procedure\:\s*(\S+)',
797 'volid', 'part', 'action'],
798 ($AFS_Parms{'vostrace'} > 2) ? ([ '', '?']) : () ]);