ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/StatusServer.py
Revision: 1.24
Committed: Tue Mar 18 15:26:25 2008 UTC (17 years, 1 month ago) by farinafa
Content type: text/x-python
Branch: MAIN
Changes since 1.23: +79 -234 lines
Log Message:
Various fixes in submission/status use cases + added the SubmitterServer for the new front-end supporting BossLite

File Contents

# User Rev Content
1 spiga 1.1 from Actor import *
2     from crab_util import *
3     import common
4     from ApmonIf import ApmonIf
5     import time
6    
7 farinafa 1.24 import traceback
8     from xml.dom import minidom
9     from ServerCommunicator import ServerCommunicator
10     from Status import Status
11    
12     class StatusServer(Status):
13    
14     def __init__(self, *args):
15     self.cfg_params = args[0]
16     self.server_name = None
17     self.server_path = None
18    
19     print self.cfg_params['CRAB.server_name']
20     try:
21     ## SERVER HARDCODED - MATTY
22     ## the API (wget or siteDB) can be callet here
23     self.server_name, self.server_path = self.cfg_params['CRAB.server_name'].split('/',1)
24     self.server_path = os.path.join('/',self.server_path)
25     self.server_port = int("20081")
26 spiga 1.3 except KeyError:
27 farinafa 1.24 msg = 'No server selected or port specified.'
28     msg = msg + 'Please specify a server in the crab cfg file'
29     raise CrabException(msg)
30 spiga 1.1 return
31 mcinquil 1.2
32 farinafa 1.24 # all the behaviors are inherited from the direct status. Only some mimimal modifications
33     # are needed in order to extract data from status XML and to align back DB information
34     # Fabio
35    
36     def compute(self):
37     # proxy management
38     proxy = None # common._db.queryTask('proxy')
39     if 'X509_USER_PROXY' in os.environ:
40     proxy = os.environ['X509_USER_PROXY']
41     else:
42     status, proxy = commands.getstatusoutput('ls /tmp/x509up_u`id -u`')
43     proxy = proxy.strip()
44     common.scheduler.checkProxy()
45 spiga 1.1
46 farinafa 1.24 task = common._db.getTask()
47 spiga 1.1
48 farinafa 1.24 # communicator allocation
49     common.logger.message("Checking the status of all jobs: please wait")
50     csCommunicator = ServerCommunicator(self.server_name, self.server_port, self.cfg_params, proxy)
51     reportXML = csCommunicator.getStatus( str(task['name']) )
52     del csCommunicator
53    
54     # align back data and print
55     reportList = minidom.parseString(reportXML).getElementsByTagName('Job')
56     toPrint=[]
57     for job in task.jobs:
58     id = str(job.runningJob['id'])
59     # TODO sub-linear search, probably it can be optized with binary search
60     rForJ = None
61     for r in reportList:
62     if id == r.getAttribute('id'):
63     rForJ = r
64     break
65    
66     # Data alignment
67     job.runningJob['statusScheduler'] = str( rForJ.getAttribute('status') )
68     jobStatus = str(job.runningJob['statusScheduler'])
69    
70     job.runningJob['destination'] = str( rForJ.getAttribute('site') )
71     dest = str(job.runningJob['destination']).split(':')[0]
72    
73     job.runningJob['applicationReturnCode'] = str( rForJ.getAttribute('exe_exit') )
74     exe_exit_code = str(job.runningJob['applicationReturnCode'])
75    
76     job.runningJob['wrapperReturnCode'] = str( rForJ.getAttribute('job_exit') )
77     job_exit_code = str(job.runningJob['wrapperReturnCode'])
78    
79     job['submissionNumber'] = int(rForJ.getAttribute('resubmit'))
80     # TODO cleared='0' field, how should it be handled/mapped in BL? #Fabio
81     common.bossSession.updateDB( task )
82    
83     printline=''
84     if dest == 'None' : dest = ''
85     if exe_exit_code == 'None' : exe_exit_code = ''
86     if job_exit_code == 'None' : job_exit_code = ''
87     printline+="%-8s %-18s %-40s %-13s %-15s" % (id,jobStatus,dest,exe_exit_code,job_exit_code)
88     toPrint.append(printline)
89 spiga 1.1
90 farinafa 1.24 self.detailedReport(toPrint)
91     pass
92 spiga 1.1
93 mcinquil 1.2
94 farinafa 1.9
95 spiga 1.1