[bonfiredemokit] Annotation of /ea/job_submission.py
Annotation of /ea/job_submission.py
Parent Directory
| Revision Log
Revision 9 -
(view)
(download)
(as text)
1 : |
agomez |
9 |
#
|
2 : |
|
|
# BonFIRE Virtual Clusters on Federated Clouds Demonstration Kit
|
3 : |
|
|
#
|
4 : |
|
|
# Copyright (c) Fundacion Centro Tecnologico de Supercomputacion de Galicia 2012
|
5 : |
|
|
#
|
6 : |
|
|
# License GPL Version 3
|
7 : |
|
|
#
|
8 : |
|
|
# The research leading to these results has received funding from
|
9 : |
|
|
# the European Community's Seventh Frameqork Programme (FP7/2007-2013)
|
10 : |
|
|
# under agreement number 257386
|
11 : |
|
|
#
|
12 : |
|
|
# This software is provided with ABSOLUTELY NO WARRANTY
|
13 : |
|
|
#
|
14 : |
agomez |
1 |
'''
|
15 : |
|
|
Created on 01/03/2012
|
16 : |
|
|
|
17 : |
|
|
@author: R. Valin
|
18 : |
|
|
'''
|
19 : |
|
|
import saga
|
20 : |
|
|
|
21 : |
|
|
try:
|
22 : |
|
|
# create an "echo 'hello, world' job"
|
23 : |
|
|
jd = saga.job.description()
|
24 : |
|
|
jd.set_attribute("Executable", "/bin/echo")
|
25 : |
|
|
jd.set_vector_attribute("Arguments", ["Hello, World!"])
|
26 : |
|
|
jd.set_attribute("Interactive", "True")
|
27 : |
|
|
|
28 : |
|
|
# connect to the local job service
|
29 : |
|
|
js = saga.job.service("fork://localhost");
|
30 : |
|
|
|
31 : |
|
|
# submit the job
|
32 : |
|
|
job = js.create_job(jd)
|
33 : |
|
|
job.run()
|
34 : |
|
|
|
35 : |
|
|
# wait for the job to complete
|
36 : |
|
|
job.wait(-1)
|
37 : |
|
|
|
38 : |
|
|
# print the job's output
|
39 : |
|
|
output = job.get_stdout()
|
40 : |
|
|
print output.read()
|
41 : |
|
|
|
42 : |
|
|
except saga.exception, e:
|
43 : |
|
|
print "ERROR: "
|
44 : |
|
|
for err in e.get_all_messages():
|
45 : |
|
|
print err
|
46 : |
|
|
|
|