Skip to main content

openstack_cli_compute/v2/
assisted_volume_snapshot.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//! Assisted volume snapshot commands
16
17use clap::{Parser, Subcommand};
18
19use openstack_sdk::AsyncOpenStack;
20
21use openstack_cli_core::{cli::CliArgs, error::OpenStackCliError};
22
23pub mod create;
24pub mod delete;
25
26/// Assisted volume snapshots (os-assisted-volume-snapshots)
27///
28/// Creates and deletes snapshots through an emulator/hypervisor. Only qcow2 file format is
29/// supported.
30///
31/// This API is only implemented by the libvirt compute driver.
32///
33/// An internal snapshot that lacks storage such as NFS can use an emulator/hypervisor to add the
34/// snapshot feature. This is used to enable snapshot of volumes on backends such as NFS by storing
35/// data as qcow2 files on these volumes.
36///
37/// This API is only ever called by Cinder, where it is used to create a snapshot for drivers that
38/// extend the remotefs Cinder driver.
39#[derive(Parser)]
40pub struct AssistedVolumeSnapshotCommand {
41    /// subcommand
42    #[command(subcommand)]
43    command: AssistedVolumeSnapshotCommands,
44}
45
46/// Supported subcommands
47#[allow(missing_docs)]
48#[derive(Subcommand)]
49pub enum AssistedVolumeSnapshotCommands {
50    Create(create::AssistedVolumeSnapshotCommand),
51    Delete(delete::AssistedVolumeSnapshotCommand),
52}
53
54impl AssistedVolumeSnapshotCommand {
55    /// Perform command action
56    pub async fn take_action<C: CliArgs>(
57        &self,
58        parsed_args: &C,
59        session: &mut AsyncOpenStack,
60    ) -> Result<(), OpenStackCliError> {
61        match &self.command {
62            AssistedVolumeSnapshotCommands::Create(cmd) => {
63                cmd.take_action(parsed_args, session).await
64            }
65            AssistedVolumeSnapshotCommands::Delete(cmd) => {
66                cmd.take_action(parsed_args, session).await
67            }
68        }
69    }
70}