本文整理汇总了Python中DIRAC.ResourceStatusSystem.Client.ResourceManagementClient.ResourceManagementClient.addOrModifyGGUSTicketsCache方法的典型用法代码示例。如果您正苦于以下问题:Python ResourceManagementClient.addOrModifyGGUSTicketsCache方法的具体用法?Python ResourceManagementClient.addOrModifyGGUSTicketsCache怎么用?Python ResourceManagementClient.addOrModifyGGUSTicketsCache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DIRAC.ResourceStatusSystem.Client.ResourceManagementClient.ResourceManagementClient
的用法示例。
在下文中一共展示了ResourceManagementClient.addOrModifyGGUSTicketsCache方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GGUSTicketsCommand
# 需要导入模块: from DIRAC.ResourceStatusSystem.Client.ResourceManagementClient import ResourceManagementClient [as 别名]
# 或者: from DIRAC.ResourceStatusSystem.Client.ResourceManagementClient.ResourceManagementClient import addOrModifyGGUSTicketsCache [as 别名]
class GGUSTicketsCommand(Command):
"""
GGUSTickets "master" Command
"""
def __init__(self, args=None, clients=None):
super(GGUSTicketsCommand, self).__init__(args, clients)
if "GGUSTicketsClient" in self.apis:
self.gClient = self.apis["GGUSTicketsClient"]
else:
self.gClient = GGUSTicketsClient()
if "ResourceManagementClient" in self.apis:
self.rmClient = self.apis["ResourceManagementClient"]
else:
self.rmClient = ResourceManagementClient()
def _storeCommand(self, result):
"""
Stores the results of doNew method on the database.
"""
for ggus in result:
resQuery = self.rmClient.addOrModifyGGUSTicketsCache(
ggus["GocSite"], ggus["Link"], ggus["OpenTickets"], ggus["Tickets"]
)
if not resQuery["OK"]:
return resQuery
return S_OK()
def _prepareCommand(self):
"""
GGUSTicketsCommand requires one arguments:
- elementName : <str>
GGUSTickets are associated with gocDB names, so we have to transform the
diracSiteName into a gocSiteName.
"""
if not "name" in self.args:
return S_ERROR('"name" not found in self.args')
name = self.args["name"]
return getGOCSiteName(name)
def doNew(self, masterParams=None):
"""
Gets the parameters to run, either from the master method or from its
own arguments.
For every elementName ( cannot process bulk queries.. ) contacts the
ggus client. The server is not very stable, so we protect against crashes.
If there are ggus tickets, are recorded and then returned.
"""
if masterParams is not None:
gocName = masterParams
gocNames = [gocName]
else:
gocName = self._prepareCommand()
if not gocName["OK"]:
return gocName
gocName = gocName["Value"]
gocNames = [gocName]
try:
results = self.gClient.getTicketsList(gocName)
except urllib2.URLError, e:
return S_ERROR("%s %s" % (gocName, e))
if not results["OK"]:
return results
results = results["Value"]
uniformResult = []
for gocSite, ggusResult in results.items():
if not gocSite in gocNames:
continue
ggusDict = {}
ggusDict["GocSite"] = gocSite
ggusDict["Link"] = ggusResult["URL"]
del ggusResult["URL"]
openTickets = 0
for priorityDict in ggusResult.values():
openTickets += len(priorityDict)
ggusDict["Tickets"] = ggusResult
ggusDict["OpenTickets"] = openTickets
uniformResult.append(ggusDict)
#.........这里部分代码省略.........
示例2: GGUSTicketsCommand
# 需要导入模块: from DIRAC.ResourceStatusSystem.Client.ResourceManagementClient import ResourceManagementClient [as 别名]
# 或者: from DIRAC.ResourceStatusSystem.Client.ResourceManagementClient.ResourceManagementClient import addOrModifyGGUSTicketsCache [as 别名]
class GGUSTicketsCommand(Command):
'''
GGUSTickets "master" Command
'''
def __init__(self, args=None, clients=None):
super(GGUSTicketsCommand, self).__init__(args, clients)
if 'GGUSTicketsClient' in self.apis:
self.gClient = self.apis['GGUSTicketsClient']
else:
self.gClient = GGUSTicketsClient()
if 'ResourceManagementClient' in self.apis:
self.rmClient = self.apis['ResourceManagementClient']
else:
self.rmClient = ResourceManagementClient()
def _storeCommand(self, result):
'''
Stores the results of doNew method on the database.
'''
for ggus in result:
resQuery = self.rmClient.addOrModifyGGUSTicketsCache(ggus['GocSite'],
ggus['Link'],
ggus['OpenTickets'],
ggus['Tickets'])
if not resQuery['OK']:
return resQuery
return S_OK()
def _prepareCommand(self):
'''
GGUSTicketsCommand requires one arguments:
- elementName : <str>
GGUSTickets are associated with gocDB names, so we have to transform the
diracSiteName into a gocSiteName.
'''
if 'name' not in self.args:
return S_ERROR('"name" not found in self.args')
name = self.args['name']
return getGOCSiteName(name)
def doNew(self, masterParams=None):
'''
Gets the parameters to run, either from the master method or from its
own arguments.
For every elementName ( cannot process bulk queries.. ) contacts the
ggus client. The server is not very stable, so we protect against crashes.
If there are ggus tickets, are recorded and then returned.
'''
if masterParams is not None:
gocName = masterParams
gocNames = [gocName]
else:
gocName = self._prepareCommand()
if not gocName['OK']:
return gocName
gocName = gocName['Value']
gocNames = [gocName]
try:
results = self.gClient.getTicketsList(gocName)
except urllib2.URLError as e:
return S_ERROR('%s %s' % (gocName, e))
if not results['OK']:
return results
results = results['Value']
uniformResult = []
for gocSite, ggusResult in results.items():
if gocSite not in gocNames:
continue
ggusDict = {}
ggusDict['GocSite'] = gocSite
ggusDict['Link'] = ggusResult['URL']
del ggusResult['URL']
openTickets = 0
for priorityDict in ggusResult.values():
openTickets += len(priorityDict)
ggusDict['Tickets'] = ggusResult
ggusDict['OpenTickets'] = openTickets
uniformResult.append(ggusDict)
#.........这里部分代码省略.........