Debian Codegraph @

script/ecaccess-ectrans-restart

raw
1 #!/usr/bin/perl -w
2 #
3 # ecaccess-ectrans-restart: Restart an existing ECtrans transfer
4 #
5 # [email protected] - 2010-10-15
6
7 use ECMWF::ECaccess;
8 use Getopt::Long;
9 use Pod::Usage;
10
11 my %opt = (
12 gateway => undef,
13 remote => undef,
14 target => undef,
15 mailTo => undef,
16 retryCount => undef,
17 retryFrequency => undef,
18 priority => undef,
19 lifeTime => undef,
20 onSuccess => undef,
21 onFailure => undef,
22 onRetry => undef,
23 keep => undef,
24 reject => undef,
25 append => undef,
26 resume => undef,
27 overwrite => undef,
28 maximumDuration => undef,
29 minimumDuration => undef,
30 minimumRate => undef,
31 version => 0,
32 help => 0,
33 manual => 0,
34 retry => 0,
35 debug => 0
36 );
37
38 pod2usage( -noperldoc => 1, -exit => 1, verbose => 1 ) if !GetOptions(
39 \%opt,
40 qw(
41 gateway=s
42 remote=s
43 target=s
44 mailTo=s
45 retryCount=i
46 retryFrequency=i
47 priority=i
48 lifeTime=s
49 onSuccess
50 onFailure
51 onRetry
52 keep
53 reject
54 append
55 resume
56 overwrite
57 maximumDuration=s
58 minimumDuration=s
59 minimumRate=i
60 version
61 help|?
62 manual
63 retry=i
64 debug
65 )
66 );
67
68 # Display version if requested
69 die ECMWF::ECaccess->VERSION . "\n" if ( $opt{version} );
70
71 my $transferId = $ARGV[0];
72
73 pod2usage( -noperldoc => 1, -exit => 1, verbose => 1 ) if ( $opt{help} );
74 pod2usage( -noperldoc => 1, -exit => 1, verbose => 2 ) if ( $opt{manual} );
75 pod2usage( -noperldoc => 1, -exit => 1, verbose => 0, -msg => "No transfer-id specified!\n" ) if not($transferId);
76 pod2usage( -noperldoc => 1, -exit => 1, verbose => 0, -msg => "Invalid -retryCount specified (>0)!\n" ) if $opt{retryCount} && not( $opt{retryCount} >= 0 );
77 pod2usage( -noperldoc => 1, -exit => 1, verbose => 0, -msg => "Invalid -retryFrequency specified (>0)!\n" ) if $opt{retryFrequency} && not( $opt{retryFrequency} > 0 );
78 pod2usage( -noperldoc => 1, -exit => 1, verbose => 0, -msg => "Invalid -priority specified (0-99)!\n" ) if $opt{priority} && not( $opt{priority} >= 0 && $opt{priority} <= 99 );
79 pod2usage( -noperldoc => 1, -exit => 1, verbose => 0, -msg => "Incompatible options (-append,-resume)!\n" ) if ( $opt{append} && $opt{resume} );
80 pod2usage( -noperldoc => 1, -exit => 1, verbose => 0, -msg => "Incompatible options (-append,-overwrite)!\n" ) if ( $opt{append} && $opt{overwrite} );
81 pod2usage( -noperldoc => 1, -exit => 1, verbose => 0, -msg => "Incompatible options (-append,-reject)!\n" ) if ( $opt{append} && $opt{reject} );
82 pod2usage( -noperldoc => 1, -exit => 1, verbose => 0, -msg => "Incompatible options!(-resume,-overwrite)\n" ) if ( $opt{resume} && $opt{overwrite} );
83 pod2usage( -noperldoc => 1, -exit => 1, verbose => 0, -msg => "Incompatible options!(-resume,-reject)\n" ) if ( $opt{resume} && $opt{reject} );
84 pod2usage( -noperldoc => 1, -exit => 1, verbose => 0, -msg => "Incompatible options!(-reject,-overwrite)\n" ) if ( $opt{reject} && $opt{overwrite} );
85
86 # Create the ECaccess Controler
87 my $ecaccess = ECMWF::ECaccess->new( $opt{retry}, $opt{debug});
88
89 # Get the Token (using the Certificate in $HOME)
90 my $token = $ecaccess->getToken();
91
92 # Get the Control Channel
93 my $controlChannel = $ecaccess->getControlChannel();
94
95 # Value for "ifTargetFileExists" option
96 my $ifTargetFileExists = undef;
97 $ifTargetFileExists = 'reject' if ( $opt{reject} );
98 $ifTargetFileExists = 'append' if ( $opt{append} );
99 $ifTargetFileExists = 'resume' if ( $opt{resume} );
100 $ifTargetFileExists = 'overwrite' if ( $opt{overwrite} );
101
102 # Restart the existing ECTrans
103 $controlChannel->restartTransfer(
104 $token,
105 SOAP::Data->name(
106 "request" => \SOAP::Data->value(
107 SOAP::Data->name( 'gatewayName' => $opt{gateway} ),
108 SOAP::Data->name( 'remoteLocation' => $opt{remote} ),
109 SOAP::Data->name( 'targetFileName' => $opt{target} ),
110 SOAP::Data->name( 'retryCount' => $opt{retryCount} ),
111 SOAP::Data->name( 'retryFrequency' => $opt{retryFrequency} ),
112 SOAP::Data->name( 'priority' => $opt{priority} ),
113 SOAP::Data->name( 'lifeTime' => $opt{lifeTime} ),
114 SOAP::Data->name( 'maximumDuration' => $opt{maximumDuration} ),
115 SOAP::Data->name( 'minimumDuration' => $opt{minimumDuration} ),
116 SOAP::Data->name( 'minimumRate' => $opt{minimumRate} ),
117 SOAP::Data->name( 'keepInSpool' => defined $opt{keep} ? $opt{keep} ? 'true' : 'false' : undef ),
118 SOAP::Data->name( 'userMailAddress' => $opt{mailTo} ),
119 SOAP::Data->name( 'sendMailOnSuccess' => defined $opt{onSuccess} ? $opt{onSuccess} ? 'true' : 'false' : undef ),
120 SOAP::Data->name( 'sendMailOnFailure' => defined $opt{onFailure} ? $opt{onFailure} ? 'true' : 'false' : undef ),
121 SOAP::Data->name( 'sendMailOnRetry' => defined $opt{onRetry} ? $opt{onRetry} ? 'true' : 'false' : undef ),
122 SOAP::Data->name( 'ifTargetFileExists' => $ifTargetFileExists )
123 )
124 ),
125 $transferId
126 );
127
128 # Logout
129 END {
130 $ecaccess->releaseToken($token) if ($token);
131 }
132
133 __END__
134
135 =head1 NAME
136
137 ecaccess-ectrans-restart - Restart an existing ECtrans transfer
138
139 =head1 SYNOPSIS
140
141 B<ecaccess-ectrans-restart -version|-help|-manual>
142
143 B<ecaccess-ectrans-restart [-debug] [-gateway> I<name>B<] [-remote> I<location>B<] [-target> I<file-name>B<] [-retryCount> I<number>B<]
144 [-retryFrequency> I<frequency>B<] [-priority> I<priority>B<] [-lifeTime> I<duration>B<] [-mailTo> I<email>B<] [-onSuccess] [-onFailure] [-onRetry]
145 [-keep] [-reject>|B<-append>|B<-resume>|B<-overwrite] [-maximumDuration> I<duration>B<] [-minimumDuration> I<duration>B<] [-minimumRate> I<rate>B<]>
146 I<ectrans-id>
147
148 =head1 DESCRIPTION
149
150 Allow restarting the ECtrans transfer with the I<ectrans-id> identifier.
151
152 In order to get the list of ECtrans transfers and the corresponding I<ectrans-id> please use the
153 B<ecaccess-ectrans-list> command. If you want to setup an ECtrans transfer then use the
154 B<ecaccess-ectrans-request> command which will give you an I<ectrans-id> (this one can be kept
155 for a later restart).
156
157 =head1 ARGUMENTS
158
159 =over 8
160
161 =item I<ectrans-id>
162
163 The identifier of the ECtrans transfer to restart.
164
165 =back
166
167 =head1 OPTIONS
168
169 =over 8
170
171 =item B<-gateway> I<name>
172
173 Update the I<name> of the ECaccess Gateway.
174
175 =item B<-remote> I<location>
176
177 Update the target I<location> in the format I<association-name>B<[>I<@protocol>B<]>.
178
179 =item B<-target> I<file-name>
180
181 Update the target I<file-name>.
182
183 =item B<-retryCount> I<number>
184
185 Update the I<number> of retries.
186
187 =item B<-retryFrequency> I<frequency>
188
189 Update the I<frequency> of retries in seconds.
190
191 =item B<-priority> I<priority>
192
193 Update the transmission I<priority> 0-99.
194
195 =item B<-lifeTime> I<duration>
196
197 Update the lifetime of the transfer request. The I<duration> is specified
198 in [w]eeks, [d]ays, [h]ours, [m]inutes or [s]econds (e.g. I<1w> or I<2d>).
199
200 =item B<-mailTo> I<email>
201
202 Update the target I<email> address.
203
204 =item B<-onSuccess>
205
206 Allow sending a mail when the transfer is successful.
207
208 =item B<-onFailure>
209
210 Allow sending a mail when the transfer has failed.
211
212 =item B<-onRetry>
213
214 Allow sending a mail when the transfer is retried.
215
216 =item B<-keep>
217
218 Allow keeping the request in the spool until the duration specified in the
219 B<-lifeTime> option has passed. By default a successful transfer is removed
220 from the spool.
221
222 =item B<-reject>
223
224 Allow failing if there is an existing target file.
225
226 =item B<-append>
227
228 Allow appending if there is an existing target file.
229
230 =item B<-resume>
231
232 Allow resuming if there is an existing target file.
233
234 =item B<-overwrite>
235
236 Allow overwriting if there is an existing target file.
237
238 =item B<-maximumDuration> I<duration>
239
240 Allow updating the maximum transfer I<duration>. The I<duration> is specified in [w]eeks,
241 [d]ays, [h]ours, [m]inutes or [s]econds (e.g. I<10m> or I<1h>). A value <=0 will deactivate
242 the feature.
243
244 =item B<-minimumDuration> I<duration>
245
246 Allow updating the I<duration> before to control a transmission (e.g. for the first 10 minutes
247 ECtrans don't try to check the transfer rate, which allow not to enforce some minimum transfer
248 rates for very small files). The I<duration> is specified in [w]eeks, [d]ays, [h]ours, [m]inutes
249 or [s]econds (e.g. I<30s> or I<10m>). A value <=0 will deactivate the feature.
250
251 =item B<-minimumRate> I<rate>
252
253 Allow updating the minimum transfer I<rate> for a transmission (expressed in bytes/s). This is an
254 average value, not the transmission I<rate> at one particular moment in time (e.g. if a big file
255 is stuck for 5 minutes but then transmit much faster later on then it will not be interrupted
256 as long as the overall transfer rate is above the minimum). A value <=0 will deactivate the feature.
257
258 =item B<-version>
259
260 Display version number and exits.
261
262 =item B<-help>
263
264 Print a brief help message and exits.
265
266 =item B<-manual>
267
268 Prints the manual page and exits.
269
270 =item B<-retry> I<count>
271
272 Number of SSL connection retries per 5s to ECMWF. This parameter only apply to the
273 initial SSL connection initiated by the command to the ECMWF server. It does not
274 apply to all the subsequent requests made afteward as it is mainly targeting errors
275 that can happen from time to time during the SSL handshake. Default is no retry.
276
277 =item B<-debug>
278
279 Display the SOAP and SSL messages exchanged.
280
281 =back
282
283 =head1 EXAMPLES
284
285 B<ecaccess-ectrans-restart> I<124356>
286
287 Restart the ECtrans transfer with the identifier I<124356>.
288
289 =head1 SEE ALSO
290
291 B<ecaccess-ectrans-delete>, B<ecaccess-ectrans-list>, B<ecaccess-ectrans-request> and B<ecaccess>.
292
293 =cut