forked from NVIDIA/infra-controller
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli_options.rs
More file actions
377 lines (332 loc) · 12.9 KB
/
Copy pathcli_options.rs
File metadata and controls
377 lines (332 loc) · 12.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
/*
* SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
use clap::{Parser, ValueEnum, ValueHint};
use rpc::admin_cli::OutputFormat;
use crate::{
attestation, bmc_machine, boot_override, component_manager, compute_allocation, credential,
devenv, domain, dpa, dpu, dpu_remediation, expected_machines, expected_power_shelf,
expected_rack, expected_switch, extension_service, firmware, generate_shell_complete, host,
ib_partition, instance, instance_type, inventory, ip, ipxe_template, jump, machine,
machine_interfaces, machine_validation, managed_host, managed_switch, mlx, network_devices,
network_security_group, network_segment, nvl_logical_partition, nvl_partition,
nvlink_nmxc_endpoints, operating_system, os_image, ping, power_shelf, rack, redfish,
resource_pool, rms, route_server, scout_stream, set, site_explorer, sku, spx_partition, ssh,
switch, tenant, tenant_keyset, tpm_ca, trim_table, version, vpc, vpc_peering, vpc_prefix,
};
#[derive(Parser, Debug)]
#[clap(name = "carbide-admin-cli")]
#[clap(author = "https://github.com/NVIDIA/ncx-infra-controller-core")]
pub struct CliOptions {
#[clap(
long,
default_value = "false",
help = "Print version number of carbide-admin-cli and exit. For API server version see 'version' command."
)]
pub version: bool,
#[clap(
long,
value_hint = ValueHint::Username,
value_name = "USERNAME",
help = "Never should be used against a production site. Use this flag only if you understand the impacts of inconsistencies with cloud db."
)]
pub cloud_unsafe_op: Option<String>,
#[clap(short, long, env = "CARBIDE_API_URL")]
#[clap(
help = "Default to CARBIDE_API_URL environment variable or $HOME/.config/carbide_api_cli.json file or https://carbide-api.forge-system.svc.cluster.local:1079."
)]
pub carbide_api: Option<String>,
#[clap(short, long, value_enum, default_value = "ascii-table")]
pub format: OutputFormat,
#[clap(short, long)]
pub output: Option<String>,
#[clap(long, env = "FORGE_ROOT_CA_PATH")]
#[clap(
help = "Default to FORGE_ROOT_CA_PATH environment variable or $HOME/.config/carbide_api_cli.json file."
)]
pub forge_root_ca_path: Option<String>,
#[clap(long, env = "CLIENT_CERT_PATH")]
#[clap(
help = "Default to CLIENT_CERT_PATH environment variable or $HOME/.config/carbide_api_cli.json file."
)]
pub client_cert_path: Option<String>,
#[clap(long, env = "CLIENT_KEY_PATH")]
#[clap(
help = "Default to CLIENT_KEY_PATH environment variable or $HOME/.config/carbide_api_cli.json file."
)]
pub client_key_path: Option<String>,
#[clap(long, env = "RMS_API_URL")]
#[clap(help = "RMS API URL. Default to RMS_API_URL environment variable.")]
pub rms_api_url: Option<String>,
#[clap(long, env = "RMS_ROOT_CA_PATH")]
#[clap(help = "RMS Root CA path. Default to RMS_ROOT_CA_PATH environment variable.")]
pub rms_root_ca_path: Option<String>,
#[clap(long, env = "RMS_CLIENT_CERT_PATH")]
#[clap(
help = "RMS client certificate path. Default to RMS_CLIENT_CERT_PATH environment variable."
)]
pub rms_client_cert_path: Option<String>,
#[clap(long, env = "RMS_CLIENT_KEY_PATH")]
#[clap(help = "RMS client key path. Default to RMS_CLIENT_KEY_PATH environment variable.")]
pub rms_client_key_path: Option<String>,
#[clap(short, long, num_args(0..), default_value = "0")]
pub debug: u8,
// This is primarily used by measured boot, where basic output contains just
// what you probably care about, and "extended" output also dumps out all of
// the internal UUIDs that are used to associate instances. Helpful for filing
// reports, doing site import/exports, etc.
#[clap(long, global = true, help = "Extended result output.")]
pub extended: bool,
#[clap(subcommand)]
pub commands: Option<CliCommand>,
#[clap(short = 'p', long, default_value_t = 100)]
#[clap(help = "For commands that internally retrieve data with paging, use this page size.")]
pub internal_page_size: usize,
#[clap(
long,
value_enum,
global = true,
help = "Sort output by specified field",
default_value = "primary-id"
)]
pub sort_by: SortField,
}
#[derive(PartialEq, Eq, ValueEnum, Clone, Debug)]
#[clap(rename_all = "kebab_case")]
pub enum SortField {
#[clap(help = "Sort by the primary id")]
PrimaryId,
#[clap(help = "Sort by state")]
State,
}
#[derive(Parser, Debug)]
pub enum CliCommand {
#[clap(about = "Print API server version", visible_alias = "v")]
Version(version::Opts),
#[clap(about = "Machine related handling", subcommand, visible_alias = "m")]
Machine(machine::Cmd),
#[clap(about = "Instance related handling", subcommand, visible_alias = "i")]
Instance(instance::Cmd),
#[clap(
about = "Network Segment related handling",
subcommand,
visible_alias = "ns"
)]
NetworkSegment(network_segment::Cmd),
#[clap(
name = "nvlink-nmxc-endpoints",
about = "Rack chassis serial → NMX-C endpoint mappings",
subcommand
)]
NvlinkNmxcEndpoints(nvlink_nmxc_endpoints::Cmd),
#[clap(about = "Domain related handling", subcommand, visible_alias = "d")]
Domain(domain::Cmd),
#[clap(
about = "Managed host related handling",
subcommand,
visible_alias = "mh"
)]
ManagedHost(managed_host::Cmd),
#[clap(
about = "Managed switch related handling",
subcommand,
visible_alias = "ms"
)]
ManagedSwitch(managed_switch::Cmd),
#[clap(about = "Resource pool handling", subcommand, visible_alias = "rp")]
ResourcePool(resource_pool::Cmd),
#[clap(about = "Redfish BMC actions", visible_alias = "rf")]
Redfish(redfish::RedfishAction),
#[clap(about = "Network Devices handling", subcommand)]
NetworkDevice(network_devices::Cmd),
#[clap(about = "IP address handling", subcommand)]
Ip(ip::Cmd),
#[clap(about = "DPU specific handling", subcommand)]
Dpu(dpu::Cmd),
#[clap(about = "Host specific handling", subcommand)]
Host(host::Cmd),
#[clap(about = "Generate Ansible Inventory")]
Inventory(inventory::Cmd),
#[clap(about = "Machine boot override", subcommand)]
BootOverride(boot_override::Cmd),
#[clap(
about = "BMC Machine related handling",
subcommand,
visible_alias = "bmc"
)]
BmcMachine(bmc_machine::Cmd),
#[clap(about = "Credential related handling", subcommand, visible_alias = "c")]
Credential(credential::Cmd),
#[clap(about = "Route server handling", subcommand)]
RouteServer(route_server::Cmd),
#[clap(about = "Site explorer functions", subcommand)]
SiteExplorer(site_explorer::Cmd),
#[clap(
about = "Machine interfaces and address management",
subcommand,
visible_alias = "mi"
)]
MachineInterfaces(machine_interfaces::Cmd),
#[clap(
about = "Generate shell autocomplete. Source the output of this command: `source <(carbide-admin-cli generate-shell-complete bash)`"
)]
GenerateShellComplete(generate_shell_complete::Cmd),
#[clap(
about = "Query the Version gRPC endpoint repeatedly printing how long it took and any failures."
)]
Ping(ping::Opts),
#[clap(about = "Set carbide-api dynamic features", subcommand)]
Set(set::Cmd),
#[clap(about = "Expected machine handling", subcommand, visible_alias = "em")]
ExpectedMachine(expected_machines::Cmd),
#[clap(
about = "Expected power shelf handling",
subcommand,
visible_alias = "ep"
)]
ExpectedPowerShelf(expected_power_shelf::Cmd),
#[clap(about = "Expected rack handling", subcommand, visible_alias = "er")]
ExpectedRack(expected_rack::Cmd),
#[clap(about = "Expected switch handling", subcommand, visible_alias = "ew")]
ExpectedSwitch(expected_switch::Cmd),
#[clap(about = "VPC related handling", subcommand)]
Vpc(vpc::Cmd),
#[clap(about = "VPC peering handling", subcommand)]
VpcPeering(vpc_peering::Cmd),
#[clap(about = "VPC prefix handling", subcommand)]
VpcPrefix(vpc_prefix::Cmd),
#[clap(
about = "InfiniBand Partition related handling",
subcommand,
visible_alias = "ibp"
)]
IbPartition(ib_partition::Cmd),
#[clap(
about = "Tenant KeySet related handling",
subcommand,
visible_alias = "tks"
)]
TenantKeySet(tenant_keyset::Cmd),
#[clap(
about = "Broad search across multiple object types",
visible_alias = "j"
)]
Jump(jump::Cmd),
#[clap(about = "Machine Validation", subcommand, visible_alias = "mv")]
MachineValidation(machine_validation::Cmd),
#[clap(
about = "iPXE template management",
visible_alias = "ipxe-tmpl",
subcommand
)]
IpxeTemplate(ipxe_template::Cmd),
#[clap(about = "OS catalog management", visible_alias = "os", subcommand)]
OsImage(os_image::Cmd),
#[clap(
about = "Operating system definition management",
visible_alias = "osd",
subcommand
)]
OperatingSystem(operating_system::Cmd),
#[clap(about = "Manage TPM CA certificates", subcommand)]
TpmCa(tpm_ca::Cmd),
#[clap(
about = "Network security group management",
visible_alias = "nsg",
subcommand
)]
NetworkSecurityGroup(network_security_group::Cmd),
#[clap(about = "Manage machine SKUs", subcommand)]
Sku(sku::Cmd),
#[clap(about = "Dev Env related handling", subcommand)]
DevEnv(devenv::Cmd),
#[clap(about = "Instance type management", visible_alias = "it", subcommand)]
InstanceType(instance_type::Cmd),
#[clap(
about = "Compute allocation management",
visible_alias = "ca",
subcommand
)]
ComputeAllocation(compute_allocation::Cmd),
#[clap(about = "Component manager actions", visible_alias = "cm", subcommand)]
ComponentManager(component_manager::Cmd),
#[clap(about = "SSH Util functions", subcommand)]
Ssh(ssh::Cmd),
#[clap(about = "Power Shelf management", subcommand, visible_alias = "ps")]
PowerShelf(power_shelf::Cmd),
#[clap(about = "Switch management", subcommand, visible_alias = "sw")]
Switch(switch::Cmd),
#[clap(about = "Rack Management", subcommand)]
Rack(rack::Cmd),
#[clap(about = "RMS Actions")]
Rms(rms::args::RmsAction),
#[clap(about = "Firmware related actions", subcommand)]
Firmware(firmware::Cmd),
#[clap(about = "DPA related handling", subcommand)]
Dpa(dpa::Cmd),
#[clap(about = "Trim DB tables", subcommand)]
TrimTable(trim_table::Cmd),
#[clap(about = "Dpu Remediation handling", subcommand)]
DpuRemediation(dpu_remediation::Cmd),
#[clap(
about = "Extension service management",
visible_alias = "es",
subcommand
)]
ExtensionService(extension_service::Cmd),
#[clap(about = "Mellanox Device Handling", subcommand)]
Mlx(mlx::MlxAction),
#[clap(about = "Scout Stream Connection Handling", subcommand)]
ScoutStream(scout_stream::ScoutStreamAction),
#[clap(
about = "NvLink Partition related handling",
subcommand,
visible_alias = "nvp"
)]
NvlPartition(nvl_partition::Cmd),
#[clap(
about = "SPX Partition related handling",
subcommand,
visible_alias = "spx"
)]
SpxPartition(spx_partition::Cmd),
#[clap(
about = "Logical partition related handling",
subcommand,
visible_alias = "lp"
)]
LogicalPartition(nvl_logical_partition::Cmd),
#[clap(subcommand)]
#[clap(verbatim_doc_comment)]
/// DPF-related commands.
/// Note: These commands update the DPF state of the machine, which determines DPF-based DPU re-provisioning.
/// The state is saved in the machine's metadata and will be deleted if the machine is force-deleted.
/// To make the state persistent, add the DPF state for a machine (host) to the expected machines table.
Dpf(crate::dpf::Cmd),
#[clap(about = "Tenant management", subcommand, visible_alias = "tm")]
Tenant(tenant::Cmd),
#[clap(
about = "MeasuredBoot or SPDM attestations",
subcommand,
visible_alias = "att"
)]
Attestation(attestation::Cmd),
}
impl CliOptions {
pub fn load() -> Self {
Self::parse()
}
}