Acme-Globus

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
    rather than covering all the capabilities of the Globus CLI. It is
    therefore very stubtastic.
 
    This module also relies very much on SSH, and thus the rules of private
    and public keys. Therefore, using it as a shared tool would be
    ill-advised if not impossible.
 
SYNOPSIS
 
        my $g = Globus->new($username,$path_to_ssh_key) ;
        $g->endpoint_add_shared( 'institution#endpoint', $directory, $endpoint_name ) ;
        $g->acl_add( $endpoint . '/', 'djacoby@example.com' ) ;
         
 
METHODS
 
 BASICS
 
  new
 
        Creates a new Globus object. Takes two options:
        the username and path to the SSH key you use to connect to Globus.

README  view on Meta::CPAN

72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
delete
 
 rm
 
   Currently stubs
 
 scp
 
 transfer
 
   Both commands take a source, or from path (including endpoint), a
   destination, or to path (includint endpoint), and a boolean indicating
   whether you're copying recursively or not.
 
FILE MANAGEMENT
 
 ls
 
   Works?
 
 rename

README  view on Meta::CPAN

100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
acl_add
 
 acl_list
 
 acl_remove
 
   acl-* is the way that Globus refers to permissions
 
   By the interface, Globus supports adding shares by email address, by
   Globus username or by Globus group name. This module sticks to using
   email address. acl_add() takes an endpoint, an email address you're
   sharing to, and a boolean indicating whether this share is read-only or
   read-write. acl_add() returns a share id.
 
   acl_remove() uses that share id to identify which shares are to be
   removed.
 
   acl_list() returns an array of hashes containing the information about
   each user with access to an endpoint, including the share ID and
   permissions.
 
 endpoint_add_shared
 
 endpoint_list
 
 endpoint_search
 
 endpoint_remove
 
   endpoint_add_shared() handles the specific case of creating an endpoint
   from an existing endpoint, not the general case. It takes the endpoint
   where you're sharing from, the path you're sharing, and the endpoint
   you're creating. If you are user 'user' and creating the endpoint
   'test', the command takes 'test', not 'user#test'.
 
   endpoint_remove and endpoint_list, however, take a full endpoint name,
   like 'user#test'.
 
   Current usage is endpoint_list for a list of all our shares, and
   endpoint_search for details of each individual share
 
 list_my_endpoints
 
 search_my_endpoints
 
   list_my_endpoints() and search_my_endpoints() were added once I
   discovered the failings of existing list and search. These tools return
   a hashref of hashrefs holding the owner, host_endpoint,
   host_endpoint_name, credential_status, and most importantly, the id,
   legacy_name and display_name.
 
   For older shares, legacy_name will be something like
   'purduegcore#hr00001_firstshare' and display_name will be 'n/a', while
   for newer shares, legacy_name will be 'purduegcore#SAME_AS_ID' and
   display_name will be like older shares' legacy_name,
   'purduegcore#hr99999_filled_the_space'. In both cases, the value you
   want to use to get details or to remove a share is the id, which is a
   UUID.
 
 endpoint_activate
 
 endpoint_add
 
 endpoint_deactivate
 
 endpoint_modify
 
 endpoint_rename
 
   Stubs
 
OTHER
 
 help
 
 history
 
 man

lib/Acme/Globus.pm  view on Meta::CPAN

33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
rather than covering all the capabilities of the Globus CLI. It is
therefore very stubtastic.
 
This module also relies very much on SSH, and thus the rules of
private and public keys. Therefore, using it as a shared tool would
be ill-advised if not impossible.
 
=head1 SYNOPSIS
 
    my $g = Globus->new($username,$path_to_ssh_key) ;
    $g->endpoint_add_shared( 'institution#endpoint', $directory, $endpoint_name ) ;
    $g->acl_add( $endpoint . '/', 'djacoby@example.com' ) ;
     
=head1 METHODS
 
=head2 BASICS
 
=head3 B<new>
 
    Creates a new Globus object. Takes two options:
    the username and path to the SSH key you use to connect to Globus.

lib/Acme/Globus.pm  view on Meta::CPAN

124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
=head3 B<delete>
 
=head3 B<rm>
 
Currently stubs
 
=head3 B<scp>
 
=head3 B<transfer>
 
Both commands take a source, or from path (including endpoint),
a destination, or to path (includint endpoint), and a boolean indicating
whether you're copying recursively or not.
 
=cut
 
sub delete { }
sub rm     { }
 
sub scp {
    my ( $self, $from_path, $to_path, $recurse ) = @_ ;
    $recurse = $recurse ? '-r' : '' ;

lib/Acme/Globus.pm  view on Meta::CPAN

189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
=head3 B<acl_add>
 
=head3 B<acl_list>
 
=head3 B<acl_remove>
 
acl-* is the way that Globus refers to permissions
 
By the interface, Globus supports adding shares by email address,
by Globus username or by Globus group name. This module sticks to
using email address. acl_add() takes an endpoint, an email address
you're sharing to, and a boolean indicating whether this share is
read-only or read-write. acl_add() returns a share id.
 
acl_remove() uses that share id to identify which shares are to be
removed.
 
acl_list() returns an array of hashes containing the information about
each user with access to an endpoint, including the share ID and permissions.
 
=cut
 
sub identity_details {
    my ( $self, $identity_id ) = @_ ;
    my $command = qq{identity-details $identity_id } ;
    my $result
        = _globus_action( $command, $self->{username}, $self->{key_path} ) ;
    return {} unless $result =~ m{\w} ;
    my $obj = decode_json $result ;
    return wantarray ? %$obj : $obj ;
    }
 
sub acl_add {
    my ( $self, $endpoint, $email, $rw ) = @_ ;
    my $readwrite = 'rw' ;
    $readwrite = 'r' unless $rw ;
    my $command
        = qq{acl-add $endpoint --identityusername=${email} --perm $readwrite }
        ;
    my $result
        = _globus_action( $command, $self->{username}, $self->{key_path} ) ;
    my ($id) = reverse grep {m{\w}} split m{\s}, $result ;
    return $id ;
    }
 
sub acl_list {
    my ( $self, $endpoint ) = @_ ;
    my $command = qq{acl-list $endpoint} ;
    my $result
        = _globus_action( $command, $self->{username}, $self->{key_path} ) ;
    my $slist = decode_json $result ;
    my @list = grep { $_->{permissions} ne 'rw' } @$slist ;
    return wantarray ? @list : \@list ;
    }
 
sub acl_remove {
    my ( $self, $endpoint_uuid, $share_uuid ) = @_ ;
    my $command = qq{acl-remove $endpoint_uuid --id $share_uuid} ;
    my $result
        = _globus_action( $command, $self->{username}, $self->{key_path} ) ;
    return $result ;
    }
 
=head3 B<endpoint_add_shared>
 
=head3 B<endpoint_list>
 
=head3 B<endpoint_search>
 
=head3 B<endpoint_remove>
 
endpoint_add_shared() handles the specific case of creating an endpoint
from an existing endpoint, not the general case.  It takes the endpoint
where you're sharing from, the path you're sharing, and the endpoint
you're creating. If you are user 'user' and creating the endpoint 'test',
the command takes 'test', not 'user#test'.
 
endpoint_remove and endpoint_list, however, take a full endpoint name, like 'user#test'.
 
Current usage is endpoint_list for a list of all our shares, and endpoint_search
for details of each individual share
 
=head3 B<list_my_endpoints>
 
=head3 B<search_my_endpoints>
 
list_my_endpoints() and search_my_endpoints() were added once I discovered
the failings of existing list and search. These tools return a hashref
of hashrefs holding the owner, host_endpoint, host_endpoint_name,
credential_status, and most importantly, the id, legacy_name and display_name.
 
For older shares, legacy_name will be something like 'purduegcore#hr00001_firstshare'
and display_name will be 'n/a', while for newer shares, legacy_name will be
'purduegcore#SAME_AS_ID' and display_name will be like older shares' legacy_name,
'purduegcore#hr99999_filled_the_space'. In both cases, the value you want
to use to get details or to remove a share is the id, which is a UUID.
 
=cut
 
sub endpoint_add_shared {
    my ( $self, $sharer_endpoint, $path, $endpoint ) = @_ ;
 
    # my $command
    #     = qq{endpoint-add --sharing "$sharer_endpoint$path" $endpoint } ;
    # my $command
    #     = qq{endpoint-add -n $endpoint --sharing "$sharer_endpoint$path" } ;
    my $command = join ' ',
        q{endpoint-add},
        q{--sharing}, "$sharer_endpoint$path",
        q{-n},        $endpoint,
        ;
    my $result
        = _globus_action( $command, $self->{username}, $self->{key_path} ) ;
    return $result ;
    }
 
# sub endpoint_list {
#     my ( $self, $endpoint ) = @_ ;
#     my $command ;
#     if ($endpoint) {
#         $command = qq{endpoint-list $endpoint } ;
#         }
#     else {
#         $command = qq{endpoint-list} ;
#         }
#     my $result
#         = _globus_action( $command, $self->{username}, $self->{key_path} ) ;
#     my @result = map { ( split m{\s}, $_ )[0] } split "\n", $result ;
#     return wantarray ? @result : \@result ;
#     }
 
#lists all my endpoint
sub endpoint_list {
    my ($self) = @_ ;
    my $command = 'endpoint-search --scope=my-endpoints' ;
    my $result
        = _globus_action( $command, $self->{username}, $self->{key_path} ) ;
    my @result = map { s{\s}{}g ; $_ }
        map   { ( reverse split m{:} )[0] }
        grep  {m{Legacy}}
        split m{\n}, $result ;
    return wantarray ? @result : \@result ;
    }
 
sub endpoint_search {
    my ( $self, $search ) = @_ ;
    return {} unless $search ;
    my $command = qq{endpoint-search $search --scope=my-endpoints} ;
    my $result
        = _globus_action( $command, $self->{username}, $self->{key_path} ) ;
    my %result = map {
        chomp ;
        my ( $k, $v ) = split m{\s*:\s}, $_ ;
        $k => $v
        }
        split m{\n}, $result ;
    return wantarray ? %result : \%result ;
    }
 
sub list_my_endpoints {
    my ($self) = @_ ;
    my $command = 'endpoint-search --scope=my-endpoints' ;
    my $result
        = _globus_action( $command, $self->{username}, $self->{key_path} ) ;
    my %result = map {
        my $hash ;
        %$hash = map {
            my ( $k, $v ) = split m{\s*:\s*} ;
            $k =~ s{\s+}{_}gmx ;
            $k = lc $k ;
            $k => $v
            }

lib/Acme/Globus.pm  view on Meta::CPAN

362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
        my $id
            = $hash->{display_name} ne 'n/a'
            ? $hash->{display_name}
            : $hash->{legacy_name} ;
        $id => $hash ;
        }
        split m{\n\n}, $result ;
    return wantarray ? %result : \%result ;
    }
 
sub search_my_endpoints {
    my ( $self, $search ) = @_ ;
    my %result ;
    my $command = qq{endpoint-search $search --scope=my-endpoints} ;
    my $result
        = _globus_action( $command, $self->{username}, $self->{key_path} ) ;
    %result = map {
        my $hash ;
        %$hash = map {
            my ( $k, $v ) = split m{\s*:\s*} ;
            $k =~ s{\s+}{_}gmx ;
            $k = lc $k ;
            $k => $v
            }

lib/Acme/Globus.pm  view on Meta::CPAN

387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
        my $id
            = $hash->{display_name} ne 'n/a'
            ? $hash->{display_name}
            : $hash->{legacy_name} ;
        $id => $hash ;
        }
        split m{\n\n}, $result ;
    return wantarray ? %result : \%result ;
    }
 
sub endpoint_remove {
    my ( $self, $endpoint ) = @_ ;
    my $command = qq{endpoint-remove $endpoint} ;
    my $result
        = _globus_action( $command, $self->{username}, $self->{key_path} ) ;
    return $result ;
    }
 
# Sucks. Use endpoint_search instead
sub endpoint_details {
    my ( $self, $endpoint ) = @_ ;
    my $command = qq{endpoint-details $endpoint} ;
    my $result
        = _globus_action( $command, $self->{username}, $self->{key_path} ) ;
 
    my %result = map {
        chomp ;
        my ( $key, $value ) = split m{\s*:\s*}, $_ ;
        $key => $value
        } split m{\n}, $result ;
 
    return wantarray ? %result : \%result ;
    }
 
=head3 B<endpoint_activate>
 
=head3 B<endpoint_add>
 
=head3 B<endpoint_deactivate>
 
=head3 B<endpoint_modify>
 
=head3 B<endpoint_rename>
 
Stubs
 
=cut
 
sub endpoint_activate   { }
sub endpoint_add        { }
sub endpoint_deactivate { }
sub endpoint_modify     { }
sub endpoint_rename     { }
 
=head2 OTHER
 
=head3 B<help>  
 
=head3 B<history>
 
=head3 B<man>        
 
=head3 B<profile>



( run in 0.618 second using v1.01-cache-2.11-cpan-49f99fa48dc )