Debian Codegraph @

script/ecaccess-association-list

raw
1 #!/usr/bin/perl -w
2 #
3 # ecaccess-association-list: List your ECtrans Associations
4 #
5 # [email protected] - 2010-10-15
6
7 use ECMWF::ECaccess;
8 use Getopt::Long;
9 use Pod::Usage;
10 use Term::ReadKey;
11
12 my %opt = ( gateway => undef, version => 0, help => 0, manual => 0, retry => 0, debug => 0 );
13
14 pod2usage( -noperldoc => 1, -exit => 1, verbose => 1 ) if !GetOptions(
15 \%opt,
16 qw(
17 gateway=s
18 version
19 help|?
20 manual
21 retry=i
22 debug
23 )
24 );
25
26 # Display version if requested
27 die ECMWF::ECaccess->VERSION . "\n" if ( $opt{version} );
28
29 my $associationName = $ARGV[0];
30
31 pod2usage( -noperldoc => 1, -exit => 1, verbose => 1 ) if ( $opt{help} );
32 pod2usage( -noperldoc => 1, -exit => 1, verbose => 2 ) if ( $opt{manual} );
33
34 # Create the ECaccess Controler
35 my $ecaccess = ECMWF::ECaccess->new( $opt{retry}, $opt{debug});
36
37 # Get the Token (using the Certificate in $HOME)
38 my $token = $ecaccess->getToken();
39
40 # Get the Control Channel
41 my $controlChannel = $ecaccess->getControlChannel();
42
43 # If no Gateway is specified then use the default Gateway
44 $opt{gateway} = $controlChannel->getGatewayName()->result if ( not $opt{gateway} );
45
46 if ( not($associationName) ) {
47
48 # Get the list of associations
49 my $associations = $controlChannel->getAssociationList( $token, $opt{gateway} );
50
51 # Display the information for each association
52 foreach $association ( $associations->valueof('//getAssociationListResponse/return') ) {
53 printf "%-20s %-20s %-10s %s\n", $association->{name}, $association->{hostName}, ( $association->{active} eq 'true' ? 'active' : 'not-active' ),
54 $association->{comment};
55 }
56 }
57 else {
58
59 # Get the detail for the specified associationName
60 my $association = $controlChannel->getAssociation( $token, $opt{gateway}, $associationName )->valueof('//getAssociationResponse/return');
61 print " Name: " . $association->{name} . "\n";
62 print " Owner: " . $association->{owner} . "\n";
63 print " Active: " . ( $association->{active} eq 'true' ? 'yes' : 'no' ) . "\n";
64 print " Comment: " . $association->{comment} . "\n";
65 print "Directory: " . $association->{directory} . "\n";
66 print "Host Name: " . $association->{hostName} . "\n";
67 print " Login: " . $association->{login} . "\n";
68 print " Protocol: " . $association->{protocol} . "\n";
69 }
70
71 # Logout
72 END {
73 $ecaccess->releaseToken($token) if ($token);
74 }
75
76 __END__
77
78 =head1 NAME
79
80 ecaccess-association-list - List your ECtrans Associations
81
82 =head1 SYNOPSIS
83
84 B<ecaccess-association-list -version|-help|-manual>
85
86 B<ecaccess-association-list [-debug] [-gateway> I<name>B<] [>I<association-name>B<]>
87
88 =head1 DESCRIPTION
89
90 List all your ECtrans Associations. When an I<association-name> is specified
91 then the details for this Association is displayed.
92
93 =head1 ARGUMENTS
94
95 =over 8
96
97 =item I<association-name> (optional)
98
99 The name of the Association to retrieve the details.
100
101 =back
102
103 =head1 OPTIONS
104
105 =over 8
106
107 =item B<-gateway> I<name>
108
109 This is the name of the ECaccess Gateway where the Associations are installed.
110 It is by default the Gateway you are connected to. In order to get the name
111 of your current Gateway you can use the B<ecaccess-gateway-name> command. When
112 using the commands at ECMWF the default Gateway is always "boaccess.ecmwf.int".
113
114 =item B<-version>
115
116 Display version number and exits.
117
118 =item B<-help>
119
120 Print a brief help message and exits.
121
122 =item B<-manual>
123
124 Prints the manual page and exits.
125
126 =item B<-retry> I<count>
127
128 Number of SSL connection retries per 5s to ECMWF. This parameter only apply to the
129 initial SSL connection initiated by the command to the ECMWF server. It does not
130 apply to all the subsequent requests made afteward as it is mainly targeting errors
131 that can happen from time to time during the SSL handshake. Default is no retry.
132
133 =item B<-debug>
134
135 Display the SOAP and SSL messages exchanged.
136
137 =back
138
139 =head1 EXAMPLES
140
141 B<ecaccess-association-list>
142
143 List all your Associations on your default Gateway.
144
145 B<ecaccess-association-list -gateway> I<boaccess.ecmwf.int> I<ginko>
146
147 List the details of the Association I<ginko> on the I<boaccess.ecmwf.int> Gateway.
148
149 =head1 SEE ALSO
150
151 B<ecaccess-association-delete>, B<ecaccess-association-get>, B<ecaccess-association-protocol>,
152 B<ecaccess-association-put> and B<ecaccess>.
153
154 =cut