ironic.api.controllers.v1.utils module¶
- class ironic.api.controllers.v1.utils.PassthruResponse(obj, status_code=None)[source]¶
Bases:
object
Object to hold the “response” from a passthru call
- obj¶
Store the result object from the view
- status_code¶
Store an optional status_code
- 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_attach_detach_vmedia()[source]¶
Check if we should support virtual media actions.
- 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_continue_inspection_endpoint()[source]¶
Check if /v1/continue_inspection endpoint is available.
As a special exception, we allow it in the base version so that the API can be used as a drop-in replacement for the Inspector’s API.
- 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_firmware_interface()[source]¶
Check if we should support firmware interface and endpoints.
Version 1.86 of the API added support for firmware interface.
- ironic.api.controllers.v1.utils.allow_get_vmedia()[source]¶
Check if we should support get virtual media action.
- 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.
- ironic.api.controllers.v1.utils.allow_links_node_states_and_driver_properties()[source]¶
Check if links are displayable.
Version 1.14 of the API allows the display of links to node states and driver properties.
- ironic.api.controllers.v1.utils.allow_local_link_connection_network_type()[source]¶
Check if network_type is allowed in ports link_local_connection
- ironic.api.controllers.v1.utils.allow_node_history()[source]¶
Check if node history access is permitted by API version.
- ironic.api.controllers.v1.utils.allow_node_ident_as_param_for_port_creation()[source]¶
Check if ‘node_ident’ parameter is allowed for port creation.
- 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_ovn_vtep_version()[source]¶
Check if ovn vtep version is allowed.
Version 1.90 of the API added support for ovn vtep switches in port.local_link_connection.
- 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_name()[source]¶
Check if name is allowed for ports.
Version 1.88 of the API added name 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_query_bios()[source]¶
Check if BIOS queries should be allowed based on version
- 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_runbooks()[source]¶
Check if accessing runbook endpoints is allowed.
Version 1.92 of the API exposed runbook endpoints.
- ironic.api.controllers.v1.utils.allow_service_verb()[source]¶
Check if the service verb may be passed to the API.
- ironic.api.controllers.v1.utils.allow_shards_endpoint()[source]¶
Check if shards endpoint is available.
- 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_status_in_heartbeat()[source]¶
Check if heartbeat accepts agent_status and agent_status_message.
- 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_unhold_verb()[source]¶
Check if the unhold verb may be passed to the API
- ironic.api.controllers.v1.utils.allow_verify_ca_in_heartbeat()[source]¶
Check if heartbeat accepts agent_verify_ca.
- 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_boot_mode(node_capabilities, disallowed_boot_modes)[source]¶
Check if boot mode is allowed
- ironic.api.controllers.v1.utils.check_allow_child_node_params(include_children=None, parent_node=None)[source]¶
- ironic.api.controllers.v1.utils.check_allow_deploy_steps(target, deploy_steps)[source]¶
Check if deploy steps are allowed
- 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_by_shard(shard)[source]¶
Check if filtering nodes by shard is allowed.
Version 1.82 of the API allows filtering nodes by shard.
- 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_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_and_retrieve_public_runbook(runbook_ident)[source]¶
If policy authorization check fails, check if runbook is public.
- Param:
runbook_ident: the UUID or logical name of a runbook.
- Raises:
HTTPForbidden if runbook is not public.
- Returns:
RPC runbook identified by runbook_ident
- 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_multiple_runbook_policies_and_retrieve(policy_names, runbook_ident)[source]¶
Check if the specified policies authorize this request on a runbook.
- Param:
policy_names: List of policy names to check.
- Param:
runbook_ident: the UUID or logical name of a runbook.
- Raises:
HTTPForbidden if the policy forbids access.
- Raises:
RunbookNotFound if the runbook is not found.
- Returns:
RPC runbook identified by runbook_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, conceal_node=False)[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
- Param:
conceal_node: the UUID of the node IF we should conceal the existence of the node with a 404 Error instead of a 403 Error.
- 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_policy_true(policy_name)[source]¶
Check if the specified policy is authorised for this request.
- Policy_name:
Name of the policy to check.
- Returns:
True if policy is matched, otherwise false.
- ironic.api.controllers.v1.utils.check_port_list_policy(portgroup=False, parent_node=None, parent_portgroup=None)[source]¶
Check if the specified policy authorizes this request on a port.
- Parameters:
portgroup – Boolean value, default false, indicating if the list policy check is for a portgroup as the policy names are different between ports and portgroups.
parent_node – The UUID of a node, if any, to apply a policy check to as well before applying other policy check operations.
parent_portgroup – The UUID of the parent portgroup if the list of ports was retrieved via the /v1/portgroups/<uuid>/ports.
- 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_ident, portgroup=False)[source]¶
Check if the specified policy authorizes this request on a port.
- Param:
policy_name: Name of the policy to check.
- Param:
port_ident: The name, uuid, or other valid ID value to find a port or portgroup by.
- Raises:
HTTPForbidden if the policy forbids access.
- Raises:
PortNotFound if the port is not found.
- Raises:
PortgroupNotFound if the portgroup is not found.
- Returns:
RPC port identified by port_ident associated node
- ironic.api.controllers.v1.utils.check_runbook_policy_and_retrieve(policy_name, runbook_ident)[source]¶
Check if the specified policy authorizes this request on a node.
- Param:
policy_name: Name of the policy to check.
- Param:
runbook_ident: the UUID or logical name of a runbook.
- Raises:
HTTPForbidden if the policy forbids access.
- Raises:
RunbookNotFound if the runbook is not found.
- Returns:
a runbook object
- ironic.api.controllers.v1.utils.check_volume_list_policy(parent_node=None)[source]¶
Check if the specified policy authorizes this request on a volume.
- Parameters:
parent_node – The UUID of a node, if any, to apply a policy check to as well before applying other policy check operations.
- Raises:
HTTPForbidden if the policy forbids access.
- Returns:
owner that should be used for list query, if needed
- ironic.api.controllers.v1.utils.check_volume_policy_and_retrieve(policy_name, vol_ident, target=False)[source]¶
Check if the specified policy authorizes this request on a volume.
- Param:
policy_name: Name of the policy to check.
- Param:
vol_ident: The name, uuid, or other valid ID value to find a volume target or connector by.
- Param:
target: Boolean value to indicate if the check is for a volume target or connector. Default value is False, implying connector.
- Raises:
HTTPForbidden if the policy forbids access.
- Raises:
VolumeConnectorNotFound if the node is not found.
- Raises:
VolumeTargetNotFound if the node is not found.
- Returns:
RPC port identified by port_ident associated node
- ironic.api.controllers.v1.utils.disallowed_fields()[source]¶
Generator of fields not allowed in the current request.
- ironic.api.controllers.v1.utils.duplicate_steps(name, value)[source]¶
Argument validator to check template for duplicate steps
- 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, check_detail_version=<function allow_detail_query>, check_fields_version=None)[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 expected, likewise some APIs require a certain version for the fields query. This function raises an InvalidParameterValue exception if any 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.
check_detail_version – Function to check if detail query is allowed based on the version.
check_fields_version – Function to check if fields query is allowed based on the version.
- 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.get_rpc_runbook(runbook_ident)[source]¶
Get the RPC runbook from the UUID or logical name.
- Parameters:
runbook_ident – the UUID or logical name of a runbook.
- Returns:
The RPC runbook.
- Raises:
InvalidUuidOrName if the name or uuid provided is not valid.
- Raises:
RunbookNotFound if the runbook is not found.
- 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.new_continue_inspection_endpoint()[source]¶
Check if /v1/continue_inspection endpoint is explicitly requested.
- ironic.api.controllers.v1.utils.object_to_dict(obj, include_created_at=True, include_updated_at=True, include_uuid=True, link_resource=None, link_resource_args=None, fields=None)[source]¶
Helper function to convert RPC objects to REST API dicts.
- Parameters:
obj – RPC object to convert to a dict
include_created_at – Whether to include standard base class attribute created_at
include_updated_at – Whether to include standard base class attribute updated_at
include_uuid – Whether to include standard base class attribute uuid
link_resource – When specified, generate a
links
value with aself
andbookmark
using this resource namelink_resource_args – Resource arguments to be added to generated links. When not specified, the object
uuid
will be used.fields – Key names for dict values to populate directly from object attributes
- Returns:
A dict containing values from the object
- ironic.api.controllers.v1.utils.patch_update_changed_fields(from_dict, rpc_object, fields, schema, id_map=None)[source]¶
Update rpc object based on changed fields in a dict.
Only fields which have a corresponding schema field are updated when changed. Other values can be updated using the id_map.
- Parameters:
from_dict – Dict containing changed field values
rpc_object – Object to update changed fields on
fields – Field names on the rpc object
schema – jsonschema to get field names of the dict
id_map – Optional dict mapping object field names to arbitrary values when there is no matching field in the schema
- ironic.api.controllers.v1.utils.patch_validate_allowed_fields(patch, allowed_fields)[source]¶
Validate that a patch list only modifies allowed fields.
- Parameters:
patch – List of patch dicts to validate
allowed_fields – List of fields which are allowed to be patched
- Returns:
The list of fields which will be patched
- Raises:
exception.Invalid if any patch changes a field not in
allowed_fields
- ironic.api.controllers.v1.utils.patched_validate_with_schema(patched_dict, schema, validator=None)[source]¶
Validate a patched dict object against a validator or schema.
This function has the side-effect of deleting any dict value which is not in the schema. This allows database-loaded objects to be pruned of their internal values before validation.
- Parameters:
patched_dict – dict representation of the object with patch updates applied
schema – Any dict key not in the schema will be deleted from the dict. If no validator is specified then the resulting
patched_dict
will be validated against the schemavalidator – Optional validator to use if there is extra validation required beyond the schema
- Raises:
exception.Invalid if validation fails
- ironic.api.controllers.v1.utils.populate_node_uuid(obj, to_dict)[source]¶
Look up the node referenced in the object and populate a dict.
The node is fetched with the object
node_id
attribute and the dictnode_uuid
value is populated with the node uuid- Parameters:
obj – object to get the node_id attribute
to_dict – dict to populate with a
node_uuid
value
- Raises:
exception.NodeNotFound if the node is not found
- ironic.api.controllers.v1.utils.replace_node_id_with_uuid(to_dict)[source]¶
Replace
node_id
dict value withnode_uuid
node_uuid
is found by fetching the node by id lookup.- Parameters:
to_dict – Dict to set
node_uuid
value on- Returns:
The node object from the lookup
- Raises:
NodeNotFound with status_code set to 400 BAD_REQUEST when node is not found.
- ironic.api.controllers.v1.utils.replace_node_uuid_with_id(to_dict)[source]¶
Replace
node_uuid
dict value withnode_id
node_id
is found by fetching the node by uuid lookup.- Parameters:
to_dict – Dict to set
node_id
value on- Returns:
The node object from the lookup
- Raises:
NodeNotFound with status_code set to 400 BAD_REQUEST when node is not found.
- ironic.api.controllers.v1.utils.sanitize_dict(to_sanitize, fields)[source]¶
Removes sensitive and unrequested data.
Will only keep the fields specified in the
fields
parameter (plus thelinks
field).- Parameters:
to_sanitize – dict to sanitize
fields (list of str) – list of fields to preserve, or
None
to preserve them all
- 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.