Skip to main content

openstack_cli_compute/v2/server/
confirm_resize.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//! Action Server command
19//!
20//! Wraps invoking of the `v2.1/servers/{id}/action` with `POST` method
21
22use clap::Args;
23use tracing::info;
24
25use openstack_cli_core::cli::CliArgs;
26use openstack_cli_core::error::OpenStackCliError;
27use openstack_cli_core::output::OutputProcessor;
28use openstack_sdk::AsyncOpenStack;
29
30use openstack_sdk::api::QueryAsync;
31use openstack_sdk::api::compute::v2::server::confirm_resize;
32use serde_json::Value;
33
34/// Confirms a pending resize action for a server.
35///
36/// Specify the `confirmResize` action in the request body.
37///
38/// After you make this request, you typically must keep polling the server
39/// status to determine whether the request succeeded. A successfully
40/// confirming resize operation shows a status of `ACTIVE` or `SHUTOFF` and a
41/// migration status of `confirmed`. You can also see the resized server in the
42/// compute node that OpenStack Compute manages.
43///
44/// **Preconditions**
45///
46/// You can only confirm the resized server where the status is
47/// `VERIFY_RESIZE`.
48///
49/// If the server is locked, you must have administrator privileges to confirm
50/// the server.
51///
52/// **Troubleshooting**
53///
54/// If the server status remains `VERIFY_RESIZE`, the request failed. Ensure
55/// you meet the preconditions and run the request again. If the request fails
56/// again, the server status should be `ERROR` and a migration status of
57/// `error`. Investigate the compute back end or ask your cloud provider. There
58/// are some options for trying to correct the server status:
59///
60/// Note that the cloud provider may still need to cleanup any orphaned
61/// resources on the source hypervisor.
62///
63/// Normal response codes: 204
64///
65/// Error response codes: badRequest(400), unauthorized(401), forbidden(403),
66/// itemNotFound(404), conflict(409)
67#[derive(Args)]
68#[command(about = "Confirm Resized Server (confirmResize Action)")]
69pub struct ServerCommand {
70    /// Request Query parameters
71    #[command(flatten)]
72    query: QueryParameters,
73
74    /// Path parameters
75    #[command(flatten)]
76    path: PathParameters,
77
78    /// OpenAPI specifies the field as '{}'.
79    #[arg(default_value_t=Value::Null, help_heading = "Body parameters", long, value_name="JSON", value_parser=openstack_cli_core::common::parse_json)]
80    confirm_resize: Value,
81}
82
83/// Query parameters
84#[derive(Args)]
85struct QueryParameters {}
86
87/// Path parameters
88#[derive(Args)]
89struct PathParameters {
90    /// id parameter for /v2.1/servers/{id}/action API
91    #[arg(
92        help_heading = "Path parameters",
93        id = "path_param_id",
94        value_name = "ID"
95    )]
96    id: String,
97}
98
99impl ServerCommand {
100    /// Perform command action
101    pub async fn take_action<C: CliArgs>(
102        &self,
103        parsed_args: &C,
104        client: &mut AsyncOpenStack,
105    ) -> Result<(), OpenStackCliError> {
106        info!("Action Server");
107
108        let op =
109            OutputProcessor::from_args(parsed_args, Some("compute.server"), Some("confirm_resize"));
110        op.validate_args(parsed_args)?;
111
112        let mut ep_builder = confirm_resize::Request::builder();
113
114        ep_builder.id(&self.path.id);
115
116        // Set body parameters
117        // Set Request.confirm_resize data
118        ep_builder.confirm_resize(self.confirm_resize.clone());
119
120        let ep = ep_builder
121            .build()
122            .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?;
123        openstack_sdk::api::ignore(ep).query_async(client).await?;
124        // Show command specific hints
125        op.show_command_hint()?;
126        Ok(())
127    }
128}