Skip to content

Commit

Permalink
add env var
Browse files Browse the repository at this point in the history
  • Loading branch information
chaen committed Aug 30, 2023
1 parent a52b97e commit 07bd1ca
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 11 deletions.
5 changes: 4 additions & 1 deletion integration_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@
"DIRAC_USE_JSON_ENCODE": None,
"INSTALLATION_BRANCH": "",
}
DIRACX_OPTIONS = ("DIRAC_ENABLE_DIRACX_JOB_MONITORING",)
DIRACX_OPTIONS = (
"DIRAC_ENABLE_DIRACX_LOGIN",
"DIRAC_ENABLE_DIRACX_JOB_MONITORING",
)
DEFAULT_MODULES = {"DIRAC": Path(__file__).parent.absolute()}

# Static configuration
Expand Down
6 changes: 5 additions & 1 deletion src/DIRAC/FrameworkSystem/Service/ProxyManagerHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,11 @@ def export_getVOMSProxyWithToken(self, userDN, userGroup, requestPem, requiredLi

def export_exchangeProxyForToken(self):
try:
from diracx.routers.auth import AuthSettings, create_access_token, TokenResponse
from diracx.routers.auth import (
AuthSettings,
create_access_token,
TokenResponse,
) # pylint: disable=import-error

authSettings = AuthSettings()

Expand Down
9 changes: 5 additions & 4 deletions src/DIRAC/FrameworkSystem/scripts/dirac_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,10 @@ def loginWithCertificate(self):
return res

# Get a token for use with diracx
res = Client(url="Framework/ProxyManager").exchangeProxyForToken()
if res["OK"]:
if os.getenv("DIRAC_ENABLE_DIRACX_LOGIN", "No").lower() in ("yes", "true"):
res = Client(url="Framework/ProxyManager").exchangeProxyForToken()
if not res["OK"]:
return res
DIRAC_TOKEN_FILE.parent.mkdir(parents=True, exist_ok=True)
expires = datetime.datetime.now(tz=datetime.timezone.utc) + datetime.timedelta(
seconds=res["Value"]["expires_in"] - EXPIRES_GRACE_SECONDS
Expand All @@ -331,8 +333,7 @@ def loginWithCertificate(self):
"expires": expires.isoformat(),
}
DIRAC_TOKEN_FILE.write_text(json.dumps(credential_data))
else:
gLogger.warn(res["Message"])

return S_OK()

def __enableCS(self):
Expand Down
9 changes: 4 additions & 5 deletions src/DIRAC/FrameworkSystem/scripts/dirac_proxy_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,10 @@ def doTheMagic(self):
if self.__piParams.strict:
return resultProxyUpload

# res = Client(url="dips://lhcbvoboxcertif00.cern.ch:9152/Framework/ProxyManager").exchangeProxyForToken()
res = Client(url="Framework/ProxyManager").exchangeProxyForToken()
if res["OK"]:
if os.getenv("DIRAC_ENABLE_DIRACX_LOGIN", "No").lower() in ("yes", "true"):
res = Client(url="Framework/ProxyManager").exchangeProxyForToken()
if not res["OK"]:
return res
DIRAC_TOKEN_FILE.parent.mkdir(parents=True, exist_ok=True)
expires = datetime.datetime.now(tz=datetime.timezone.utc) + datetime.timedelta(
seconds=res["Value"]["expires_in"] - EXPIRES_GRACE_SECONDS
Expand All @@ -258,8 +259,6 @@ def doTheMagic(self):
"expires": expires.isoformat(),
}
DIRAC_TOKEN_FILE.write_text(json.dumps(credential_data))
else:
gLogger.warn(res["Message"])

return S_OK()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# pylint: disable=import-error
from diracx.client import Dirac
from diracx.client.models import JobSearchParams

Expand Down

0 comments on commit 07bd1ca

Please sign in to comment.