From ebd1f0e2f273c84943ff45fcc0a4bcf8471e3cba Mon Sep 17 00:00:00 2001 From: Artem Goncharov Date: Thu, 26 Sep 2024 15:09:49 +0200 Subject: [PATCH] feat: Enable network.default-security-group-rule commands - Add default-security-group-rule commands - hide few latest network functional tests behind feature flags - stop running nextest with `--all-features` until method to identify known capabilities is found. --- .github/workflows/functional.yml | 2 +- openstack_cli/Cargo.toml | 4 + openstack_cli/src/network/v2.rs | 5 ++ openstack_cli/src/network/v2/agent/list.rs | 4 +- .../network/v2/default_security_group_rule.rs | 75 +++++++++++++++++++ .../v2/default_security_group_rule/set.rs | 1 - .../v2/auto_allocated_topology/list.rs | 31 ++++++++ .../network/v2/auto_allocated_topology/mod.rs | 2 + .../v2/default_security_group_rule/list.rs | 31 ++++++++ .../v2/default_security_group_rule/mod.rs | 35 +++++++++ openstack_cli/tests/network/v2/mod.rs | 1 + 11 files changed, 187 insertions(+), 4 deletions(-) create mode 100644 openstack_cli/src/network/v2/default_security_group_rule.rs create mode 100644 openstack_cli/tests/network/v2/auto_allocated_topology/list.rs create mode 100644 openstack_cli/tests/network/v2/default_security_group_rule/list.rs create mode 100644 openstack_cli/tests/network/v2/default_security_group_rule/mod.rs diff --git a/.github/workflows/functional.yml b/.github/workflows/functional.yml index 9d1b64f3b..f2a2855b8 100644 --- a/.github/workflows/functional.yml +++ b/.github/workflows/functional.yml @@ -73,4 +73,4 @@ jobs: - name: Execute functional tests env: OS_CLOUD: devstack - run: cargo nextest run --test functional --all-features + run: cargo nextest run --test functional diff --git a/openstack_cli/Cargo.toml b/openstack_cli/Cargo.toml index f0c59f5e8..da6ba199b 100644 --- a/openstack_cli/Cargo.toml +++ b/openstack_cli/Cargo.toml @@ -39,6 +39,10 @@ image = ["openstack_sdk/image"] load_balancer = ["openstack_sdk/load_balancer"] network = ["openstack_sdk/network"] object_store = ["openstack_sdk/object_store"] +_test_net_auto-allocated-topology = [] +_test_net_dhcp_agent_scheduler = [] +_test_net_l3_agent_scheduler = [] + [dependencies] better-panic = { workspace = true } diff --git a/openstack_cli/src/network/v2.rs b/openstack_cli/src/network/v2.rs index 95c5985b7..4dff24fee 100644 --- a/openstack_cli/src/network/v2.rs +++ b/openstack_cli/src/network/v2.rs @@ -25,6 +25,7 @@ mod address_scope; mod agent; mod auto_allocated_topology; mod availability_zone; +mod default_security_group_rule; mod extension; mod floatingip; mod network; @@ -53,6 +54,7 @@ pub enum NetworkCommands { Agent(Box), AutoAllocatedTopology(Box), AvailabilityZone(Box), + DefaultSecurityGroupRule(Box), Extension(Box), FloatingIP(Box), Network(Box), @@ -85,6 +87,9 @@ impl NetworkCommand { cmd.take_action(parsed_args, session).await } NetworkCommands::AvailabilityZone(cmd) => cmd.take_action(parsed_args, session).await, + NetworkCommands::DefaultSecurityGroupRule(cmd) => { + cmd.take_action(parsed_args, session).await + } NetworkCommands::Extension(cmd) => cmd.take_action(parsed_args, session).await, NetworkCommands::FloatingIP(cmd) => cmd.take_action(parsed_args, session).await, NetworkCommands::Network(cmd) => cmd.take_action(parsed_args, session).await, diff --git a/openstack_cli/src/network/v2/agent/list.rs b/openstack_cli/src/network/v2/agent/list.rs index 24b3fde95..41cd79fcd 100644 --- a/openstack_cli/src/network/v2/agent/list.rs +++ b/openstack_cli/src/network/v2/agent/list.rs @@ -176,7 +176,7 @@ struct ResponseData { /// #[serde()] #[structable(optional, wide)] - alive: Option, + alive: Option, /// The availability zone of the agent. /// @@ -196,7 +196,7 @@ struct ResponseData { /// #[serde()] #[structable(optional, wide)] - configurations: Option, + configurations: Option, /// Time at which the resource has been created (in UTC ISO8601 format). /// diff --git a/openstack_cli/src/network/v2/default_security_group_rule.rs b/openstack_cli/src/network/v2/default_security_group_rule.rs new file mode 100644 index 000000000..e92bdd479 --- /dev/null +++ b/openstack_cli/src/network/v2/default_security_group_rule.rs @@ -0,0 +1,75 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 + +//! DefaultSecurityGroupRule resource commands + +use clap::{Parser, Subcommand}; + +use openstack_sdk::AsyncOpenStack; + +use crate::{Cli, OpenStackCliError}; + +mod create; +mod delete; +mod list; +mod set; +mod show; + +/// Security group default rules (security-group-default-rules) +/// +/// Lists, creates, shows information for, and deletes security group default rules. +#[derive(Parser)] +pub struct DefaultSecurityGroupRuleCommand { + /// subcommand + #[command(subcommand)] + command: DefaultSecurityGroupRuleCommands, +} + +/// Supported subcommands +#[allow(missing_docs)] +#[derive(Subcommand)] +pub enum DefaultSecurityGroupRuleCommands { + Create(Box), + Delete(Box), + List(Box), + Set(Box), + Show(Box), +} + +impl DefaultSecurityGroupRuleCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + session: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + match &self.command { + DefaultSecurityGroupRuleCommands::Create(cmd) => { + cmd.take_action(parsed_args, session).await + } + DefaultSecurityGroupRuleCommands::Delete(cmd) => { + cmd.take_action(parsed_args, session).await + } + DefaultSecurityGroupRuleCommands::List(cmd) => { + cmd.take_action(parsed_args, session).await + } + DefaultSecurityGroupRuleCommands::Set(cmd) => { + cmd.take_action(parsed_args, session).await + } + DefaultSecurityGroupRuleCommands::Show(cmd) => { + cmd.take_action(parsed_args, session).await + } + } + } +} diff --git a/openstack_cli/src/network/v2/default_security_group_rule/set.rs b/openstack_cli/src/network/v2/default_security_group_rule/set.rs index 1dadbba72..d0bb3e48f 100644 --- a/openstack_cli/src/network/v2/default_security_group_rule/set.rs +++ b/openstack_cli/src/network/v2/default_security_group_rule/set.rs @@ -31,7 +31,6 @@ use crate::OpenStackCliError; use crate::OutputConfig; use crate::StructTable; -use crate::common::parse_json; use crate::common::parse_key_val; use crate::common::BoolString; use openstack_sdk::api::network::v2::default_security_group_rule::set; diff --git a/openstack_cli/tests/network/v2/auto_allocated_topology/list.rs b/openstack_cli/tests/network/v2/auto_allocated_topology/list.rs new file mode 100644 index 000000000..972b1dabf --- /dev/null +++ b/openstack_cli/tests/network/v2/auto_allocated_topology/list.rs @@ -0,0 +1,31 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +use assert_cmd::prelude::*; +use std::process::Command; + +#[test] +fn list() -> Result<(), Box> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("network") + .arg("auto-allocated-topology") + .arg("list"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/network/v2/auto_allocated_topology/mod.rs b/openstack_cli/tests/network/v2/auto_allocated_topology/mod.rs index ec3f8c09e..5bdb6d2f3 100644 --- a/openstack_cli/tests/network/v2/auto_allocated_topology/mod.rs +++ b/openstack_cli/tests/network/v2/auto_allocated_topology/mod.rs @@ -14,6 +14,8 @@ mod create_autogen; mod delete_autogen; +#[cfg(feature = "_test_net_auto-allocated-topology")] +mod list; mod list_autogen; mod set_autogen; mod show_autogen; diff --git a/openstack_cli/tests/network/v2/default_security_group_rule/list.rs b/openstack_cli/tests/network/v2/default_security_group_rule/list.rs new file mode 100644 index 000000000..598a3f778 --- /dev/null +++ b/openstack_cli/tests/network/v2/default_security_group_rule/list.rs @@ -0,0 +1,31 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +use assert_cmd::prelude::*; +use std::process::Command; + +#[test] +fn help() -> Result<(), Box> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("network") + .arg("default-security-group-rule") + .arg("list"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/network/v2/default_security_group_rule/mod.rs b/openstack_cli/tests/network/v2/default_security_group_rule/mod.rs new file mode 100644 index 000000000..507a7e0d5 --- /dev/null +++ b/openstack_cli/tests/network/v2/default_security_group_rule/mod.rs @@ -0,0 +1,35 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 + +mod create_autogen; +mod delete_autogen; +mod list; +mod list_autogen; +mod set_autogen; +mod show_autogen; + +use assert_cmd::prelude::*; +use std::process::Command; + +#[test] +fn help() -> Result<(), Box> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("network") + .arg("default-security-group-rule") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/network/v2/mod.rs b/openstack_cli/tests/network/v2/mod.rs index 3e79fa1f4..de095917b 100644 --- a/openstack_cli/tests/network/v2/mod.rs +++ b/openstack_cli/tests/network/v2/mod.rs @@ -17,6 +17,7 @@ mod address_scope; mod agent; mod auto_allocated_topology; mod availability_zone; +mod default_security_group_rule; mod extension; mod floatingip; mod network;