IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 28525 for trunk/Nebulous


Ignore:
Timestamp:
Jun 28, 2010, 2:59:29 PM (16 years ago)
Author:
watersc1
Message:

Final update to nebulous for this iteration. Changes:

  • nebdiskd reads its configuration from a sane location.
  • neb-ls is useful.
Location:
trunk/Nebulous
Files:
2 edited

Legend:

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

    r24346 r28525  
    11#!/usr/bin/env perl
    22
    3 # Copyright (C) 2007-2009  Joshua Hoblitt
     3# Copyright (C) 2007-2009  Joshua Hoblitt, 2010 Chris Waters
    44
    55use strict;
     
    1616my (
    1717    $server,
    18     $long,
    19 #    $recursive,
     18    $path,
     19    $column,
    2020);
    2121
    2222$server = $ENV{'NEB_SERVER'} unless $server;
    2323
    24 # make --long the default
    25 $long = 1;
    2624
    2725GetOptions(
    2826    'server|s=s'    => \$server,
    29 #    'recursive|r'   => \$recursive,
    30     'l|1'           => \$long,
     27    'path|p'        => \$path,
     28    'column|c'      => \$column,
    3129) || pod2usage( 2 );
     30
     31# twiddle column so that it does it by default.
     32
     33$column = not $column;
    3234
    3335my $pattern = shift;
     
    4749$pattern ||= "/";
    4850
    49 #if ($recursive) {
    50 #    $pattern = "^" . $pattern . ".*";
    51 #} else {
    52 #    $pattern = "^" . $pattern . "\$";
    53 #}
     51my $keys = $neb->find_objects_wildcard($pattern);
    5452
    55 my $keys = $neb->find_objects($pattern);
    56 
     53if ($path) {
     54    my @files;
     55    foreach my $key (@{ $keys }) {
     56        my $uris = $neb->find_instances($key);
     57        if (defined $uris) {
     58            push @files, URI->new(@$uris[0])->file;
     59        }
     60    }
     61    @{ $keys } = @files;
     62}
    5763if ($keys) {
    58     if ($long) {
    59         print join("\n", @{ $keys }), "\n";
    60     } else {
    61         print join(" ", @{ $keys }), "\n";
     64    if ($column) {
     65        open(COLUMN,"|column") || die "Cannot open column command.";
     66        print COLUMN join("\n", @{ $keys }), "\n";
     67        close(COLUMN);
     68    }
     69    else {
     70        print join("\n", @{ $keys }), "\n";
    6271    }
    6372}
     73
    6474
    6575__END__
     
    7383=head1 SYNOPSIS
    7484
    75     neb-ls [--server <URL>] [-l|-1] [--recursive] <pattern>
     85    neb-ls [--server <URL>] [-c] [-p] <pattern>
    7686
    7787=head1 DESCRIPTION
    7888
    7989This program list Nebulous keys matched by C<<pattern>>.  Call it with no
    80 arguments is equivalanet to searching with the pattern C<.*>.  Where
    81 C<<pattern>> is a POSIX 1003.2 compatable regular repression.
     90arguments is equivalent to searching with the pattern C<neb://>.  SQL like
     91wildcards are supported to select out certain files.
    8292
    8393=head1 OPTIONS
     
    8595=over 4
    8696
    87 =item * -l|-1
     97=item * --path|-p
    8898
    89 Use a long listing format.
     99Find the disk files corresponding to the keys found.
     100
     101=item * --column|-c
     102
     103Disable column formatting, and output results one to a line.
    90104
    91105Optional
    92106
    93 =cut
    94 #=item * --recursive|-r
    95 #
    96 #By default C<neb-ls> will only try to match the exact string provided to it.
    97 #With this option set all keys which match C<<pattern>> as a REGEX or substring
    98 #will be returned.
    99 #
    100 #Optional
    101 #
    102107=item * --server|-s <URL>
    103108
     
    122127=back
    123128
    124 =head1 CREDITS
    125 
    126 Just me, myself, and I.
    127 
    128129=head1 SUPPORT
    129130
     
    132133=head1 AUTHOR
    133134
    134 Joshua Hoblitt <jhoblitt@cpan.org>
     135Joshua Hoblitt <jhoblitt@cpan.org>, Chris Waters
    135136
    136137=head1 COPYRIGHT
    137138
    138 Copyright (C) 2007-2009  Joshua Hoblitt.  All rights reserved.
     139Copyright (C) 2007-2010  Joshua Hoblitt / Chris Waters.  All rights reserved.
    139140
    140141This program is free software; you can redistribute it and/or modify it under
  • trunk/Nebulous/lib/Nebulous/Client.pm

    r28446 r28525  
    99no warnings qw( uninitialized );
    1010
    11 our $VERSION = '0.17';
     11our $VERSION = '0.18';
    1212
    1313use Digest::MD5;
     
    741741}
    742742
     743sub find_objects_wildcard
     744{
     745    my $self = shift;
     746
     747    my @args = validate_pos( @_,
     748        {
     749            type        => SCALAR,
     750            optional    => 1,
     751        },
     752    );
     753
     754    $log->debug( "entered - @_" );
     755
     756    my $response = $self->{ 'server' }->find_objects_wildcard( @args );
     757    if ( $response->fault ) {
     758        $self->set_err($response->faultstring);
     759
     760        if ($response->faultstring =~ /no keys found/) {
     761            $log->debug( "leaving" );
     762            return;
     763        }
     764        if ($response->faultstring =~ /does not match any key or directory/) {
     765            $log->debug( "leaving" );
     766            return;
     767        }
     768
     769        $log->logdie("unhandled fault - ", $self->err);
     770    }
     771
     772    my $keys = $response->result;
     773
     774    $log->debug( "server found: @$keys" );
     775
     776#    foreach my $path ( @{ $uris } ) {
     777#        $path = _get_file_path( $path );
     778#    }
     779
     780    $log->debug( "leaving" );
     781
     782    return $keys;
     783}
     784
    743785
    744786sub find_instances
Note: See TracChangeset for help on using the changeset viewer.