Skip to content

Commit

Permalink
feat: Add /DiracX/EnabledVOs to the CS for enabling DiracX
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisburr committed Oct 12, 2023
1 parent 79c68ab commit 84e5daa
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ DIRAC_DEPRECATED_FAIL
DIRAC_ENABLE_DIRACX_JOB_MONITORING
If set, calls the diracx job monitoring service. Off by default.

DIRAC_ENABLE_DIRACX_LOGIN
If set, retrieve a DiracX token when calling dirac-proxy-init or dirac-login

DIRAC_FEWER_CFG_LOCKS
If ``true`` or ``yes`` or ``on`` or ``1`` or ``y`` or ``t``, DIRAC will reduce the number of locks used when accessing the CS for better performance (default, ``no``).

Expand Down
5 changes: 1 addition & 4 deletions integration_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@
"DIRAC_USE_JSON_ENCODE": None,
"INSTALLATION_BRANCH": "",
}
DIRACX_OPTIONS = (
"DIRAC_ENABLE_DIRACX_LOGIN",
"DIRAC_ENABLE_DIRACX_JOB_MONITORING",
)
DIRACX_OPTIONS = ("DIRAC_ENABLE_DIRACX_JOB_MONITORING",)
DEFAULT_MODULES = {"DIRAC": Path(__file__).parent.absolute()}

# Static configuration
Expand Down
4 changes: 3 additions & 1 deletion src/DIRAC/FrameworkSystem/scripts/dirac_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,9 @@ def loginWithCertificate(self):
return res

# Get a token for use with diracx
if os.getenv("DIRAC_ENABLE_DIRACX_LOGIN", "No").lower() in ("yes", "true"):
vo = getVOMSVOForGroup(self.group)
enabledVOs = gConfig.getValue("/DiracX/EnabledVOs", [])
if vo in enabledVOs:
from diracx.core.utils import write_credentials # pylint: disable=import-error
from diracx.core.models import TokenResponse # pylint: disable=import-error

Expand Down
8 changes: 4 additions & 4 deletions src/DIRAC/FrameworkSystem/scripts/dirac_proxy_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,19 @@
import os
import sys
import glob
import json
import time
import datetime

import DIRAC

from DIRAC import gLogger, S_OK, S_ERROR
from DIRAC import gLogger, gConfig, S_OK, S_ERROR
from DIRAC.Core.Base.Script import Script
from DIRAC.FrameworkSystem.Client import ProxyGeneration, ProxyUpload
from DIRAC.Core.Security import X509Chain, ProxyInfo, VOMS
from DIRAC.Core.Security.Locations import getCAsLocation
from DIRAC.ConfigurationSystem.Client.Helpers import Registry
from DIRAC.FrameworkSystem.Client.BundleDeliveryClient import BundleDeliveryClient
from DIRAC.Core.Base.Client import Client
from pathlib import Path


class Params(ProxyGeneration.CLIParams):
Expand Down Expand Up @@ -240,7 +238,9 @@ def doTheMagic(self):
if self.__piParams.strict:
return resultProxyUpload

if os.getenv("DIRAC_ENABLE_DIRACX_LOGIN", "No").lower() in ("yes", "true"):
vo = Registry.getVOMSVOForGroup(self.__piParams.diracGroup)
enabledVOs = gConfig.getValue("/DiracX/EnabledVOs", [])
if vo in enabledVOs:
from diracx.core.utils import write_credentials # pylint: disable=import-error
from diracx.core.models import TokenResponse # pylint: disable=import-error
from diracx.core.preferences import DiracxPreferences # pylint: disable=import-error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
import threading
import time

from DIRAC import S_ERROR, S_OK, gLogger
from DIRAC import S_ERROR, S_OK, gLogger, gConfig
from DIRAC.ConfigurationSystem.Client.Helpers import Registry
from DIRAC.Core.DISET.RequestHandler import RequestHandler
from DIRAC.Core.Security import Locations, Properties, X509Certificate
from DIRAC.Core.Utilities.File import mkDir
Expand Down Expand Up @@ -108,8 +109,10 @@ def _getFromClient(self, fileId, token, fileSize, fileHelper=None, data=""):
gLogger.info("Upload requested", f"for {aHash} [{extension}]")

credDict = self.getRemoteCredentials()
vo = Registry.getVOForGroup(credDict["group"])

if self._useDiracXBackend:
enabledVOs = gConfig.getValue("/DiracX/EnabledVOs", [])
if self._useDiracXBackend and vo in enabledVOs:
from DIRAC.FrameworkSystem.Utilities.diracx import TheImpersonator
from diracx.client.models import SandboxInfo # pylint: disable=import-error

Expand Down

0 comments on commit 84e5daa

Please sign in to comment.