Skip to main content

openstack_cli_network/v2/
vpn.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//! VPN-as-a-service commands
16
17use clap::{Parser, Subcommand};
18
19use openstack_cli_core::{cli::CliArgs, error::OpenStackCliError};
20use openstack_sdk::AsyncOpenStack;
21
22pub mod endpoint_group;
23pub mod ikepolicy;
24pub mod ipsec_site_connection;
25pub mod ipsecpolicy;
26pub mod vpnservice;
27
28/// VPNaaS 2.0 (vpn, vpnservices, ikepolicies, ipsecpolicies, endpoint-groups,
29/// ipsec-site-connections)
30///
31/// The Virtual-Private-Network-as-a-Service (VPNaaS) extension enables OpenStack projects to
32/// extend private networks across the public telecommunication infrastructure.
33///
34/// This initial implementation of the VPNaaS extension provides:
35///
36///   - Site-to-site VPN that connects two private networks.
37///
38///   - Multiple VPN connections per project.
39///
40///   - IKEv1 policy support with 3des, aes-128, aes-256, or aes-192 encryption.
41///
42///   - IPsec policy support with 3des, aes-128, aes-192, or aes-256 encryption, sha1
43///     authentication, ESP, AH, or AH-ESP transform protocol, and tunnel or transport mode
44///     encapsulation.
45///
46///   - Dead Peer Detection (DPD) with hold, clear, restart, disabled, or restart-by-peer actions.
47///
48/// This extension introduces these resources:
49///
50///   - service. A parent object that associates VPN with a specific subnet and router.
51///
52///   - ikepolicy. The Internet Key Exchange (IKE) policy that identifies the authentication and
53///     encryption algorithm to use during phase one and two negotiation of a VPN connection.
54///
55///   - ipsecpolicy. The IP security policy that specifies the authentication and encryption
56///     algorithm and encapsulation mode to use for the established VPN connection.
57///
58///   - ipsec-site-connection. Details for the site-to-site IPsec connection, including the peer
59///     CIDRs, MTU, authentication mode, peer address, DPD settings, and status.
60///
61/// VPN Endpoint Groups
62///
63/// The endpoint-groups extension adds support for defining one or more endpoints of a specific
64/// type, and can be used to specify both local and peer endpoints for IPsec connections.
65///
66/// VPN Flavors
67///
68/// The vpn-flavors extension adds the flavor_id attribute to vpnservices resources. During
69/// vpnservice creation, if a flavor_id is passed, it is used to find the provider for the driver
70/// which would handle the newly created vpnservice.
71#[derive(Parser)]
72pub struct VpnCommand {
73    /// subcommand
74    #[command(subcommand)]
75    command: VpnCommands,
76}
77
78/// Supported subcommands
79#[allow(missing_docs)]
80#[derive(Subcommand)]
81pub enum VpnCommands {
82    EndpointGroup(Box<endpoint_group::EndpointGroupCommand>),
83    Ikepolicy(ikepolicy::IkepolicyCommand),
84    IpsecSiteConnection(Box<ipsec_site_connection::IpsecSiteConnectionCommand>),
85    Ipsecpolicy(Box<ipsecpolicy::IpsecpolicyCommand>),
86    Vpnservice(Box<vpnservice::VpnserviceCommand>),
87}
88
89impl VpnCommand {
90    /// Perform command action
91    pub async fn take_action<C: CliArgs>(
92        &self,
93        parsed_args: &C,
94        session: &mut AsyncOpenStack,
95    ) -> Result<(), OpenStackCliError> {
96        match &self.command {
97            VpnCommands::EndpointGroup(cmd) => cmd.take_action(parsed_args, session).await,
98            VpnCommands::Ikepolicy(cmd) => cmd.take_action(parsed_args, session).await,
99            VpnCommands::IpsecSiteConnection(cmd) => cmd.take_action(parsed_args, session).await,
100            VpnCommands::Ipsecpolicy(cmd) => cmd.take_action(parsed_args, session).await,
101            VpnCommands::Vpnservice(cmd) => cmd.take_action(parsed_args, session).await,
102        }
103    }
104}