another working example
authorAleš Křenek <ljocha@ics.muni.cz>
Wed, 26 Mar 2008 16:32:01 +0000 (16:32 +0000)
committerAleš Křenek <ljocha@ics.muni.cz>
Wed, 26 Mar 2008 16:32:01 +0000 (16:32 +0000)
org.glite.lb.client/examples/job-status.pl [new file with mode: 0755]

diff --git a/org.glite.lb.client/examples/job-status.pl b/org.glite.lb.client/examples/job-status.pl
new file mode 100755 (executable)
index 0000000..e3ea58b
--- /dev/null
@@ -0,0 +1,44 @@
+#!/usr/bin/perl
+
+use SOAP::Lite;
+use Data::Dumper;
+
+$ENV{HTTPS_CA_DIR}='/etc/grid-security/certificates';
+$ENV{HTTPS_VERSION}='3';
+
+$proxy = $ENV{X509_USER_PROXY} ? $ENV{X509_USER_PROXY} : "/tmp/x509up_u$<";
+$ENV{HTTPS_CERT_FILE}= $ENV{HTTPS_KEY_FILE} = $ENV{HTTPS_CA_FILE} = $proxy;
+
+$job = shift or die "usage: $0 jobid\n";
+$job =~ /(https:\/\/.*):([0-9]+)\/.*/ or die "$job: invalid jobid\n";
+$host = $1; $port = $2;
+$server = $host . ':' . ($port + 3);
+
+$c = SOAP::Lite
+       -> proxy($server) -> uri('http://glite.org/wsdl/services/lb');
+
+service $c 'http://egee.cesnet.cz/cms/export/sites/egee/en/WSDL/HEAD/LB.wsdl';
+ns $c 'http://glite.org/wsdl/elements/lb';
+$c->serializer->register_ns('http://glite.org/wsdl/types/lb','lbtype');
+
+on_fault $c sub { print Dumper($_[1]->fault); $fault = 1; };
+
+$req = SOAP::Data->value(
+               SOAP::Data->name(jobid=>$job),
+               SOAP::Data->name(flags=>'')->type('lbtype:jobFlags')
+       );
+
+$resp = JobStatus $c $req;
+$body = $resp->body();
+
+# print Dumper $resp->body();
+
+unless ($fault) {
+       @fields = qw/state jobtype owner networkServer doneCode exitCode childrenNum/;
+       $stat = $resp->body()->{JobStatusResponse}->{stat};
+
+       for (@fields) {
+               print "$_: $stat->{$_}\n";
+       }
+}
+