Skip to content

Commit 1f0d0f7

Browse files
authored
Merge pull request #5764 from chaen/cherry-pick-2-3eade1f52-integration
[sweep:integration] Replace RPCClient with Client
2 parents 3dd4e90 + b23c2f9 commit 1f0d0f7

File tree

28 files changed

+98
-107
lines changed

28 files changed

+98
-107
lines changed

docs/source/DeveloperGuide/AddingNewComponents/DevelopingAgents/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ functional although simplest possible agent::
2626
# # imports
2727
from DIRAC import S_OK, S_ERROR
2828
from DIRAC.Core.Base.AgentModule import AgentModule
29-
from DIRAC.Core.DISET.RPCClient import RPCClient
29+
from DIRAC.Core.Base.Client import Client
3030

3131

3232
__RCSID__ = "Id$"
@@ -54,7 +54,7 @@ functional although simplest possible agent::
5454
:param self: self reference
5555
"""
5656
self.log.info("message is: %s" % self.message)
57-
simpleMessageService = RPCClient('Framework/Hello')
57+
simpleMessageService = Client(url='Framework/Hello')
5858
result = simpleMessageService.sayHello(self.message)
5959
if not result['OK']:
6060
self.log.error("Error while calling the service: %s" % result['Message'])

docs/source/DeveloperGuide/WebAppDIRAC/DevelopWebApp/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ by the server is shown in the textarea.
198198
.. code-block:: python
199199
200200
from WebAppDIRAC.Lib.WebHandler import WebHandler
201-
from DIRAC.Core.DISET.RPCClient import RPCClient
201+
from DIRAC.Core.Base.Client import Client
202202
import random
203203
204204
@@ -235,7 +235,7 @@ by the server is shown in the textarea.
235235
"""
236236
@asyncGen
237237
def web_getServiceInfo(self):
238-
RPC = RPCClient("WorkloadManagement/JobMonitoring")
238+
RPC = Client(url="WorkloadManagement/JobMonitoring")
239239
result = yield self.threadTask(RPC.ping)
240240
self.finish({"info": str(result['Value'])})
241241

src/DIRAC/AccountingSystem/Client/Types/BaseAccountingType.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from DIRAC import S_OK, S_ERROR
1010
from DIRAC.Core.Utilities import Time
11-
from DIRAC.Core.DISET.RPCClient import RPCClient
11+
from DIRAC.Core.Base.Client import Client
1212
from DIRAC.AccountingSystem.Client.DataStoreClient import gDataStoreClient
1313

1414

@@ -169,7 +169,7 @@ def registerToServer(self):
169169
"""
170170
Register type in server
171171
"""
172-
rpcClient = RPCClient("Accounting/DataStore")
172+
rpcClient = Client(url="Accounting/DataStore")
173173
return rpcClient.registerType(*self.getDefinition())
174174

175175
def commit(self):

src/DIRAC/AccountingSystem/Service/DataStoreHandler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from DIRAC.Core.DISET.RequestHandler import RequestHandler, getServiceOption
2323
from DIRAC.Core.Utilities import Time
2424
from DIRAC.Core.Utilities.ThreadScheduler import gThreadScheduler
25-
from DIRAC.Core.DISET.RPCClient import RPCClient
25+
from DIRAC.Core.Base.Client import Client
2626

2727
__RCSID__ = "$Id$"
2828

@@ -184,7 +184,7 @@ def export_compactDB(self):
184184
if self.runBucketing:
185185
return self.__acDB.compactBuckets() # pylint: disable=no-member
186186

187-
return RPCClient("Accounting/DataStoreMaster").compactDB()
187+
return Client(url="Accounting/DataStoreMaster").compactDB()
188188

189189
types_remove = [str, datetime.datetime, datetime.datetime, list]
190190

src/DIRAC/Core/Tornado/Client/private/TornadoBaseClient.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@
5151
from DIRAC.Core.Utilities import Network
5252
from DIRAC.Core.Utilities.JEncode import decode, encode
5353

54-
from DIRAC.Resources.IdProvider.IdProviderFactory import IdProviderFactory
55-
from DIRAC.FrameworkSystem.private.authorization.utils.Tokens import getLocalTokenDict, writeTokenDictToTokenFile
5654

5755
# TODO CHRIS: refactor all the messy `discover` methods
5856
# I do not do it now because I want first to decide
@@ -249,6 +247,8 @@ def __discoverCredentialsToUse(self):
249247
self.kwargs[self.KW_USE_ACCESS_TOKEN] = self.__useAccessToken
250248

251249
if self.__useAccessToken:
250+
from DIRAC.Resources.IdProvider.IdProviderFactory import IdProviderFactory
251+
252252
result = IdProviderFactory().getIdProvider("DIRACCLI")
253253
if not result["OK"]:
254254
return result
@@ -531,6 +531,11 @@ def _request(self, retry=0, outputFile=None, **kwargs):
531531

532532
# Use access token?
533533
elif self.__useAccessToken:
534+
from DIRAC.FrameworkSystem.private.authorization.utils.Tokens import (
535+
getLocalTokenDict,
536+
writeTokenDictToTokenFile,
537+
)
538+
534539
# Read token from token environ variable or from token file
535540
result = getLocalTokenDict()
536541
if not result["OK"]:

src/DIRAC/FrameworkSystem/Client/MonitoringClient.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from DIRAC.Core.Utilities.LockRing import LockRing
1919
from DIRAC.ConfigurationSystem.Client import PathFinder
2020
from DIRAC.Core.Utilities import Time, Network, ThreadScheduler
21-
from DIRAC.Core.DISET.RPCClient import RPCClient
21+
from DIRAC.Core.Base.Client import Client
2222

2323

2424
class MonitoringClientActivityNotDefined(Exception):
@@ -395,7 +395,7 @@ def __sendData(self, secsTimeout=False):
395395
else:
396396
self.logger.debug("Creating RPC client")
397397
# Here is where the client is created from the running Framework/Monitoring service.
398-
rpcClient = RPCClient("Framework/Monitoring", timeout=secsTimeout)
398+
rpcClient = Client(url="Framework/Monitoring", timeout=secsTimeout)
399399
# Send registrations
400400
if not self.__sendRegistration(rpcClient):
401401
return False
@@ -475,7 +475,7 @@ def getComponentsStatus(self, condDict):
475475
:param condDict: A condition dictionary.
476476
:return: S_OK with status and message about the component.
477477
"""
478-
rpcClient = RPCClient("Framework/Monitoring", timeout=100)
478+
rpcClient = Client(url="Framework/Monitoring", timeout=100)
479479
return rpcClient.getComponentsStatus(condDict)
480480

481481
def __filterComponent(self, component, condDict):

src/DIRAC/FrameworkSystem/Client/PlottingClient.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
import tempfile
1010
from DIRAC import S_OK, S_ERROR
11-
from DIRAC.Core.DISET.RPCClient import RPCClient
1211
from DIRAC.Core.Tornado.Client.ClientSelector import TransferClientSelector as TransferClient
12+
from DIRAC.Core.Base.Client import Client
1313

1414

1515
class PlottingClient(object):
@@ -21,7 +21,7 @@ def __init__(self, rpcClient=None, transferClient=None):
2121
def __getRPCClient(self):
2222
if self.rpcClient:
2323
return self.rpcClient
24-
return RPCClient(self.serviceName)
24+
return Client(url=self.serviceName)
2525

2626
def __getTransferClient(self):
2727
if self.transferClient:

src/DIRAC/FrameworkSystem/Client/ProxyManagerClient.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from DIRAC.Core.Security.X509Request import X509Request # pylint: disable=import-error
1616
from DIRAC.Core.Security.VOMS import VOMS
1717
from DIRAC.Core.Security import Locations
18-
from DIRAC.Core.DISET.RPCClient import RPCClient
18+
from DIRAC.Core.Base.Client import Client
1919

2020
gUsersSync = ThreadSafe.Synchronizer()
2121
gProxiesSync = ThreadSafe.Synchronizer()
@@ -68,7 +68,7 @@ def __refreshUserCache(self, validSeconds=0):
6868
6969
:return: S_OK()/S_ERROR()
7070
"""
71-
rpcClient = RPCClient("Framework/ProxyManager", timeout=120)
71+
rpcClient = Client(url="Framework/ProxyManager", timeout=120)
7272
retVal = rpcClient.getRegisteredUsers(validSeconds)
7373
if not retVal["OK"]:
7474
return retVal
@@ -151,7 +151,7 @@ def setPersistency(self, userDN, userGroup, persistent):
151151
persistentFlag = True
152152
if not persistent:
153153
persistentFlag = False
154-
rpcClient = RPCClient("Framework/ProxyManager", timeout=120)
154+
rpcClient = Client(url="Framework/ProxyManager", timeout=120)
155155
retVal = rpcClient.setPersistency(userDN, userGroup, persistentFlag)
156156
if not retVal["OK"]:
157157
return retVal
@@ -196,7 +196,7 @@ def uploadProxy(self, proxy=None, restrictLifeTime=0, rfcIfPossible=False):
196196
if chain.getDIRACGroup(ignoreDefault=True).get("Value") or chain.isVOMS().get("Value"):
197197
return S_ERROR("Cannot upload proxy with DIRAC group or VOMS extensions")
198198

199-
rpcClient = RPCClient("Framework/ProxyManager", timeout=120)
199+
rpcClient = Client(url="Framework/ProxyManager", timeout=120)
200200
# Get a delegation request
201201
result = rpcClient.requestDelegationUpload(chain.getRemainingSecs()["Value"])
202202
if not result["OK"]:
@@ -237,9 +237,9 @@ def downloadProxy(
237237
req = X509Request()
238238
req.generateProxyRequest(limited=limited)
239239
if proxyToConnect:
240-
rpcClient = RPCClient("Framework/ProxyManager", proxyChain=proxyToConnect, timeout=120)
240+
rpcClient = Client(url="Framework/ProxyManager", proxyChain=proxyToConnect, timeout=120)
241241
else:
242-
rpcClient = RPCClient("Framework/ProxyManager", timeout=120)
242+
rpcClient = Client(url="Framework/ProxyManager", timeout=120)
243243
if token:
244244
retVal = rpcClient.getProxyWithToken(
245245
userDN, userGroup, req.dumpRequest()["Value"], int(cacheTime + requiredTimeLeft), token
@@ -322,9 +322,9 @@ def downloadVOMSProxy(
322322
req = X509Request()
323323
req.generateProxyRequest(limited=limited)
324324
if proxyToConnect:
325-
rpcClient = RPCClient("Framework/ProxyManager", proxyChain=proxyToConnect, timeout=120)
325+
rpcClient = Client(url="Framework/ProxyManager", proxyChain=proxyToConnect, timeout=120)
326326
else:
327-
rpcClient = RPCClient("Framework/ProxyManager", timeout=120)
327+
rpcClient = Client(url="Framework/ProxyManager", timeout=120)
328328
if token:
329329
retVal = rpcClient.getVOMSProxyWithToken(
330330
userDN,
@@ -542,7 +542,7 @@ def deleteProxyBundle(self, idList):
542542
543543
:return: S_OK(int)/S_ERROR()
544544
"""
545-
rpcClient = RPCClient("Framework/ProxyManager", timeout=120)
545+
rpcClient = Client(url="Framework/ProxyManager", timeout=120)
546546
return rpcClient.deleteProxyBundle(idList)
547547

548548
def requestToken(self, requesterDN, requesterGroup, numUses=1):
@@ -555,7 +555,7 @@ def requestToken(self, requesterDN, requesterGroup, numUses=1):
555555
556556
:return: S_OK(tuple)/S_ERROR() -- tuple contain token, number uses
557557
"""
558-
rpcClient = RPCClient("Framework/ProxyManager", timeout=120)
558+
rpcClient = Client(url="Framework/ProxyManager", timeout=120)
559559
return rpcClient.generateToken(requesterDN, requesterGroup, numUses)
560560

561561
def renewProxy(self, proxyToBeRenewed=None, minLifeTime=3600, newProxyLifeTime=43200, proxyToConnect=None):
@@ -641,7 +641,7 @@ def getDBContents(self, condDict={}, sorting=[["UserDN", "DESC"]], start=0, limi
641641
642642
:return: S_OK(dict)/S_ERROR() -- dict contain fields, record list, total records
643643
"""
644-
rpcClient = RPCClient("Framework/ProxyManager", timeout=120)
644+
rpcClient = Client(url="Framework/ProxyManager", timeout=120)
645645
return rpcClient.getContents(condDict, sorting, start, limit)
646646

647647
def getVOMSAttributes(self, chain):
@@ -683,7 +683,7 @@ def getUserProxiesInfo(self):
683683
684684
:return: S_OK(dict)/S_ERROR()
685685
"""
686-
result = RPCClient("Framework/ProxyManager", timeout=120).getUserProxiesInfo()
686+
result = Client(url="Framework/ProxyManager", timeout=120).getUserProxiesInfo()
687687
if "rpcStub" in result:
688688
result.pop("rpcStub")
689689
return result

src/DIRAC/FrameworkSystem/Client/SecurityLogClient.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import syslog
88

99
from DIRAC import gLogger, gConfig
10-
from DIRAC.Core.DISET.RPCClient import RPCClient
10+
from DIRAC.Core.Base.Client import Client
1111
from DIRAC.Core.Utilities import Time
1212
from DIRAC.Core.Utilities.ThreadScheduler import gThreadScheduler
1313

@@ -67,7 +67,7 @@ def __sendData(self):
6767
gLogger.debug("Sending records to security log service...")
6868
msgList = self.__messagesList
6969
self.__messagesList = []
70-
rpcClient = RPCClient("Framework/SecurityLogging")
70+
rpcClient = Client(url="Framework/SecurityLogging")
7171
for _i in range(0, len(msgList), self.__maxMessagesInBundle):
7272
msgsToSend = msgList[: self.__maxMessagesInBundle]
7373
result = rpcClient.logActionBundle(msgsToSend)

src/DIRAC/FrameworkSystem/Client/UserProfileClient.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33
from __future__ import print_function
44

55
from DIRAC import S_OK, S_ERROR
6-
from DIRAC.Core.DISET.RPCClient import RPCClient
6+
from DIRAC.Core.Base.Client import Client
77
from DIRAC.Core.Utilities import DEncode
88

99

1010
class UserProfileClient(object):
11-
def __init__(self, profile, rpcClientFunctor=RPCClient):
11+
def __init__(self, profile, rpcClientFunctor=Client):
1212
self.rpcClientFunctor = rpcClientFunctor
1313
self.profile = profile
1414

1515
def __getRPCClient(self):
16-
return self.rpcClientFunctor("Framework/UserProfileManager")
16+
return self.rpcClientFunctor(url="Framework/UserProfileManager")
1717

1818
def storeVar(self, varName, data, perms={}):
1919
try:

0 commit comments

Comments
 (0)