Skip to main content

openstack_cli_placement/v1/resource_provider/
aggregate.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//! Placement `ResourceProviderAggregate` command with subcommands
16use clap::{Parser, Subcommand};
17
18use openstack_cli_core::{cli::CliArgs, error::OpenStackCliError};
19use openstack_sdk::AsyncOpenStack;
20
21pub mod list;
22pub mod set_11;
23pub mod set_119;
24
25/// Resource provider aggregates
26///
27/// Each resource provider can be associated with one or more other resource providers in groups
28/// called aggregates. API calls in this section are used to list and update the aggregates that
29/// are associated with one resource provider.
30///
31/// Provider aggregates are used for modeling relationships among providers. Examples may include:
32///
33///   - A shared storage pool providing DISK_GB resources to compute node providers that provide
34///     VCPU and MEMORY_MB resources.
35///
36///   - Affinity/anti-affinity relationships such as physical location, power failure domains, or
37///     other reliability/availability constructs.
38///
39///   - Groupings of compute host providers corresponding to Nova host aggregates or availability
40///     zones.
41///
42/// Note: Placement aggregates are not the same as Nova host aggregates and should not be
43/// considered equivalent.
44///
45/// The primary differences between Nova’s host aggregates and placement aggregates are the
46/// following:
47///
48///   - In Nova, a host aggregate associates a nova-compute service with other nova-compute
49///     services. Placement aggregates are not specific to a nova-compute service and are, in fact,
50///     not compute-specific at all. A resource provider in the Placement API is generic, and
51///     placement aggregates are simply groups of generic resource providers. This is an important
52///     difference especially for Ironic, which when used with Nova, has many Ironic baremetal nodes
53///     attached to a single nova-compute service. In the Placement API, each Ironic baremetal node
54///     is its own resource provider and can therefore be associated to other Ironic baremetal nodes
55///     via a placement aggregate association.
56///
57///   - In Nova, a host aggregate may have metadata key/value pairs attached to it. All
58///     nova-compute services associated with a Nova host aggregate share the same metadata.
59///     Placement aggregates have no such metadata because placement aggregates only represent the
60///     grouping of resource providers. In the Placement API, resource providers are individually
61///     decorated with traits that provide qualitative information about the resource provider.
62///
63///   - In Nova, a host aggregate dictates the availability zone within which one or more
64///     nova-compute services reside. While placement aggregates may be used to model availability
65///     zones, they have no inherent concept thereof.
66#[derive(Parser)]
67pub struct AggregateCommand {
68    #[command(subcommand)]
69    command: AggregateCommands,
70}
71
72/// Supported subcommands
73#[allow(missing_docs)]
74#[derive(Subcommand)]
75pub enum AggregateCommands {
76    List(list::AggregateCommand),
77    #[command(visible_alias = "set")]
78    Set119(set_119::AggregateCommand),
79    Set11(set_11::AggregateCommand),
80}
81
82impl AggregateCommand {
83    /// Perform command action
84    pub async fn take_action<C: CliArgs>(
85        &self,
86        parsed_args: &C,
87        session: &mut AsyncOpenStack,
88    ) -> Result<(), OpenStackCliError> {
89        match &self.command {
90            AggregateCommands::List(cmd) => cmd.take_action(parsed_args, session).await,
91            AggregateCommands::Set119(cmd) => cmd.take_action(parsed_args, session).await,
92            AggregateCommands::Set11(cmd) => cmd.take_action(parsed_args, session).await,
93        }
94    }
95}