Commit Graph

370 Commits

Author SHA1 Message Date
Sharpz7 949387bd80 [codespell] Fixing Spelling Mistakes
This is the first in a series of commits to add support for codespell. This is continuning the process completed in ironic-python-agent.

Future Commits will add a Tox Target, CI support and potentially a git-blame-ignore-revs file if their are lots of spelling mistakes that could clutter git blame.

Change-Id: Id328ff64c352e85b58181e9d9e35973a8706ab7a
2024-02-12 19:58:56 +00:00
Zuul 13d6b02716 Merge "add default conductor group capability" 2024-01-23 19:17:57 +00:00
Jay Faulkner fe48440326 Update to latest pep8/code style versions
Update to latest versions for pep8 tox environment, correct any failures
created by change.

Change-Id: I605193dacc5e6be5c664b8daab44be16065b154d
2023-12-28 14:23:05 -08:00
Dmitry Tantsur 0902912217 Generic API for attaching/detaching virtual media
This patch allows to attach or detach a generic image as
virtual media device after a node has been provisioned.

Closes-Bug: #2033288
Change-Id: I97b68047d769f6fb686c53e89084b5874e02b8c7
2023-11-23 09:55:09 +01:00
Zuul f9a93c503d Merge "Reset parent_node values to uuids instead of names" 2023-10-18 22:29:41 +00:00
Julia Kreger d1ca14289e Reset parent_node values to uuids instead of names
So, I got myself nice and confused with testing parent_node logic
when I used a name, but the ironic internals are modeled around
queries involving UUID matching.

We now identify names, and reset the values to be a UUID.

Change-Id: I46ece586c254c58b80723bc905cad3144691fc5d
2023-10-10 13:06:42 +00:00
Julia Kreger 2366a4b86e Adds service steps
A huge list of initial work for service steps

* Adds service_step verb
* Adds service_step db/object/API field on the node object for the
  status.
* Increments the API version to 1.87 for both changes.
* Increments the RPC API version to 1.57.
* Adds initial testing to facilitate ensurance that supplied steps
  are passed through and executed upon.

Does not:

* Have tests for starting the agent ramdisk, although this is
  relatively boiler plate.
* Have a collection of pre-decorated steps available for immediate
  consumption.

Change-Id: I5b9dd928f24dff7877a4ab8dc7b743058cace994
2023-08-16 06:34:08 -07:00
Iury Gregory Melo Ferreira aecb581082 Firmware Interface
FirmwareInterface base
New Config options [default]
- enabled_firmware_interfaces
- default_firmware_interface

New FirmwareInterface base with update method
Implementations of FirmwareInterface
- FakeFirmware (fake)
- NoFirmware (no-firmware)

New entrypoint ironic.hardware.interfaces.firmware
* fake and no-firmware

Api Controllers
- Updated: driver/node/utils/versions
- Created: firmware

Unit tests
api-ref for Node Firmware

Fake and Noop implementation for FirmwareInterface

Change-Id: Ib3b9cb22099819f97d5eab1e3f1b670cb91cbb25
2023-07-11 07:39:15 -03:00
Julia Kreger c4e3100d5c Add hold steps
* Updates API version to 1.85 to permit an ``unhold`` verb
* Adds the ``deploy hold`` and ``clean hold`` provision states
  to the internal state machine.
* Adds on documentation on steps to help provide greater clarity
  to Ironic's users on how to utilize steps. It should be noted
  this documentation also includes the power state reserved step
  names from the DPU functionality patch.
* Fixes the state machine diagram. Changes type to PNG as SVG
  rendering is broken due to python libraries utilized for SVG
  generation which do not work on more recent Python versions.

Change-Id: I34f58f4e77e7757b89247fd64f5fcde26f679453
2023-06-30 14:34:26 -07:00
Julia Kreger 013ac0cb41 execute on child node support
Allows steps to be executed on child nodes, and adds
the reserved power_on, power_off, and reboot step names.

Change-Id: I4673214d2ed066aa8b95a35513b144668ade3e2b
2023-05-24 15:42:46 -07:00
Julia Kreger 3f5e25e182 DPU modeling - parent_node DB/Model/API
Adds the parent node support and tests in one change
including all DB/Model/API changes along with RBAC and
basic API tests.

* Updates the API version to 1.83
* Adds parent_node and related index to the nodes table.
* Adds new API parameters to list by parent node relationship.

Depends-On: https://review.opendev.org/c/openstack/ironic/+/883967
Change-Id: I8d64fee7105718199986db4994e13352d639f04f
2023-05-23 18:23:25 +00:00
Zuul ea6a037210 Merge "Refactoring: clean up inspection data handlers" 2023-03-23 16:06:49 +00:00
Dmitry Tantsur e30ba65f94 Refactoring: clean up inspection data handlers
* Avoid using the term "introspection". We need to settle on either
  "inspection" or "introspection", and the Ironic API already uses
  the former.

* Accept (and return) inventory and plugin data separately to reflect
  the Ironic API (single JSON blobs are an Inspector legacy).

* Make sure to mention the container name in error logging.

* Use more readable formatting syntax for building Swift names.

* Do not mock objects with dicts (in unit tests).

* Simplify inventory API tests.

Change-Id: Id8c4bc6d35b9634f5a5ac2b345a8fd7f1dba13c0
2023-03-14 18:26:06 +01:00
Julia Kreger 9953b5a2e8 add default conductor group capability
When creating nodes, previously there was no way to set a
default conductor group to create nodes with, thus forcing
a two step process, a dedicated conductor without a conductor
group to serve reqeusts for it.

With this change, an operator can set specific conductor_group
settings by API, allowing increased delineation with reduced
risk of misconfiguration or mis-step.

Story: 2010267
Task: 46183
Change-Id: I21d58750504b2eecf3368d2e03eaca050065c3d7
2023-03-13 12:00:40 -07:00
Duc Truong 005f21c0df Fix auth_protocol and priv_protocol for SNMP v3
SNMP driver was using the wrong dictionary key to retrieve auth_protocol
and priv_protocol from driver info.  As a result, the SNMP client was
created with empty strings for both those fields.  Any nodes configured
to use SNMP v3 with those fields failed because the SNMP driver was
unable to perform power related operations due to authentication error.

- Use correct keys for snmp auth_protocol and priv_protocol when
  creating SNMP client
- Sanitize snmp auth_key and priv_key in API results

Story: 2010613
Task: 47535

Change-Id: I5efd3c9f79a021f1a8e613c3d13b6596a7972672
2023-03-01 16:44:40 -08:00
Zuul c4997e0137 Merge "Add support for filtering for sharded nodes" 2023-02-14 21:28:18 +00:00
Zuul e8888aa9ae Merge "Erase swift inventory entry on node deletion" 2023-02-14 18:39:57 +00:00
Jakub Jelinek bc921118b1 Erase swift inventory entry on node deletion
Follow-up to Ie174904420691be64ce6ca10bca3231f45a5bc58
which enables storage of inventory in Swift, but does not delete
the Swift entry when the node whose inventory is stored is deleted

Story: 2010275
Task: 46204
Change-Id: I74b19f7a42c1326d7ec04e6320176e81639ebfb4
2023-02-14 10:58:05 +00:00
Jay Faulkner a0c1fd8888 Add support for filtering for sharded nodes
This request parameter will allow an operator to ask the question
"Do I need to assign shards to any of my nodes?".

Change-Id: I26b745e5ef2b320a8d8a0667ac61c080fcdcd576
2023-02-13 11:46:21 -08:00
Jay Faulkner 8e34d622af API support for CRUD node.shard
- Basic support and testing for CRUD for node.shard.
- Policy checking for update node.shard.
- New API endpoint: GET /v1/shards
- Policy checking for GET /v1/shards
- Support for querying for nodes in a list of shards

Story: 2010378
Task: 46624
Change-Id: I385594339028c20cfc83fdcc4cbbec107efdacff
2023-02-13 11:46:21 -08:00
Jay Faulkner 36ef217fdb DB & Object layer for node.shard
DB and object implementations for new node.shard key.

Story: 2010768
Task: 46624
Change-Id: Ia7ef3cffc321c93501b1cc5185972a4ac1dcb212
2023-02-13 11:46:21 -08:00
Jakub Jelinek fe69e06c7c Reorganise Inventory Storage
Move functions storing and obtaining introspection data
from drivers/modules/inspector.py and api/controllers/v1/node.py
to driver/modules/inspect_utils.py

Follow-up to change If50f665da5fbb16f7646f3d6195a6e14e7325b0a

Story: 2010275
Task: 46204
Change-Id: I2b206670aff6ad3a9f9cc76236453abf42663cad
2023-01-21 14:46:21 +00:00
Jakub Jelinek f113210999 Create [inventory]
Create [inventory] to hold CONF parameters for storage of introspection data

Story: 2010275
Task: 46204
Change-Id: I06fa4f69160206dd350856e264cbb0842e34fd2a
2023-01-17 18:40:28 +00:00
Jakub Jelinek 2e80ea9099 API for node inventory
Add api to access node inventory

Story: 2010275
Task: 46204
Change-Id: If50f665da5fbb16f7646f3d6195a6e14e7325b0a
2023-01-12 15:09:18 +00:00
Julia Kreger bc8705c160 Allow project scoped admins to create/delete nodes
Adds capabilites for a project scoped admin to
create and delete nodes in Ironic's API.

These nodes are automatically associated with the
project of the requestor.

Effectively, this does allow anyone with sufficient
privilges, i.e. admin, in an OpenStack deployment
to be able to create new baremetal nodes and delete
those baremetal nodes. In this case, the user has
the "owner" level of rights in the RBAC model.

Change-Id: I3fd9ce5de0bc600275b5c4b7a95b0f9405342688
2022-08-17 09:53:14 -07:00
Julia Kreger fb253a670f Suppress Chassis Not Found on API Operation
When you have a multi-db deployment, or even just many
different threads operating on the same server with different
transactions, you can run into a situation where one thread
initiates a transaction to get a list of nodes, and then
another triggers a delete of the chassis (and most likely node,
but hey, there is really no way to detect that and work.)

So as the API is processing the response and making the json
result set, the query to resolve a chassis_id on a node object
can begin to fail.

Before this patch, this would raise an exception to the client.

Now, we just suppress the error, and return the field value
as None.

In the grand scheme, the node is likely has also already
been deleted as well.

Change-Id: I3594ac580c01454c70922a965a2a653a8b568cbb
Closes-Bug: 1508995
Story: 1508995
Task: 10038
2022-08-02 02:56:07 +00:00
Dmitry Tantsur 55b9579f14 Fix compatibility with jsonschema>=4.0.0
Specify the schema version for network_data and node, otherwise the
latest one is used.

Also fix one test where the error messages was changed.

Change-Id: I4a614d7e73348bbe6c355a40881b013cbfe00b03
2022-07-14 18:07:48 +02:00
Zuul e5a1997df8 Merge "Create API documentation from docstrings" 2022-03-17 15:35:42 +00:00
Mahnoor Asghar 3e631a5931 Create API documentation from docstrings
Create a new Sphinx extension called 'web_api_docstring' to process
docstrings from the API classes, in order to generate API
documentation.

Story: 2009785
Task: 44291
Change-Id: Ia6b2b3741e2b1cbd29531c21795df4f0f0dc70ca
2022-03-17 01:22:44 +05:00
Dmitry Tantsur 55144d3bd2 Fix resource_url in the remaining resources
Node history was particularly affected: limit was not converted from
string to integer, so "next" link was never added.

Add some safeguards to the generic API code.

Change-Id: I1328e2f07621bf7e39b96eb4a7ddb66c9a2b65bb
2022-01-24 19:10:29 +01:00
Arne Wiebalck 69227c66c2 Set resource_url when getting all nodes
Since the default value resource_url is None, make sure the
parameter is set to 'nodes' when getting all nodes.

Change-Id: I6cc52eb56c7888a433d24aa79154143d6f35cf83
2022-01-17 14:30:58 +01:00
Julia Kreger fb9eae7412 API endpoints to get node history
Adds API for retrieving node history events
via a node. Includes pagination and limitation
of the response set.

Story: 2002980
Tas: 42961

Change-Id: I22a92fa6c30d721f6a5dd0670b2e0a9cf76ad7b1
2021-09-15 10:54:11 -07:00
Cenne 5b545086ac Minor formatting and doc changes to change boot mode feature commit.
Story: 2008567
Task: 41709
depends-on: https://review.opendev.org/c/openstack/ironic/+/800084
Change-Id: I44e41dc3d8abcb99a2248d7b9c7ac5e9d786bb98
2021-08-24 14:29:53 +02:00
Cenne bc95c92f7c Add api endpoints for changing boot_mode and secure_boot state
Done:
  - Node API endpoints expose
  - RPC methods
  - Conductor Manager methods
  - Conductor utils new methods
  - RBAC new policies
  - Node API tests
  - Manager Tests (+ some testing for utils methods)
  - RBAC tests
  - Docs (api-ref)
  - REST API version history
  - Releasenotes

Story: 2008567
Task: 41709

Change-Id: I2d72389edf546b99c536c6b130ca85ababf80591
2021-08-23 19:38:58 +02:00
Cenne 46ff51487a Add `boot_mode` and `secure_boot` to node object and expose in api
* add fields to Node object
  * expose them at endpoint `/v1/nodes/{node_ident}/states`
  * update states on powersync / entering managed state.
  * tests
  * update api endpoint info in api-ref

Story: 2008567
Task: 41709

Change-Id: Iddd1421a6fa37d69da56658a2fefa5bc8cfd15e4
2021-07-08 15:04:15 +02:00
Julia Kreger 9e477d1787 Fix typos in API sanitization change notes
Change https://review.opendev.org/c/openstack/ironic/+/794880
included a few minor typos and required a clarification of a point
which.

This change just makes those minor text changes.

Change-Id: I883d4ca89ba984c29b53b531af98f2f0be39edbf
2021-07-07 10:08:51 -07:00
Julia Kreger 9851b68ee9 Allow node_sanitize function to be provided overrides
The biggest amount of API overhead is the node sanitization
process, at least at this point in time.

We have streamlined the database interaction to ensure specific
field selection lists are as orderly as possible, but the
node sanitization code re-executes some methods over and over
which do not require variable data from the underlying node.

These are blanket settings "is the user allowed to see x, or y".

Which means we can call node_sanitize pre-seeding these
arguments and execute the calls once, instead of a thousand times
to have the same exact result.

Story: 2008885
Task: 42433

Change-Id: I342e7900cac388cb4749480684418a5a15ac60eb
2021-07-06 11:07:34 -07:00
Julia Kreger 87e42afb9e API to pass fields to node object list
This change modifies the nodes _get_nodes_collection method to
consider and pass in an explicit lisst of requested fields into
the node list method, while also including the required fields
for things like ownership/policy checking.

And slightly modifies node_convert_with_links method to simplify
it while enabling field validity to be checked, and specific
requisite field lists provided in based upon that value.

And also optionally builds the traits list as they are nolonger
*always* populated on all objects with fully populated objects
as only partially hydrated objects are provided back when specific
fields are requested.

Story: 2008885
Task: 42572
Change-Id: Ided419263d84184cab902944b6c518f98618c9d2
2021-06-25 23:04:31 +00:00
Julia Kreger be3c153d56 Fix node detail instance_uuid request handling
The instance_uuid handling on the detailed node information
endpoint of the api (/v1/nodes/detail?instance_uuid=<uuid>),
which is used by services such as Nova for explicit node status
lookups, previously had special conditional logic surrounding it
which skipped the inclusion of the API requestor project-id, from
being incorporated into the database query.

Ultimately, this allowed an authenticated user to obtain a partially
redacted node entry where sensitive informational fields were scrubbed
from the response payload.

With this fix, queries for an explicit instance_uuid now follow the
standard path inside the Ironic API to the database which includes
inclusion of a requestor Project-ID if required by configured policy.

Change-Id: I9bfa5a54e02c8a1e9c8cad6b9acdbad6ab62bef3
Story: 2008976
Task: 42620
2021-06-17 08:55:18 -07:00
Zuul 2f139acded Merge "Secure RBAC - Efficent node santiziation" 2021-06-01 19:12:05 +00:00
Julia Kreger 6cd6457479 Secure RBAC - Efficent node santiziation
An investigation of performance issues in Ironic revealed that the
policy checking was performing extra un-needed work which performed
excess computational overhead when parsing the result data.

In this specific case, the Secure RBAC work added some additional
policy checks around individual the fields.

Change-Id: I77b6e0e6c721f2ff1f8b9f511acde97fcdb21a39
Story: 2008885
Task: 42432
2021-05-24 14:05:28 +00:00
Dmitry Tantsur 172d1b22df Delay rendering configdrive
When the configdrive input is JSON (meta_data, etc), delay the rendering
until the ISO image is actually used. It has two benefits:
1) Avoid storing a large ISO image in instance_info,
2) Allow deploy steps to access the original user's input.

Fix configdrive masking to correctly mask dicts.

Story: #2008875
Task: #42419
Change-Id: I86d30bbb505b8c794bfa6412606f4516f8885aa9
2021-05-19 15:17:49 +02:00
kafilat-adeleke 5c303a5e0a Aliases for a few unfortunately named state transitions
This RFE proposes a new microversion that will provide
aliases to two poorly named provisioning verbs
to match the existing CLI commands

Story: #2007551
Task: #39402
Change-Id: Ifd14aebbfb4b17c5108f44092dac0b89d1c2c50a
2021-04-15 08:25:13 +01:00
Dmitry Tantsur 24be3c2286 Allow using per-site network_data schema
I have been against it since the beginning of this work, hoping that we
can settle down on one network data format, one is more native for
Ironic because of our relation to OpenStack. This has not happened, with
e.g. CoreOS only using its own formats. So, let it be. Use with caution.

Change-Id: I872d010517cd343fcbcafadb4535f07ca15c2c95
2021-03-26 15:33:14 +01:00
Dmitry Tantsur 30a85bd0ce API to force manual cleaning without booting IPA
Adds a new argument disable_ramdisk to the manual cleaning API.
Only steps that are marked with requires_ramdisk=False can be
run in this mode. Cleaning prepare/tear down is not done.

Some steps (like redfish BIOS) currently require IPA to detect
a successful reboot. They are not marked with requires_ramdisk
just yet.

Change-Id: Icacac871603bd48536188813647bc669c574de2a
Story: #2008491
Task: #41540
2021-03-16 16:08:46 +01:00
Julia Kreger e9dfe5ddaa Port/Portgroup project scoped access
This patch implements the project scoped rbac policies for a
system and project scoped deployment of ironic. Because of the
nature of Ports and Portgroups, along with the subcontroller
resources, this change was a little more invasive than was
originally anticipated. In that process, along with some
discussion in the #openstack-ironic IRC channel, that it
would be most security concious to respond only with 404s if
the user simply does not have access to the underlying node
object.

In essence, their view of the universe has been restricted as
they have less acess rights, and we appropriately enforce that.
Not expecting that, or not conciously being aware of that, can
quickly lead to confusion though. Possibly a day or more of
Julia's life as well, but it comes down to perceptions and
awareness.

Change-Id: I68c5f2bae76ca313ba77285747dc6b1bc8b623b9
2021-03-02 15:45:03 -08:00
Julia Kreger f1641468bb Project Scoping Node endpoint
* Adds additional policies:
  * baremetal:node_get:last_error
  * baremetal:node:get:reservation
  * baremetal:node:get:driver_internal_info
  * baremetal:node:get:driver_info
  * baremetal:node:update:driver_info
  * baremetal:node:update:properties
  * baremetal:node:update:chassis_uuid
  * baremetal:node:update:instance_uuid
  * baremetal:node:update:lessee
  * baremetal:node:update:driver_interfaces
  * baremetal:node:update:network_data
  * baremetal:node:update:conductor_group
  * baremetal:node:update:name

* With new policies, responses of filtering and posted data is
  performed. Testing has been added to the RBAC testing files
  to align with this and the defaults where pertinant.

* Adds another variation of the common policy check method
  which may be useful in the long term. This is too soon to
  tell, but the overall purpose is to allow similar logic
  patterns to the authorize behavior. This is because the
  standard policies are, at present, also used to control
  behavior of response, and node response sanitization needs
  to be carefully navigated.

This change excludes linked resources such as /nodes/<uuid>/ports,
portgroups, volumes/[targets|connectors]. Those will be in later
changes, as the node itself is quite a bit.

Special note:
* The indicator endpoint code in the API appears to be broken
  and given that should be fixed in a separate patch.

Change-Id: I2869bf21f761cfc543798cf1f7d97c5500cd3681
2021-03-02 15:43:29 -08:00
Aija Jauntēva 3138acc836 Add 'deploy steps' parameter for provisioning API
Story: 2008043
Task: 40705
Change-Id: I3dc2d42b3edd2a9530595e752895e9d113f76ea8
2021-02-03 11:47:53 -05:00
Steve Baker 8669837ea2 Consistently use utils functions for policy auth
The check_policy function exists in api utils, along with other more
complex policy utility functions. This change replaces direct calls to
authorize with calls to check_policy.

Having authorize calls consolidated in api utils may help with the
upcoming secure-rbac work.

Change-Id: If4779b08b9f360f4c2f4675c605aa519f6ea4778
2020-12-17 12:11:08 +13:00
Steve Baker a3644ebd63 Improve object_to_dict arguments
As a follow-up to the review feedback in[1], type specific fields
arguments are removed and the type is inferred from the versioned
object fields.

Story: 1651346
Task: 10551
[1] https://review.opendev.org/751160

Change-Id: I89a65214ab7d550d0b4a327dd033c27399ae13bf
2020-11-27 10:52:14 +13:00