InstalledComponentsDB
Classes and functions for easier management of the InstalledComponents database
- class DIRAC.FrameworkSystem.DB.InstalledComponentsDB.Component(system=<sqlalchemy.sql.elements.Null object>, module=<sqlalchemy.sql.elements.Null object>, cType=<sqlalchemy.sql.elements.Null object>)
Bases:
Base
This class defines the schema of the Components table in the InstalledComponentsDB database
- __init__(system=<sqlalchemy.sql.elements.Null object>, module=<sqlalchemy.sql.elements.Null object>, cType=<sqlalchemy.sql.elements.Null object>)
just defines some instance members
- cType
- componentID
- fromDict(dictionary)
Fill the fields of the Component object from a dictionary The dictionary may contain the keys: ComponentID, System, Module, Type
- metadata: MetaData = MetaData()
- module
- registry: RegistryType = <sqlalchemy.orm.decl_api.registry object>
- system
- toDict(includeInstallations=False, includeHosts=False)
Return the object as a dictionary If includeInstallations is True, the dictionary returned will also include information about the installations in which this Component is included If includeHosts is also True, further information about the Hosts where the installations are is included
- class DIRAC.FrameworkSystem.DB.InstalledComponentsDB.Host(host=<sqlalchemy.sql.elements.Null object>, cpu=<sqlalchemy.sql.elements.Null object>)
Bases:
Base
This class defines the schema of the Hosts table in the InstalledComponentsDB database
- __init__(host=<sqlalchemy.sql.elements.Null object>, cpu=<sqlalchemy.sql.elements.Null object>)
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.
- cpu
- fromDict(dictionary)
Fill the fields of the Host object from a dictionary The dictionary may contain the keys: HostID, HostName, CPU
- hostID
- hostName
- installationList
- metadata: MetaData = MetaData()
- registry: RegistryType = <sqlalchemy.orm.decl_api.registry object>
- toDict(includeInstallations=False, includeComponents=False)
Return the object as a dictionary If includeInstallations is True, the dictionary returned will also include information about the installations in this Host If includeComponents is also True, further information about which Components where installed is included
- class DIRAC.FrameworkSystem.DB.InstalledComponentsDB.HostLogging(host=<sqlalchemy.sql.elements.Null object>, **kwargs)
Bases:
Base
This class defines the schema of the HostLogging table in the InstalledComponentsDB database
- CPUClock
- CPUModel
- CertificateDN
- CertificateIssuer
- CertificateValidity
- Cores
- DIRAC
- DiskOccupancy
- Extension
- Load1
- Load15
- Load5
- Memory
- OpenFiles
- OpenPipes
- OpenSockets
- PhysicalCores
- Setup
- Swap
- Timestamp
- Uptime
- __init__(host=<sqlalchemy.sql.elements.Null object>, **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 HostLogging object from a dictionary
- hostName
- metadata: MetaData = MetaData()
- registry: RegistryType = <sqlalchemy.orm.decl_api.registry object>
- toDict()
Return the object as a dictionary
- class DIRAC.FrameworkSystem.DB.InstalledComponentsDB.InstalledComponent(instance=<sqlalchemy.sql.elements.Null object>, installationTime=<sqlalchemy.sql.elements.Null object>, unInstallationTime=<sqlalchemy.sql.elements.Null object>, installedBy=<sqlalchemy.sql.elements.Null object>, unInstalledBy=<sqlalchemy.sql.elements.Null object>)
Bases:
Base
This class defines the schema of the InstalledComponents table in the InstalledComponentsDB database
- __init__(instance=<sqlalchemy.sql.elements.Null object>, installationTime=<sqlalchemy.sql.elements.Null object>, unInstallationTime=<sqlalchemy.sql.elements.Null object>, installedBy=<sqlalchemy.sql.elements.Null object>, unInstalledBy=<sqlalchemy.sql.elements.Null object>)
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.
- componentID
- fromDict(dictionary)
Fill the fields of the InstalledComponent object from a dictionary The dictionary may contain the keys: ComponentID, HostID, Instance, InstallationTime, UnInstallationTime
- hostID
- installationComponent
- installationTime
- installedBy
- instance
- metadata: MetaData = MetaData()
- registry: RegistryType = <sqlalchemy.orm.decl_api.registry object>
- toDict(includeComponents=False, includeHosts=False)
Return the object as a dictionary If includeComponents is True, information about which Components where installed is included If includeHosts is True, information about the Hosts where the installations are is included
- unInstallationTime
- unInstalledBy
- class DIRAC.FrameworkSystem.DB.InstalledComponentsDB.InstalledComponentsDB
Bases:
object
Class used to work with the InstalledComponentsDB database. It creates the tables on initialization and allows inserting, querying, deleting from/to the tables
- __init__()
- addComponent(newComponent)
Add a new component to the database newComponent argument should be a dictionary with the Component fields and its values
NOTE: The addition of the items is temporary. To commit the changes to the database it is necessary to call commitChanges()
- addHost(newHost)
Add a new host to the database host argument should be a dictionary with the Host fields and its values
NOTE: The addition of the items is temporary. To commit the changes to the database it is necessary to call commitChanges()
- addInstalledComponent(newInstallation, componentDict, hostDict, forceCreate=False)
Add a new installation of a component to the database installation argument should be a dictionary with the InstalledComponent fields and its values componentDict argument should be a dictionary with the Component fields and its values hostDict argument should be a dictionary with the Host fields and its values If forceCreate is set to True, both the component and the host will be created if they do not exist
NOTE: The addition of the items is temporary. To commit the changes to the database it is necessary to call commitChanges()
- addLog(newLog)
Add a new log to the database newLog argument should be a dictionary with the log fields and its values. Valid keys for newLog include fields that are present in a HostLogging object: HostName, DIRACVersion, Load1, Load5, … of which only HostName is mandatory
- componentExists(component)
Checks whether the given component exists in the database or not
- exists(table, matchFields)
Checks whether an instance matching the given criteria exists table argument must be one the following three: Component, Host, InstalledComponent matchFields argument should be a dictionary with the fields to match. If matchFields is empty, no filtering will be done matchFields may contain entries of the form ‘Component.attribute’ or ‘Host.attribute’ if table equals InstalledComponent
- getComponentByID(cId)
Returns a component given its id
- getComponents(matchFields={}, includeInstallations=False, includeHosts=False)
Returns a list with all the components with matches in the given fields matchFields argument should be a dictionary with the fields to match or empty to get all the instances matchFields also accepts fields of the form <Field.bigger> and <Field.smaller> to filter using > and < relationships includeInstallations indicates whether data about the installations in which the components takes part is to be retrieved includeHosts (only if includeInstallations is set to True) indicates whether data about the host in which there are instances of this component is to be retrieved
- getHostByID(cId)
Returns a host given its id
- getHosts(matchFields={}, includeInstallations=False, includeComponents=False)
Returns a list with all the hosts with matches in the given fields matchFields argument should be a dictionary with the fields to match or empty to get all the instances matchFields also accepts fields of the form <Field.bigger> and <Field.smaller> to filter using > and < relationships includeInstallations indicates whether data about the installations in which the host takes part is to be retrieved includeComponents (only if includeInstallations is set to True) indicates whether data about the components installed into this host is to be retrieved
- getInstalledComponents(matchFields=None, installationsInfo=False)
Returns a list with all the InstalledComponents with matches in the given fields matchFields argument should be a dictionary with the fields to match or empty to get all the instances and may contain entries of the form ‘Component.attribute’ or ‘Host.attribute’ matchFields also accepts fields of the form <Field.bigger> and <Field.smaller> to filter using > and < relationships installationsInfo indicates whether information about the components and host taking part in the installation is to be provided
- getLogs(matchFields={})
Returns a list with all the logs with matches in the given fields matchFields argument should be a dictionary with the fields to match or empty to get all the instances matchFields also accepts fields of the form <Field.bigger> and <Field.smaller> to filter using > and < relationships
- hostExists(host)
Checks whether the given host exists in the database or not
- removeComponents(matchFields=None)
Removes components with matches in the given fields matchFields argument should be a dictionary with the fields and values to match matchFields also accepts fields of the form <Field.bigger> and <Field.smaller> to filter using > and < relationships matchFields argument can be empty to remove all the components
NOTE: The removal of the items is temporary. To commit the changes to the database it is necessary to call commitChanges()
- removeHosts(matchFields={})
Removes hosts with matches in the given fields matchFields argument should be a dictionary with the fields and values to match matchFields also accepts fields of the form <Field.bigger> and <Field.smaller> to filter using > and < relationships matchFields argument can be empty to remove all the hosts
NOTE: The removal of the items is temporary. To commit the changes to the database it is necessary to call commitChanges()
- removeInstalledComponents(matchFields={})
Removes InstalledComponents with matches in the given fields matchFields argument should be a dictionary with the fields and values to match and may contain entries of the form ‘Component.attribute’ or ‘Host.attribute’ matchFields also accepts fields of the form <Field.bigger> and <Field.smaller> to filter using > and < relationships. matchFields argument can be empty to remove all the hosts
NOTE: The removal of the items is temporary. To commit the changes to the database it is necessary to call commitChanges()
- removeLogs(matchFields={})
Removes logs with matches in the given fields matchFields argument should be a dictionary with the fields and values to match matchFields also accepts fields of the form <Field.bigger> and <Field.smaller> to filter using > and < relationships matchFields argument can be empty to remove all the logs
- updateComponents(matchFields={}, updates={})
Updates Components objects on the database matchFields argument should be a dictionary with the fields to match (instances matching the fields will be updated) or empty to update all the instances matchFields also accepts fields of the form <Field.bigger> and <Field.smaller> to filter using > and < relationships updates argument should be a dictionary with the Component fields and their new updated values updates argument should be a dictionary with the Installation fields and their new updated values
- updateHosts(matchFields={}, updates={})
Updates Hosts objects on the database matchFields argument should be a dictionary with the fields to match (instances matching the fields will be updated) or empty to update all the instances matchFields also accepts fields of the form <Field.bigger> and <Field.smaller> to filter using > and < relationships updates argument should be a dictionary with the Host fields and their new updated values updates argument should be a dictionary with the Installation fields and their new updated values
- updateInstalledComponents(matchFields={}, updates={})
Updates installations matching the given criteria matchFields argument should be a dictionary with the fields to match or empty to get all the instances and may contain entries of the form ‘Component.attribute’ or ‘Host.attribute’ matchFields also accepts fields of the form <Field.bigger> and <Field.smaller> to filter using > and < relationships updates argument should be a dictionary with the Installation fields and their new updated values
- updateLogs(matchFields={}, updates={})
Updates logs matching the given criteria matchFields argument should be a dictionary with the fields to match or empty to get all the instances matchFields also accepts fields of the form <Field.bigger> and <Field.smaller> to filter using > and < relationships updates argument should be a dictionary with the logs fields and their new updated values