IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 30, 2008, 2:35:11 PM (18 years ago)
Author:
jhoblitt
Message:

add neb-replicate --copies option

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Nebulous/bin/neb-replicate

    r16183 r18390  
    33# Copyright (C) 2007-2008  Joshua Hoblitt
    44#
    5 # $Id: neb-replicate,v 1.1 2008-01-22 22:10:27 jhoblitt Exp $
     5# $Id: neb-replicate,v 1.2 2008-07-01 00:35:11 jhoblitt Exp $
    66
    77use strict;
     
    99
    1010use vars qw( $VERSION );
    11 $VERSION = '0.01';
     11$VERSION = '0.02';
    1212
    1313use Nebulous::Client;
     
    1616use Pod::Usage qw( pod2usage );
    1717
    18 my ($server, $volume);
     18my ($server, $volume, $copies);
     19$copies = 1;  # default to making just one copy
    1920
    2021$server = $ENV{'NEB_SERVER'} unless $server;
     
    2324    'server|s=s'    => \$server,
    2425    'volume|v=s'    => \$volume,
     26    'copies|c=i'    => \$copies,
    2527) || pod2usage( 2 );
    2628
     
    3234pod2usage( -msg => "missing key", exitval => 2 )
    3335    unless defined $key;
     36pod2usage( -msg => "--copies must be > 0", exitval => 2 )
     37    unless $copies > 0;
    3438
    3539my $neb = Nebulous::Client->new(
     
    4044    unless defined $neb;
    4145
    42 if (defined $volume) {
    43     $neb->replicate($key, $volume)
    44         or die "failed to replicate Nebulous key: $key";
    45 } else {
    46     $neb->replicate($key)
    47         or die "failed to replicate Nebulous key: $key";
     46for (my $i = 0; $i < $copies; $i++) {
     47    if (defined $volume) {
     48        $neb->replicate($key, $volume)
     49            or die "failed to replicate Nebulous key: $key";
     50    } else {
     51        $neb->replicate($key)
     52            or die "failed to replicate Nebulous key: $key";
     53    }
    4854}
    4955
     
    5965=head1 SYNOPSIS
    6066
    61     neb-replicate [--server <URL>] [--volume <volume name>] <key>
     67    neb-replicate [--server <URL>] [--volume <volume name>]
     68                  [--copies <n>] <key>
    6269
    6370=head1 DESCRIPTION
     
    8188
    8289Optional.
     90
     91=item * --copies|c <n>
     92
     93The number of new replications to create.
     94
     95Optional.  Defaults to 0.
    8396
    8497=back
Note: See TracChangeset for help on using the changeset viewer.