Skip to content

Commit 3565f21

Browse files
committed
fix: SiteDirector acts for a VO
1 parent ba9e6c5 commit 3565f21

File tree

1 file changed

+21
-22
lines changed

1 file changed

+21
-22
lines changed

src/DIRAC/WorkloadManagementSystem/Agent/SiteDirector.py

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
from DIRAC import S_ERROR, S_OK, gConfig
2020
from DIRAC.AccountingSystem.Client.DataStoreClient import gDataStoreClient
2121
from DIRAC.AccountingSystem.Client.Types.Pilot import Pilot as PilotAccounting
22-
from DIRAC.AccountingSystem.Client.Types.PilotSubmission import PilotSubmission as PilotSubmissionAccounting
22+
from DIRAC.AccountingSystem.Client.Types.PilotSubmission import (
23+
PilotSubmission as PilotSubmissionAccounting,
24+
)
2325
from DIRAC.ConfigurationSystem.Client.Helpers import CSGlobals, Registry
2426
from DIRAC.ConfigurationSystem.Client.Helpers.Operations import Operations
2527
from DIRAC.ConfigurationSystem.Client.Helpers.Resources import getCESiteMapping
@@ -29,15 +31,16 @@
2931
from DIRAC.FrameworkSystem.Client.ProxyManagerClient import gProxyManager
3032
from DIRAC.FrameworkSystem.Client.TokenManagerClient import gTokenManager
3133
from DIRAC.MonitoringSystem.Client.MonitoringReporter import MonitoringReporter
34+
from DIRAC.Resources.Computing.ComputingElement import ComputingElement
3235
from DIRAC.ResourceStatusSystem.Client.ResourceStatus import ResourceStatus
3336
from DIRAC.ResourceStatusSystem.Client.SiteStatus import SiteStatus
34-
from DIRAC.Resources.Computing.ComputingElement import ComputingElement
3537
from DIRAC.WorkloadManagementSystem.Client import PilotStatus
36-
from DIRAC.WorkloadManagementSystem.Client.PilotScopes import PILOT_SCOPES
37-
3838
from DIRAC.WorkloadManagementSystem.Client.MatcherClient import MatcherClient
39+
from DIRAC.WorkloadManagementSystem.Client.PilotScopes import PILOT_SCOPES
3940
from DIRAC.WorkloadManagementSystem.Client.ServerUtils import getPilotAgentsDB
40-
from DIRAC.WorkloadManagementSystem.private.ConfigHelper import findGenericPilotCredentials
41+
from DIRAC.WorkloadManagementSystem.private.ConfigHelper import (
42+
findGenericPilotCredentials,
43+
)
4144
from DIRAC.WorkloadManagementSystem.Service.WMSUtilities import getGridEnv
4245
from DIRAC.WorkloadManagementSystem.Utilities.PilotWrapper import (
4346
_writePilotWrapperFile,
@@ -126,25 +129,24 @@ def initialize(self):
126129
self.gridEnv = getGridEnv()
127130

128131
# The SiteDirector is for a particular user community
129-
self.vo = self.am_getOption("VO", "")
130-
if not self.vo:
131-
self.vo = self.am_getOption("Community", "")
132+
self.vo = self.am_getOption("VO", self.am_getOption("Community", ""))
132133
if not self.vo:
133134
self.vo = CSGlobals.getVO()
135+
if not self.vo:
136+
return S_ERROR("Need a VO")
134137
# The SiteDirector is for a particular user group
135138
self.group = self.am_getOption("Group", "")
136139

137140
# Choose the group for which pilots will be submitted. This is a hack until
138141
# we will be able to match pilots to VOs.
139142
if not self.group:
140-
if self.vo:
141-
result = Registry.getGroupsForVO(self.vo)
142-
if not result["OK"]:
143-
return result
144-
self.voGroups = []
145-
for group in result["Value"]:
146-
if "NormalUser" in Registry.getPropertiesForGroup(group):
147-
self.voGroups.append(group)
143+
result = Registry.getGroupsForVO(self.vo)
144+
if not result["OK"]:
145+
return result
146+
self.voGroups = []
147+
for group in result["Value"]:
148+
if "NormalUser" in Registry.getPropertiesForGroup(group):
149+
self.voGroups.append(group)
148150
else:
149151
self.voGroups = [self.group]
150152

@@ -570,8 +572,7 @@ def _getTQDictForMatching(self):
570572
:returns dict: tqDict of task queue descriptions
571573
"""
572574
tqDict = {"Setup": CSGlobals.getSetup(), "CPUTime": 9999999}
573-
if self.vo:
574-
tqDict["Community"] = self.vo
575+
tqDict["Community"] = self.vo
575576
if self.voGroups:
576577
tqDict["OwnerGroup"] = self.voGroups
577578

@@ -667,8 +668,7 @@ def _getCE(self, queue):
667668

668669
if self.queueDict[queue]["Site"] not in self.siteMaskList:
669670
ceDict["JobType"] = "Test"
670-
if self.vo:
671-
ceDict["Community"] = self.vo
671+
ceDict["Community"] = self.vo
672672
if self.voGroups:
673673
ceDict["OwnerGroup"] = self.voGroups
674674

@@ -1049,8 +1049,7 @@ def _getPilotOptions(self, queue, **kwargs):
10491049
# SiteName
10501050
pilotOptions.append(f"-n {queueDict['Site']}")
10511051
# VO
1052-
if self.vo:
1053-
pilotOptions.append(f"--wnVO={self.vo}")
1052+
pilotOptions.append(f"--wnVO={self.vo}")
10541053

10551054
# Generic Options
10561055
if "GenericOptions" in queueDict:

0 commit comments

Comments
 (0)