Skip to main content

openstack_cli_compute/v2/
flavor.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//! Compute Flavor commands
16
17use clap::{Parser, Subcommand};
18
19use openstack_sdk::AsyncOpenStack;
20
21use openstack_cli_core::{cli::CliArgs, error::OpenStackCliError};
22
23pub mod add_tenant_access;
24pub mod create_20;
25pub mod create_21;
26pub mod create_255;
27pub mod delete;
28pub mod extra_spec;
29pub mod flavor_access;
30pub mod list;
31pub mod remove_tenant_access;
32pub mod set_255;
33pub mod show;
34
35/// Flavor commands
36///
37/// Flavors are a way to describe the basic dimensions of a server
38/// to be created including how much cpu, ram, and disk space are
39/// allocated to a server built with this flavor.
40#[derive(Parser)]
41pub struct FlavorCommand {
42    /// subcommand
43    #[command(subcommand)]
44    command: FlavorCommands,
45}
46
47/// Supported subcommands
48#[allow(missing_docs)]
49#[derive(Subcommand)]
50pub enum FlavorCommands {
51    Access(Box<flavor_access::FlavorAccessCommand>),
52    #[command(visible_alias = "create")]
53    Create255(Box<create_255::FlavorCommand>),
54    Create21(Box<create_21::FlavorCommand>),
55    Create20(Box<create_20::FlavorCommand>),
56    Delete(Box<delete::FlavorCommand>),
57    Extraspecs(Box<extra_spec::ExtraSpecsCommand>),
58    List(Box<list::FlavorsCommand>),
59    #[command(visible_alias = "set")]
60    Set255(Box<set_255::FlavorCommand>),
61    Show(Box<show::FlavorCommand>),
62}
63
64impl FlavorCommand {
65    /// Perform command action
66    pub async fn take_action<C: CliArgs>(
67        &self,
68        parsed_args: &C,
69        session: &mut AsyncOpenStack,
70    ) -> Result<(), OpenStackCliError> {
71        match &self.command {
72            FlavorCommands::Access(cmd) => cmd.take_action(parsed_args, session).await,
73            FlavorCommands::Create255(cmd) => cmd.take_action(parsed_args, session).await,
74            FlavorCommands::Create21(cmd) => cmd.take_action(parsed_args, session).await,
75            FlavorCommands::Create20(cmd) => cmd.take_action(parsed_args, session).await,
76            FlavorCommands::Delete(cmd) => cmd.take_action(parsed_args, session).await,
77            FlavorCommands::Extraspecs(cmd) => cmd.take_action(parsed_args, session).await,
78            FlavorCommands::List(cmd) => cmd.take_action(parsed_args, session).await,
79            FlavorCommands::Set255(cmd) => cmd.take_action(parsed_args, session).await,
80            FlavorCommands::Show(cmd) => cmd.take_action(parsed_args, session).await,
81        }
82    }
83}