ResourceStatusDB

ResourceStatusDB: This module provides definition of the DB tables, and methods to access them.

Written using sqlalchemy declarative_base

For extending the ResourceStatusDB tables:

  1. In the extended module, call:

from DIRAC.ResourceStatusSystem.DB.ResourceStatusDB import rmsBase, TABLESLIST, TABLESLISTWITHID TABLESLIST = TABLESLIST + [list of new table names] TABLESLISTWITHID = TABLESLISTWITHID + [list of new table names]

  1. provide a declarative_base definition of the tables (new or extended) in the extension module
class DIRAC.ResourceStatusSystem.DB.ResourceStatusDB.ElementStatusBase

Bases: object

Prototype for tables

__init__

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

dateeffective = Column('DateEffective', DateTime(), table=None, nullable=False)
elementtype = Column('ElementType', String(length=32), table=None, nullable=False, server_default=DefaultClause('', for_update=False))
fromDict(dictionary)

Fill the fields of the AccountingCache object from a dictionary

Parameters:dictionary – Dictionary to fill a single line
lastchecktime = Column('LastCheckTime', DateTime(), table=None, nullable=False, server_default=DefaultClause('1000-01-01 00:00:00', for_update=False))
name = Column('Name', String(length=64), table=None, primary_key=True, nullable=False)
reason = Column('Reason', String(length=512), table=None, nullable=False, server_default=DefaultClause('Unspecified', for_update=False))
status = Column('Status', String(length=8), table=None, nullable=False, server_default=DefaultClause('', for_update=False))
statustype = Column('StatusType', String(length=128), table=None, primary_key=True, nullable=False, server_default=DefaultClause('all', for_update=False))
toList()

Simply returns a list of column values

tokenexpiration = Column('TokenExpiration', DateTime(), table=None, nullable=False, server_default=DefaultClause('9999-12-31 23:59:59', for_update=False))
tokenowner = Column('TokenOwner', String(length=16), table=None, nullable=False, server_default=DefaultClause('rs_svc', for_update=False))
class DIRAC.ResourceStatusSystem.DB.ResourceStatusDB.ElementStatusBaseWithID

Bases: DIRAC.ResourceStatusSystem.DB.ResourceStatusDB.ElementStatusBase

Prototype for tables

This is almost the same as ElementStatusBase, with the following differences: - there’s an autoincrement ID column which is also the primary key - the name and statusType components are not part of the primary key

__init__

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

dateeffective = Column('DateEffective', DateTime(), table=None, nullable=False)
elementtype = Column('ElementType', String(length=32), table=None, nullable=False, server_default=DefaultClause('', for_update=False))
fromDict(dictionary)

Fill the fields of the AccountingCache object from a dictionary

Parameters:dictionary – Dictionary to fill a single line
id = Column('ID', BigInteger(), table=None, primary_key=True, nullable=False)
lastchecktime = Column('LastCheckTime', DateTime(), table=None, nullable=False, server_default=DefaultClause('1000-01-01 00:00:00', for_update=False))
name = Column('Name', String(length=64), table=None, nullable=False)
reason = Column('Reason', String(length=512), table=None, nullable=False, server_default=DefaultClause('Unspecified', for_update=False))
status = Column('Status', String(length=8), table=None, nullable=False, server_default=DefaultClause('', for_update=False))
statustype = Column('StatusType', String(length=128), table=None, nullable=False, server_default=DefaultClause('all', for_update=False))
toList()

Simply returns a list of column values

tokenexpiration = Column('TokenExpiration', DateTime(), table=None, nullable=False, server_default=DefaultClause('9999-12-31 23:59:59', for_update=False))
tokenowner = Column('TokenOwner', String(length=16), table=None, nullable=False, server_default=DefaultClause('rs_svc', for_update=False))
class DIRAC.ResourceStatusSystem.DB.ResourceStatusDB.NodeHistory(**kwargs)

Bases: DIRAC.ResourceStatusSystem.DB.ResourceStatusDB.ElementStatusBaseWithID, sqlalchemy.ext.declarative.api.Base

NodeHistory table

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

dateeffective
elementtype
fromDict(dictionary)

Fill the fields of the AccountingCache object from a dictionary

Parameters:dictionary – Dictionary to fill a single line
id
lastchecktime
metadata = MetaData(bind=None)
name
reason
status
statustype
toList()

Simply returns a list of column values

tokenexpiration
tokenowner
class DIRAC.ResourceStatusSystem.DB.ResourceStatusDB.NodeLog(**kwargs)

Bases: DIRAC.ResourceStatusSystem.DB.ResourceStatusDB.ElementStatusBaseWithID, sqlalchemy.ext.declarative.api.Base

NodeLog table

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

dateeffective
elementtype
fromDict(dictionary)

Fill the fields of the AccountingCache object from a dictionary

Parameters:dictionary – Dictionary to fill a single line
id
lastchecktime
metadata = MetaData(bind=None)
name
reason
status
statustype
toList()

Simply returns a list of column values

tokenexpiration
tokenowner
class DIRAC.ResourceStatusSystem.DB.ResourceStatusDB.NodeStatus(**kwargs)

Bases: DIRAC.ResourceStatusSystem.DB.ResourceStatusDB.ElementStatusBase, sqlalchemy.ext.declarative.api.Base

NodeStatus table

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

dateeffective
elementtype
fromDict(dictionary)

Fill the fields of the AccountingCache object from a dictionary

Parameters:dictionary – Dictionary to fill a single line
lastchecktime
metadata = MetaData(bind=None)
name
reason
status
statustype
toList()

Simply returns a list of column values

tokenexpiration
tokenowner
class DIRAC.ResourceStatusSystem.DB.ResourceStatusDB.ResourceHistory(**kwargs)

Bases: DIRAC.ResourceStatusSystem.DB.ResourceStatusDB.ElementStatusBaseWithID, sqlalchemy.ext.declarative.api.Base

ResourceHistory table

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

dateeffective
elementtype
fromDict(dictionary)

Fill the fields of the AccountingCache object from a dictionary

Parameters:dictionary – Dictionary to fill a single line
id
lastchecktime
metadata = MetaData(bind=None)
name
reason
status
statustype
toList()

Simply returns a list of column values

tokenexpiration
tokenowner
class DIRAC.ResourceStatusSystem.DB.ResourceStatusDB.ResourceLog(**kwargs)

Bases: DIRAC.ResourceStatusSystem.DB.ResourceStatusDB.ElementStatusBaseWithID, sqlalchemy.ext.declarative.api.Base

ResourceLog table

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

dateeffective
elementtype
fromDict(dictionary)

Fill the fields of the AccountingCache object from a dictionary

Parameters:dictionary – Dictionary to fill a single line
id
lastchecktime
metadata = MetaData(bind=None)
name
reason
status
statustype
toList()

Simply returns a list of column values

tokenexpiration
tokenowner
class DIRAC.ResourceStatusSystem.DB.ResourceStatusDB.ResourceStatus(**kwargs)

Bases: DIRAC.ResourceStatusSystem.DB.ResourceStatusDB.ElementStatusBase, sqlalchemy.ext.declarative.api.Base

ResourceStatusDB table

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

dateeffective
elementtype
fromDict(dictionary)

Fill the fields of the AccountingCache object from a dictionary

Parameters:dictionary – Dictionary to fill a single line
lastchecktime
metadata = MetaData(bind=None)
name
reason
status
statustype
toList()

Simply returns a list of column values

tokenexpiration
tokenowner
class DIRAC.ResourceStatusSystem.DB.ResourceStatusDB.ResourceStatusDB

Bases: object

Class that defines the interactions with the tables of the ResourceStatusDB.

__init__()

c’tor

Parameters:self – self reference
addIfNotThere(table, params)

Using the PrimaryKeys of the table, it looks for the record in the database. If it is not there, it is inserted as a new entry.

Parameters:
  • table (str) – table where to add or modify
  • params (dict) – dictionary of what to add or modify
Returns:

S_OK() || S_ERROR()

addOrModify(table, params)

Using the PrimaryKeys of the table, it looks for the record in the database. If it is there, it is updated, if not, it is inserted as a new entry.

Parameters:
  • table (str) – table where to add or modify
  • params (dict) – dictionary of what to add or modify
Returns:

S_OK() || S_ERROR()

delete(table, params)
Parameters:
  • table (str) – table from where to delete
  • params (dict) – dictionary of which line(s) to delete
Returns:

S_OK() || S_ERROR()

insert(table, params)

Inserts params in the DB.

Parameters:
  • table (str) – table where to insert
  • params (dict) – Dictionary to fill a single line
Returns:

S_OK() || S_ERROR()

select(table, params)

Uses params to build conditional SQL statement ( WHERE … ).

Parameters:
params - dict

arguments for the mysql query ( must match table columns ! ).

Returns:

S_OK() || S_ERROR()

class DIRAC.ResourceStatusSystem.DB.ResourceStatusDB.SiteHistory(**kwargs)

Bases: DIRAC.ResourceStatusSystem.DB.ResourceStatusDB.ElementStatusBaseWithID, sqlalchemy.ext.declarative.api.Base

SiteHistory table

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

dateeffective
elementtype
fromDict(dictionary)

Fill the fields of the AccountingCache object from a dictionary

Parameters:dictionary – Dictionary to fill a single line
id
lastchecktime
metadata = MetaData(bind=None)
name
reason
status
statustype
toList()

Simply returns a list of column values

tokenexpiration
tokenowner
class DIRAC.ResourceStatusSystem.DB.ResourceStatusDB.SiteLog(**kwargs)

Bases: DIRAC.ResourceStatusSystem.DB.ResourceStatusDB.ElementStatusBaseWithID, sqlalchemy.ext.declarative.api.Base

SiteLog table

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

dateeffective
elementtype
fromDict(dictionary)

Fill the fields of the AccountingCache object from a dictionary

Parameters:dictionary – Dictionary to fill a single line
id
lastchecktime
metadata = MetaData(bind=None)
name
reason
status
statustype
toList()

Simply returns a list of column values

tokenexpiration
tokenowner
class DIRAC.ResourceStatusSystem.DB.ResourceStatusDB.SiteStatus(**kwargs)

Bases: DIRAC.ResourceStatusSystem.DB.ResourceStatusDB.ElementStatusBase, sqlalchemy.ext.declarative.api.Base

SiteStatus table

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

dateeffective
elementtype
fromDict(dictionary)

Fill the fields of the AccountingCache object from a dictionary

Parameters:dictionary – Dictionary to fill a single line
lastchecktime
metadata = MetaData(bind=None)
name
reason
status
statustype
toList()

Simply returns a list of column values

tokenexpiration
tokenowner