33
33
from DIRAC .ResourceStatusSystem .Client .SiteStatus import SiteStatus
34
34
from DIRAC .WorkloadManagementSystem .Client import PilotStatus
35
35
from DIRAC .WorkloadManagementSystem .Client .MatcherClient import MatcherClient
36
- from DIRAC .WorkloadManagementSystem .Client .ServerUtils import pilotAgentsDB
36
+ from DIRAC .WorkloadManagementSystem .Client .ServerUtils import getPilotAgentsDB
37
37
from DIRAC .WorkloadManagementSystem .private .ConfigHelper import findGenericPilotCredentials
38
38
from DIRAC .WorkloadManagementSystem .Service .WMSUtilities import getGridEnv
39
39
from DIRAC .WorkloadManagementSystem .Utilities .PilotWrapper import (
@@ -93,6 +93,7 @@ def __init__(self, *args, **kwargs):
93
93
self .sendSubmissionMonitoring = False
94
94
self .siteClient = None
95
95
self .rssClient = None
96
+ self .pilotAgentsDB = None
96
97
self .rssFlag = None
97
98
98
99
self .globalParameters = {"NumberOfProcessors" : 1 , "MaxRAM" : 2048 }
@@ -148,6 +149,7 @@ def initialize(self):
148
149
self .siteClient = SiteStatus ()
149
150
self .rssClient = ResourceStatus ()
150
151
self .matcherClient = MatcherClient ()
152
+ self .pilotAgentsDB = getPilotAgentsDB ()
151
153
152
154
return S_OK ()
153
155
@@ -390,7 +392,7 @@ def submitPilots(self):
390
392
manyWaitingPilotsFlag = False
391
393
if self .pilotWaitingFlag :
392
394
tqIDList = list (additionalInfo )
393
- result = pilotAgentsDB .countPilots (
395
+ result = self . pilotAgentsDB .countPilots (
394
396
{"TaskQueueID" : tqIDList , "Status" : PilotStatus .PILOT_WAITING_STATES }, None
395
397
)
396
398
if not result ["OK" ]:
@@ -533,7 +535,9 @@ def _ifAndWhereToSubmit(self):
533
535
def monitorJobsQueuesPilots (self , matchingTQs ):
534
536
"""Just printout of jobs queues and pilots status in TQ"""
535
537
tqIDList = list (matchingTQs )
536
- result = pilotAgentsDB .countPilots ({"TaskQueueID" : tqIDList , "Status" : PilotStatus .PILOT_WAITING_STATES }, None )
538
+ result = self .pilotAgentsDB .countPilots (
539
+ {"TaskQueueID" : tqIDList , "Status" : PilotStatus .PILOT_WAITING_STATES }, None
540
+ )
537
541
538
542
totalWaitingJobs = 0
539
543
for tqDescription in matchingTQs .values ():
@@ -834,7 +838,7 @@ def _addPilotTQReference(self, queue, taskQueueDict, pilotList, stampDict):
834
838
tqDict [tqID ].append (pilotID )
835
839
836
840
for tqID , pilotsList in tqDict .items ():
837
- result = pilotAgentsDB .addPilotTQReference (
841
+ result = self . pilotAgentsDB .addPilotTQReference (
838
842
pilotsList ,
839
843
tqID ,
840
844
self .pilotDN ,
@@ -847,7 +851,7 @@ def _addPilotTQReference(self, queue, taskQueueDict, pilotList, stampDict):
847
851
self .log .error ("Failed add pilots to the PilotAgentsDB" , result ["Message" ])
848
852
continue
849
853
for pilot in pilotsList :
850
- result = pilotAgentsDB .setPilotStatus (
854
+ result = self . pilotAgentsDB .setPilotStatus (
851
855
pilot ,
852
856
PilotStatus .SUBMITTED ,
853
857
self .queueDict [queue ]["CEName" ],
@@ -871,7 +875,7 @@ def getQueueSlots(self, queue, manyWaitingPilotsFlag):
871
875
872
876
# See if there are waiting pilots for this queue. If not, allow submission
873
877
if totalSlots and manyWaitingPilotsFlag :
874
- result = pilotAgentsDB .selectPilots (
878
+ result = self . pilotAgentsDB .selectPilots (
875
879
{"DestinationSite" : ceName , "Queue" : queueName , "Status" : PilotStatus .PILOT_WAITING_STATES }
876
880
)
877
881
if result ["OK" ]:
@@ -886,7 +890,7 @@ def getQueueSlots(self, queue, manyWaitingPilotsFlag):
886
890
if availableSlotsCount % self .availableSlotsUpdateCycleFactor == 0 :
887
891
# Get the list of already existing pilots for this queue
888
892
jobIDList = None
889
- result = pilotAgentsDB .selectPilots (
893
+ result = self . pilotAgentsDB .selectPilots (
890
894
{"DestinationSite" : ceName , "Queue" : queueName , "Status" : PilotStatus .PILOT_TRANSIENT_STATES }
891
895
)
892
896
@@ -916,7 +920,7 @@ def getQueueSlots(self, queue, manyWaitingPilotsFlag):
916
920
waitingJobs = 0
917
921
totalJobs = 0
918
922
if jobIDList :
919
- result = pilotAgentsDB .getPilotInfo (jobIDList )
923
+ result = self . pilotAgentsDB .getPilotInfo (jobIDList )
920
924
if not result ["OK" ]:
921
925
self .log .warn ("Failed to check PilotAgentsDB" , f"for queue { queue } : \n { result ['Message' ]} " )
922
926
self .failedQueues [queue ] += 1
@@ -1127,7 +1131,7 @@ def updatePilotStatus(self):
1127
1131
queueName = self .queueDict [queue ]["QueueName" ]
1128
1132
ceType = self .queueDict [queue ]["CEType" ]
1129
1133
siteName = self .queueDict [queue ]["Site" ]
1130
- result = pilotAgentsDB .selectPilots (
1134
+ result = self . pilotAgentsDB .selectPilots (
1131
1135
{
1132
1136
"DestinationSite" : ceName ,
1133
1137
"Queue" : queueName ,
@@ -1144,7 +1148,7 @@ def updatePilotStatus(self):
1144
1148
pilotRefs = result ["Value" ]
1145
1149
if not pilotRefs :
1146
1150
continue
1147
- result = pilotAgentsDB .getPilotInfo (pilotRefs )
1151
+ result = self . pilotAgentsDB .getPilotInfo (pilotRefs )
1148
1152
if not result ["OK" ]:
1149
1153
self .log .error ("Failed to get pilots info from DB" , result ["Message" ])
1150
1154
continue
@@ -1155,7 +1159,7 @@ def updatePilotStatus(self):
1155
1159
1156
1160
# Check if the accounting is to be sent
1157
1161
if self .sendAccounting :
1158
- result = pilotAgentsDB .selectPilots (
1162
+ result = self . pilotAgentsDB .selectPilots (
1159
1163
{
1160
1164
"DestinationSite" : ceName ,
1161
1165
"Queue" : queueName ,
@@ -1172,7 +1176,7 @@ def updatePilotStatus(self):
1172
1176
pilotRefs = result ["Value" ]
1173
1177
if not pilotRefs :
1174
1178
continue
1175
- result = pilotAgentsDB .getPilotInfo (pilotRefs )
1179
+ result = self . pilotAgentsDB .getPilotInfo (pilotRefs )
1176
1180
if not result ["OK" ]:
1177
1181
self .log .error ("Failed to get pilots info from DB" , result ["Message" ])
1178
1182
continue
@@ -1195,7 +1199,7 @@ def _updatePilotStatusPerQueue(self, queue, proxy):
1195
1199
ceType = self .queueDict [queue ]["CEType" ]
1196
1200
siteName = self .queueDict [queue ]["Site" ]
1197
1201
1198
- result = pilotAgentsDB .selectPilots (
1202
+ result = self . pilotAgentsDB .selectPilots (
1199
1203
{
1200
1204
"DestinationSite" : ceName ,
1201
1205
"Queue" : queueName ,
@@ -1213,7 +1217,7 @@ def _updatePilotStatusPerQueue(self, queue, proxy):
1213
1217
if not pilotRefs :
1214
1218
return
1215
1219
1216
- result = pilotAgentsDB .getPilotInfo (pilotRefs )
1220
+ result = self . pilotAgentsDB .getPilotInfo (pilotRefs )
1217
1221
if not result ["OK" ]:
1218
1222
self .log .error ("Failed to get pilots info from DB" , result ["Message" ])
1219
1223
return
@@ -1289,7 +1293,7 @@ def _updatePilotStatus(self, pilotRefs, pilotDict, pilotCEDict):
1289
1293
1290
1294
if newStatus :
1291
1295
self .log .info ("Updating status" , f"to { newStatus } for pilot { pRef } " )
1292
- result = pilotAgentsDB .setPilotStatus (pRef , newStatus , "" , "Updated by SiteDirector" )
1296
+ result = self . pilotAgentsDB .setPilotStatus (pRef , newStatus , "" , "Updated by SiteDirector" )
1293
1297
if not result ["OK" ]:
1294
1298
self .log .error (result ["Message" ])
1295
1299
if newStatus == "Aborted" :
@@ -1328,7 +1332,7 @@ def _getPilotOutput(self, pRef, pilotDict, ce, ceName):
1328
1332
output , error = result ["Value" ]
1329
1333
1330
1334
if output :
1331
- result = pilotAgentsDB .storePilotOutput (pRef , output , error )
1335
+ result = self . pilotAgentsDB .storePilotOutput (pRef , output , error )
1332
1336
if not result ["OK" ]:
1333
1337
self .log .error ("Failed to store pilot output" , result ["Message" ])
1334
1338
else :
@@ -1368,7 +1372,7 @@ def sendPilotAccounting(self, pilotDict):
1368
1372
self .log .error ("Failed to send accounting info for pilot " , pRef )
1369
1373
else :
1370
1374
# Set up AccountingSent flag
1371
- result = pilotAgentsDB .setAccountingFlag (pRef )
1375
+ result = self . pilotAgentsDB .setAccountingFlag (pRef )
1372
1376
if not result ["OK" ]:
1373
1377
self .log .error ("Failed to set accounting flag for pilot " , pRef )
1374
1378
@@ -1377,7 +1381,7 @@ def sendPilotAccounting(self, pilotDict):
1377
1381
if result ["OK" ]:
1378
1382
for pRef in pilotDict :
1379
1383
self .log .verbose ("Setting AccountingSent flag" , f"for pilot { pRef } " )
1380
- result = pilotAgentsDB .setAccountingFlag (pRef )
1384
+ result = self . pilotAgentsDB .setAccountingFlag (pRef )
1381
1385
if not result ["OK" ]:
1382
1386
self .log .error ("Failed to set accounting flag for pilot " , pRef )
1383
1387
else :
0 commit comments