openstack.baremetal.v1.Node

The Node Class

The Node class inherits from Resource.

class openstack.baremetal.v1.node.Node(_synchronized=False, connection=None, **attrs)

The base resource

Parameters
  • _synchronized (bool) – This is not intended to be used directly. See new() and existing().

  • connection (openstack.connection.Connection) – Reference to the Connection being used. Defaults to None to allow Resource objects to be used without an active Connection, such as in unit tests. Use of self._connection in Resource code should protect itself with a check for None.

allocation_id

The UUID of the allocation associated with this node. Added in API microversion 1.52.

owner

A string or UUID of the tenant who owns the baremetal node. Added in API microversion 1.50.

chassis_id

The UUID of the chassis associated wit this node. Can be empty or None.

clean_step

The current clean step.

conductor_group

Conductor group this node is managed by. Added in API microversion 1.46.

created_at

Timestamp at which the node was last updated.

deploy_step

The current deploy step. Added in API microversion 1.44.

driver

The name of the driver.

driver_info

All the metadata required by the driver to manage this node. List of fields varies between drivers, and can be retrieved from the openstack.baremetal.v1.driver.Driver resource.

driver_internal_info

Internal metadata set and stored by node’s driver. This is read-only.

extra

A set of one or more arbitrary metadata key and value pairs.

fault

Fault type that caused the node to enter maintenance mode. Introduced in API microversion 1.42.

id

The UUID of the node resource.

instance_info

Information used to customize the deployed image, e.g. size of root partition, config drive in the form of base64 encoded string and other metadata.

instance_id

UUID of the nova instance associated with this node.

is_automated_clean_enabled

Override enabling of automated cleaning. Added in API microversion 1.47.

is_console_enabled

Whether console access is enabled on this node.

is_maintenance

Whether node is currently in “maintenance mode”. Nodes put into maintenance mode are removed from the available resource pool.

is_retired

Whether the node is marked for retirement. Added in API microversion 1.61.

last_error

Any error from the most recent transaction that started but failed to finish.

A list of relative links, including self and bookmark links.

maintenance_reason

user settable description of the reason why the node was placed into maintenance mode.

name

Human readable identifier for the node. May be undefined. Certain words are reserved. Added in API microversion 1.5

ports

Links to the collection of ports on this node.

port_groups

Links to the collection of portgroups on this node. Available since API microversion 1.24.

power_state

The current power state. Usually “power on” or “power off”, but may be “None” if service is unable to determine the power state.

properties

Physical characteristics of the node. Content populated by the service during inspection.

provision_state

The current provisioning state of the node.

retired_reason

The reason why the node is marked for retirement. Added in API microversion 1.61.

raid_config

The current RAID configuration of the node.

reservation

The name of an service conductor host which is holding a lock on this node, if a lock is held.

resource_class

A string to be used by external schedulers to identify this node as a unit of a specific type of resource. Added in API microversion 1.21.

states

Links to the collection of states.

target_provision_state

The requested state if a provisioning action has been requested. For example, AVAILABLE, DEPLOYING, DEPLOYWAIT, DEPLOYING, ACTIVE etc.

target_power_state

The requested state during a state transition.

target_raid_config

The requested RAID configuration of the node which will be applied when the node next transitions through the CLEANING state.

traits

Traits of the node. Introduced in API microversion 1.37.

updated_at

Timestamp at which the node was last updated.

bios_interface

BIOS interface to use when setting BIOS properties of the node. Introduced in API microversion 1.40.

boot_interface

Boot interface to use when configuring boot of the node. Introduced in API microversion 1.31.

console_interface

Console interface to use when working with serial console. Introduced in API microversion 1.31.

deploy_interface

Deploy interface to use when deploying the node. Introduced in API microversion 1.31.

inspect_interface

Inspect interface to use when inspecting the node. Introduced in API microversion 1.31.

management_interface

Management interface to use for management actions on the node. Introduced in API microversion 1.31.

network_interface

Network interface provider to use when plumbing the network connections for this node. Introduced in API microversion 1.20.

power_interface

Power interface to use for power actions on the node. Introduced in API microversion 1.31.

raid_interface

RAID interface to use for configuring RAID on the node. Introduced in API microversion 1.31.

rescue_interface

Rescue interface to use for rescuing of the node. Introduced in API microversion 1.38.

storage_interface

Storage interface to use when attaching remote storage. Introduced in API microversion 1.33.

vendor_interface

Vendor interface to use for vendor-specific actions on the node. Introduced in API microversion 1.31.

create(session, *args, **kwargs)

Create a remote resource based on this instance.

The overridden version is capable of handling the populated provision_state field of one of three values: enroll, manageable or available. The default is currently available, since it’s the only state supported by all API versions.

Note that Bare Metal API 1.4 is required for manageable and 1.11 is required for enroll.

Parameters

session (Adapter) – The session to use for making this request.

Returns

This Resource instance.

Raises

ValueError if the Node’s provision_state is not one of None, enroll, manageable or available.

Raises

NotSupported if the provision_state cannot be reached with any API version supported by the server.

commit(session, *args, **kwargs)

Commit the state of the instance to the remote resource.

Parameters

session (Adapter) – The session to use for making this request.

Returns

This Node instance.

set_provision_state(session, target, config_drive=None, clean_steps=None, rescue_password=None, wait=False, timeout=None)

Run an action modifying this node’s provision state.

This call is asynchronous, it will return success as soon as the Bare Metal service acknowledges the request.

Parameters
  • session (Adapter) – The session to use for making this request.

  • target – Provisioning action, e.g. active, provide. See the Bare Metal service documentation for available actions.

  • config_drive – Config drive to pass to the node, only valid for active` and ``rebuild targets. You can use functions from openstack.baremetal.configdrive to build it.

  • clean_steps – Clean steps to execute, only valid for clean target.

  • rescue_password – Password for the rescue operation, only valid for rescue target.

  • wait – Whether to wait for the target state to be reached.

  • timeout – Timeout (in seconds) to wait for the target state to be reached. If None, wait without timeout.

Returns

This Node instance.

Raises

ValueError if config_drive, clean_steps or rescue_password are provided with an invalid target.

Raises

ResourceFailure if the node reaches an error state while waiting for the state.

Raises

ResourceTimeout if timeout is reached while waiting for the state.

wait_for_provision_state(session, expected_state, timeout=None, abort_on_failed_state=True)

Wait for the node to reach the expected state.

Parameters
  • session (Adapter) – The session to use for making this request.

  • expected_state – The expected provisioning state to reach.

  • timeout – If wait is set to True, specifies how much (in seconds) to wait for the expected state to be reached. The value of None (the default) means no client-side timeout.

  • abort_on_failed_state – If True (the default), abort waiting if the node reaches a failure state which does not match the expected one. Note that the failure state for enroll -> manageable transition is enroll again.

Returns

This Node instance.

Raises

ResourceFailure if the node reaches an error state and abort_on_failed_state is True.

Raises

ResourceTimeout on timeout.

wait_for_reservation(session, timeout=None)

Wait for a lock on the node to be released.

Bare metal nodes in ironic have a reservation lock that is used to represent that a conductor has locked the node while performing some sort of action, such as changing configuration as a result of a machine state change.

This lock can occur during power syncronization, and prevents updates to objects attached to the node, such as ports.

Note that nothing prevents a conductor from acquiring the lock again after this call returns, so it should be treated as best effort.

Returns immediately if there is no reservation on the node.

Parameters
  • session (Adapter) – The session to use for making this request.

  • timeout – How much (in seconds) to wait for the lock to be released. The value of None (the default) means no timeout.

Returns

This Node instance.

set_power_state(session, target)

Run an action modifying this node’s power state.

This call is asynchronous, it will return success as soon as the Bare Metal service acknowledges the request.

Parameters
  • session (Adapter) – The session to use for making this request.

  • target – Target power state, e.g. “rebooting”, “power on”. See the Bare Metal service documentation for available actions.

attach_vif(session, vif_id, retry_on_conflict=True)

Attach a VIF to the node.

The exact form of the VIF ID depends on the network interface used by the node. In the most common case it is a Network service port (NOT a Bare Metal port) ID. A VIF can only be attached to one node at a time.

Parameters
  • session (Adapter) – The session to use for making this request.

  • vif_id (string) – Backend-specific VIF ID.

  • retry_on_conflict – Whether to retry HTTP CONFLICT errors. This can happen when either the VIF is already used on a node or the node is locked. Since the latter happens more often, the default value is True.

Returns

None

Raises

NotSupported if the server does not support the VIF API.

detach_vif(session, vif_id, ignore_missing=True)

Detach a VIF from the node.

The exact form of the VIF ID depends on the network interface used by the node. In the most common case it is a Network service port (NOT a Bare Metal port) ID.

Parameters
  • session (Adapter) – The session to use for making this request.

  • vif_id (string) – Backend-specific VIF ID.

  • ignore_missing (bool) – When set to False ResourceNotFound will be raised when the VIF does not exist. Otherwise, False is returned.

Returns

True if the VIF was detached, otherwise False.

Raises

NotSupported if the server does not support the VIF API.

list_vifs(session)

List IDs of VIFs attached to the node.

The exact form of the VIF ID depends on the network interface used by the node. In the most common case it is a Network service port (NOT a Bare Metal port) ID.

Parameters

session (Adapter) – The session to use for making this request.

Returns

List of VIF IDs as strings.

Raises

NotSupported if the server does not support the VIF API.

validate(session, required='boot', 'deploy', 'power')

Validate required information on a node.

Parameters
  • session (Adapter) – The session to use for making this request.

  • required – List of interfaces that are required to pass validation. The default value is the list of minimum required interfaces for provisioning.

Returns

dict mapping interface names to ValidationResult objects.

Raises

ValidationException if validation fails for a required interface.

set_maintenance(session, reason=None)

Enable maintenance mode on the node.

Parameters
  • session (Adapter) – The session to use for making this request.

  • reason – Optional reason for maintenance.

Returns

This Node instance.

unset_maintenance(session)

Disable maintenance mode on the node.

Parameters

session (Adapter) – The session to use for making this request.

Returns

This Node instance.

set_boot_device(session, boot_device, persistent=False)

Set node boot device

Parameters
  • session – The session to use for making this request.

  • boot_device – Boot device to assign to the node.

  • persistent – If the boot device change is maintained after node reboot

Returns

The updated Node

add_trait(session, trait)

Add a trait to a node.

Parameters
  • session – The session to use for making this request.

  • trait – The trait to add to the node.

Returns

The updated Node

remove_trait(session, trait, ignore_missing=True)

Remove a trait from a node.

Parameters
  • session – The session to use for making this request.

  • trait – The trait to remove from the node.

  • ignore_missing (bool) – When set to False ResourceNotFound will be raised when the trait does not exist. Otherwise, False is returned.

Returns

The updated Node

set_traits(session, traits)

Set traits for a node.

Removes any existing traits and adds the traits passed in to this method.

Parameters
  • session – The session to use for making this request.

  • traits – list of traits to add to the node.

Returns

The updated Node

patch(session, patch=None, prepend_key=True, has_body=True, retry_on_conflict=None, base_path=None, reset_interfaces=None)

Patch the remote resource.

Allows modifying the resource by providing a list of JSON patches to apply to it. The patches can use both the original (server-side) and SDK field names.

Parameters
  • session (Adapter) – The session to use for making this request.

  • patch – Additional JSON patch as a list or one patch item. If provided, it is applied on top of any changes to the current resource.

  • prepend_key – A boolean indicating whether the resource_key should be prepended in a resource update request. Default to True.

  • retry_on_conflict (bool) – Whether to enable retries on HTTP CONFLICT (409). Value of None leaves the Adapter defaults.

  • base_path (str) – Base part of the URI for modifying resources, if different from base_path.

Returns

This Resource instance.

Raises

MethodNotSupported if Resource.allow_patch is not set to True.

The ValidationResult Class

The ValidationResult class represents the result of a validation.

class openstack.baremetal.v1.node.ValidationResult(result, reason)

Result of a single interface validation.

Variables
  • result – Result of a validation, True for success, False for failure, None for unsupported interface.

  • reason – If result is False or None, explanation of the result.

The WaitResult Class

The WaitResult class represents the result of waiting for several nodes.

class openstack.baremetal.v1.node.WaitResult

A named tuple representing a result of waiting for several nodes.

Each component is a list of Node objects:

Variables
  • success – a list of Node objects that reached the state.

  • timeout – a list of Node objects that reached timeout.

  • failure – a list of Node objects that hit a failure.

Create new instance of WaitResult(success, failure, timeout)