ironic.db.sqlalchemy.api module¶
SQLAlchemy storage backend.
- class ironic.db.sqlalchemy.api.Connection[source]¶
Bases:
Connection
SqlAlchemy connection.
- add_node_tag(node_id, tag)[source]¶
Add tag to the node.
If the node_id and tag pair already exists, this should still succeed.
- Parameters:
node_id – The id of a node.
tag – A tag string.
- Returns:
the NodeTag object.
- Raises:
NodeNotFound if the node is not found.
- add_node_trait(node_id, trait, version)[source]¶
Add trait to the node.
If the node_id and trait pair already exists, this should still succeed.
- Parameters:
node_id – The id of a node.
trait – A trait string.
version – the version of the object.Trait.
- Returns:
the NodeTrait object.
- Raises:
InvalidParameterValue if adding the trait would exceed the per-node traits limit.
- Raises:
NodeNotFound if the node is not found.
- bulk_delete_node_history_records(entries)[source]¶
Utility method to bulk delete node history entries.
- Parameters:
entries – A list of node history entry id’s to be queried for deletion.
- check_node_list(idents, project=None)[source]¶
Check a list of node identities and map it to UUIDs.
This call takes a list of node names and/or UUIDs and tries to convert them to UUIDs. It fails early if any identities cannot possible be used as names or UUIDs.
- Parameters:
idents – List of identities.
- Returns:
A mapping from requests identities to node UUIDs.
- Raises:
NodeNotFound if some identities were not found or cannot be valid names or UUIDs.
- check_versions(ignore_models=(), permit_initial_version=False)[source]¶
Checks the whole database for incompatible objects.
This scans all the tables in search of objects that are not supported; i.e., those that are not specified in ironic.common.release_mappings.RELEASE_MAPPING. This includes objects that have null ‘version’ values.
- Parameters:
ignore_models – List of model names to skip.
permit_initial_version – Boolean, default False, to permit a NoSuchTableError exception to be raised by SQLAlchemy and accordingly bypass when an object has it’s initial object version.
- Returns:
A Boolean. True if all the objects have supported versions; False otherwise.
- count_nodes_in_provision_state(state)[source]¶
Count the number of nodes in given provision state.
- Parameters:
state – A provision_state value to match for the count operation. This can be a single provision state value or a list of values.
- create_allocation(values)[source]¶
Create a new allocation.
- Parameters:
values – Dict of values to create an allocation with
- Returns:
An allocation
- Raises:
AllocationDuplicateName
- Raises:
AllocationAlreadyExists
- create_bios_setting_list(node_id, settings, version)[source]¶
Create a list of BIOSSetting records for a given node.
- Parameters:
node_id – The node id.
settings –
A list of BIOS Settings to be created.
[ { 'name': String, 'value': String, additional settings from BIOS registry }, { 'name': String, 'value': String, additional settings from BIOS registry }, ... ]
version – the version of the object.BIOSSetting.
- Returns:
A list of BIOSSetting object.
- Raises:
NodeNotFound if the node is not found.
- Raises:
BIOSSettingAlreadyExists if any of the setting records already exists.
- create_deploy_template(values)[source]¶
Create a deployment template.
- Parameters:
values –
A dict describing the deployment template. For example:
{ 'uuid': uuidutils.generate_uuid(), 'name': 'CUSTOM_DT1', }
- Raises:
DeployTemplateDuplicateName if a deploy template with the same name exists.
- Raises:
DeployTemplateAlreadyExists if a deploy template with the same UUID exists.
- Returns:
A deploy template.
- create_firmware_component(values)[source]¶
Create a FirmwareComponent record for a given node.
- Parameters:
values –
a dictionary with the necessary information to create a FirmwareComponent.
{ 'component': String, 'initial_version': String, 'current_version': String, 'last_version_flashed': String }
- Returns:
A FirmwareComponent object.
- Raises:
FirmwareComponentAlreadyExists if any of the component records already exists.
- create_node(values)[source]¶
Create a new node.
- Parameters:
values –
A dict containing several items used to identify and track the node, and several dicts which are passed into the Drivers when managing this node. For example:
{ 'uuid': uuidutils.generate_uuid(), 'instance_uuid': None, 'power_state': states.POWER_OFF, 'provision_state': states.AVAILABLE, 'driver': 'ipmi', 'driver_info': { ... }, 'properties': { ... }, 'extra': { ... }, }
- Raises:
InvalidParameterValue if ‘values’ contains ‘tags’ or ‘traits’.
- Returns:
A node.
- create_node_history(values)[source]¶
Create a new history record.
- Parameters:
values – Dict of values.
- create_node_inventory(values)[source]¶
Create a new inventory record.
- Parameters:
values – Dict of values.
- create_portgroup(values)[source]¶
Create a new portgroup.
- Parameters:
values – Dict of values with the following keys: ‘id’ ‘uuid’ ‘name’ ‘node_id’ ‘address’ ‘extra’ ‘created_at’ ‘updated_at’
- Returns:
A portgroup
- Raises:
PortgroupDuplicateName
- Raises:
PortgroupMACAlreadyExists
- Raises:
PortgroupAlreadyExists
- create_runbook(values)[source]¶
Create a runbook.
- Parameters:
values –
A dict describing the runbook. For example:
{ 'uuid': uuidutils.generate_uuid(), 'name': 'CUSTOM_DT1', }
- Raises:
RunbookDuplicateName if a runbook with the same name exists.
- Raises:
RunbookAlreadyExists if a runbook with the same UUID exists.
- Returns:
A runbook.
- create_volume_connector(connector_info)[source]¶
Create a new volume connector.
- Parameters:
connector_info –
Dictionary containing information about the connector. Example:
{ 'uuid': '000000-..', 'type': 'wwnn', 'connector_id': '00:01:02:03:04:05:06', 'node_id': 2 }
- Returns:
A volume connector.
- Raises:
VolumeConnectorTypeAndIdAlreadyExists If a connector already exists with a matching type and connector_id.
- Raises:
VolumeConnectorAlreadyExists If a volume connector with the same UUID already exists.
- create_volume_target(target_info)[source]¶
Create a new volume target.
- Parameters:
target_info –
Dictionary containing the information about the volume target. Example:
{ 'uuid': '000000-..', 'node_id': 2, 'boot_index': 0, 'volume_id': '12345678-...' 'volume_type': 'some type', }
- Returns:
A volume target.
- Raises:
VolumeTargetBootIndexAlreadyExists if a volume target already exists with the same boot index and node ID.
- Raises:
VolumeTargetAlreadyExists if a volume target with the same UUID exists.
- delete_bios_setting_list(node_id, names)[source]¶
Delete a list of BIOS settings.
- Parameters:
node_id – The node id.
names – List of BIOS setting names to be deleted.
- Raises:
NodeNotFound if the node is not found.
- Raises:
BIOSSettingNotFound if any of BIOS setting name is not found.
- delete_node_tag(node_id, tag)[source]¶
Delete specified tag from the node.
- Parameters:
node_id – The id of a node.
tag – A tag string.
- Raises:
NodeNotFound if the node is not found.
- Raises:
NodeTagNotFound if the tag is not found.
- delete_node_trait(node_id, trait)[source]¶
Delete specified trait from the node.
- Parameters:
node_id – The id of a node.
trait – A trait string.
- Raises:
NodeNotFound if the node is not found.
- Raises:
NodeTraitNotFound if the trait is not found.
- destroy_allocation(allocation_id)[source]¶
Destroy an allocation.
- Parameters:
allocation_id – Allocation ID or UUID
- Raises:
AllocationNotFound
- destroy_chassis(chassis_id)[source]¶
Destroy a chassis.
- Parameters:
chassis_id – The id or the uuid of a chassis.
- destroy_deploy_template(template_id)[source]¶
Destroy a deployment template.
- Parameters:
template_id – ID of the deployment template to destroy.
- Raises:
DeployTemplateNotFound if the deploy template does not exist.
- destroy_node(node_id)[source]¶
Destroy a node and its associated resources.
Destroy a node, including any associated ports, port groups, tags, traits, volume connectors, and volume targets.
- Parameters:
node_id – The ID or UUID of a node.
- destroy_node_history_by_uuid(history_uuid)[source]¶
Destroy a history record.
- Parameters:
history_uuid – The uuid of a history record
- destroy_node_inventory_by_node_id(node_id)[source]¶
Destroy a inventory record.
- Parameters:
inventory_uuid – The uuid of a inventory record
- destroy_portgroup(portgroup_id)[source]¶
Destroy a portgroup.
- Parameters:
portgroup_id – The UUID or MAC of a portgroup.
- Raises:
PortgroupNotEmpty
- Raises:
PortgroupNotFound
- destroy_runbook(runbook_id)[source]¶
Destroy a runbook.
- Parameters:
runbook_id – ID of the runbook to destroy.
- Raises:
RunbookNotFound if the runbook does not exist.
- destroy_volume_connector(ident)[source]¶
Destroy a volume connector.
- Parameters:
ident – The UUID or integer ID of a volume connector.
- Raises:
VolumeConnectorNotFound If a volume connector with the specified ident does not exist.
- destroy_volume_target(ident)[source]¶
Destroy a volume target.
- Parameters:
ident – The UUID or integer ID of a volume target.
- Raises:
VolumeTargetNotFound if a volume target with the specified ident does not exist.
- get_active_hardware_type_dict(use_groups=False)[source]¶
Retrieve hardware types for the registered and active conductors.
- Parameters:
use_groups – Whether to factor conductor_group into the keys.
- Returns:
A dict which maps hardware type names to the set of hosts which support them. For example:
{hardware-type-a: set([host1, host2]), hardware-type-b: set([host2, host3])}
- get_allocation_by_id(allocation_id)[source]¶
Return an allocation representation.
- Parameters:
allocation_id – The id of an allocation.
- Returns:
An allocation.
- Raises:
AllocationNotFound
- get_allocation_by_name(name)[source]¶
Return an allocation representation.
- Parameters:
name – The logical name of an allocation.
- Returns:
An allocation.
- Raises:
AllocationNotFound
- get_allocation_by_uuid(allocation_uuid)[source]¶
Return an allocation representation.
- Parameters:
allocation_uuid – The uuid of an allocation.
- Returns:
An allocation.
- Raises:
AllocationNotFound
- get_allocation_list(filters=None, limit=None, marker=None, sort_key=None, sort_dir=None)[source]¶
Return a list of allocations.
- Parameters:
filters –
Filters to apply. Defaults to None.
- node_uuid:
uuid of node
- state:
allocation state
- resource_class:
requested resource class
limit – Maximum number of allocations to return.
marker – The last item of the previous page; we return the next result set.
sort_key – Attribute by which results should be sorted.
sort_dir – Direction in which results should be sorted. (asc, desc)
- Returns:
A list of allocations.
- get_bios_setting(node_id, name)[source]¶
Retrieve BIOS setting value.
- Parameters:
node_id – The node id.
name – String containing name of BIOS setting to be retrieved.
- Returns:
The BIOSSetting object.
- Raises:
NodeNotFound if the node is not found.
- Raises:
BIOSSettingNotFound if the BIOS setting is not found.
- get_bios_setting_list(node_id)[source]¶
Retrieve BIOS settings of a given node.
- Parameters:
node_id – The node id.
- Returns:
A list of BIOSSetting objects.
- Raises:
NodeNotFound if the node is not found.
- get_chassis_by_id(chassis_id)[source]¶
Return a chassis representation.
- Parameters:
chassis_id – The id of a chassis.
- Returns:
A chassis.
- get_chassis_by_uuid(chassis_uuid)[source]¶
Return a chassis representation.
- Parameters:
chassis_uuid – The uuid of a chassis.
- Returns:
A chassis.
- get_chassis_list(limit=None, marker=None, sort_key=None, sort_dir=None)[source]¶
Return a list of chassis.
- Parameters:
limit – Maximum number of chassis to return.
marker – the last item of the previous page; we return the next result set.
sort_key – Attribute by which results should be sorted.
sort_dir – direction in which results should be sorted. (asc, desc)
- get_child_node_ids_by_parent_uuid(node_uuid, exclude_dedicated_power=False)[source]¶
Retrieve a list of child node IDs for a given parent UUID.
This is an “internal” method, intended for use with power management logic to facilitate power actions upon nodes, where we obtain a list of nodes which requires additional actions, and return only the required node IDs in order to launch new tasks for power management activities.
- Parameters:
node_uuid – The uuid of the parent node, in order to directly match the “parent_node” field.
exclude_dedicated_power – Boolean, False, if the list should include child nodes with their own power supplies.
- Returns:
A list of tuples.
- get_conductor(hostname, online=True)[source]¶
Retrieve a conductor’s service record from the database.
- Parameters:
hostname – The hostname of the conductor service.
online – Specify the filter value on the online field when querying conductors. The
online
field is ignored if this value is set to None.
- Returns:
A conductor.
- Raises:
ConductorNotFound if the conductor with given hostname does not exist or doesn’t meet the specified online expectation.
- get_conductor_list(limit=None, marker=None, sort_key=None, sort_dir=None)[source]¶
Return a list of conductors.
- Parameters:
limit – Maximum number of conductors to return.
marker – the last item of the previous page; we return the next result set.
sort_key – Attribute by which results should be sorted.
sort_dir – direction in which results should be sorted. (asc, desc)
- get_deploy_template_by_id(template_id)[source]¶
Retrieve a deployment template by ID.
- Parameters:
template_id – ID of the deployment template to retrieve.
- Raises:
DeployTemplateNotFound if the deploy template does not exist.
- Returns:
A deploy template.
- get_deploy_template_by_name(template_name)[source]¶
Retrieve a deployment template by name.
- Parameters:
template_name – name of the deployment template to retrieve.
- Raises:
DeployTemplateNotFound if the deploy template does not exist.
- Returns:
A deploy template.
- get_deploy_template_by_uuid(template_uuid)[source]¶
Retrieve a deployment template by UUID.
- Parameters:
template_uuid – UUID of the deployment template to retrieve.
- Raises:
DeployTemplateNotFound if the deploy template does not exist.
- Returns:
A deploy template.
- get_deploy_template_list(limit=None, marker=None, sort_key=None, sort_dir=None)[source]¶
Retrieve a list of deployment templates.
- Parameters:
limit – Maximum number of deploy templates to return.
marker – The last item of the previous page; we return the next result set.
sort_key – Attribute by which results should be sorted.
sort_dir – Direction in which results should be sorted. (asc, desc)
- Returns:
A list of deploy templates.
- get_deploy_template_list_by_names(names)[source]¶
Return a list of deployment templates with one of a list of names.
- Parameters:
names – List of names to filter by.
- Returns:
A list of deploy templates.
- get_firmware_component(node_id, name)[source]¶
Retrieve Firmware Component.
- Parameters:
node_id – The node id.
name – name of Firmware component.
- Returns:
The FirmwareComponent object.
- Raises:
NodeNotFound if the node is not found.
- Raises:
FirmwareComponentNotFound if the FirmwareComponent is not found.
- get_firmware_component_list(node_id)[source]¶
Retrieve Firmware Components of a given node.
- Parameters:
node_id – The node id.
- Returns:
A list of FirmwareComponent objects.
- Raises:
NodeNotFound if the node is not found.
- get_node_by_id(node_id)[source]¶
Return a node.
- Parameters:
node_id – The id of a node.
- Returns:
A node.
- get_node_by_instance(instance)[source]¶
Return a node.
- Parameters:
instance – The instance uuid to search for.
- Returns:
A node.
- Raises:
InstanceNotFound if the instance is not found.
- Raises:
InvalidUUID if the instance uuid is invalid.
- get_node_by_name(node_name)[source]¶
Return a node.
- Parameters:
node_name – The logical name of a node.
- Returns:
A node.
- get_node_by_port_addresses(addresses)[source]¶
Find a node by any matching port address.
- Parameters:
addresses – list of port addresses (e.g. MACs).
- Returns:
Node object.
- Raises:
NodeNotFound if none or several nodes are found.
- get_node_by_uuid(node_uuid)[source]¶
Return a node.
- Parameters:
node_uuid – The uuid of a node.
- Returns:
A node.
- get_node_history_by_id(history_id)[source]¶
Return a node history representation.
- Parameters:
history_id – The id of a history record.
- Returns:
A history.
- get_node_history_by_node_id(node_id, limit=None, marker=None, sort_key=None, sort_dir=None)[source]¶
List all the history records for a given node.
- Parameters:
node_id – The integer node ID.
limit – Maximum number of history records to return.
marker – the last item of the previous page; we return the next result set.
sort_key – Attribute by which results should be sorted
sort_dir – direction in which results should be sorted (asc, desc)
- Returns:
A list of histories.
- get_node_history_by_uuid(history_uuid)[source]¶
Return a node history representation.
- Parameters:
history_uuid – The uuid of a history record
- Returns:
A history.
- get_node_history_list(limit=None, marker=None, sort_key='created_at', sort_dir='asc')[source]¶
Return a list of node history records
- Parameters:
limit – Maximum number of history records to return.
marker – the last item of the previous page; we return the next result set.
sort_key – Attribute by which results should be sorted.
sort_dir – direction in which results should be sorted. (asc, desc)
- get_node_inventory_by_node_id(node_id)[source]¶
Get the node inventory for a given node.
- Parameters:
node_id – The integer node ID.
- Returns:
An inventory of a node.
- get_node_list(filters=None, limit=None, marker=None, sort_key=None, sort_dir=None, fields=None)[source]¶
Return a list of nodes.
- Parameters:
filters –
Filters to apply. Defaults to None.
- associated:
True | False
- reserved:
True | False
- maintenance:
True | False
- chassis_uuid:
uuid of chassis
- driver:
driver’s name
- provision_state:
provision state of node
- provisioned_before:
nodes with provision_updated_at field before this interval in seconds
- shard:
nodes with the given shard
limit – Maximum number of nodes to return.
marker – the last item of the previous page; we return the next result set.
sort_key – Attribute by which results should be sorted.
sort_dir – direction in which results should be sorted. (asc, desc)
fields – Comma separated field list to return, to allow for only specific fields to be returned to have maximum API performance calls where not all columns are needed from the database.
- get_node_list_columns(columns=None, filters=None, limit=None, marker=None, sort_key=None, sort_dir=None)[source]¶
Get a node list with specific fields/columns.
- Parameters:
columns – A list of columns to retrieve from the database and populate into the object.
filters – The requested database field filters in the form of a dictionary with the applicable key, and filter value.
limit – Limit the number of returned nodes, default None.
marker – Starting marker to generate a paginated result set for the consumer.
sort_key – Sort key to apply to the result set.
sort_dir – Sort direction to apply to the result set.
- Returns:
A list of Node objects based on the data model from a SQLAlchemy result set, which the object layer can use to convert the node into an Node object list.
- get_node_tags_by_node_id(node_id)[source]¶
Get node tags based on its id.
- Parameters:
node_id – The id of a node.
- Returns:
A list of NodeTag objects.
- Raises:
NodeNotFound if the node is not found.
- get_node_traits_by_node_id(node_id)[source]¶
Get node traits based on its id.
- Parameters:
node_id – The id of a node.
- Returns:
A list of NodeTrait objects.
- Raises:
NodeNotFound if the node is not found.
- get_nodeinfo_list(columns=None, filters=None, limit=None, marker=None, sort_key=None, sort_dir=None)[source]¶
Get specific columns for matching nodes.
Return a list of the specified columns for all nodes that match the specified filters.
- Parameters:
columns – List of column names to return. Defaults to ‘id’ column when columns == None.
filters –
Filters to apply. Defaults to None.
- associated:
True | False
- chassis_uuid:
uuid of chassis
- conductor_group:
conductor group name
- console_enabled:
True | False
- description_contains:
substring in description
- driver:
driver’s name
- fault:
current fault type
- id:
numeric ID
- inspection_started_before:
nodes with inspection_started_at field before this interval in seconds
- instance_uuid:
uuid of instance
- lessee:
node’s lessee (e.g. project ID)
- maintenance:
True | False
- owner:
node’s owner (e.g. project ID)
- project:
either owner or lessee
- reserved:
True | False
- reserved_by_any_of:
[conductor1, conductor2]
- resource_class:
resource class name
- retired:
True | False
- shard_in:
shard (multiple possibilities)
- provision_state:
provision state of node
- provision_state_in:
provision state of node (multiple possibilities)
- provisioned_before:
nodes with provision_updated_at field before this interval in seconds
- uuid:
uuid of node
- uuid_in:
uuid of node (multiple possibilities)
- with_power_state:
True | False
limit – Maximum number of nodes to return.
marker – the last item of the previous page; we return the next result set.
sort_key – Attribute by which results should be sorted.
sort_dir – direction in which results should be sorted. (asc, desc)
- Returns:
A list of tuples of the specified columns.
- get_offline_conductors(field='hostname')[source]¶
Get a list conductors that are offline (dead).
- Parameters:
field – A field to return, hostname by default.
- Returns:
A list of requested fields of offline conductors.
- get_online_conductors()[source]¶
Get a list conductor hostnames that are online and active.
- Returns:
A list of conductor hostnames.
- get_port_by_address(address, owner=None, project=None)[source]¶
Return a network port representation.
- Parameters:
address – The MAC address of a port.
- Returns:
A port.
- get_port_by_id(port_id)[source]¶
Return a network port representation.
- Parameters:
port_id – The id of a port.
- Returns:
A port.
- get_port_by_name(port_name)[source]¶
Return a network port representation.
- Parameters:
port_name – The name of a port.
- Returns:
A port.
- get_port_by_uuid(port_uuid)[source]¶
Return a network port representation.
- Parameters:
port_uuid – The uuid of a port.
- Returns:
A port.
- get_port_list(limit=None, marker=None, sort_key=None, sort_dir=None, owner=None, project=None)[source]¶
Return a list of ports.
- Parameters:
limit – Maximum number of ports to return.
marker – the last item of the previous page; we return the next result set.
sort_key – Attribute by which results should be sorted.
sort_dir – direction in which results should be sorted. (asc, desc)
- get_portgroup_by_address(address, project=None)[source]¶
Return a network portgroup representation.
- Parameters:
address – The MAC address of a portgroup.
project – A node owner or lessee to filter by.
- Returns:
A portgroup.
- Raises:
PortgroupNotFound
- get_portgroup_by_id(portgroup_id, project=None)[source]¶
Return a network portgroup representation.
- Parameters:
portgroup_id – The id of a portgroup.
- Returns:
A portgroup.
- Raises:
PortgroupNotFound
- get_portgroup_by_name(name)[source]¶
Return a network portgroup representation.
- Parameters:
name – The logical name of a portgroup.
- Returns:
A portgroup.
- Raises:
PortgroupNotFound
- get_portgroup_by_uuid(portgroup_uuid)[source]¶
Return a network portgroup representation.
- Parameters:
portgroup_uuid – The uuid of a portgroup.
- Returns:
A portgroup.
- Raises:
PortgroupNotFound
- get_portgroup_list(limit=None, marker=None, sort_key=None, sort_dir=None, project=None)[source]¶
Return a list of portgroups.
- Parameters:
limit – Maximum number of portgroups to return.
marker – The last item of the previous page; we return the next result set.
sort_key – Attribute by which results should be sorted.
sort_dir – Direction in which results should be sorted. (asc, desc)
project – A node owner or lessee to filter by.
- Returns:
A list of portgroups.
- get_portgroups_by_node_id(node_id, limit=None, marker=None, sort_key=None, sort_dir=None, project=None)[source]¶
List all the portgroups for a given node.
- Parameters:
node_id – The integer node ID.
limit – Maximum number of portgroups to return.
marker – The last item of the previous page; we return the next result set.
sort_key – Attribute by which results should be sorted
sort_dir – Direction in which results should be sorted (asc, desc)
project – A node owner or lessee to filter by.
- Returns:
A list of portgroups.
- get_ports_by_node_id(node_id, limit=None, marker=None, sort_key=None, sort_dir=None, owner=None, project=None)[source]¶
List all the ports for a given node.
- Parameters:
node_id – The integer node ID.
limit – Maximum number of ports to return.
marker – the last item of the previous page; we return the next result set.
sort_key – Attribute by which results should be sorted
sort_dir – direction in which results should be sorted (asc, desc)
- Returns:
A list of ports.
- get_ports_by_portgroup_id(portgroup_id, limit=None, marker=None, sort_key=None, sort_dir=None, owner=None, project=None)[source]¶
List all the ports for a given portgroup.
- Parameters:
portgroup_id – The integer portgroup ID.
limit – Maximum number of ports to return.
marker – The last item of the previous page; we return the next result set.
sort_key – Attribute by which results should be sorted
sort_dir – Direction in which results should be sorted (asc, desc)
- Returns:
A list of ports.
- get_ports_by_shards(shards, limit=None, marker=None, sort_key=None, sort_dir=None)[source]¶
Return a list of ports contained in the provided shards.
- Parameters:
shard_ids – A list of shards to filter ports by.
- get_runbook_by_id(runbook_id)[source]¶
Retrieve a runbook by ID.
- Parameters:
runbook_id – ID of the runbook to retrieve.
- Raises:
RunbookNotFound if the runbook does not exist.
- Returns:
A runbook.
- get_runbook_by_name(runbook_name)[source]¶
Retrieve a runbook by name.
- Parameters:
runbook_name – name of the runbook to retrieve.
- Raises:
RunbookNotFound if the runbook does not exist.
- Returns:
A runbook.
- get_runbook_by_uuid(runbook_uuid)[source]¶
Retrieve a runbook by UUID.
- Parameters:
runbook_uuid – UUID of the runbook to retrieve.
- Raises:
RunbookNotFound if the runbook does not exist.
- Returns:
A runbook.
- get_runbook_list(limit=None, marker=None, filters=None, sort_key=None, sort_dir=None)[source]¶
Retrieve a list of runbooks.
- Parameters:
limit – Maximum number of runbooks to return.
marker – The last item of the previous page; we return the next result set.
sort_key – Attribute by which results should be sorted.
sort_dir – Direction in which results should be sorted. (asc, desc)
- Returns:
A list of runbooks.
- get_runbook_list_by_names(names)[source]¶
Return a list of runbooks with one of a list of names.
- Parameters:
names – List of names to filter by.
- Returns:
A list of runbooks.
- get_shard_list()[source]¶
Return a list of shards.
- Returns:
A list of dicts containing the keys name and count.
- get_volume_connector_by_id(db_id)[source]¶
Return a volume connector representation.
- Parameters:
db_id – The integer database ID of a volume connector.
- Returns:
A volume connector with the specified ID.
- Raises:
VolumeConnectorNotFound If a volume connector with the specified ID is not found.
- get_volume_connector_by_uuid(connector_uuid)[source]¶
Return a volume connector representation.
- Parameters:
connector_uuid – The UUID of a connector.
- Returns:
A volume connector with the specified UUID.
- Raises:
VolumeConnectorNotFound If a volume connector with the specified UUID is not found.
- get_volume_connector_list(limit=None, marker=None, sort_key=None, sort_dir=None, project=None)[source]¶
Return a list of volume connectors.
- Parameters:
limit – Maximum number of volume connectors to return.
marker – The last item of the previous page; we return the next result set.
sort_key – Attribute by which results should be sorted.
sort_dir – Direction in which results should be sorted. (asc, desc)
project – The associated node project to search with.
- Returns:
a list of
VolumeConnector
objects- Returns:
A list of volume connectors.
- Raises:
InvalidParameterValue If sort_key does not exist.
- get_volume_connectors_by_node_id(node_id, limit=None, marker=None, sort_key=None, sort_dir=None, project=None)[source]¶
List all the volume connectors for a given node.
- Parameters:
node_id – The integer node ID.
limit – Maximum number of volume connectors to return.
marker – The last item of the previous page; we return the next result set.
sort_key – Attribute by which results should be sorted
sort_dir – Direction in which results should be sorted (asc, desc)
project – The associated node project to search with.
- Returns:
a list of
VolumeConnector
objects- Returns:
A list of volume connectors.
- Raises:
InvalidParameterValue If sort_key does not exist.
- get_volume_target_by_id(db_id)[source]¶
Return a volume target representation.
- Parameters:
db_id – The database primary key (integer) ID of a volume target.
- Returns:
A volume target.
- Raises:
VolumeTargetNotFound if no volume target with this ID exists.
- get_volume_target_by_uuid(uuid)[source]¶
Return a volume target representation.
- Parameters:
uuid – The UUID of a volume target.
- Returns:
A volume target.
- Raises:
VolumeTargetNotFound if no volume target with this UUID exists.
- get_volume_target_list(limit=None, marker=None, sort_key=None, sort_dir=None, project=None)[source]¶
Return a list of volume targets.
- Parameters:
limit – Maximum number of volume targets to return.
marker – the last item of the previous page; we return the next result set.
sort_key – Attribute by which results should be sorted.
sort_dir – direction in which results should be sorted. (asc, desc)
project – The associated node project to search with.
- Returns:
a list of
VolumeConnector
objects- Returns:
A list of volume targets.
- Raises:
InvalidParameterValue if sort_key does not exist.
- get_volume_targets_by_node_id(node_id, limit=None, marker=None, sort_key=None, sort_dir=None, project=None)[source]¶
List all the volume targets for a given node.
- Parameters:
node_id – The integer node ID.
limit – Maximum number of volume targets to return.
marker – the last item of the previous page; we return the next result set.
sort_key – Attribute by which results should be sorted
sort_dir – direction in which results should be sorted (asc, desc)
project – The associated node project to search with.
- Returns:
a list of
VolumeConnector
objects- Returns:
A list of volume targets.
- Raises:
InvalidParameterValue if sort_key does not exist.
- get_volume_targets_by_volume_id(volume_id, limit=None, marker=None, sort_key=None, sort_dir=None, project=None)[source]¶
List all the volume targets for a given volume id.
- Parameters:
volume_id – The UUID of the volume.
limit – Maximum number of volume targets to return.
marker – the last item of the previous page; we return the next result set.
sort_key – Attribute by which results should be sorted
sort_dir – direction in which results should be sorted (asc, desc)
- Returns:
A list of volume targets.
- Raises:
InvalidParameterValue if sort_key does not exist.
- list_conductor_hardware_interfaces(conductor_id)[source]¶
List all registered hardware interfaces for a conductor.
- Parameters:
conductor_id – Database ID of conductor.
- Returns:
List of
ConductorHardwareInterfaces
objects.
- list_hardware_type_interfaces(hardware_types)[source]¶
List registered hardware interfaces for given hardware types.
This is restricted to only active conductors. :param hardware_types: list of hardware types to filter by. :returns: list of
ConductorHardwareInterfaces
objects.
- migrate_to_builtin_inspection(context, max_count)[source]¶
Handle the migration from “inspector” to “agent” inspection.
- Parameters:
context – the admin context
max_count – The maximum number of objects to migrate. Must be >= 0. If zero, all the objects will be migrated.
- Returns:
A 2-tuple, 1. the total number of objects that need to be migrated (at the beginning of this call) and 2. the number of migrated objects.
- node_tag_exists(node_id, tag)[source]¶
Check if the specified tag exist on the node.
- Parameters:
node_id – The id of a node.
tag – A tag string.
- Returns:
True if the tag exists otherwise False.
- Raises:
NodeNotFound if the node is not found.
- node_trait_exists(node_id, trait)[source]¶
Check if the specified trait exists on the node.
- Parameters:
node_id – The id of a node.
trait – A trait string.
- Returns:
True if the trait exists otherwise False.
- Raises:
NodeNotFound if the node is not found.
- query_node_history_records_for_purge(conductor_id)[source]¶
Utility method to identify nodes to clean history records for.
- Parameters:
conductor_id – Id value for the conductor to perform this query on behalf of.
- Returns:
A dictionary with key values of node database ID values and a list of values associated with the node.
- register_conductor(values, update_existing=False)[source]¶
Register an active conductor with the cluster.
- Parameters:
values –
A dict of values which must contain the following:
{ 'hostname': the unique hostname which identifies this Conductor service. 'drivers': a list of supported drivers. 'version': the version of the object.Conductor }
update_existing – When false, registration will raise an exception when a conflicting online record is found. When true, will overwrite the existing record. Default: False.
- Returns:
A conductor.
- Raises:
ConductorAlreadyRegistered
- register_conductor_hardware_interfaces(conductor_id, interfaces)[source]¶
Registers hardware interfaces for a conductor.
- Parameters:
conductor_id – Database ID of conductor to register for.
hardware_type – Name of hardware type for the interfaces.
interface_type – Type of interfaces, e.g. ‘deploy’ or ‘boot’.
interfaces – List of interface names to register.
default_interface – String, the default interface for this hardware type and interface type.
- Raises:
ConductorHardwareInterfacesAlreadyRegistered if at least one of the interfaces in the combination of all parameters is already registered.
- release_node(tag, node_id)[source]¶
Release the reservation on a node.
- Parameters:
tag – A string uniquely identifying the reservation holder.
node_id – A node id or uuid.
- Raises:
NodeNotFound if the node is not found.
- Raises:
NodeLocked if the node is reserved by another host.
- Raises:
NodeNotLocked if the node was found to not have a reservation at all.
- reserve_node(tag, node_id)[source]¶
Reserve a node.
To prevent other ManagerServices from manipulating the given Node while a Task is performed, mark it reserved by this host.
- Parameters:
tag – A string uniquely identifying the reservation holder.
node_id – A node id or uuid.
- Returns:
A Node object.
- Raises:
NodeNotFound if the node is not found.
- Raises:
NodeLocked if the node is already reserved.
- set_node_tags(node_id, tags)[source]¶
Replace all of the node tags with specified list of tags.
This ignores duplicate tags in the specified list.
- Parameters:
node_id – The id of a node.
tags – List of tags.
- Returns:
A list of NodeTag objects.
- Raises:
NodeNotFound if the node is not found.
- set_node_traits(node_id, traits, version)[source]¶
Replace all of the node traits with specified list of traits.
This ignores duplicate traits in the specified list.
- Parameters:
node_id – The id of a node.
traits – List of traits.
version – the version of the object.Trait.
- Returns:
A list of NodeTrait objects.
- Raises:
InvalidParameterValue if setting the traits would exceed the per-node traits limit.
- Raises:
NodeNotFound if the node is not found.
- take_over_allocation(allocation_id, old_conductor_id, new_conductor_id)[source]¶
Do a take over for an allocation.
The allocation is only updated if the old conductor matches the provided value, thus guarding against races.
- Parameters:
allocation_id – Allocation ID
old_conductor_id – The conductor ID we expect to be the current
conductor_affinity
of the allocation.new_conductor_id – The conductor ID of the new
conductor_affinity
.
- Returns:
True if the take over was successful, False otherwise.
- Raises:
AllocationNotFound
- touch_conductor(hostname, online=True)[source]¶
Mark a conductor as active by updating its ‘updated_at’ property.
Calling periodically with
online=False
will result in the conductor appearing unregistered, but recently enough to prevent other conductors failing orphan nodes. This improves the behaviour of graceful and drain shutdown.- Parameters:
hostname – The hostname of this conductor service.
online – Whether the conductor is online.
- Raises:
ConductorNotFound
- touch_node_provisioning(node_id)[source]¶
Mark the node’s provisioning as running.
Mark the node’s provisioning as running by updating its ‘provision_updated_at’ property.
- Parameters:
node_id – The id of a node.
- Raises:
NodeNotFound
- unregister_conductor(hostname)[source]¶
Remove this conductor from the service registry immediately.
- Parameters:
hostname – The hostname of this conductor service.
- Raises:
ConductorNotFound
- unregister_conductor_hardware_interfaces(conductor_id)[source]¶
Unregisters all hardware interfaces for a conductor.
- Parameters:
conductor_id – Database ID of conductor to unregister for.
- unset_node_tags(node_id)[source]¶
Remove all tags of the node.
- Parameters:
node_id – The id of a node.
- Raises:
NodeNotFound if the node is not found.
- unset_node_traits(node_id)[source]¶
Remove all traits of the node.
- Parameters:
node_id – The id of a node.
- Raises:
NodeNotFound if the node is not found.
- update_allocation(allocation_id, values, update_node=True)[source]¶
Update properties of an allocation.
- Parameters:
allocation_id – Allocation ID
values – Dict of values to update.
update_node – If True and node_id is updated, update the node with instance_uuid and traits from the allocation
- Returns:
An allocation.
- Raises:
AllocationNotFound
- Raises:
AllocationDuplicateName
- Raises:
InstanceAssociated
- Raises:
NodeAssociated
- update_bios_setting_list(node_id, settings, version)[source]¶
Update a list of BIOSSetting records.
- Parameters:
node_id – The node id.
settings –
A list of BIOS Settings to be updated.
[ { 'name': String, 'value': String, additional settings from BIOS registry }, { 'name': String, 'value': String, additional settings from BIOS registry }, ... ]
version – the version of the object.BIOSSetting.
- Returns:
A list of BIOSSetting objects.
- Raises:
NodeNotFound if the node is not found.
- Raises:
BIOSSettingNotFound if any of the settings is not found.
- update_chassis(chassis_id, values)[source]¶
Update properties of an chassis.
- Parameters:
chassis_id – The id or the uuid of a chassis.
values – Dict of values to update.
- Returns:
A chassis.
- update_deploy_template(template_id, values)[source]¶
Update a deployment template.
- Parameters:
template_id – ID of the deployment template to update.
values –
A dict describing the deployment template. For example:
{ 'uuid': uuidutils.generate_uuid(), 'name': 'CUSTOM_DT1', }
- Raises:
DeployTemplateDuplicateName if a deploy template with the same name exists.
- Raises:
DeployTemplateNotFound if the deploy template does not exist.
- Returns:
A deploy template.
- update_firmware_component(node_id, component, values)[source]¶
Update a FirmwareComponent record.
- Parameters:
node_id – The node id.
component – The component of the node to update.
values –
A dictionary with the new information about the FirmwareComponent.
{ 'current_version': String, 'last_version_flashed': String }
- Returns:
A FirmwareComponent object.
- Raises:
FirmwareComponentNotFound the component is not found.
- update_node(node_id, values)[source]¶
Update properties of a node.
- Parameters:
node_id – The id or uuid of a node.
values –
Dict of values to update. May be a partial list, eg. when setting the properties for a driver. For example:
{ 'driver_info': { 'my-field-1': val1, 'my-field-2': val2, } }
- Returns:
A node.
- Raises:
NodeAssociated
- Raises:
NodeNotFound
- update_port(port_id, values)[source]¶
Update properties of an port.
- Parameters:
port_id – The id or MAC of a port.
values – Dict of values to update.
- Returns:
A port.
- update_portgroup(portgroup_id, values)[source]¶
Update properties of a portgroup.
- Parameters:
portgroup_id – The UUID or MAC of a portgroup.
values – Dict of values to update. May contain the following keys: ‘uuid’ ‘name’ ‘node_id’ ‘address’ ‘extra’ ‘created_at’ ‘updated_at’
- Returns:
A portgroup.
- Raises:
InvalidParameterValue
- Raises:
PortgroupNotFound
- Raises:
PortgroupDuplicateName
- Raises:
PortgroupMACAlreadyExists
- update_runbook(runbook_id, values)[source]¶
Update a runbook.
- Parameters:
runbook_id – ID of the runbook to update.
values –
A dict describing the runbook. For example:
{ 'uuid': uuidutils.generate_uuid(), 'name': 'CUSTOM_DT1', }
- Raises:
RunbookDuplicateName if a runbook with the same name exists.
- Raises:
RunbookNotFound if the runbook does not exist.
- Returns:
A runbook.
- update_to_latest_versions(context, max_count)[source]¶
Updates objects to their latest known versions.
This scans all the tables and for objects that are not in their latest version, updates them to that version.
- Parameters:
context – the admin context
max_count – The maximum number of objects to migrate. Must be >= 0. If zero, all the objects will be migrated.
- Returns:
A 2-tuple, 1. the total number of objects that need to be migrated (at the beginning of this call) and 2. the number of migrated objects.
- update_volume_connector(ident, connector_info)[source]¶
Update properties of a volume connector.
- Parameters:
ident – The UUID or integer ID of a volume connector.
connector_info – Dictionary containing the information about connector to update.
- Returns:
A volume connector.
- Raises:
VolumeConnectorTypeAndIdAlreadyExists If another connector already exists with a matching type and connector_id field.
- Raises:
VolumeConnectorNotFound If a volume connector with the specified ident does not exist.
- Raises:
InvalidParameterValue When a UUID is included in connector_info.
- update_volume_target(ident, target_info)[source]¶
Update information for a volume target.
- Parameters:
ident – The UUID or integer ID of a volume target.
target_info – Dictionary containing the information about volume target to update.
- Returns:
A volume target.
- Raises:
InvalidParameterValue if a UUID is included in target_info.
- Raises:
VolumeTargetBootIndexAlreadyExists if a volume target already exists with the same boot index and node ID.
- Raises:
VolumeTargetNotFound if no volume target with this ident exists.
- ironic.db.sqlalchemy.api.add_identity_filter(query, value)[source]¶
Adds an identity filter to a query.
Filters results by ID, if supplied value is a valid integer. Otherwise attempts to filter results by UUID.
- Parameters:
query – Initial query to add filter to.
value – Value for filtering results by.
- Returns:
Modified query.
- ironic.db.sqlalchemy.api.add_identity_where(op, model, value)[source]¶
Adds an identity filter to operation for where method.
Filters results by ID, if supplied value is a valid integer. Otherwise attempts to filter results by UUID.
- Parameters:
op – Initial operation to add filter to. i.e. a update or delete statement.
model – The SQLAlchemy model to apply.
value – Value for filtering results by.
- Returns:
Modified query.
- ironic.db.sqlalchemy.api.add_port_filter(query, value)[source]¶
Adds a port-specific filter to a query.
Filters results by address, if supplied value is a valid MAC address. Otherwise attempts to filter results by identity.
- Parameters:
query – Initial query to add filter to.
value – Value for filtering results by.
- Returns:
Modified query.
- ironic.db.sqlalchemy.api.add_portgroup_filter(query, value)[source]¶
Adds a portgroup-specific filter to a query.
Filters results by address, if supplied value is a valid MAC address. Otherwise attempts to filter results by identity.
- Parameters:
query – Initial query to add filter to.
value – Value for filtering results by.
- Returns:
Modified query.