Debian Codegraph @

script/ecaccess-job-list

raw
1 #!/usr/bin/perl -w
2 #
3 # ecaccess-job-list: List all ECaccess Jobs
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 = ( 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 version
18 help|?
19 manual
20 retry=i
21 debug
22 )
23 );
24
25 # Display version if requested
26 die ECMWF::ECaccess->VERSION . "\n" if ( $opt{version} );
27
28 my $jobId = $ARGV[0];
29
30 pod2usage( -noperldoc => 1, -exit => 1, verbose => 1 ) if ( $opt{help} );
31 pod2usage( -noperldoc => 1, -exit => 1, verbose => 2 ) if ( $opt{manual} );
32
33 # Create the ECaccess Controler
34 my $ecaccess = ECMWF::ECaccess->new( $opt{retry}, $opt{debug});
35
36 # Get the Token (using the Certificate in $HOME)
37 my $token = $ecaccess->getToken();
38
39 # Get the Control Channel
40 my $controlChannel = $ecaccess->getControlChannel();
41
42 if ( not($jobId) ) {
43
44 # Get the list of jobs
45 my $jobs = $controlChannel->getJobList($token);
46
47 # Display the information for each job
48 foreach $job ( $jobs->valueof('//getJobListResponse/return') ) {
49 printf "%-10s %-10s %-10s %-6s %-15s", $job->{jobId}, $job->{queueName}, $job->{status}, $job->{tryDone} . "/" . $job->{tryCount},
50 $job->{scheduledDate};
51 my $space = 0;
52 if ( $job->{eventIds} ) {
53 if ( @{$job->{eventIds}} > 0 ) {
54 # This is a list of events
55 print "[";
56 foreach my $eventId(@{$job->{eventIds}}) {
57 print ";" if ($space != 0);
58 print $eventId;
59 $space = 1;
60 }
61 print "]";
62 } else {
63 # Only one event to display
64 print "[".$job->{eventIds}."]";
65 }
66 } else {
67 print "[-]";
68 }
69 print " " . $job->{name} if ( $job->{name} );
70 print "\n";
71 }
72 }
73 else {
74
75 # Get the detail for the specified jobId
76 my $job = $controlChannel->getJob( $token, $jobId )->valueof('//getJobResponse/return');
77 print " Job-Id: " . $job->{jobId} . "\n";
78 print " Job Name: " . $job->{name} . "\n" if ( $job->{name} );
79 print " Queue: " . $job->{queueName} . "\n";
80 print " Host: " . $job->{hostName} . "\n" if ( $job->{hostName} );
81 print " Schedule: " . $job->{scheduledDate} . "\n";
82 print " Expiration: " . $job->{expirationDate} . "\n";
83 print " Try Count: " . $job->{tryDone} . "/" . $job->{tryCount} . "\n";
84 print " Status: " . $job->{status} . "\n";
85
86 my $space = 0;
87 if ( $job->{eventIds} && @{$job->{eventIds}} > 0 ) {
88 print " Event-Ids:";
89 foreach my $eventId(@{$job->{eventIds}}) {
90 print ";" if ($space != 0);
91 print $eventId;
92 $space = 1;
93 }
94 print "\n";
95 } else {
96 if ( $job->{eventIds} && @{$job->{eventIds}} == 0 ) {
97 print " Event-Ids: ".$job->{eventIds}."\n";
98 }
99 }
100
101 if ( $job->{status} eq 'DONE' ) {
102 print "Stdout Size: " . $job->{outputFileSize} . "\n" if ( $job->{outputFileSize} != '-1' );
103 print "Stderr Size: " . $job->{errorFileSize} . "\n" if ( $job->{errorFileSize} != '-1' );
104 print " Stdin Size: " . $job->{inputFileSize} . "\n" if ( $job->{inputFileSize} != '-1' );
105 }
106
107 print " Comment: " . $job->{comment} . "\n" if ( $job->{comment} );
108 }
109
110 # Logout
111 END {
112 $ecaccess->releaseToken($token) if ($token);
113 }
114
115 __END__
116
117 =head1 NAME
118
119 ecaccess-job-list - List all ECaccess Jobs
120
121 =head1 SYNOPSIS
122
123 B<ecaccess-job-list -version|-help|-manual>
124
125 B<ecaccess-job-list [-debug]> B<[>I<job-id>B<]>
126
127 =head1 DESCRIPTION
128
129 List all your ECaccess Jobs. When a I<job-id> is specified
130 then the details for this job are displayed.
131
132 The Job statuses can have the following values:
133
134 =over 8
135
136 =item B<INIT>
137
138 Jobs are being initialised
139
140 =item B<STDBY>
141
142 Jobs are waiting for an event
143
144 =item B<EXEC>
145
146 Jobs are running
147
148 =item B<WAIT>
149
150 Jobs have been queued to the scheduler (e.g. LoadLeveler)
151
152 =item B<RETR>
153
154 Jobs will be resubmitted
155
156 =item B<STOP>
157
158 Jobs have NOT completed (error)
159
160 =item B<DONE>
161
162 Jobs have successfully completed
163
164 =back
165
166 =head1 ARGUMENTS
167
168 =over 8
169
170 =item I<job-id> (optional)
171
172 The identifier of the ECaccess Job to retrieve the details.
173
174 =back
175
176 =head1 OPTIONS
177
178 =over 8
179
180 =item B<-version>
181
182 Display version number and exits.
183
184 =item B<-help>
185
186 Print a brief help message and exits.
187
188 =item B<-manual>
189
190 Prints the manual page and exits.
191
192 =item B<-retry> I<count>
193
194 Number of SSL connection retries per 5s to ECMWF. This parameter only apply to the
195 initial SSL connection initiated by the command to the ECMWF server. It does not
196 apply to all the subsequent requests made afteward as it is mainly targeting errors
197 that can happen from time to time during the SSL handshake. Default is no retry.
198
199 =item B<-debug>
200
201 Display the SOAP and SSL messages exchanged.
202
203 =back
204
205 =head1 EXAMPLES
206
207 B<ecaccess-job-list> I<124356>
208
209 Give the informations concerning the ECaccess Job with identifier I<124356>.
210
211 B<ecaccess-job-list>
212
213 List all your ECaccess Jobs in the spool.
214
215 =head1 SEE ALSO
216
217 B<ecaccess-queue-list>, B<ecaccess-job-delete>, B<ecaccess-job-get>, B<ecaccess-job-restart>,
218 B<ecaccess-job-submit> and B<ecaccess>.
219
220 =cut