InstalledComponentsDB

Classes and functions for easier management of the InstalledComponents database

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

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