1#!/usr/bin/perl 2 3=head1 NAME 4 5moglistkeys -- Lists keys out of a MogileFS domain 6 7=head1 SYNOPSIS 8 9 $ moglistkeys --trackers=host --domain=foo --key_prefix="/foo/bar/" 10 11=head1 DESCRIPTION 12 13If you store your MogileFS keys in a logical "structure", you may use this 14tool to view lists of subsets of keys. Note that this is not going to be 15equivalent to "cd" and "ls" tools, as listing "foo/" will list everything 16underneath, so it's more akin to "ls -R" 17 18=head1 OPTIONS 19 20=over 21 22=item --trackers=host1:7001,host2:7001 23 24Use these MogileFS trackers to negotiate with. 25 26=item --domain=<domain> 27 28Set the MogileFS domain to use. 29 30=item --key_prefix="/foo/bar/" 31 32Search for keys starting with this prefix. Can be an arbitrary string. 33 34=back 35 36=head1 AUTHOR 37 38Dormando E<lt>L<dormando@rydia.net>E<gt> 39 40=head1 BUGS 41 42None known. 43 44=head1 LICENSE 45 46Licensed for use and redistribution under the same terms as Perl itself. 47 48=cut 49 50# TODO: Add ways to limit # of keys displayed 51 52use strict; 53use warnings; 54 55use lib './lib'; 56use MogileFS::Utils; 57 58my $util = MogileFS::Utils->new; 59my $usage = "--trackers=host --domain=foo --key_prefix='bar/'"; 60my $c = $util->getopts($usage, 'key_prefix=s'); 61 62my $mogc = $util->client; 63 64$mogc->foreach_key(prefix => $c->{key_prefix}, sub { 65 my $key = shift; 66 print $key, "\n"; 67}); 68 69if ($mogc->errcode) { 70 die "Error listing files: ", $mogc->errstr, "\n"; 71} 72