Skip to main content

openstack_cli_compute/v2/server/
volume_attachment.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//! Server volume attachment commands
16
17use clap::{Parser, Subcommand};
18
19use openstack_sdk::AsyncOpenStack;
20
21use openstack_cli_core::{cli::CliArgs, error::OpenStackCliError};
22
23mod create_20;
24mod create_249;
25mod create_279;
26mod delete;
27mod list;
28mod set_20;
29mod set_285;
30mod show;
31
32/// Servers with volume attachments
33///
34/// Attaches volumes that are created through the volume API to server
35/// instances. Also, lists volume attachments for a server, shows details for a
36/// volume attachment, and detaches a volume.
37#[derive(Parser)]
38pub struct VolumeAttachmentCommand {
39    /// subcommand
40    #[command(subcommand)]
41    command: VolumeAttachmentCommands,
42}
43
44/// Supported subcommands
45#[allow(missing_docs)]
46#[derive(Subcommand)]
47pub enum VolumeAttachmentCommands {
48    Create20(create_20::VolumeAttachmentCommand),
49    Create249(create_249::VolumeAttachmentCommand),
50    #[command(visible_alias = "create")]
51    Create279(create_279::VolumeAttachmentCommand),
52    Delete(delete::VolumeAttachmentCommand),
53    List(list::VolumeAttachmentsCommand),
54    Set20(set_20::VolumeAttachmentCommand),
55    #[command(visible_alias = "set")]
56    Set285(set_285::VolumeAttachmentCommand),
57    Show(show::VolumeAttachmentCommand),
58}
59
60impl VolumeAttachmentCommand {
61    /// Perform command action
62    pub async fn take_action<C: CliArgs>(
63        &self,
64        parsed_args: &C,
65        session: &mut AsyncOpenStack,
66    ) -> Result<(), OpenStackCliError> {
67        match &self.command {
68            VolumeAttachmentCommands::Create20(cmd) => cmd.take_action(parsed_args, session).await,
69            VolumeAttachmentCommands::Create249(cmd) => cmd.take_action(parsed_args, session).await,
70            VolumeAttachmentCommands::Create279(cmd) => cmd.take_action(parsed_args, session).await,
71            VolumeAttachmentCommands::Delete(cmd) => cmd.take_action(parsed_args, session).await,
72            VolumeAttachmentCommands::List(cmd) => cmd.take_action(parsed_args, session).await,
73            VolumeAttachmentCommands::Set20(cmd) => cmd.take_action(parsed_args, session).await,
74            VolumeAttachmentCommands::Set285(cmd) => cmd.take_action(parsed_args, session).await,
75            VolumeAttachmentCommands::Show(cmd) => cmd.take_action(parsed_args, session).await,
76        }
77    }
78}