ResourceManagementClient
ResourceManagementClient
Client to interact with the ResourceManagement service and from it with the DB.
- class DIRAC.ResourceStatusSystem.Client.ResourceManagementClient.ResourceManagementClient(**kwargs)
Bases:
Client
The
ResourceManagementClient
class exposes theDIRAC.ResourceManagement
API. All functions you need are on this client.You can use this client on this way
>>> from DIRAC.ResourceManagementSystem.Client.ResourceManagementClient import ResourceManagementClient >>> rsClient = ResourceManagementClient()
- __init__(**kwargs)
C’tor.
- Parameters:
kwargs – just stored as an attribute and passed when creating the RPCClient
- addOrModify(self, table, params, **kwargs)
This method is a bridge to access
ResourceManagementDB
remotely. It does not add neither processing nor validation. If you need to know more about this method, you must keep reading on the database documentation.- Parameters:
table – string or dict - should contain the table from which querying
- Paract dict params:
arguments for the mysql query. Currently it is being used only for column selection.
For example: meta = {‘columns’: [‘Name’]} will return only the ‘Name’ column.
- Returns:
S_OK() || S_ERROR()
Automatically created for the service function
export_addOrModify()
- addOrModifyAccountingCache(name=None, plotType=None, plotName=None, result=None, dateEffective=None, lastCheckTime=None)
Adds or updates-if-duplicated to AccountingCache. Using name, plotType and plotName to query the database, decides whether to insert or update the table.
- Parameters:
name (str) – name of an individual of the grid topology
plotType (str) – name (e.g. ‘Pilot’)
plotName (str) – the plot name
result (str) – command result
dateEffective (datetime) – timestamp from which the result is effective
lastCheckTime (datetime) – timestamp setting last time the result was checked
- Returns:
S_OK() || S_ERROR()
- addOrModifyDowntimeCache(downtimeID=None, element=None, name=None, startDate=None, endDate=None, severity=None, description=None, link=None, dateEffective=None, lastCheckTime=None, gOCDBServiceType=None)
Adds or updates-if-duplicated to DowntimeCache. Using downtimeID to query the database, decides whether to insert or update the table.
- Parameters:
downtimeID (str) – unique id for the downtime
element (str) – valid element in the topology ( Site, Resource, Node )
name (str) – name of the element where the downtime applies
startDate (datetime) – starting time for the downtime
endDate (datetime) – ending time for the downtime
severity (str) – severity assigned by the gocdb
description (str) – brief description of the downtime
link (str) – url to the details
dateEffective (datetime) – time when the entry was created in this database
lastCheckTime (datetime) – timestamp setting last time the result was checked
gOCDBServiceType (str) – service type assigned by gocdb
- Returns:
S_OK() || S_ERROR()
- addOrModifyGGUSTicketsCache(gocSite=None, link=None, openTickets=None, tickets=None, lastCheckTime=None)
Adds or updates-if-duplicated to GGUSTicketsCache all rows that match the parameters given.
- addOrModifyJobCache(site=None, maskStatus=None, efficiency=None, status=None, lastCheckTime=None)
Adds or updates-if-duplicated to JobCache. Using site to query the database, decides whether to insert or update the table.
- Parameters:
site (string, list) – name of the site element
maskStatus (string, list) – maskStatus for the site
efficiency (float, list) – job efficiency ( successful / total )
status (string, list) – status for the site computed
lastCheckTime (datetime, list) – time-stamp setting last time the result was checked
- Returns:
S_OK() || S_ERROR()
- addOrModifyPilotCache(site=None, cE=None, pilotsPerJob=None, pilotJobEff=None, status=None, lastCheckTime=None, vO=None)
Adds or updates-if-duplicated to PilotCache. Using site and cE to query the database, decides whether to insert or update the table.
- Parameters:
- Returns:
S_OK() || S_ERROR()
- addOrModifyPolicyResult(element=None, name=None, policyName=None, statusType=None, status=None, reason=None, dateEffective=None, lastCheckTime=None, vO=None)
Adds or updates-if-duplicated to PolicyResult. Using name, policyName and statusType to query the database, decides whether to insert or update the table.
- Parameters:
element (str) – it has to be a valid element ( ValidElement ), any of the defaults: ‘Site’ | ‘Service’ | ‘Resource’ | ‘StorageElement’
name (str) – name of the element
policyName (str) – name of the policy
statusType (str) – it has to be a valid status type for the given element
status (str) – it has to be a valid status, any of the defaults: ‘Active’ | ‘Degraded’ | ‘Probing’ | ‘Banned’
reason (str) – decision that triggered the assigned status
dateEffective (datetime) – time-stamp from which the policy result is effective
lastCheckTime (datetime) – time-stamp setting last time the policy result was checked
- Returns:
S_OK() || S_ERROR()
- addOrModifySpaceTokenOccupancyCache(endpoint=None, token=None, total=None, guaranteed=None, free=None, lastCheckTime=None)
Adds or updates-if-duplicated to SpaceTokenOccupancyCache. Using site and token to query the database, decides whether to insert or update the table.
- addOrModifyTransferCache(sourceName=None, destinationName=None, metric=None, value=None, lastCheckTime=None)
Adds or updates-if-duplicated to TransferCache. Using elementName, direction and metric to query the database, decides whether to insert or update the table.
- Parameters:
- Returns:
S_OK() || S_ERROR()
- property call
To be removed once we’re sure self.call has been removed
- Type:
Deprecated
- delete(self, table, params, **kwargs)
This method is a bridge to access
ResourceManagementDB
remotely. It does not add neither processing nor validation. If you need to know more about this method, you must keep reading on the database documentation.- Parameters:
table – string or dict - should contain the table from which querying
- Paract dict params:
arguments for the mysql query. Currently it is being used only for column selection.
For example: meta = {‘columns’: [‘Name’]} will return only the ‘Name’ column.
- Returns:
S_OK() || S_ERROR()
Automatically created for the service function
export_delete()
- deleteAccountingCache(name=None, plotType=None, plotName=None, result=None, dateEffective=None, lastCheckTime=None)
Deletes from AccountingCache all rows that match the parameters given.
- Parameters:
name (str) – name of an individual of the grid topology
plotType (str) – the plotType name (e.g. ‘Pilot’)
plotName (str) – the plot name
result (str) – command result
dateEffective (datetime) – timestamp from which the result is effective
lastCheckTime (datetime) – timestamp setting last time the result was checked
- Returns:
S_OK() || S_ERROR()
- deleteDowntimeCache(downtimeID=None, element=None, name=None, startDate=None, endDate=None, severity=None, description=None, link=None, dateEffective=None, lastCheckTime=None, gOCDBServiceType=None)
Deletes from DowntimeCache all rows that match the parameters given.
- Parameters:
downtimeID (string, list) – unique id for the downtime
element (string, list) – valid element in the topology ( Site, Resource, Node )
name (string, list) – name of the element where the downtime applies
startDate (datetime, list) – starting time for the downtime
endDate (datetime, list) – ending time for the downtime
severity (string, list) – severity assigned by the gocdb
description (string, list) – brief description of the downtime
link (string, list) – url to the details
dateEffective (datetime, list) – time when the entry was created in this database
lastCheckTime (datetime, list) – time-stamp setting last time the result was checked
gOCDBServiceType (str) – service type assigned by gocdb
- Returns:
S_OK() || S_ERROR()
- deleteGGUSTicketsCache(gocSite=None, link=None, openTickets=None, tickets=None, lastCheckTime=None)
Deletes from GGUSTicketsCache all rows that match the parameters given.
- deleteJobCache(site=None, maskStatus=None, efficiency=None, status=None, lastCheckTime=None)
Deletes from JobCache all rows that match the parameters given.
- Parameters:
site (string, list) – name of the site element
maskStatus (string, list) – maskStatus for the site
efficiency (float, list) – job efficiency ( successful / total )
status (string, list) – status for the site computed
lastCheckTime (datetime, list) – timestamp setting last time the result was checked
- Returns:
S_OK() || S_ERROR()
- deletePilotCache(site=None, cE=None, pilotsPerJob=None, pilotJobEff=None, status=None, lastCheckTime=None, vO=None)
Deletes from TransferCache all rows that match the parameters given.
- deletePolicyResult(element=None, name=None, policyName=None, statusType=None, status=None, reason=None, dateEffective=None, lastCheckTime=None, vO=None)
Deletes from PolicyResult all rows that match the parameters given.
- Parameters:
granularity (string, list) – it has to be a valid element ( ValidElement ), any of the defaults: ‘Site’ | ‘Service’ | ‘Resource’ | ‘StorageElement’
name (string, list) – name of the element
policyName (string, list) – name of the policy
statusType (string, list) – it has to be a valid status type for the given granularity
status (string, list) – it has to be a valid status, any of the defaults: ‘Active’ | ‘Degraded’ | ‘Probing’ | ‘Banned’
reason (string, list) – decision that triggered the assigned status
dateEffective (datetime) – time-stamp from which the policy result is effective
lastCheckTime (datetime, list) – time-stamp setting last time the policy result was checked
- Returns:
S_OK() || S_ERROR()
- deleteSpaceTokenOccupancyCache(endpoint=None, token=None, total=None, guaranteed=None, free=None, lastCheckTime=None)
Deletes from SpaceTokenOccupancyCache all rows that match the parameters given.
- Parameters:
- Returns:
S_OK() || S_ERROR()
- deleteTransferCache(sourceName=None, destinationName=None, metric=None, value=None, lastCheckTime=None)
Deletes from TransferCache all rows that match the parameters given.
- Parameters:
- Returns:
S_OK() || S_ERROR()
- executeRPC(*parms, **kws)
This method extracts some parameters from kwargs that are used as parameter of the constructor or RPCClient. Unfortunately, only a few of all the available parameters of BaseClient are exposed.
- Parameters:
rpc – if an RPC client is passed, use that one
timeout – we can change the timeout on a per call bases. Default is self.timeout
url – We can specify which url to use
- getClientKWArgs()
Returns a copy of the connection arguments
- getServer()
Getter for the server url. Useful ?
- httpsClient
alias of
TornadoClient
- insert(self, table, params, **kwargs)
This method is a bridge to access
ResourceManagementDB
remotely. It does not add neither processing nor validation. If you need to know more about this method, you must keep reading on the database documentation.- Parameters:
table – string or dict - should contain the table from which querying
- Paract dict params:
arguments for the mysql query. Currently it is being used only for column selection.
For example: meta = {‘columns’: [‘Name’]} will return only the ‘Name’ column.
- Returns:
S_OK() || S_ERROR()
Automatically created for the service function
export_insert()
- select(self, table, params, **kwargs)
This method is a bridge to access
ResourceManagementDB
remotely. It does not add neither processing nor validation. If you need to know more about this method, you must keep reading on the database documentation.- Parameters:
table – string or dict - should contain the table from which querying
- Paract dict params:
arguments for the mysql query. Currently it is being used only for column selection.
For example: meta = {‘columns’: [‘Name’]} will return only the ‘Name’ column.
- Returns:
S_OK() || S_ERROR()
Automatically created for the service function
export_select()
- selectAccountingCache(name=None, plotType=None, plotName=None, result=None, dateEffective=None, lastCheckTime=None, meta=None)
Gets from PolicyResult all rows that match the parameters given.
- Parameters:
name (string, list) – name of an individual of the grid topology
plotType (string, list) – the plotType name (e.g. ‘Pilot’)
plotName (string, list) – the plot name
result (string, list) – command result
dateEffective (datetime, list) – time-stamp from which the result is effective
lastCheckTime (datetime, list) – time-stamp setting last time the result was checked
meta (dict) – metadata for the mysql query. Currently it is being used only for column selection. For example: meta={‘columns’: [‘Name’]} will return only the ‘Name’ column.
- Returns:
S_OK() || S_ERROR()
- selectDowntimeCache(downtimeID=None, element=None, name=None, startDate=None, endDate=None, severity=None, description=None, link=None, dateEffective=None, lastCheckTime=None, gOCDBServiceType=None, meta=None)
Gets from DowntimeCache all rows that match the parameters given.
- Parameters:
downtimeID (string, list) – unique id for the downtime
element (string, list) – valid element in the topology (Site, Resource, Node)
name (string, list) – name of the element(s) where the downtime applies
startDate (datetime, list) – starting time for the downtime
endDate (datetime, list) – ending time for the downtime
severity (string, list) – severity assigned by the gocdb
description (string, list) – brief description of the downtime
link (string, list) – url to the details
dateEffective (datetime, list) – time when the entry was created in this database
lastCheckTime (datetime, list) – timestamp setting last time the result was checked
gOCDBServiceType (str) – service type assigned by gocdb
meta (dict) – metadata for the mysql query. Currently it is being used only for column selection. For example: meta={‘columns’: [‘Name’]} will return only the ‘Name’ column.
- Returns:
S_OK() || S_ERROR()
- selectGGUSTicketsCache(gocSite=None, link=None, openTickets=None, tickets=None, lastCheckTime=None, meta=None)
Gets from GGUSTicketsCache all rows that match the parameters given.
- Parameters:
gocSite (str)
link (str) – url to the details
openTickets (int)
tickets (str)
lastCheckTime (datetime) – timestamp setting last time the result was checked
meta (dict) – metadata for the mysql query. Currently it is being used only for column selection. For example: meta={‘columns’: [‘Name’]} will return only the ‘Name’ column.
- Returns:
S_OK() || S_ERROR()
- selectJobCache(site=None, maskStatus=None, efficiency=None, status=None, lastCheckTime=None, meta=None)
Gets from JobCache all rows that match the parameters given.
- Parameters:
site (string, list) – name of the site element
maskStatus (string, list) – maskStatus for the site
efficiency (float, list) – job efficiency ( successful / total )
status (string, list) – status for the site computed
lastCheckTime (datetime, list) – timestamp setting last time the result was checked
meta (dict) – metadata for the mysql query. Currently it is being used only for column selection. For example: meta={‘columns’: [‘Name’]} will return only the ‘Name’ column.
- Returns:
S_OK() || S_ERROR()
- selectPilotCache(site=None, cE=None, pilotsPerJob=None, pilotJobEff=None, status=None, lastCheckTime=None, meta=None, vO=None)
Gets from TransferCache all rows that match the parameters given.
- Parameters:
site (string, list) – name of the site
cE (string, list) – name of the CE of ‘Multiple’ if all site CEs are considered
lastCheckTime (datetime, list) – measure calculated
meta (dict) – metadata for the mysql query. Currently it is being used only for column selection. For example: meta={‘columns’: [‘Name’]} will return only the ‘Name’ column.
- Returns:
S_OK() || S_ERROR()
- selectPolicyResult(element=None, name=None, policyName=None, statusType=None, status=None, reason=None, lastCheckTime=None, meta=None, vO=None)
Gets from PolicyResult all rows that match the parameters given.
- Parameters:
granularity (string, list) – it has to be a valid element ( ValidElement ), any of the defaults: ‘Site’ | ‘Service’ | ‘Resource’ | ‘StorageElement’
name (string, list) – name of the element
policyName (string, list) – name of the policy
statusType (string, list) – it has to be a valid status type for the given granularity
status (string, list) – it has to be a valid status, any of the defaults: ‘Active’ | ‘Degraded’ | ‘Probing’ | ‘Banned’
reason (string, list) – decision that triggered the assigned status
lastCheckTime (datetime, list) – time-stamp setting last time the policy result was checked
meta (dict) – metadata for the mysql query. Currently it is being used only for column selection. For example: meta={‘columns’: [‘Name’]} will return only the ‘Name’ column.
- Returns:
S_OK() || S_ERROR()
- selectSpaceTokenOccupancyCache(endpoint=None, token=None, total=None, guaranteed=None, free=None, lastCheckTime=None, meta=None)
Gets from SpaceTokenOccupancyCache all rows that match the parameters given.
- Parameters:
endpoint (string, list) – endpoint
token (string, list) – name of the token
total (integer, list) – total terabytes
guaranteed (integer, list) – guaranteed terabytes
free (integer, list) – free terabytes
lastCheckTime (datetime, list) – time-stamp from which the result is effective
meta (dict) – metadata for the mysql query. Currently it is being used only for column selection. For example: meta={‘columns’: [‘Name’]} will return only the ‘Name’ column.
- Returns:
S_OK() || S_ERROR()
- selectTransferCache(sourceName=None, destinationName=None, metric=None, value=None, lastCheckTime=None, meta=None)
Gets from TransferCache all rows that match the parameters given.
- Parameters:
elementName (string, list) – name of the element
direction (string, list) – the element taken as Source or Destination of the transfer
metric (string, list) – measured quality of failed transfers
lastCheckTime (float, list) – time-stamp setting last time the result was checked
meta (dict) – metadata for the mysql query. Currently it is being used only for column selection. For example: meta={‘columns’: [‘Name’]} will return only the ‘Name’ column.
- Returns:
S_OK() || S_ERROR()
- setServer(url)
Set the server URL used by default
- Parameters:
url – url of the service
- DIRAC.ResourceStatusSystem.Client.ResourceManagementClient.prepareDict(columnNames, columnValues)
Convert 2 same size lists into a key->value dict. All Nonetype values are removed.