Skip to main content

openstack_cli_compute/v2/
quota_class_set.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//! Quota Class Set
16
17use clap::{Parser, Subcommand};
18
19use openstack_sdk::AsyncOpenStack;
20
21use openstack_cli_core::{cli::CliArgs, error::OpenStackCliError};
22
23pub mod set_21;
24pub mod show;
25
26/// Quota class sets (os-quota-class-sets)
27///
28/// Show, Create or Update the quotas for a Quota Class. Nova supports implicit ‘default’ Quota
29/// Class only.
30///
31/// **Note**
32///
33/// Once a default limit is set via the default quota class via the API, that takes precedence over
34/// any changes to that resource limit in the configuration options. In other words, once you’ve
35/// changed things via the API, you either have to keep those synchronized with the configuration
36/// values or remove the default limit from the database manually as there is no REST API for
37/// removing quota class values from the database.
38///
39/// For Example: If you updated default quotas for instances, to 20, but didn’t change
40/// quota_instances in your nova.conf, you’d now have default quota for instances as 20 for all
41/// projects. If you then change quota_instances=5 in nova.conf, but didn’t update the default
42/// quota class via the API, you’ll still have a default quota of 20 for instances regardless of
43/// nova.conf. Refer: Quotas for more details.
44///
45/// **Warning**
46///
47/// There is a bug in the v2.1 API until microversion 2.49 and the legacy v2 compatible API which
48/// does not return the server_groups and server_group_members quotas in GET and PUT
49/// os-quota-class-sets API response, whereas the v2 API used to return those keys in the API
50/// response. There is workaround to get the server_groups and server_group_members quotas using
51/// “List Default Quotas For Tenant” API in Quota sets (os-quota-sets) but that is per project
52/// quota. This issue is fixed in microversion 2.50, here onwards server_groups and
53/// server_group_members keys are returned in API response body.
54#[derive(Parser)]
55pub struct QuotaClassSetCommand {
56    /// subcommand
57    #[command(subcommand)]
58    command: QuotaClassSetCommands,
59}
60
61/// Supported subcommands
62#[allow(missing_docs)]
63#[derive(Subcommand)]
64pub enum QuotaClassSetCommands {
65    #[command(visible_alias = "set")]
66    Set21(set_21::QuotaClassSetCommand),
67    Show(show::QuotaClassSetCommand),
68}
69
70impl QuotaClassSetCommand {
71    /// Perform command action
72    pub async fn take_action<C: CliArgs>(
73        &self,
74        parsed_args: &C,
75        session: &mut AsyncOpenStack,
76    ) -> Result<(), OpenStackCliError> {
77        match &self.command {
78            QuotaClassSetCommands::Set21(cmd) => cmd.take_action(parsed_args, session).await,
79            QuotaClassSetCommands::Show(cmd) => cmd.take_action(parsed_args, session).await,
80        }
81    }
82}