IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 17645 for trunk/Nebulous/lib


Ignore:
Timestamp:
May 12, 2008, 2:27:28 PM (18 years ago)
Author:
jhoblitt
Message:

add ->setxattr_object(), ->getxattr_object(), ->listxattr_object(), ->removexattr_object()
change ->create() to accept volume == undef

File:
1 edited

Legend:

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

    r17610 r17645  
    11# Copyright (c) 2004-2008  Joshua Hoblitt
    22#
    3 # $Id: Client.pm,v 1.46 2008-05-09 21:15:07 jhoblitt Exp $
     3# $Id: Client.pm,v 1.47 2008-05-13 00:27:28 jhoblitt Exp $
    44
    55package Nebulous::Client;
     
    104104        },
    105105        {
    106             type        => SCALAR,
     106            type        => SCALAR|UNDEF,
    107107            optional    => 1,
    108108        },
     
    416416}
    417417
     418
     419sub setxattr_object
     420{
     421    my $self = shift;
     422
     423    my ($key, $name, $value, $flags) = validate_pos(@_,
     424        {
     425            type        => SCALAR,
     426        },
     427        {
     428            type        => SCALAR,
     429        },
     430        {
     431            type        => SCALAR,
     432        },
     433        {
     434            type        => SCALAR,
     435            callbacks   => {
     436                'is read or write' => sub { $_[0] =~ /^(?:create|replace)$/i },
     437            },
     438        },
     439    );
     440
     441    $log->debug( "entered - @_" );
     442
     443    my $response = $self->{ 'server' }->setxattr_object( $key, $name, $value, $flags);
     444    if ( $response->fault ) {
     445        $log->error( $response->faultcode, " - ", $response->faultstring );
     446        $log->debug( "leaving" );
     447
     448        return;
     449    }
     450
     451    $log->debug( "leaving" );
     452   
     453    return 1;
     454}
     455
     456
     457sub getxattr_object
     458{
     459    my $self = shift;
     460
     461    my ($key, $name) = validate_pos(@_,
     462        {
     463            type        => SCALAR,
     464        },
     465        {
     466            type        => SCALAR,
     467        },
     468    );
     469
     470    $log->debug( "entered - @_" );
     471
     472    my $response = $self->{ 'server' }->getxattr_object( $key, $name );
     473    if ( $response->fault ) {
     474        $log->error( $response->faultcode, " - ", $response->faultstring );
     475        $log->debug( "leaving" );
     476
     477        return;
     478    }
     479
     480    my $res = $response->result;
     481    $log->debug( "server response: $res" );
     482
     483    $log->debug( "leaving" );
     484   
     485    return $res;
     486}
     487
     488
     489sub listxattr_object
     490{
     491    my $self = shift;
     492
     493    my ($key) = validate_pos(@_,
     494        {
     495            type        => SCALAR,
     496        },
     497    );
     498
     499    $log->debug( "entered - @_" );
     500
     501    my $response = $self->{ 'server' }->listxattr_object( $key );
     502    if ( $response->fault ) {
     503        $log->error( $response->faultcode, " - ", $response->faultstring );
     504        $log->debug( "leaving" );
     505
     506        return;
     507    }
     508
     509    my $res = $response->result;
     510    $log->debug( "server response: $res" );
     511
     512    $log->debug( "leaving" );
     513   
     514    return $res;
     515}
     516
     517
     518sub removexattr_object
     519{
     520    my $self = shift;
     521
     522    my ($key, $name) = validate_pos(@_,
     523        {
     524            type        => SCALAR,
     525        },
     526        {
     527            type        => SCALAR,
     528        },
     529    );
     530
     531    $log->debug( "entered - @_" );
     532
     533    my $response = $self->{ 'server' }->removexattr_object( $key, $name );
     534    if ( $response->fault ) {
     535        $log->error( $response->faultcode, " - ", $response->faultstring );
     536        $log->debug( "leaving" );
     537
     538        return;
     539    }
     540
     541    $log->debug( "leaving" );
     542   
     543    return 1;
     544}
     545
     546
    418547sub find_objects {
    419548    my $self = shift;
Note: See TracChangeset for help on using the changeset viewer.