openstack_cli_compute/v2/server/create_252.rs
1// Licensed under the Apache License, Version 2.0 (the "License");
2// you may not use this file except in compliance with the License.
3// You may obtain a copy of the License at
4//
5// http://www.apache.org/licenses/LICENSE-2.0
6//
7// Unless required by applicable law or agreed to in writing, software
8// distributed under the License is distributed on an "AS IS" BASIS,
9// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10// See the License for the specific language governing permissions and
11// limitations under the License.
12//
13// SPDX-License-Identifier: Apache-2.0
14//
15// WARNING: This file is automatically generated from OpenAPI schema using
16// `openstack-codegenerator`.
17
18//! Create Server command [microversion = 2.52]
19//!
20//! Wraps invoking of the `v2.1/servers` with `POST` method
21
22use clap::Args;
23use eyre::WrapErr;
24use tracing::info;
25
26use openstack_cli_core::cli::CliArgs;
27use openstack_cli_core::error::OpenStackCliError;
28use openstack_cli_core::output::OutputProcessor;
29use openstack_sdk::AsyncOpenStack;
30
31use clap::ValueEnum;
32use openstack_cli_core::common::parse_key_val;
33use openstack_sdk::api::QueryAsync;
34use openstack_sdk::api::compute::v2::server::create_252;
35use openstack_types::compute::v2::server::response;
36use serde_json::Value;
37
38/// Creates a server.
39///
40/// The progress of this operation depends on the location of the requested
41/// image, network I/O, host load, selected flavor, and other factors.
42///
43/// To check the progress of the request, make a `GET /servers/{id}` request.
44/// This call returns a progress attribute, which is a percentage value from 0
45/// to 100.
46///
47/// The `Location` header returns the full URL to the newly created server and
48/// is available as a `self` and `bookmark` link in the server representation.
49///
50/// When you create a server, the response shows only the server ID, its links,
51/// and the admin password. You can get additional attributes through
52/// subsequent `GET` requests on the server.
53///
54/// Include the `block_device_mapping_v2` parameter in the create request body
55/// to boot a server from a volume.
56///
57/// Include the `key_name` parameter in the create request body to add a
58/// keypair to the server when you create it. To create a keypair, make a
59/// [create keypair](https://docs.openstack.org/api-ref/compute/#create-or-import-keypair)
60/// request.
61///
62/// **Preconditions**
63///
64/// **Asynchronous postconditions**
65///
66/// **Troubleshooting**
67///
68/// Normal response codes: 202
69///
70/// Error response codes: badRequest(400), unauthorized(401), forbidden(403),
71/// itemNotFound(404), conflict(409)
72#[derive(Args)]
73#[command(about = "Create Server (microversion = 2.52)")]
74pub struct ServerCommand {
75 /// Request Query parameters
76 #[command(flatten)]
77 query: QueryParameters,
78
79 /// Path parameters
80 #[command(flatten)]
81 path: PathParameters,
82
83 /// The dictionary of data to send to the scheduler. Alternatively, you can
84 /// specify `OS-SCH-HNT:scheduler_hints` as the key in the request body.
85 ///
86 /// Note
87 ///
88 /// This is a top-level key in the request body, not part of the server
89 /// portion of the request body.
90 ///
91 /// There are a few caveats with scheduler hints:
92 ///
93 /// - The request validation schema is per hint. For example, some require
94 /// a single string value, and some accept a list of values.
95 /// - Hints are only used based on the cloud scheduler configuration, which
96 /// varies per deployment.
97 /// - Hints are pluggable per deployment, meaning that a cloud can have
98 /// custom hints which may not be available in another cloud.
99 ///
100 /// For these reasons, it is important to consult each cloud’s user
101 /// documentation to know what is available for scheduler hints.
102 #[command(flatten)]
103 os_scheduler_hints: Option<OsSchedulerHints>,
104
105 /// A `server` object.
106 #[command(flatten)]
107 server: Server,
108}
109
110/// Query parameters
111#[derive(Args)]
112struct QueryParameters {}
113
114/// Path parameters
115#[derive(Args)]
116struct PathParameters {}
117/// OsSchedulerHints Body data
118#[derive(Args, Clone)]
119struct OsSchedulerHints {
120 /// Schedule the server on a host in the network specified with this
121 /// parameter and a cidr (`os:scheduler_hints.cidr`). It is available when
122 /// `SimpleCIDRAffinityFilter` is available on cloud side.
123 #[arg(help_heading = "Body parameters", long)]
124 build_near_host_ip: Option<String>,
125
126 /// Schedule the server on a host in the network specified with an IP
127 /// address (`os:scheduler_hints:build_near_host_ip`) and this parameter.
128 /// If `os:scheduler_hints:build_near_host_ip` is specified and this
129 /// parameter is omitted, `/24` is used. It is available when
130 /// `SimpleCIDRAffinityFilter` is available on cloud side.
131 #[arg(help_heading = "Body parameters", long)]
132 cidr: Option<String>,
133
134 /// A list of cell routes or a cell route (string). Schedule the server in
135 /// a cell that is not specified. It is available when
136 /// `DifferentCellFilter` is available on cloud side that is cell v1
137 /// environment.
138 ///
139 /// Parameter is an array, may be provided multiple times.
140 #[arg(action=clap::ArgAction::Append, help_heading = "Body parameters", long)]
141 different_cell: Option<Vec<String>>,
142
143 /// A list of server UUIDs or a server UUID. Schedule the server on a
144 /// different host from a set of servers. It is available when
145 /// `DifferentHostFilter` is available on cloud side.
146 ///
147 /// Parameter is an array, may be provided multiple times.
148 #[arg(action=clap::ArgAction::Append, help_heading = "Body parameters", long)]
149 different_host: Option<Vec<String>>,
150
151 /// The server group UUID. Schedule the server according to a policy of the
152 /// server group (`anti-affinity`, `affinity`, `soft-anti-affinity` or
153 /// `soft-affinity`). It is available when `ServerGroupAffinityFilter`,
154 /// `ServerGroupAntiAffinityFilter`, `ServerGroupSoftAntiAffinityWeigher`,
155 /// `ServerGroupSoftAffinityWeigher` are available on cloud side.
156 ///
157 /// Parameter is an array, may be provided multiple times.
158 #[arg(action=clap::ArgAction::Append, help_heading = "Body parameters", long)]
159 group: Option<Vec<String>>,
160
161 /// Schedule the server by using a custom filter in JSON format. For
162 /// example:
163 ///
164 /// ```text
165 /// "query": "[\">=\",\"$free_ram_mb\",1024]"
166 /// ```
167 ///
168 /// It is available when `JsonFilter` is available on cloud side.
169 #[arg(help_heading = "Body parameters", long, value_name="JSON", value_parser=openstack_cli_core::common::parse_json)]
170 query: Option<Value>,
171
172 /// A list of server UUIDs or a server UUID. Schedule the server on the
173 /// same host as another server in a set of servers. It is available when
174 /// `SameHostFilter` is available on cloud side.
175 ///
176 /// Parameter is an array, may be provided multiple times.
177 #[arg(action=clap::ArgAction::Append, help_heading = "Body parameters", long)]
178 same_host: Option<Vec<String>>,
179
180 /// A target cell name. Schedule the server in a host in the cell
181 /// specified. It is available when `TargetCellFilter` is available on
182 /// cloud side that is cell v1 environment.
183 #[arg(help_heading = "Body parameters", long)]
184 target_cell: Option<String>,
185}
186
187#[derive(Clone, Eq, Ord, PartialEq, PartialOrd, ValueEnum)]
188enum OsDcfDiskConfig {
189 Auto,
190 Manual,
191}
192
193#[derive(Clone, Eq, Ord, PartialEq, PartialOrd, ValueEnum)]
194enum NetworksStringEnum {
195 Auto,
196 None,
197}
198
199/// ServerNetworks Body data
200#[derive(Args, Clone)]
201#[group(required = true, multiple = false)]
202struct ServerNetworks {
203 #[arg(action=clap::ArgAction::SetTrue, help_heading = "Body parameters", long, required=false)]
204 auto_networks: bool,
205
206 /// Parameter is an array, may be provided multiple times.
207 #[arg(action=clap::ArgAction::Append, help_heading = "Body parameters", long, value_name="JSON", value_parser=openstack_cli_core::common::parse_json)]
208 networks: Option<Vec<Value>>,
209
210 #[arg(action=clap::ArgAction::SetTrue, help_heading = "Body parameters", long, required=false)]
211 none_networks: bool,
212}
213
214/// Server Body data
215#[derive(Args, Clone)]
216struct Server {
217 /// IPv4 address that should be used to access this server.
218 #[arg(help_heading = "Body parameters", long)]
219 access_ipv4: Option<String>,
220
221 /// IPv6 address that should be used to access this server.
222 #[arg(help_heading = "Body parameters", long)]
223 access_ipv6: Option<String>,
224
225 /// The administrative password of the server. If you omit this parameter,
226 /// the operation generates a new password.
227 #[arg(help_heading = "Body parameters", long)]
228 admin_pass: Option<String>,
229
230 /// A target cell name. Schedule the server in a host in the cell
231 /// specified. It is available when `TargetCellFilter` is available on
232 /// cloud side that is cell v1 environment.
233 #[arg(help_heading = "Body parameters", long)]
234 availability_zone: Option<String>,
235
236 /// Parameter is an array, may be provided multiple times.
237 #[arg(action=clap::ArgAction::Append, help_heading = "Body parameters", long, value_name="JSON", value_parser=openstack_cli_core::common::parse_json)]
238 block_device_mapping: Option<Vec<Value>>,
239
240 /// Enables fine grained control of the block device mapping for an
241 /// instance. This is typically used for booting servers from volumes. An
242 /// example format would look as follows:
243 ///
244 /// > ```text
245 /// > "block_device_mapping_v2": [{
246 /// > "boot_index": "0",
247 /// > "uuid": "ac408821-c95a-448f-9292-73986c790911",
248 /// > "source_type": "image",
249 /// > "volume_size": "25",
250 /// > "destination_type": "volume",
251 /// > "delete_on_termination": true,
252 /// > "tag": "disk1",
253 /// > "disk_bus": "scsi"}]
254 /// > ```
255 ///
256 /// In microversion 2.32, `tag` is an optional string attribute that can be
257 /// used to assign a tag to the block device. This tag is then exposed to
258 /// the guest in the metadata API and the config drive and is associated to
259 /// hardware metadata for that block device, such as bus (ex: SCSI), bus
260 /// address (ex: 1:0:2:0), and serial.
261 ///
262 /// A bug has caused the `tag` attribute to no longer be accepted starting
263 /// with version 2.33. It has been restored in version 2.42.
264 ///
265 /// Parameter is an array, may be provided multiple times.
266 #[arg(action=clap::ArgAction::Append, help_heading = "Body parameters", long, value_name="JSON", value_parser=openstack_cli_core::common::parse_json)]
267 block_device_mapping_v2: Option<Vec<Value>>,
268
269 /// Indicates whether a config drive enables metadata injection. The
270 /// config_drive setting provides information about a drive that the
271 /// instance can mount at boot time. The instance reads files from the
272 /// drive to get information that is normally available through the
273 /// metadata service. This metadata is different from the user data. Not
274 /// all cloud providers enable the `config_drive`. Read more in the
275 /// [OpenStack End User Guide](https://docs.openstack.org/nova/latest/user/config-drive.html).
276 #[arg(action=clap::ArgAction::Set, help_heading = "Body parameters", long)]
277 config_drive: Option<bool>,
278
279 /// A free form description of the server. Limited to 255 characters in
280 /// length. Before microversion 2.19 this was set to the server name.
281 ///
282 /// **New in version 2.19**
283 #[arg(help_heading = "Body parameters", long)]
284 description: Option<String>,
285
286 /// Set explicit NULL for the description
287 #[arg(help_heading = "Body parameters", long, action = clap::ArgAction::SetTrue, conflicts_with = "description")]
288 no_description: bool,
289
290 /// The flavor reference, as an ID (including a UUID) or full URL, for the
291 /// flavor for your server instance.
292 #[arg(help_heading = "Body parameters", long)]
293 flavor_ref: String,
294
295 /// The UUID of the image to use for your server instance. This is not
296 /// required in case of boot from volume. In all other cases it is required
297 /// and must be a valid UUID otherwise API will return 400.
298 #[arg(help_heading = "Body parameters", long)]
299 image_ref: Option<String>,
300
301 /// A target cell name. Schedule the server in a host in the cell
302 /// specified. It is available when `TargetCellFilter` is available on
303 /// cloud side that is cell v1 environment.
304 #[arg(help_heading = "Body parameters", long)]
305 key_name: Option<String>,
306
307 #[arg(help_heading = "Body parameters", long)]
308 max_count: Option<i32>,
309
310 /// Metadata key and value pairs. The maximum size of the metadata key and
311 /// value is 255 bytes each.
312 #[arg(help_heading = "Body parameters", long, value_name="key=value", value_parser=parse_key_val::<String, String>)]
313 metadata: Option<Vec<(String, String)>>,
314
315 #[arg(help_heading = "Body parameters", long)]
316 min_count: Option<i32>,
317
318 /// A target cell name. Schedule the server in a host in the cell
319 /// specified. It is available when `TargetCellFilter` is available on
320 /// cloud side that is cell v1 environment.
321 #[arg(help_heading = "Body parameters", long)]
322 name: String,
323
324 /// A list of `network` object. Required parameter when there are multiple
325 /// networks defined for the tenant. When you do not specify the networks
326 /// parameter, the server attaches to the only network created for the
327 /// current tenant. Optionally, you can create one or more NICs on the
328 /// server. To provision the server instance with a NIC for a network,
329 /// specify the UUID of the network in the `uuid` attribute in a `networks`
330 /// object. To provision the server instance with a NIC for an already
331 /// existing port, specify the port-id in the `port` attribute in a
332 /// `networks` object.
333 ///
334 /// If multiple networks are defined, the order in which they appear in the
335 /// guest operating system will not necessarily reflect the order in which
336 /// they are given in the server boot request. Guests should therefore not
337 /// depend on device order to deduce any information about their network
338 /// devices. Instead, device role tags should be used: introduced in 2.32,
339 /// broken in 2.37, and re-introduced and fixed in 2.42, the `tag` is an
340 /// optional, string attribute that can be used to assign a tag to a
341 /// virtual network interface. This tag is then exposed to the guest in the
342 /// metadata API and the config drive and is associated to hardware
343 /// metadata for that network interface, such as bus (ex: PCI), bus address
344 /// (ex: 0000:00:02.0), and MAC address.
345 ///
346 /// A bug has caused the `tag` attribute to no longer be accepted starting
347 /// with version 2.37. Therefore, network interfaces could only be tagged
348 /// in versions 2.32 to 2.36 inclusively. Version 2.42 has restored the
349 /// `tag` attribute.
350 ///
351 /// Starting with microversion 2.37, this field is required and the special
352 /// string values *auto* and *none* can be specified for networks. *auto*
353 /// tells the Compute service to use a network that is available to the
354 /// project, if one exists. If one does not exist, the Compute service will
355 /// attempt to automatically allocate a network for the project (if
356 /// possible). *none* tells the Compute service to not allocate a network
357 /// for the instance. The *auto* and *none* values cannot be used with any
358 /// other network values, including other network uuids, ports, fixed IPs
359 /// or device tags. These are requested as strings for the networks value,
360 /// not in a list. See the associated example.
361 #[command(flatten)]
362 networks: ServerNetworks,
363
364 /// Controls how the API partitions the disk when you create, rebuild, or
365 /// resize servers. A server inherits the `OS-DCF:diskConfig` value from
366 /// the image from which it was created, and an image inherits the
367 /// `OS-DCF:diskConfig` value from the server from which it was created. To
368 /// override the inherited setting, you can include this attribute in the
369 /// request body of a server create, rebuild, or resize request. If the
370 /// `OS-DCF:diskConfig` value for an image is `MANUAL`, you cannot create a
371 /// server from that image and set its `OS-DCF:diskConfig` value to `AUTO`.
372 /// A valid value is:
373 ///
374 /// - `AUTO`. The API builds the server with a single partition the size of
375 /// the target flavor disk. The API automatically adjusts the file system
376 /// to fit the entire partition.
377 /// - `MANUAL`. The API builds the server by using whatever partition
378 /// scheme and file system is in the source image. If the target flavor
379 /// disk is larger, the API does not partition the remaining disk space.
380 #[arg(help_heading = "Body parameters", long)]
381 os_dcf_disk_config: Option<OsDcfDiskConfig>,
382
383 /// The file path and contents, text only, to inject into the server at
384 /// launch. The maximum size of the file path data is 255 bytes. The
385 /// maximum limit is the number of allowed bytes in the decoded, rather
386 /// than encoded, data.
387 ///
388 /// **Available until version 2.56**
389 ///
390 /// Parameter is an array, may be provided multiple times.
391 #[arg(action=clap::ArgAction::Append, help_heading = "Body parameters", long, value_name="JSON", value_parser=openstack_cli_core::common::parse_json)]
392 personality: Option<Vec<Value>>,
393
394 /// Indicates whether a config drive enables metadata injection. The
395 /// config_drive setting provides information about a drive that the
396 /// instance can mount at boot time. The instance reads files from the
397 /// drive to get information that is normally available through the
398 /// metadata service. This metadata is different from the user data. Not
399 /// all cloud providers enable the `config_drive`. Read more in the
400 /// [OpenStack End User Guide](https://docs.openstack.org/nova/latest/user/config-drive.html).
401 #[arg(action=clap::ArgAction::Set, help_heading = "Body parameters", long)]
402 return_reservation_id: Option<bool>,
403
404 /// One or more security groups. Specify the name of the security group in
405 /// the `name` attribute. If you omit this attribute, the API creates the
406 /// server in the `default` security group. Requested security groups are
407 /// not applied to pre-existing ports.
408 ///
409 /// Parameter is an array, may be provided multiple times.
410 #[arg(action=clap::ArgAction::Append, help_heading = "Body parameters", long)]
411 security_groups: Option<Vec<String>>,
412
413 /// A list of tags. Tags have the following restrictions:
414 ///
415 /// - Tag is a Unicode bytestring no longer than 60 characters.
416 /// - Tag is a non-empty string.
417 /// - ‘/’ is not allowed to be in a tag name
418 /// - Comma is not allowed to be in a tag name in order to simplify
419 /// requests that specify lists of tags
420 /// - All other characters are allowed to be in a tag name
421 /// - Each server can have up to 50 tags.
422 ///
423 /// **New in version 2.52**
424 ///
425 /// Parameter is an array, may be provided multiple times.
426 #[arg(action=clap::ArgAction::Append, help_heading = "Body parameters", long)]
427 tags: Option<Vec<String>>,
428
429 /// Configuration information or scripts to use upon launch. Must be Base64
430 /// encoded. Restricted to 65535 bytes.
431 ///
432 /// Note
433 ///
434 /// The `null` value allowed in Nova legacy v2 API, but due to the strict
435 /// input validation, it isn’t allowed in Nova v2.1 API.
436 #[arg(help_heading = "Body parameters", long)]
437 user_data: Option<String>,
438}
439
440impl ServerCommand {
441 /// Perform command action
442 pub async fn take_action<C: CliArgs>(
443 &self,
444 parsed_args: &C,
445 client: &mut AsyncOpenStack,
446 ) -> Result<(), OpenStackCliError> {
447 info!("Create Server");
448
449 let op = OutputProcessor::from_args(parsed_args, Some("compute.server"), Some("create"));
450 op.validate_args(parsed_args)?;
451
452 let mut ep_builder = create_252::Request::builder();
453 ep_builder.header(
454 http::header::HeaderName::from_static("openstack-api-version"),
455 http::header::HeaderValue::from_static("compute 2.52"),
456 );
457
458 // Set body parameters
459 // Set Request.os_scheduler_hints data
460 if let Some(args) = &self.os_scheduler_hints {
461 let mut os_scheduler_hints_builder = create_252::OsSchedulerHintsBuilder::default();
462 if let Some(val) = &args.build_near_host_ip {
463 os_scheduler_hints_builder.build_near_host_ip(val);
464 }
465
466 if let Some(val) = &args.cidr {
467 os_scheduler_hints_builder.cidr(val);
468 }
469
470 if let Some(val) = &args.different_cell {
471 os_scheduler_hints_builder
472 .different_cell(val.iter().map(Into::into).collect::<Vec<_>>());
473 }
474
475 if let Some(val) = &args.different_host {
476 os_scheduler_hints_builder
477 .different_host(val.iter().map(Into::into).collect::<Vec<_>>());
478 }
479
480 if let Some(val) = &args.group {
481 os_scheduler_hints_builder.group(val.iter().map(Into::into).collect::<Vec<_>>());
482 }
483
484 if let Some(val) = &args.query {
485 os_scheduler_hints_builder.query(val.clone());
486 }
487
488 if let Some(val) = &args.same_host {
489 os_scheduler_hints_builder
490 .same_host(val.iter().map(Into::into).collect::<Vec<_>>());
491 }
492
493 if let Some(val) = &args.target_cell {
494 os_scheduler_hints_builder.target_cell(val);
495 }
496
497 ep_builder.os_scheduler_hints(
498 os_scheduler_hints_builder
499 .build()
500 .wrap_err("error preparing the request data")?,
501 );
502 }
503
504 // Set Request.server data
505 let args = &self.server;
506 let mut server_builder = create_252::ServerBuilder::default();
507 if let Some(val) = &args.os_dcf_disk_config {
508 let tmp = match val {
509 OsDcfDiskConfig::Auto => create_252::OsDcfDiskConfig::Auto,
510 OsDcfDiskConfig::Manual => create_252::OsDcfDiskConfig::Manual,
511 };
512 server_builder.os_dcf_disk_config(tmp);
513 }
514
515 if let Some(val) = &args.access_ipv4 {
516 server_builder.access_ipv4(val);
517 }
518
519 if let Some(val) = &args.access_ipv6 {
520 server_builder.access_ipv6(val);
521 }
522
523 if let Some(val) = &args.admin_pass {
524 server_builder.admin_pass(val);
525 }
526
527 if let Some(val) = &args.availability_zone {
528 server_builder.availability_zone(val);
529 }
530
531 if let Some(val) = &args.block_device_mapping {
532 let block_device_mapping_builder: Vec<create_252::BlockDeviceMapping> = val
533 .iter()
534 .flat_map(|v| {
535 serde_json::from_value::<create_252::BlockDeviceMapping>(v.to_owned())
536 })
537 .collect::<Vec<create_252::BlockDeviceMapping>>();
538 server_builder.block_device_mapping(block_device_mapping_builder);
539 }
540
541 if let Some(val) = &args.block_device_mapping_v2 {
542 let block_device_mapping_v2_builder: Vec<create_252::BlockDeviceMappingV2> = val
543 .iter()
544 .flat_map(|v| {
545 serde_json::from_value::<create_252::BlockDeviceMappingV2>(v.to_owned())
546 })
547 .collect::<Vec<create_252::BlockDeviceMappingV2>>();
548 server_builder.block_device_mapping_v2(block_device_mapping_v2_builder);
549 }
550
551 if let Some(val) = &args.config_drive {
552 server_builder.config_drive(*val);
553 }
554
555 if let Some(val) = &args.description {
556 server_builder.description(Some(val.into()));
557 } else if args.no_description {
558 server_builder.description(None);
559 }
560
561 server_builder.flavor_ref(&args.flavor_ref);
562
563 if let Some(val) = &args.image_ref {
564 server_builder.image_ref(val);
565 }
566
567 if let Some(val) = &args.key_name {
568 server_builder.key_name(val);
569 }
570
571 if let Some(val) = &args.max_count {
572 server_builder.max_count(*val);
573 }
574
575 if let Some(val) = &args.metadata {
576 server_builder.metadata(val.iter().cloned());
577 }
578
579 if let Some(val) = &args.min_count {
580 server_builder.min_count(*val);
581 }
582
583 server_builder.name(&args.name);
584
585 if args.networks.auto_networks {
586 server_builder.networks(create_252::ServerNetworks::F2(
587 create_252::NetworksStringEnum::Auto,
588 ));
589 }
590
591 if let Some(data) = &args.networks.networks {
592 let networks_builder: Vec<create_252::Networks> = data
593 .iter()
594 .flat_map(|v| serde_json::from_value::<create_252::Networks>(v.to_owned()))
595 .collect();
596 server_builder.networks(create_252::ServerNetworks::F1(networks_builder));
597 }
598 if args.networks.none_networks {
599 server_builder.networks(create_252::ServerNetworks::F2(
600 create_252::NetworksStringEnum::None,
601 ));
602 }
603
604 if let Some(val) = &args.personality {
605 let personality_builder: Vec<create_252::Personality> = val
606 .iter()
607 .flat_map(|v| serde_json::from_value::<create_252::Personality>(v.to_owned()))
608 .collect::<Vec<create_252::Personality>>();
609 server_builder.personality(personality_builder);
610 }
611
612 if let Some(val) = &args.return_reservation_id {
613 server_builder.return_reservation_id(*val);
614 }
615
616 if let Some(val) = &args.security_groups {
617 let security_groups_builder: Vec<create_252::SecurityGroups> = val
618 .iter()
619 .flat_map(|v| create_252::SecurityGroupsBuilder::default().name(v).build())
620 .collect();
621 server_builder.security_groups(security_groups_builder);
622 }
623
624 if let Some(val) = &args.tags {
625 server_builder.tags(val.iter().map(Into::into).collect::<Vec<_>>());
626 }
627
628 if let Some(val) = &args.user_data {
629 server_builder.user_data(val);
630 }
631
632 ep_builder.server(
633 server_builder
634 .build()
635 .wrap_err("error preparing the request data")?,
636 );
637
638 let ep = ep_builder
639 .build()
640 .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?;
641
642 let data: serde_json::Value = ep.query_async(client).await?;
643
644 op.output_single::<response::create_a::ServerResponse>(data.clone())
645 .or_else(|_| op.output_single::<response::create_b::ServerResponse>(data.clone()))?;
646 // Show command specific hints
647 op.show_command_hint()?;
648 Ok(())
649 }
650}