Skip to content

Commit 14f416e

Browse files
committed
fix: dirac_admin_add_pilot for single VOs
1 parent 5aa70cf commit 14f416e

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

src/DIRAC/FrameworkSystem/scripts/dirac_admin_update_pilot.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ def main():
2525
if switch[0] == "v" or switch[0] == "vo":
2626
vo = switch[1]
2727

28-
from DIRAC import S_OK, S_ERROR
29-
from DIRAC import gConfig, gLogger
28+
from DIRAC import S_OK
29+
from DIRAC import gLogger
30+
from DIRAC.ConfigurationSystem.Client.Helpers.Operations import Operations
3031
from DIRAC.ConfigurationSystem.Client.CSAPI import CSAPI
3132

3233
def updatePilot(version, vo):
@@ -38,21 +39,24 @@ def updatePilot(version, vo):
3839
:param version: version vArBpC of pilot you want to use
3940
:param vo: Location of pilot version in CS /Operations/<vo>/Pilot/Version
4041
"""
41-
# FIXME: use Operations() object
42-
pilotVersion = gConfig.getValue(f"Operations/{vo}/Pilot/Version", [])
43-
if not pilotVersion:
44-
return S_ERROR(f"No pilot version set under Operations/{vo}/Pilot/Version in CS")
45-
46-
pilotVersion.pop()
47-
pilotVersion.insert(0, version)
42+
res = Operations(vo=vo).getValue("Pilot/Version", [])
43+
if not res["OK"]:
44+
gLogger.warn("No pilot version set in CS")
45+
pilotVersion = [version]
46+
else:
47+
pilotVersion = [res["Value"].pop()]
48+
pilotVersion.insert(0, version)
4849
api = CSAPI()
49-
api.setOption(f"Operations/{vo}/Pilot/Version", ", ".join(pilotVersion))
50+
if vo:
51+
api.setOption(f"Operations/{vo}/Pilot/Version", ", ".join(pilotVersion))
52+
else:
53+
api.setOption("Operations/Defaults/Pilot/Version", ", ".join(pilotVersion))
5054
result = api.commit()
5155
if not result["OK"]:
5256
gLogger.fatal("Could not commit new version of pilot!")
5357
return result
5458

55-
newVersion = gConfig.getValue(f"Operations/{vo}/Pilot/Version")
59+
newVersion = Operations(vo=vo).getValue("Pilot/Version")
5660
return S_OK(f"New version of pilot set to {newVersion}")
5761

5862
result = updatePilot(version, vo)

0 commit comments

Comments
 (0)