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:
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]
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.
- columnsOrder = ['Name', 'StatusType', 'Status', 'Reason', 'DateEffective', 'TokenExpiration', 'ElementType', 'LastCheckTime', 'TokenOwner', 'VO']
- 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))
- vo = Column('VO', String(length=64), table=None, primary_key=True, nullable=False, server_default=DefaultClause('all', for_update=False))
- class DIRAC.ResourceStatusSystem.DB.ResourceStatusDB.ElementStatusBaseWithID
Bases:
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
- columnsOrder = ['ID', 'Name', 'StatusType', 'Status', 'Reason', 'DateEffective', 'TokenExpiration', 'ElementType', 'LastCheckTime', 'TokenOwner', 'VO']
- 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))
- vo = Column('VO', String(length=64), table=None, nullable=False, server_default=DefaultClause('all', for_update=False))
- class DIRAC.ResourceStatusSystem.DB.ResourceStatusDB.NodeHistory(**kwargs)
Bases:
ElementStatusBaseWithID
,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.
- columnsOrder = ['ID', 'Name', 'StatusType', 'Status', 'Reason', 'DateEffective', 'TokenExpiration', 'ElementType', 'LastCheckTime', 'TokenOwner', 'VO']
- 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()
- name
- reason
- registry = <sqlalchemy.orm.decl_api.registry object>
- status
- statustype
- toList()
Simply returns a list of column values
- tokenexpiration
- tokenowner
- vo
- class DIRAC.ResourceStatusSystem.DB.ResourceStatusDB.NodeLog(**kwargs)
Bases:
ElementStatusBaseWithID
,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.
- columnsOrder = ['ID', 'Name', 'StatusType', 'Status', 'Reason', 'DateEffective', 'TokenExpiration', 'ElementType', 'LastCheckTime', 'TokenOwner', 'VO']
- 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()
- name
- reason
- registry = <sqlalchemy.orm.decl_api.registry object>
- status
- statustype
- toList()
Simply returns a list of column values
- tokenexpiration
- tokenowner
- vo
- class DIRAC.ResourceStatusSystem.DB.ResourceStatusDB.NodeStatus(**kwargs)
Bases:
ElementStatusBase
,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.
- columnsOrder = ['Name', 'StatusType', 'Status', 'Reason', 'DateEffective', 'TokenExpiration', 'ElementType', 'LastCheckTime', 'TokenOwner', 'VO']
- 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()
- name
- reason
- registry = <sqlalchemy.orm.decl_api.registry object>
- status
- statustype
- toList()
Simply returns a list of column values
- tokenexpiration
- tokenowner
- vo
- class DIRAC.ResourceStatusSystem.DB.ResourceStatusDB.ResourceHistory(**kwargs)
Bases:
ElementStatusBaseWithID
,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.
- columnsOrder = ['ID', 'Name', 'StatusType', 'Status', 'Reason', 'DateEffective', 'TokenExpiration', 'ElementType', 'LastCheckTime', 'TokenOwner', 'VO']
- 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()
- name
- reason
- registry = <sqlalchemy.orm.decl_api.registry object>
- status
- statustype
- toList()
Simply returns a list of column values
- tokenexpiration
- tokenowner
- vo
- class DIRAC.ResourceStatusSystem.DB.ResourceStatusDB.ResourceLog(**kwargs)
Bases:
ElementStatusBaseWithID
,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.
- columnsOrder = ['ID', 'Name', 'StatusType', 'Status', 'Reason', 'DateEffective', 'TokenExpiration', 'ElementType', 'LastCheckTime', 'TokenOwner', 'VO']
- 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()
- name
- reason
- registry = <sqlalchemy.orm.decl_api.registry object>
- status
- statustype
- toList()
Simply returns a list of column values
- tokenexpiration
- tokenowner
- vo
- class DIRAC.ResourceStatusSystem.DB.ResourceStatusDB.ResourceStatus(**kwargs)
Bases:
ElementStatusBase
,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.
- columnsOrder = ['Name', 'StatusType', 'Status', 'Reason', 'DateEffective', 'TokenExpiration', 'ElementType', 'LastCheckTime', 'TokenOwner', 'VO']
- 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()
- name
- reason
- registry = <sqlalchemy.orm.decl_api.registry object>
- status
- statustype
- toList()
Simply returns a list of column values
- tokenexpiration
- tokenowner
- vo
- class DIRAC.ResourceStatusSystem.DB.ResourceStatusDB.ResourceStatusCache(**kwargs)
Bases:
Base
Table for EmailAction
- __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.
- fromDict(dictionary)
Fill the fields of the AccountingCache object from a dictionary
- Parameters:
dictionary – Dictionary to fill a single line
- id
- metadata: MetaData = MetaData()
- name
- previousstatus
- registry: RegistryType = <sqlalchemy.orm.decl_api.registry object>
- sitename
- status
- statustype
- time
- toList()
Simply returns a list of column values
- class DIRAC.ResourceStatusSystem.DB.ResourceStatusDB.ResourceStatusDB(parentLogger=None)
Bases:
SQLAlchemyDB
Class that defines the interactions with the tables of the ResourceStatusDB.
- __init__(parentLogger=None)
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.
- 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.
- delete(table, params)
- getCSOption(optionName, defaultValue=None)
- insert(table, params)
Inserts params in the DB.
- 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:
ElementStatusBaseWithID
,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.
- columnsOrder = ['ID', 'Name', 'StatusType', 'Status', 'Reason', 'DateEffective', 'TokenExpiration', 'ElementType', 'LastCheckTime', 'TokenOwner', 'VO']
- 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()
- name
- reason
- registry = <sqlalchemy.orm.decl_api.registry object>
- status
- statustype
- toList()
Simply returns a list of column values
- tokenexpiration
- tokenowner
- vo
- class DIRAC.ResourceStatusSystem.DB.ResourceStatusDB.SiteLog(**kwargs)
Bases:
ElementStatusBaseWithID
,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.
- columnsOrder = ['ID', 'Name', 'StatusType', 'Status', 'Reason', 'DateEffective', 'TokenExpiration', 'ElementType', 'LastCheckTime', 'TokenOwner', 'VO']
- 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()
- name
- reason
- registry = <sqlalchemy.orm.decl_api.registry object>
- status
- statustype
- toList()
Simply returns a list of column values
- tokenexpiration
- tokenowner
- vo
- class DIRAC.ResourceStatusSystem.DB.ResourceStatusDB.SiteStatus(**kwargs)
Bases:
ElementStatusBase
,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.
- columnsOrder = ['Name', 'StatusType', 'Status', 'Reason', 'DateEffective', 'TokenExpiration', 'ElementType', 'LastCheckTime', 'TokenOwner', 'VO']
- 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()
- name
- reason
- registry = <sqlalchemy.orm.decl_api.registry object>
- status
- statustype
- toList()
Simply returns a list of column values
- tokenexpiration
- tokenowner
- vo