manta_shared/types/api/
boot_parameters.rs

1//! HTTP request/response bodies and CLI-built parameter structs for
2//! the boot-parameter endpoints (`/v2/boot-config` and
3//! `/v2/boot-parameters`).
4
5use serde::{Deserialize, Serialize};
6use utoipa::ToSchema;
7
8/// Request body for `POST /v2/boot-config`.
9///
10/// Applies a combined boot configuration (image + runtime config +
11/// kernel parameters) to the nodes named by `hosts_expression`. The
12/// field is a hosts expression — xnames, NIDs, or hostlist notation;
13/// HSM group names are not accepted here (resolve them client-side
14/// first if needed).
15///
16/// At least one of `boot_image_id`, `boot_image_configuration`,
17/// `kernel_parameters`, or `runtime_configuration` should be set;
18/// `null` fields are left unchanged on the targeted nodes.
19///
20/// # Wire shape
21///
22/// ```json
23/// {
24///   "hosts_expression": "x3000c0s1b0n[0-3]",
25///   "boot_image_id": "0a1b2c3d-...",
26///   "boot_image_configuration": null,
27///   "kernel_parameters": "console=ttyS0 nosmt",
28///   "runtime_configuration": "cos-2.5",
29///   "enabled": true,
30///   "dry_run": false
31/// }
32/// ```
33#[derive(Debug, Serialize, Deserialize, ToSchema)]
34pub struct ApplyBootConfigRequest {
35  /// Hosts expression (xnames, NIDs, or hostlist notation) naming
36  /// the target nodes.
37  pub hosts_expression: String,
38  /// IMS image ID to set as the boot image. Mutually exclusive with
39  /// `boot_image_configuration`: set one or the other, not both.
40  pub boot_image_id: Option<String>,
41  /// CFS configuration name associated with the boot image; the
42  /// server resolves the most recent image built against this
43  /// configuration when `boot_image_id` is absent.
44  pub boot_image_configuration: Option<String>,
45  /// Kernel command-line parameters to apply.
46  pub kernel_parameters: Option<String>,
47  /// CFS configuration to assign as the runtime desired-config.
48  pub runtime_configuration: Option<String>,
49  /// Value to set on the CFS component `enabled` flag when a
50  /// `runtime_configuration` is being applied. Absent → server
51  /// default (`true`, i.e. let CFS reconfigure on its next pass);
52  /// `false` stages the desired configuration without enabling CFS.
53  /// Ignored when `runtime_configuration` is not set.
54  pub enabled: Option<bool>,
55  /// When true, return the computed changeset without persisting it.
56  #[serde(default)]
57  pub dry_run: bool,
58}
59
60/// Typed parameters for fetching boot parameters.
61///
62/// Precedence: `host_expression` > `group_name` >
63/// `settings_group_name`. The first one set is used; the others are
64/// ignored. If all three are unset the request fails.
65pub struct GetBootParametersParams {
66  /// Group whose members' boot parameters should be returned.
67  pub group_name: Option<String>,
68  /// Hosts expression (xnames, NIDs, or hostlist notation); mutually
69  /// exclusive with `group_name`.
70  pub host_expression: Option<String>,
71  /// Operator default from `cli.toml`'s `hsm_group`, used
72  /// when neither `group_name` nor `host_expression` is supplied.
73  pub settings_group_name: Option<String>,
74}
75
76impl GetBootParametersParams {
77  /// Returns the effective group name, preferring the explicit
78  /// `--group` flag and falling back to the operator default from
79  /// `cli.toml`.
80  pub fn effective_group(&self) -> Option<&str> {
81    self
82      .group_name
83      .as_deref()
84      .or(self.settings_group_name.as_deref())
85  }
86}
87
88/// Typed parameters for updating boot parameters.
89#[derive(serde::Deserialize, serde::Serialize, utoipa::ToSchema)]
90pub struct UpdateBootParametersParams {
91  /// Target node xnames.
92  pub hosts: Vec<String>,
93  /// Node IDs corresponding to `hosts` (optional alternate identifier).
94  pub nids: Option<Vec<u32>>,
95  /// MAC addresses corresponding to `hosts` (optional alternate identifier).
96  pub macs: Option<Vec<String>>,
97  /// Kernel command-line parameters string.
98  pub params: String,
99  /// S3 path to the kernel image.
100  pub kernel: String,
101  /// S3 path to the initrd image.
102  pub initrd: String,
103}