-
Notifications
You must be signed in to change notification settings - Fork 3
/
getWQStatusByWorkflow.py
64 lines (49 loc) · 2.03 KB
/
getWQStatusByWorkflow.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
"""
__getWQStatusByWorkflow.py__
Given a workflow name, it collects the status of the workqueue elements status in:
a) global workqueue
b) local workqueue
c) local workqueue_inbox
Created on September 23, 2016.
@author: amaltaro
"""
import sys
import os
from pprint import pprint
from WMCore.Configuration import loadConfigurationFile
from WMCore.WorkQueue.WorkQueueBackend import WorkQueueBackend
def createElementsSummary(reqName, elements, queueUrl):
"""
Print the local couchdb situation based on the WQE status
"""
print("\nSummary for %s and request %s" % (queueUrl, reqName))
summary = {'numberOfElements': len(elements)}
for elem in elements:
summary.setdefault(elem['Status'], {})
if elem['ChildQueueUrl'] not in summary[elem['Status']]:
summary[elem['Status']][elem['ChildQueueUrl']] = 0
summary[elem['Status']][elem['ChildQueueUrl']] += 1
pprint(summary)
def main():
"""
Whatever
"""
if 'WMAGENT_CONFIG' not in os.environ:
os.environ['WMAGENT_CONFIG'] = '/data/srv/wmagent/current/config/wmagent/config.py'
config = loadConfigurationFile(os.environ["WMAGENT_CONFIG"])
if len(sys.argv) != 2:
print("You must provide a request name")
sys.exit(1)
reqName = sys.argv[1]
globalWQBackend = WorkQueueBackend(config.WorkloadSummary.couchurl, db_name="workqueue")
localWQBackend = WorkQueueBackend(config.WorkQueueManager.couchurl, db_name="workqueue")
localWQInbox = WorkQueueBackend(config.WorkQueueManager.couchurl, db_name="workqueue_inbox")
gqDocIDs = globalWQBackend.getElements(RequestName=reqName)
localDocIDs = localWQBackend.getElements(RequestName=reqName)
localInboxDocIDs = localWQInbox.getElements(RequestName=reqName)
createElementsSummary(reqName, gqDocIDs, globalWQBackend.queueUrl)
createElementsSummary(reqName, localDocIDs, localWQBackend.queueUrl)
createElementsSummary(reqName, localInboxDocIDs, localWQInbox.queueUrl)
sys.exit(0)
if __name__ == "__main__":
sys.exit(main())