ResourceManagementClient

ResourceManagementClient

Client to interact with the ResourceManagementDB.

class DIRAC.ResourceStatusSystem.Client.ResourceManagementClient.ResourceManagementClient

Bases: object

The ResourceManagementClient class exposes the DIRAC.ResourceManagement API. All functions you need are on this client.

It has the ‘direct-db-access’ functions, the ones of the type:
  • insert
  • update
  • select
  • delete

that return parts of the RSSConfiguration stored on the CS, and used everywhere on the RSS module. Finally, and probably more interesting, it exposes a set of functions, badly called ‘boosters’. They are ‘home made’ functions using the basic database functions that are interesting enough to be exposed.

The client will ALWAYS try to connect to the DB, and in case of failure, to the XML-RPC server ( namely ResourceManagementDB and ResourceManagementHandler ).

You can use this client on this way

>>> from DIRAC.ResourceManagementSystem.Client.ResourceManagementClient import ResourceManagementClient
>>> rsClient = ResourceManagementClient()

All functions calling methods exposed on the database or on the booster are making use of some syntactic sugar, in this case a decorator that simplifies the client considerably.

__init__

x.__init__(…) initializes x; see help(type(x)) for signature

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.

Parameters:
  • gocSite (str) –
  • link (str) – url to the details
  • openTickets (int) –
  • tickets (str) –
  • lastCheckTime (datetime) – timestamp setting last time the result was checked
Returns:

S_OK() || S_ERROR()

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)

Adds or updates-if-duplicated to PilotCache. Using site and cE to query the database, decides whether to insert or update the table.

Parameters:
  • site (str) – name of the site
  • cE (str) – name of the CE of ‘Multiple’ if all site CEs are considered
  • pilotsPerJob (float) – measure calculated
  • pilotJobEff (flaot) – percentage
  • status (str) – status of the CE / Site
  • lastCheckTime (datetime) – measure calculated
Returns:

S_OK() || S_ERROR()

addOrModifyPolicyResult(element=None, name=None, policyName=None, statusType=None, status=None, reason=None, dateEffective=None, lastCheckTime=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.

Parameters:
  • endpoint (string, list) – srm endpoint
  • token (str) – name of the token
  • total (int) – total terabytes
  • guaranteed (int) – guaranteed terabytes
  • free (int) – free terabytes
  • lastCheckTime (datetime) – time-stamp from which the result is effective
Returns:

S_OK() || S_ERROR()

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:
  • elementName (str) – name of the element
  • direction (str) – the element taken as Source or Destination of the transfer
  • metric (str) – measured quality of failed transfers
  • value (float) – percentage
  • lastCheckTime (datetime) – time-stamp setting last time the result was checked
Returns:

S_OK() || S_ERROR()

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.

Parameters:
  • gocSite (str) –
  • link (str) – url to the details
  • openTickets (int) –
  • tickets (str) –
  • lastCheckTime (datetime) – timestamp setting last time the result was checked
Returns:

S_OK() || S_ERROR()

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)

Deletes 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
  • pilotsPerJob (float, list) – measure calculated
  • pilotJobEff (float, list) – percentage
  • status (float, list) – status of the CE / Site
  • lastCheckTime (datetime, list) – measure calculated
Returns:

S_OK() || S_ERROR()

deletePolicyResult(element=None, name=None, policyName=None, statusType=None, status=None, reason=None, dateEffective=None, lastCheckTime=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:
  • endpoint (string, list) – srm 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
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:
  • 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
  • value (float, list) – percentage
  • lastCheckTime (float, list) – time-stamp setting last time the result was checked
Returns:

S_OK() || S_ERROR()

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 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)

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
  • pilotsPerJob (float, list) – measure calculated
  • pilotJobEff (float, list) – percentage
  • status (float, list) – status of the CE / Site
  • 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)

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) – srm 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
  • value (float, list) – percentage
  • 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()

DIRAC.ResourceStatusSystem.Client.ResourceManagementClient.uppercase_first_letter(key)

a method that makes the first letter uppercase only (and leaves the remaining letters unaffected)