Debian Codegraph @

script/ecaccess-association-protocol

raw
1 #!/usr/bin/perl -w
2 #
3 # ecaccess-association-protocol: List the supported ECtrans Protocols
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 $protocolName = $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($protocolName) ) {
47
48 # Get the list of protocols
49 my $protocols = $controlChannel->getAssociationProtocolList( $token, $opt{gateway} );
50
51 # Display the information for each protocol
52 foreach $protocol ( $protocols->valueof('//getAssociationProtocolListResponse/return') ) {
53 printf "%-20s %-20s %-10s %s\n", $protocol->{name}, $protocol->{module}, ( $protocol->{active} eq 'true' ? 'active' : 'not-active' ),
54 $protocol->{comment};
55 }
56 }
57 else {
58
59 # Get the detail for the specified protocolName
60 my $protocol = $controlChannel->getAssociationProtocol( $token, $opt{gateway}, $protocolName )->valueof('//getAssociationProtocolResponse/return');
61 print " Name: " . $protocol->{name} . "\n";
62 print "Shortname: " . $protocol->{module} . ( $protocol->{activeModule} eq 'true' ? '' : ' (disabled)' ) . "\n";
63 print " Active: " . ( $protocol->{active} eq 'true' ? 'yes' : 'no' ) . "\n";
64 print " Comment: " . $protocol->{comment} . "\n";
65 print " Archive: " . $protocol->{archive} . "\n";
66 print " Value: " . $protocol->{value} . "\n";
67 }
68
69 # Logout
70 END {
71 $ecaccess->releaseToken($token) if ($token);
72 }
73
74 __END__
75
76 =head1 NAME
77
78 ecaccess-association-protocol - List the supported ECtrans Protocols
79
80 =head1 SYNOPSIS
81
82 B<ecaccess-association-protocol -version|-help|-manual>
83
84 B<ecaccess-association-protocol [-debug] [-gateway> I<name>B<] [>I<protocol-name>B<]>
85
86 =head1 DESCRIPTION
87
88 List all the ECtrans Protocols supported. When a I<protocol-name> is specified then
89 the details for this Protocol are displayed.
90
91 =head1 ARGUMENTS
92
93 =over 8
94
95 =item I<protocol-name> (optional)
96
97 The name of the ECtrans Protocol to retrieve the details.
98
99 =back
100
101 =head1 OPTIONS
102
103 =over 8
104
105 =item B<-gateway> I<name>
106
107 This is the name of the ECaccess Gateway where to list the ECtrans Protocols supported.
108 It is by default the Gateway you are connected to. In order to get the name
109 of your current Gateway you can use the B<ecaccess-gateway-name> command. When
110 using the commands at ECMWF the default Gateway is always "boaccess.ecmwf.int".
111
112 =item B<-version>
113
114 Display version number and exits.
115
116 =item B<-help>
117
118 Print a brief help message and exits.
119
120 =item B<-manual>
121
122 Prints the manual page and exits.
123
124 =item B<-retry> I<count>
125
126 Number of SSL connection retries per 5s to ECMWF. This parameter only apply to the
127 initial SSL connection initiated by the command to the ECMWF server. It does not
128 apply to all the subsequent requests made afteward as it is mainly targeting errors
129 that can happen from time to time during the SSL handshake. Default is no retry.
130
131 =item B<-debug>
132
133 Display the SOAP and SSL messages exchanged.
134
135 =back
136
137 =head1 EXAMPLES
138
139 B<ecaccess-association-protocol>
140
141 List all the ECtrans Protocols supported on your default Gateway.
142
143 B<ecaccess-association-protocol -gateway> I<boaccess.ecmwf.int> I<genericFtp>
144
145 List the details/options of the Protocol I<genericFtp> on the I<boaccess.ecmwf.int> Gateway.
146
147 =head1 SEE ALSO
148
149 B<ecaccess-association-delete>, B<ecaccess-association-get>, B<ecaccess-association-list>,
150 B<ecaccess-association-put> and B<ecaccess>.
151
152 =cut