ResourceStatusClient

ResourceStatusClient

Client to interact with the ResourceStatus service and from it with the DB.

class DIRAC.ResourceStatusSystem.Client.ResourceStatusClient.ResourceStatusClient(**kwargs)

Bases: Client

The ResourceStatusClient class exposes the DIRAC.ResourceStatus API. All functions you need are on this client.

You can use this client on this way

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

C’tor.

Parameters:

kwargs – just stored as an attribute and passed when creating the RPCClient

addIfNotThere(self, table, params, **kwargs)

This method is a bridge to access ResourceStatusDB 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 if it’s a dict the query comes from a client prior to v6r18

params - dict

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

Parameters:
  • table – table

  • params – params

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

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

addOrModify(self, table, params, **kwargs)

This method is a bridge to access ResourceStatusDB 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 if it’s a dict the query comes from a client prior to v6r18

params - dict

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

Parameters:
  • table – table

  • params – params

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

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

property call

To be removed once we’re sure self.call has been removed

Type:

Deprecated

delete(tableName, params=None)

Delect rows from the table tableName

Parameters:
  • tableName (str) – the name of the table

  • record (dict) – dictionary of the deletion parameters

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, vO='all')

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

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(tableName, record)

Insert a dictionary record as a row in table tableName

Parameters:
  • tableName (str) – the name of the table

  • record (dict) – dictionary of record to insert in the table

Returns:

S_OK() || S_ERROR()

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

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, vO='all')

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

select(tableName, params=None)

Select rows from the table tableName

Parameters:
  • tableName (str) – the name of the table

  • record (dict) – dictionary of the selection parameters

Returns:

S_OK() || S_ERROR()

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

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

setServer(url)

Set the server URL used by default

Parameters:

url – url of the service