ResourceStatusClient

ResourceStatusClient

Client to interact with the ResourceStatusDB.

class DIRAC.ResourceStatusSystem.Client.ResourceStatusClient.ResourceStatusClient

Bases: object

The ResourceStatusClient class exposes the DIRAC.ResourceStatus 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 ResourceStatusDB and ResourceStatusHancler ).

You can use this client on this way

>>> from DIRAC.ResourceStatusSystem.Client.ResourceStatusClient import ResourceStatusClient
>>> rsClient = ResourceStatusClient()

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

addIfNotThereStatusElement(element, tableType, name=None, statusType=None, status=None, elementType=None, reason=None, dateEffective=None, lastCheckTime=None, tokenOwner=None, tokenExpiration=None)

Adds if-not-duplicated from <element><tableType> and also adds a log if flag is active.

Parameters:
element - string

it has to be a valid element ( ValidElement ), any of the defaults: Site | Resource | Node

tableType - string

it has to be a valid tableType [ ‘Status’, ‘Log’, ‘History’ ]

name - string

name of the individual of class element

statusType - string

it has to be a valid status type for the element class

status - string

it has to be a valid status, any of the defaults: Active | Degraded | Probing | Banned

elementType - string

column to distinguish between the different elements in the same element table.

reason - string

decision that triggered the assigned status

dateEffective - datetime

time-stamp from which the status & status type are effective

lastCheckTime - datetime

time-stamp setting last time the status & status were checked

tokenOwner - string

token assigned to the site & status type

tokenExpiration - datetime

time-stamp setting validity of token ownership

Returns:

S_OK() || S_ERROR()

addOrModifyStatusElement(element, tableType, name=None, statusType=None, status=None, elementType=None, reason=None, dateEffective=None, lastCheckTime=None, tokenOwner=None, tokenExpiration=None)

Adds or updates-if-duplicated from <element><tableType> and also adds a log if flag is active.

Parameters:
element - string

it has to be a valid element ( ValidElement ), any of the defaults: Site | Resource | Node

tableType - string

it has to be a valid tableType [ ‘Status’, ‘Log’, ‘History’ ]

name - string

name of the individual of class element

statusType - string

it has to be a valid status type for the element class

status - string

it has to be a valid status, any of the defaults: Active | Degraded | Probing | Banned

elementType - string

column to distinguish between the different elements in the same element table.

reason - string

decision that triggered the assigned status

dateEffective - datetime

time-stamp from which the status & status type are effective

lastCheckTime - datetime

time-stamp setting last time the status & status were checked

tokenOwner - string

token assigned to the site & status type

tokenExpiration - datetime

time-stamp setting validity of token ownership

Returns:

S_OK() || S_ERROR()

deleteStatusElement(element, tableType, name=None, statusType=None, status=None, elementType=None, reason=None, dateEffective=None, lastCheckTime=None, tokenOwner=None, tokenExpiration=None, meta=None)

Deletes from <element><tableType> all rows that match the parameters given.

Parameters:
element - string

it has to be a valid element ( ValidElement ), any of the defaults: Site | Resource | Node

tableType - string

it has to be a valid tableType [ ‘Status’, ‘Log’, ‘History’ ]

name - [, string, list]

name of the individual of class element

statusType - [, string, list]

it has to be a valid status type for the element class

status - [, string, list]

it has to be a valid status, any of the defaults: Active | Degraded | Probing | Banned

elementType - [, string, list]

column to distinguish between the different elements in the same element table.

reason - [, string, list]

decision that triggered the assigned status

dateEffective - [, datetime, list]

time-stamp from which the status & status type are effective

lastCheckTime - [, datetime, list]

time-stamp setting last time the status & status were checked

tokenOwner - [, string, list]

token assigned to the site & status type

tokenExpiration - [, datetime, list]

time-stamp setting validity of token ownership

meta - dict

metadata for the mysql query

Returns:

S_OK() || S_ERROR()

insertStatusElement(element, tableType, name, statusType, status, elementType, reason, dateEffective, lastCheckTime, tokenOwner, tokenExpiration=None)

Inserts on <element><tableType> a new row with the arguments given.

Parameters:
element - string

it has to be a valid element ( ValidElement ), any of the defaults: Site | Resource | Node

tableType - string

it has to be a valid tableType [ ‘Status’, ‘Log’, ‘History’ ]

name - string

name of the individual of class element

statusType - string

it has to be a valid status type for the element class

status - string

it has to be a valid status, any of the defaults: Active | Degraded | Probing | Banned

elementType - string

column to distinguish between the different elements in the same element table.

reason - string

decision that triggered the assigned status

dateEffective - datetime

time-stamp from which the status & status type are effective

lastCheckTime - datetime

time-stamp setting last time the status & status were checked

tokenOwner - string

token assigned to the site & status type

tokenExpiration - datetime

time-stamp setting validity of token ownership

Returns:

S_OK() || S_ERROR()

modifyStatusElement(element, tableType, name=None, statusType=None, status=None, elementType=None, reason=None, dateEffective=None, lastCheckTime=None, tokenOwner=None, tokenExpiration=None)

Updates from <element><tableType> and also adds a log if flag is active.

Parameters:
element - string

it has to be a valid element ( ValidElement ), any of the defaults: Site | Resource | Node

tableType - string

it has to be a valid tableType [ ‘Status’, ‘Log’, ‘History’ ]

name - string

name of the individual of class element

statusType - string

it has to be a valid status type for the element class

status - string

it has to be a valid status, any of the defaults: Active | Degraded | Probing | Banned

elementType - string

column to distinguish between the different elements in the same element table.

reason - string

decision that triggered the assigned status

dateEffective - datetime

time-stamp from which the status & status type are effective

lastCheckTime - datetime

time-stamp setting last time the status & status were checked

tokenOwner - string

token assigned to the site & status type

tokenExpiration - datetime

time-stamp setting validity of token ownership

Returns:

S_OK() || S_ERROR()

notify(request, params)

Send notification for a given request with its params to the diracAdmin

selectStatusElement(element, tableType, name=None, statusType=None, status=None, elementType=None, reason=None, dateEffective=None, lastCheckTime=None, tokenOwner=None, tokenExpiration=None, meta=None)

Gets from <element><tableType> all rows that match the parameters given.

Parameters:
element - string

it has to be a valid element ( ValidElement ), any of the defaults: Site | Resource | Node

tableType - string

it has to be a valid tableType [ ‘Status’, ‘Log’, ‘History’ ]

name - [, string, list]

name of the individual of class element

statusType - [, string, list]

it has to be a valid status type for the element class

status - [, string, list]

it has to be a valid status, any of the defaults: Active | Degraded | Probing | Banned

elementType - [, string, list]

column to distinguish between the different elements in the same element table.

reason - [, string, list]

decision that triggered the assigned status

dateEffective - [, datetime, list]

time-stamp from which the status & status type are effective

lastCheckTime - [, datetime, list]

time-stamp setting last time the status & status were checked

tokenOwner - [, string, list]

token assigned to the site & status type

tokenExpiration - [, datetime, list]

time-stamp setting validity of token ownership

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