ironic.api.controllers.v1.utils module

ironic.api.controllers.v1.utils.allow_agent_token()[source]

Check if agent token is available.

ironic.api.controllers.v1.utils.allow_agent_version_in_heartbeat()[source]

Check if agent version is allowed to be passed into heartbeat.

Version 1.36 of the API added the ability for agents to pass their version information to Ironic on heartbeat.

ironic.api.controllers.v1.utils.allow_allocation_backfill()[source]

Check if backfilling allocations is allowed.

Version 1.58 of the API added support for backfilling allocations.

ironic.api.controllers.v1.utils.allow_allocation_owner()[source]

Check if allocation owner field is allowed.

Version 1.60 of the API added the owner field to the allocation object.

ironic.api.controllers.v1.utils.allow_allocation_update()[source]

Check if updating an existing allocation is allowed or not.

Version 1.57 of the API added support for updating an allocation.

ironic.api.controllers.v1.utils.allow_allocations()[source]

Check if accessing allocation endpoints is allowed.

Version 1.52 of the API exposed allocation endpoints and allocation_uuid field for the node.

ironic.api.controllers.v1.utils.allow_bios_interface()[source]

Check if we should support bios interface and endpoints.

Version 1.40 of the API added support for bios interface.

ironic.api.controllers.v1.utils.allow_build_configdrive()[source]

Check if building configdrive is allowed.

Version 1.56 of the API added support for building configdrive.

ironic.api.controllers.v1.utils.allow_configdrive_vendor_data()[source]

Check if configdrive can contain a vendor_data key.

Version 1.59 of the API added support for configdrive vendor_data.

ironic.api.controllers.v1.utils.allow_deploy_templates()[source]

Check if accessing deploy template endpoints is allowed.

Version 1.55 of the API exposed deploy template endpoints.

ironic.api.controllers.v1.utils.allow_detail_query()[source]

Check if passing a detail=True query string is allowed.

Version 1.43 allows a user to pass the detail query string to list the resource with all the fields.

ironic.api.controllers.v1.utils.allow_dynamic_drivers()[source]

Check if dynamic driver API calls are allowed.

Version 1.30 of the API added support for all of the driver composition related calls in the /v1/drivers API.

ironic.api.controllers.v1.utils.allow_dynamic_interfaces()[source]

Check if dynamic interface fields are allowed.

Version 1.31 of the API added support for viewing and setting the fields in V31_FIELDS on the node object.

ironic.api.controllers.v1.utils.allow_expose_conductors()[source]

Check if accessing conductor endpoints is allowed.

Version 1.49 of the API exposed conductor endpoints and conductor field for the node.

ironic.api.controllers.v1.utils.allow_expose_events()[source]

Check if accessing events endpoint is allowed.

Version 1.54 of the API added the events endpoint.

ironic.api.controllers.v1.utils.allow_field(field)[source]

Check if a field is allowed in the current version.

ironic.api.controllers.v1.utils.allow_inject_nmi()[source]

Check if Inject NMI is allowed for the node.

Version 1.29 of the API allows Inject NMI for the node.

ironic.api.controllers.v1.utils.allow_inspect_abort()[source]

Check if inspection abort is allowed.

Version 1.41 of the API added support for inspection abort

ironic.api.controllers.v1.utils.allow_inspect_wait_state()[source]

Check if inspect wait is allowed for the node.

Version 1.39 of the API adds ‘inspect wait’ state to substitute ‘inspecting’ state during asynchronous hardware inspection.

Check if links are displayable.

Version 1.14 of the API allows the display of links to node states and driver properties.

Check if network_type is allowed in ports link_local_connection

ironic.api.controllers.v1.utils.allow_node_logical_names()[source]
ironic.api.controllers.v1.utils.allow_node_rebuild_with_configdrive()[source]

Check if we should support node rebuild with configdrive.

Version 1.35 of the API added support for node rebuild with configdrive.

ironic.api.controllers.v1.utils.allow_port_advanced_net_fields()[source]

Check if we should return local_link_connection and pxe_enabled fields.

Version 1.19 of the API added support for these new fields in port object.

ironic.api.controllers.v1.utils.allow_port_internal_info()[source]

Check if accessing internal_info is allowed for the port.

Version 1.18 of the API exposes internal_info readonly field for the port.

ironic.api.controllers.v1.utils.allow_port_is_smartnic()[source]

Check if port is_smartnic field is allowed.

Version 1.53 of the API added is_smartnic field to the port object.

ironic.api.controllers.v1.utils.allow_port_physical_network()[source]

Check if port physical network field is allowed.

Version 1.34 of the API added the physical network field to the port object. We also check whether the target version of the Port object supports the physical_network field as this may not be the case during a rolling upgrade.

ironic.api.controllers.v1.utils.allow_portgroup_mode_properties()[source]

Check if mode and properties can be added to/queried from a portgroup.

Version 1.26 of the API added mode and properties fields to portgroup object.

ironic.api.controllers.v1.utils.allow_portgroups()[source]

Check if we should support portgroup operations.

Version 1.23 of the API added support for PortGroups.

ironic.api.controllers.v1.utils.allow_portgroups_subcontrollers()[source]

Check if portgroups can be used as subcontrollers.

Version 1.24 of the API added support for Portgroups as subcontrollers

ironic.api.controllers.v1.utils.allow_raid_config()[source]

Check if RAID configuration is allowed for the node.

Version 1.12 of the API allows RAID configuration for the node.

ironic.api.controllers.v1.utils.allow_ramdisk_endpoints()[source]

Check if heartbeat and lookup endpoints are allowed.

Version 1.22 of the API introduced them.

ironic.api.controllers.v1.utils.allow_remove_chassis_uuid()[source]

Check if chassis_uuid can be removed from node.

Version 1.25 of the API added support for chassis_uuid removal

ironic.api.controllers.v1.utils.allow_rescue_interface()[source]

Check if we should support rescue and unrescue operations and interface.

Version 1.38 of the API added support for rescue and unrescue.

ironic.api.controllers.v1.utils.allow_reset_interfaces()[source]

Check if passing a reset_interfaces query string is allowed.

ironic.api.controllers.v1.utils.allow_soft_power_off()[source]

Check if Soft Power Off is allowed for the node.

Version 1.27 of the API allows Soft Power Off, including Soft Reboot, for the node.

ironic.api.controllers.v1.utils.allow_storage_interface()[source]

Check if we should support storage_interface node and driver fields.

Version 1.33 of the API added support for storage interfaces.

ironic.api.controllers.v1.utils.allow_traits()[source]

Check if traits are allowed for the node.

Version 1.37 of the API allows traits for the node.

ironic.api.controllers.v1.utils.allow_vifs_subcontroller()[source]

Check if node/vifs can be used.

Version 1.28 of the API added support for VIFs to be attached to Nodes.

ironic.api.controllers.v1.utils.allow_volume()[source]

Check if volume connectors and targets are allowed.

Version 1.32 of the API added support for volume connectors and targets

ironic.api.controllers.v1.utils.apply_jsonpatch(doc, patch)[source]

Apply a JSON patch, one operation at a time.

If the patch fails to apply, this allows us to determine which operation failed, making the error message a little less cryptic.

Parameters
  • doc – The JSON document to patch.

  • patch – The JSON patch to apply.

Returns

The result of the patch operation.

Raises

PatchError if the patch fails to apply.

Raises

exception.ClientSideError if the patch adds a new root attribute.

ironic.api.controllers.v1.utils.check_allocation_policy_and_retrieve(policy_name, allocation_ident)[source]

Check if the specified policy authorizes request on allocation.

Param

policy_name: Name of the policy to check.

Param

allocation_ident: the UUID or logical name of a node.

Raises

HTTPForbidden if the policy forbids access.

Raises

AllocationNotFound if the node is not found.

Returns

RPC node identified by node_ident

ironic.api.controllers.v1.utils.check_allow_configdrive(target, configdrive=None)[source]
ironic.api.controllers.v1.utils.check_allow_driver_detail(detail)[source]

Check if getting detailed driver info is allowed.

Version 1.30 of the API allows this.

ironic.api.controllers.v1.utils.check_allow_filter_by_conductor(conductor)[source]

Check if filtering nodes by conductor is allowed.

Version 1.49 of the API allows filtering nodes by conductor.

ironic.api.controllers.v1.utils.check_allow_filter_by_conductor_group(conductor_group)[source]

Check if filtering nodes by conductor_group is allowed.

Version 1.46 of the API allows filtering nodes by conductor_group.

ironic.api.controllers.v1.utils.check_allow_filter_by_fault(fault)[source]

Check if filtering nodes by fault is allowed.

Version 1.42 of the API allows filtering nodes by fault.

ironic.api.controllers.v1.utils.check_allow_filter_by_lessee(lessee)[source]

Check if filtering nodes by lessee is allowed.

Version 1.62 of the API allows filtering nodes by lessee.

ironic.api.controllers.v1.utils.check_allow_filter_by_owner(owner)[source]

Check if filtering nodes by owner is allowed.

Version 1.50 of the API allows filtering nodes by owner.

ironic.api.controllers.v1.utils.check_allow_filter_driver_type(driver_type)[source]

Check if filtering drivers by classic/dynamic is allowed.

Version 1.30 of the API allows this.

ironic.api.controllers.v1.utils.check_allow_management_verbs(verb)[source]
ironic.api.controllers.v1.utils.check_allow_specify_driver(driver)[source]

Check if filtering nodes by driver is allowed.

Version 1.16 of the API allows filter nodes by driver.

ironic.api.controllers.v1.utils.check_allow_specify_fields(fields)[source]

Check if fetching a subset of the resource attributes is allowed.

Version 1.8 of the API allows fetching a subset of the resource attributes, this method checks if the required version is being requested.

ironic.api.controllers.v1.utils.check_allow_specify_resource_class(resource_class)[source]

Check if filtering nodes by resource_class is allowed.

Version 1.21 of the API allows filtering nodes by resource_class.

ironic.api.controllers.v1.utils.check_allowed_fields(fields)[source]

Check if fetching a particular field is allowed.

This method checks if the required version is being requested for fields that are only allowed to be fetched in a particular API version.

ironic.api.controllers.v1.utils.check_allowed_portgroup_fields(fields)[source]

Check if fetching a particular field of a portgroup is allowed.

This method checks if the required version is being requested for fields that are only allowed to be fetched in a particular API version.

ironic.api.controllers.v1.utils.check_for_invalid_fields(fields, object_fields)[source]

Check for requested non-existent fields.

Check if the user requested non-existent fields.

Parameters

fields – A list of fields requested by the user

Object_fields

A list of fields supported by the object.

Raises

InvalidParameterValue if invalid fields were requested.

ironic.api.controllers.v1.utils.check_for_invalid_state_and_allow_filter(provision_state)[source]

Check if filtering nodes by provision state is allowed.

Version 1.9 of the API allows filter nodes by provision state.

ironic.api.controllers.v1.utils.check_list_policy(object_type, owner=None)[source]

Check if the list policy authorizes this request on an object.

Param

object_type: type of object being checked

Param

owner: owner filter for list query, if any

Raises

HTTPForbidden if the policy forbids access.

Returns

owner that should be used for list query, if needed

ironic.api.controllers.v1.utils.check_multiple_node_policies_and_retrieve(policy_names, node_ident, with_suffix=False)[source]

Check if the specified policies authorize this request on a node.

Param

policy_names: List of policy names to check.

Param

node_ident: the UUID or logical name of a node.

Param

with_suffix: whether the RPC node should include the suffix

Raises

HTTPForbidden if the policy forbids access.

Raises

NodeNotFound if the node is not found.

Returns

RPC node identified by node_ident

ironic.api.controllers.v1.utils.check_node_policy_and_retrieve(policy_name, node_ident, with_suffix=False)[source]

Check if the specified policy authorizes this request on a node.

Param

policy_name: Name of the policy to check.

Param

node_ident: the UUID or logical name of a node.

Param

with_suffix: whether the RPC node should include the suffix

Raises

HTTPForbidden if the policy forbids access.

Raises

NodeNotFound if the node is not found.

Returns

RPC node identified by node_ident

ironic.api.controllers.v1.utils.check_owner_policy(object_type, policy_name, owner, lessee=None)[source]

Check if the policy authorizes this request on an object.

Param

object_type: type of object being checked

Param

policy_name: Name of the policy to check.

Param

owner: the owner

Param

lessee: the lessee

Raises

HTTPForbidden if the policy forbids access.

ironic.api.controllers.v1.utils.check_policy(policy_name)[source]

Check if the specified policy is authorised for this request.

Policy_name

Name of the policy to check.

Raises

HTTPForbidden if the policy forbids access.

ironic.api.controllers.v1.utils.check_port_list_policy()[source]

Check if the specified policy authorizes this request on a port.

Raises

HTTPForbidden if the policy forbids access.

Returns

owner that should be used for list query, if needed

ironic.api.controllers.v1.utils.check_port_policy_and_retrieve(policy_name, port_uuid)[source]

Check if the specified policy authorizes this request on a port.

Param

policy_name: Name of the policy to check.

Param

port_uuid: the UUID of a port.

Raises

HTTPForbidden if the policy forbids access.

Raises

NodeNotFound if the node is not found.

Returns

RPC port identified by port_uuid and associated node

ironic.api.controllers.v1.utils.disallowed_fields()[source]

Generator of fields not allowed in the current request.

ironic.api.controllers.v1.utils.get_controller_reserved_names(cls)[source]

Get reserved names for a given controller.

Inspect the controller class and return the reserved names within it. Reserved names are names that can not be used as an identifier for a resource because the names are either being used as a custom action or is the name of a nested controller inside the given class.

Parameters

cls – The controller class to be inspected.

ironic.api.controllers.v1.utils.get_patch_values(patch, path)[source]

Get the patch values corresponding to the specified path.

If there are multiple values specified for the same path, for example

[{'op': 'add', 'path': '/name', 'value': 'abc'},
 {'op': 'add', 'path': '/name', 'value': 'bca'}]

return all of them in a list (preserving order)

Parameters
  • patch – HTTP PATCH request body.

  • path – the path to get the patch values for.

Returns

list of values for the specified path in the patch.

ironic.api.controllers.v1.utils.get_request_return_fields(fields, detail, default_fields)[source]

Calculate fields to return from an API request

The fields query and detail=True query can not be passed into a request at the same time. To use the detail query we need to be on a version of the API greater than 1.43. This function raises an InvalidParameterValue exception if either of these conditions are not met.

If these checks pass then this function will return either the fields passed in or the default fields provided.

Parameters
  • fields – The fields query passed into the API request.

  • detail – The detail query passed into the API request.

  • default_fields – The default fields to return if fields=None and detail=None.

Raises

InvalidParameterValue if there is an invalid combination of query strings or API version.

Returns

‘fields’ passed in value or ‘default_fields’

ironic.api.controllers.v1.utils.get_rpc_allocation(allocation_ident)[source]

Get the RPC allocation from the allocation UUID or logical name.

Parameters

allocation_ident – the UUID or logical name of an allocation.

Returns

The RPC allocation.

Raises

InvalidUuidOrName if the name or uuid provided is not valid.

Raises

AllocationNotFound if the allocation is not found.

ironic.api.controllers.v1.utils.get_rpc_allocation_with_suffix(allocation_ident)[source]

Get the RPC allocation from the allocation UUID or logical name.

If HAS_JSON_SUFFIX flag is set in the pecan environment, try also looking for allocation_ident with ‘.json’ suffix. Otherwise identical to get_rpc_allocation.

Parameters

allocation_ident – the UUID or logical name of an allocation.

Returns

The RPC allocation.

Raises

InvalidUuidOrName if the name or uuid provided is not valid.

Raises

AllocationNotFound if the allocation is not found.

ironic.api.controllers.v1.utils.get_rpc_deploy_template(template_ident)[source]

Get the RPC deploy template from the UUID or logical name.

Parameters

template_ident – the UUID or logical name of a deploy template.

Returns

The RPC deploy template.

Raises

InvalidUuidOrName if the name or uuid provided is not valid.

Raises

DeployTemplateNotFound if the deploy template is not found.

ironic.api.controllers.v1.utils.get_rpc_deploy_template_with_suffix(template_ident)[source]

Get the RPC deploy template from the UUID or logical name.

If HAS_JSON_SUFFIX flag is set in the pecan environment, try also looking for template_ident with ‘.json’ suffix. Otherwise identical to get_rpc_deploy_template.

Parameters

template_ident – the UUID or logical name of a deploy template.

Returns

The RPC deploy template.

Raises

InvalidUuidOrName if the name or uuid provided is not valid.

Raises

DeployTemplateNotFound if the deploy template is not found.

ironic.api.controllers.v1.utils.get_rpc_node(node_ident)[source]

Get the RPC node from the node uuid or logical name.

Parameters

node_ident – the UUID or logical name of a node.

Returns

The RPC Node.

Raises

InvalidUuidOrName if the name or uuid provided is not valid.

Raises

NodeNotFound if the node is not found.

ironic.api.controllers.v1.utils.get_rpc_node_with_suffix(node_ident)[source]

Get the RPC node from the node uuid or logical name.

If HAS_JSON_SUFFIX flag is set in the pecan environment, try also looking for node_ident with ‘.json’ suffix. Otherwise identical to get_rpc_node.

Parameters

node_ident – the UUID or logical name of a node.

Returns

The RPC Node.

Raises

InvalidUuidOrName if the name or uuid provided is not valid.

Raises

NodeNotFound if the node is not found.

ironic.api.controllers.v1.utils.get_rpc_portgroup(portgroup_ident)[source]

Get the RPC portgroup from the portgroup UUID or logical name.

Parameters

portgroup_ident – the UUID or logical name of a portgroup.

Returns

The RPC portgroup.

Raises

InvalidUuidOrName if the name or uuid provided is not valid.

Raises

PortgroupNotFound if the portgroup is not found.

ironic.api.controllers.v1.utils.get_rpc_portgroup_with_suffix(portgroup_ident)[source]

Get the RPC portgroup from the portgroup UUID or logical name.

If HAS_JSON_SUFFIX flag is set in the pecan environment, try also looking for portgroup_ident with ‘.json’ suffix. Otherwise identical to get_rpc_portgroup.

Parameters

portgroup_ident – the UUID or logical name of a portgroup.

Returns

The RPC portgroup.

Raises

InvalidUuidOrName if the name or uuid provided is not valid.

Raises

PortgroupNotFound if the portgroup is not found.

ironic.api.controllers.v1.utils.handle_patch_port_like_extra_vif(rpc_object, api_object, patch)[source]

Handle a Patch request that modifies .extra[‘vif_port_id’].

This handles attach/detach of VIFs via the VIF port ID in a port or port group’s extra[‘vif_port_id’] field.

Parameters
  • rpc_object – a Port or Portgroup RPC object

  • api_object – the corresponding Port or Portgroup API object

  • patch – the JSON patch in the API request

ironic.api.controllers.v1.utils.handle_post_port_like_extra_vif(p_dict)[source]

Handle a Post request that sets .extra[‘vif_port_id’].

This handles attach of VIFs via specifying the VIF port ID in a port or port group’s extra[‘vif_port_id’] field.

Parameters

p_dict – a dictionary with field names/values for the port or port group

Returns

VIF or None

ironic.api.controllers.v1.utils.initial_node_provision_state()[source]

Return node state to use by default when creating new nodes.

Previously the default state for new nodes was AVAILABLE. Starting with API 1.11 it is ENROLL.

ironic.api.controllers.v1.utils.is_path_removed(patch, path)[source]

Returns whether the patch includes removal of the path (or subpath of).

Parameters
  • patch – HTTP PATCH request body.

  • path – the path to check.

Returns

True if path or subpath being removed, False otherwise.

ironic.api.controllers.v1.utils.is_path_updated(patch, path)[source]

Returns whether the patch includes operation on path (or its subpath).

Parameters
  • patch – HTTP PATCH request body.

  • path – the path to check.

Returns

True if path or subpath being patched, False otherwise.

ironic.api.controllers.v1.utils.is_valid_logical_name(name)[source]

Determine if the provided name is a valid hostname.

ironic.api.controllers.v1.utils.is_valid_node_name(name)[source]

Determine if the provided name is a valid node name.

Check to see that the provided node name is valid, and isn’t a UUID.

Parameters

name – the node name to check.

Returns

True if the name is valid, False otherwise.

ironic.api.controllers.v1.utils.validate_limit(limit)[source]
ironic.api.controllers.v1.utils.validate_sort_dir(sort_dir)[source]
ironic.api.controllers.v1.utils.validate_trait(trait, error_prefix='Invalid trait')[source]
ironic.api.controllers.v1.utils.vendor_passthru(ident, method, topic, data=None, driver_passthru=False)[source]

Call a vendor passthru API extension.

Call the vendor passthru API extension and process the method response to set the right return code for methods that are asynchronous or synchronous; Attach the return value to the response object if it’s being served statically.

Parameters
  • ident – The resource identification. For node’s vendor passthru this is the node’s UUID, for driver’s vendor passthru this is the driver’s name.

  • method – The vendor method name.

  • topic – The RPC topic.

  • data – The data passed to the vendor method. Defaults to None.

  • driver_passthru – Boolean value. Whether this is a node or driver vendor passthru. Defaults to False.

Returns

A WSME response object to be returned by the API.