The ironic.db.api Module

Base classes for storage engines

class ironic.db.api.Connection[source]

Bases: object

Base class for storage system connections.

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.

create_chassis(values)[source]

Create a new chassis.

Parameters:values – Dict of values.
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': 'pxe_ipmitool',
 'driver_info': { ... },
 'properties': { ... },
 'extra': { ... },
}
Raises:InvalidParameterValue if create a node with tags.
Returns:A node.
create_port(values)[source]

Create a new port.

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
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.

destroy_chassis(chassis_id)[source]

Destroy a chassis.

Parameters:chassis_id – The id or the uuid of a chassis.
destroy_node(node_id)[source]

Destroy a node and all associated interfaces.

Parameters:node_id – The id or uuid of a node.
destroy_port(port_id)[source]

Destroy an port.

Parameters:port_id – The id or MAC of a port.
destroy_portgroup(portgroup_id)[source]

Destroy a portgroup.

Parameters:portgroup_id – The UUID or MAC of a portgroup.
Raises:PortgroupNotEmpty
Raises:PortgroupNotFound
get_active_driver_dict(interval)[source]

Retrieve drivers for the registered and active conductors.

Parameters:interval – Seconds since last check-in of a conductor.
Returns:A dict which maps driver names to the set of hosts which support them. For example:
{driverA: set([host1, host2]),
 driverB: set([host2, host3])}
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_conductor(hostname)[source]

Retrieve a conductor’s service record from the database.

Parameters:hostname – The hostname of the conductor service.
Returns:A conductor.
Raises:ConductorNotFound
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_list(filters=None, limit=None, marker=None, sort_key=None, sort_dir=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
  • 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)
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_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
    reserved:True | False
    reserved_by_any_of:
     [conductor1, conductor2]
    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
  • 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()[source]

Get a list conductor hostnames that are offline (dead).

Returns:A list of conductor hostnames.
get_port_by_address(address)[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_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)[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)[source]

Return a network portgroup representation.

Parameters:address – The MAC address of a portgroup.
Returns:A portgroup.
Raises:PortgroupNotFound
get_portgroup_by_id(portgroup_id)[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)[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)
Returns:

A list of portgroups.

get_portgroups_by_node_id(node_id, limit=None, marker=None, sort_key=None, sort_dir=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)
Returns:

A list of portgroups.

get_ports_by_node_id(node_id, limit=None, marker=None, sort_key=None, sort_dir=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)[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.

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.

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.
    }
    
  • 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

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.

touch_conductor(hostname)[source]

Mark a conductor as active by updating its ‘updated_at’ property.

Parameters:hostname – The hostname of this conductor service.
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
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.
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_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

Project Source

This Page