31
31
from DIRAC .MonitoringSystem .Client .MonitoringReporter import MonitoringReporter
32
32
from DIRAC .ResourceStatusSystem .Client .ResourceStatus import ResourceStatus
33
33
from DIRAC .ResourceStatusSystem .Client .SiteStatus import SiteStatus
34
+ from DIRAC .Resources .Computing .ComputingElement import ComputingElement
34
35
from DIRAC .WorkloadManagementSystem .Client import PilotStatus
35
36
from DIRAC .WorkloadManagementSystem .Client .PilotScopes import PILOT_SCOPES
36
37
@@ -446,7 +447,7 @@ def submitPilots(self):
446
447
ce .setProxy (proxy , lifetime_secs )
447
448
448
449
# Get valid token if needed
449
- if "Token" in ce . ceParameters . get ( "Tag" , [] ):
450
+ if self . __supportToken ( ce ):
450
451
result = self .__getPilotToken (audience = ce .audienceName )
451
452
if not result ["OK" ]:
452
453
return result
@@ -467,6 +468,14 @@ def submitPilots(self):
467
468
468
469
return S_OK ()
469
470
471
+ def __supportToken (self , ce : ComputingElement ) -> bool :
472
+ """Check whether the SiteDirector is able to submit pilots with tokens.
473
+
474
+ * the CE is able to receive any token. Validation: Tag = Token should be included in the CE parameters.
475
+ * the CE is able to receive VO-specifc tokens. Validation: Tag = Token:<VO> should be included in the CE parameters.
476
+ """
477
+ return "Token" in ce .ceParameters .get ("Tag" , []) or f"Token:{ self .vo } " in ce .ceParameters .get ("Tag" , [])
478
+
470
479
def __getPilotToken (self , audience : str , scope : list [str ] = None ):
471
480
"""Get the token corresponding to the pilot user identity
472
481
@@ -1242,7 +1251,7 @@ def _updatePilotStatusPerQueue(self, queue, proxy):
1242
1251
ce .setProxy (proxy , 23300 )
1243
1252
1244
1253
# Get valid token if needed
1245
- if "Token" in ce . ceParameters . get ( "Tag" , [] ):
1254
+ if self . __supportToken ( ce ):
1246
1255
result = self .__getPilotToken (audience = ce .audienceName )
1247
1256
if not result ["OK" ]:
1248
1257
self .log .error ("Failed to get token" , f"{ ceName } : { result ['Message' ]} " )
0 commit comments