IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 13067


Ignore:
Timestamp:
Apr 27, 2007, 1:50:57 PM (19 years ago)
Author:
jhoblitt
Message:

add $volume param to ->copy()

Location:
trunk/Nebulous
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Nebulous/lib/Nebulous/Client.pm

    r13058 r13067  
    11# Copyright (c) 2004  Joshua Hoblitt
    22#
    3 # $Id: Client.pm,v 1.26 2007-04-27 21:30:16 jhoblitt Exp $
     3# $Id: Client.pm,v 1.27 2007-04-27 23:50:57 jhoblitt Exp $
    44
    55package Nebulous::Client;
     
    583583    my $self = shift;
    584584
    585     my ( $key, $new_key ) = validate_pos( @_,
     585    my ( $key, $new_key, $volume ) = validate_pos( @_,
    586586        {
    587587            type => SCALAR,
     
    589589        {
    590590            type => SCALAR,
     591        },
     592        {
     593            #volume
     594            type        => SCALAR,
     595            optional    => 1,
    591596        },
    592597    );
     
    602607    }
    603608
    604     my $new_fh  = $self->open_create( $new_key );
     609    my $new_fh;
     610    if (defined $volume) {
     611        $new_fh  = $self->open_create( $new_key, 0, $volume );
     612    } else {
     613        $new_fh  = $self->open_create( $new_key );
     614    }
    605615    unless ( $new_fh ) {
    606616        $log->debug( "can not open object" );
  • trunk/Nebulous/lib/Nebulous/Client.pod

    r13058 r13067  
    2424    my $fh = $neb->open( "key", 'read' );
    2525    $data->delete( "key" );
    26     $data->copy( "key", "new_key" );
     26    $data->copy( "key", "new_key", "node01" );
    2727    $data->move( "key", "new_key" );
    2828    $data->delete_instance( $uri );
     
    330330
    331331
    332 =item * copy($key, $new_key)
     332=item * copy($key, $new_key, $volume)
    333333
    334334Copy a storage object.
     
    343343
    344344The destination object.
     345
     346=item * volume
     347
     348The preferred storage location of the new instance.
     349
     350This parameter is optional.
    345351
    346352=back
  • trunk/Nebulous/t/60_client_copy.t

    r5667 r13067  
    33# Copryight (C) 2004-2005  Joshua Hoblitt
    44#
    5 # $Id: 60_client_copy.t,v 1.1 2005-12-03 02:52:31 jhoblitt Exp $
     5# $Id: 60_client_copy.t,v 1.2 2007-04-27 23:50:57 jhoblitt Exp $
    66
    77use strict;
     
    1010use Apache::Test qw( -withtestmore );
    1111
    12 plan tests => 8;
     12plan tests => 11;
    1313
    1414use lib qw( ./t ./lib );
     
    4343        proxy => "http://$hostport/nebulous",
    4444    );
     45    $neb->create( "foo" );
     46
     47    ok( $neb->copy( "foo", "foobar", "node01" ), "copied object" );
     48
     49    my $locations1 = $neb->find_instances( "foobar" );
     50    my $locations2 = $neb->find_instances( "foobar" );
     51
     52    is( scalar @$locations1, 1, "old object has an instances" );
     53    is( scalar @$locations2, 1, "new object has an instances" );
     54}
     55
     56Test::Nebulous->setup;
     57
     58{
     59    my $neb = Nebulous::Client->new(
     60        proxy => "http://$hostport/nebulous",
     61    );
    4562
    4663    ok( ! $neb->copy( "foo", "foobar" ), "copy non-existant object" );
     
    5976    $neb->copy();
    6077};
    61 like( $@, qr/2 were expected/, "no params" );
     78like( $@, qr/2 - 3 were expected/, "no params" );
    6279
    6380Test::Nebulous->setup;
     
    6986    $neb->copy( "foo" );
    7087};
    71 like( $@, qr/2 were expected/, "not enough params" );
     88like( $@, qr/2 - 3 were expected/, "not enough params" );
    7289
    7390Test::Nebulous->setup;
     
    7794        proxy => "http://$hostport/nebulous",
    7895    );
    79     $neb->copy( "foo", "bar", "baz" );
     96    $neb->copy( "foo", "bar", "baz", "bong" );
    8097};
    81 like( $@, qr/2 were expected/, "too many params" );
     98like( $@, qr/2 - 3 were expected/, "too many params" );
    8299
    83100Test::Nebulous->cleanup;
Note: See TracChangeset for help on using the changeset viewer.