python-openstackclient 9.0.0__py3-none-any.whl → 10.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- openstackclient/__init__.py +2 -6
- openstackclient/api/api.py +41 -23
- openstackclient/api/compute_v2.py +44 -25
- openstackclient/api/object_store_v1.py +75 -97
- openstackclient/api/volume_v2.py +2 -1
- openstackclient/api/volume_v3.py +2 -1
- openstackclient/common/availability_zone.py +58 -42
- openstackclient/common/clientmanager.py +56 -29
- openstackclient/common/configuration.py +10 -3
- openstackclient/common/envvars.py +2 -2
- openstackclient/common/extension.py +14 -5
- openstackclient/common/limits.py +10 -5
- openstackclient/common/module.py +14 -6
- openstackclient/common/pagination.py +8 -2
- openstackclient/common/progressbar.py +7 -6
- openstackclient/common/project_cleanup.py +13 -7
- openstackclient/common/quota.py +97 -99
- openstackclient/common/versions.py +8 -2
- openstackclient/compute/client.py +7 -3
- openstackclient/compute/v2/agent.py +17 -10
- openstackclient/compute/v2/aggregate.py +36 -22
- openstackclient/compute/v2/console.py +14 -8
- openstackclient/compute/v2/console_connection.py +11 -3
- openstackclient/compute/v2/flavor.py +39 -21
- openstackclient/compute/v2/host.py +14 -6
- openstackclient/compute/v2/hypervisor.py +14 -5
- openstackclient/compute/v2/hypervisor_stats.py +10 -2
- openstackclient/compute/v2/keypair.py +29 -14
- openstackclient/compute/v2/server.py +249 -169
- openstackclient/compute/v2/server_backup.py +10 -4
- openstackclient/compute/v2/server_event.py +21 -12
- openstackclient/compute/v2/server_group.py +21 -11
- openstackclient/compute/v2/server_image.py +19 -10
- openstackclient/compute/v2/server_migration.py +24 -10
- openstackclient/compute/v2/server_share.py +274 -0
- openstackclient/compute/v2/server_volume.py +10 -4
- openstackclient/compute/v2/service.py +14 -7
- openstackclient/compute/v2/usage.py +26 -21
- openstackclient/identity/client.py +8 -3
- openstackclient/identity/common.py +78 -47
- openstackclient/identity/v2_0/catalog.py +14 -7
- openstackclient/identity/v2_0/ec2creds.py +21 -10
- openstackclient/identity/v2_0/endpoint.py +23 -11
- openstackclient/identity/v2_0/project.py +25 -14
- openstackclient/identity/v2_0/role.py +28 -14
- openstackclient/identity/v2_0/role_assignment.py +9 -3
- openstackclient/identity/v2_0/service.py +23 -11
- openstackclient/identity/v2_0/token.py +12 -5
- openstackclient/identity/v2_0/user.py +26 -15
- openstackclient/identity/v3/access_rule.py +26 -12
- openstackclient/identity/v3/application_credential.py +59 -24
- openstackclient/identity/v3/catalog.py +14 -7
- openstackclient/identity/v3/consumer.py +22 -11
- openstackclient/identity/v3/credential.py +36 -16
- openstackclient/identity/v3/domain.py +37 -18
- openstackclient/identity/v3/ec2creds.py +25 -12
- openstackclient/identity/v3/endpoint.py +42 -20
- openstackclient/identity/v3/endpoint_group.py +28 -17
- openstackclient/identity/v3/federation_protocol.py +38 -16
- openstackclient/identity/v3/group.py +55 -32
- openstackclient/identity/v3/identity_provider.py +92 -57
- openstackclient/identity/v3/implied_role.py +21 -9
- openstackclient/identity/v3/limit.py +38 -16
- openstackclient/identity/v3/mapping.py +26 -13
- openstackclient/identity/v3/policy.py +23 -12
- openstackclient/identity/v3/project.py +43 -23
- openstackclient/identity/v3/region.py +36 -16
- openstackclient/identity/v3/registered_limit.py +40 -16
- openstackclient/identity/v3/role.py +61 -31
- openstackclient/identity/v3/role_assignment.py +23 -6
- openstackclient/identity/v3/service.py +36 -16
- openstackclient/identity/v3/service_provider.py +37 -15
- openstackclient/identity/v3/tag.py +23 -6
- openstackclient/identity/v3/token.py +30 -14
- openstackclient/identity/v3/trust.py +32 -14
- openstackclient/identity/v3/unscoped_saml.py +10 -2
- openstackclient/identity/v3/user.py +49 -26
- openstackclient/image/client.py +7 -3
- openstackclient/image/v1/image.py +33 -26
- openstackclient/image/v2/cache.py +14 -9
- openstackclient/image/v2/image.py +74 -48
- openstackclient/image/v2/info.py +7 -1
- openstackclient/image/v2/metadef_namespaces.py +109 -13
- openstackclient/image/v2/metadef_objects.py +28 -15
- openstackclient/image/v2/metadef_properties.py +24 -13
- openstackclient/image/v2/metadef_resource_type_association.py +14 -7
- openstackclient/image/v2/metadef_resource_types.py +7 -1
- openstackclient/image/v2/task.py +15 -6
- openstackclient/locale/tr_TR/LC_MESSAGES/openstackclient.po +7 -192
- openstackclient/network/client.py +7 -2
- openstackclient/network/common.py +16 -241
- openstackclient/network/utils.py +36 -22
- openstackclient/network/v2/address_group.py +27 -16
- openstackclient/network/v2/address_scope.py +24 -13
- openstackclient/network/v2/bgpvpn/bgpvpn.py +463 -0
- openstackclient/network/v2/bgpvpn/constants.py +30 -0
- openstackclient/network/v2/bgpvpn/network_association.py +214 -0
- openstackclient/network/v2/bgpvpn/port_association.py +490 -0
- openstackclient/network/v2/bgpvpn/router_association.py +288 -0
- openstackclient/network/v2/default_security_group_rule.py +19 -10
- openstackclient/network/v2/floating_ip.py +110 -159
- openstackclient/network/v2/floating_ip_port_forwarding.py +30 -18
- openstackclient/network/v2/fwaas/__init__.py +0 -0
- openstackclient/network/v2/fwaas/group.py +466 -0
- openstackclient/network/v2/fwaas/policy.py +518 -0
- openstackclient/network/v2/fwaas/rule.py +574 -0
- openstackclient/network/v2/ip_availability.py +13 -5
- openstackclient/network/v2/l3_conntrack_helper.py +22 -13
- openstackclient/network/v2/local_ip.py +24 -13
- openstackclient/network/v2/local_ip_association.py +14 -7
- openstackclient/network/v2/ndp_proxy.py +20 -11
- openstackclient/network/v2/network.py +129 -196
- openstackclient/network/v2/network_agent.py +46 -25
- openstackclient/network/v2/network_auto_allocated_topology.py +22 -11
- openstackclient/network/v2/network_flavor.py +27 -16
- openstackclient/network/v2/network_flavor_profile.py +23 -12
- openstackclient/network/v2/network_meter.py +21 -10
- openstackclient/network/v2/network_meter_rule.py +21 -11
- openstackclient/network/v2/network_qos_policy.py +25 -15
- openstackclient/network/v2/network_qos_rule.py +32 -17
- openstackclient/network/v2/network_qos_rule_type.py +13 -5
- openstackclient/network/v2/network_rbac.py +23 -12
- openstackclient/network/v2/network_segment.py +20 -11
- openstackclient/network/v2/network_segment_range.py +56 -29
- openstackclient/network/v2/network_service_provider.py +7 -1
- openstackclient/network/v2/network_trunk.py +38 -22
- openstackclient/network/v2/port.py +54 -29
- openstackclient/network/v2/router.py +75 -52
- openstackclient/network/v2/security_group.py +87 -157
- openstackclient/network/v2/security_group_rule.py +100 -280
- openstackclient/network/v2/subnet.py +49 -28
- openstackclient/network/v2/subnet_pool.py +30 -17
- openstackclient/network/v2/taas/tap_flow.py +22 -11
- openstackclient/network/v2/taas/tap_mirror.py +22 -11
- openstackclient/network/v2/taas/tap_service.py +23 -12
- openstackclient/object/client.py +7 -2
- openstackclient/object/v1/account.py +13 -6
- openstackclient/object/v1/container.py +25 -15
- openstackclient/object/v1/object.py +25 -15
- openstackclient/py.typed +0 -0
- openstackclient/shell.py +46 -10
- openstackclient/tests/functional/base.py +55 -20
- openstackclient/tests/functional/common/test_extension.py +4 -0
- openstackclient/tests/functional/common/test_quota.py +3 -1
- openstackclient/tests/functional/compute/v2/common.py +14 -13
- openstackclient/tests/functional/compute/v2/test_flavor.py +3 -1
- openstackclient/tests/functional/compute/v2/test_server.py +3 -0
- openstackclient/tests/functional/identity/v2/common.py +10 -6
- openstackclient/tests/functional/identity/v2/test_role.py +4 -4
- openstackclient/tests/functional/identity/v3/common.py +25 -19
- openstackclient/tests/functional/identity/v3/test_group.py +20 -20
- openstackclient/tests/functional/identity/v3/test_idp.py +3 -1
- openstackclient/tests/functional/identity/v3/test_project.py +10 -10
- openstackclient/tests/functional/identity/v3/test_role.py +18 -18
- openstackclient/tests/functional/identity/v3/test_role_assignment.py +12 -12
- openstackclient/tests/functional/identity/v3/test_user.py +8 -8
- openstackclient/tests/functional/image/base.py +1 -6
- openstackclient/tests/functional/network/v2/common.py +5 -2
- openstackclient/tests/functional/network/v2/test_floating_ip.py +10 -4
- openstackclient/tests/functional/network/v2/test_ip_availability.py +4 -0
- openstackclient/tests/functional/network/v2/test_network_meter_rule.py +3 -2
- openstackclient/tests/functional/network/v2/test_network_segment.py +5 -0
- openstackclient/tests/functional/network/v2/test_subnet.py +13 -9
- openstackclient/tests/functional/object/v1/common.py +4 -0
- openstackclient/tests/functional/volume/v2/common.py +4 -0
- openstackclient/tests/functional/volume/v2/test_volume_snapshot.py +27 -11
- openstackclient/tests/functional/volume/v2/test_volume_type.py +2 -2
- openstackclient/tests/functional/volume/v3/common.py +4 -0
- openstackclient/tests/functional/volume/v3/test_volume_snapshot.py +11 -7
- openstackclient/tests/functional/volume/v3/test_volume_type.py +2 -2
- openstackclient/tests/unit/common/test_availability_zone.py +35 -49
- openstackclient/tests/unit/common/test_extension.py +2 -2
- openstackclient/tests/unit/common/test_module.py +12 -7
- openstackclient/tests/unit/common/test_project_cleanup.py +3 -1
- openstackclient/tests/unit/common/test_quota.py +6 -26
- openstackclient/tests/unit/compute/v2/fakes.py +25 -0
- openstackclient/tests/unit/compute/v2/test_flavor.py +28 -2
- openstackclient/tests/unit/compute/v2/test_keypair.py +6 -6
- openstackclient/tests/unit/compute/v2/test_server.py +11 -96
- openstackclient/tests/unit/compute/v2/test_server_share.py +287 -0
- openstackclient/tests/unit/identity/v3/fakes.py +3 -0
- openstackclient/tests/unit/identity/v3/test_group.py +4 -14
- openstackclient/tests/unit/identity/v3/test_identity_provider.py +303 -299
- openstackclient/tests/unit/identity/v3/test_user.py +4 -4
- openstackclient/tests/unit/image/v2/test_image.py +11 -11
- openstackclient/tests/unit/image/v2/test_metadef_namespaces.py +105 -6
- openstackclient/tests/unit/network/test_common.py +0 -155
- openstackclient/tests/unit/network/v2/bgpvpn/__init__.py +0 -0
- openstackclient/tests/unit/network/v2/bgpvpn/fakes.py +179 -0
- openstackclient/tests/unit/network/v2/bgpvpn/test_bgpvpn.py +584 -0
- openstackclient/tests/unit/network/v2/bgpvpn/test_network_association.py +285 -0
- openstackclient/tests/unit/network/v2/bgpvpn/test_port_association.py +384 -0
- openstackclient/tests/unit/network/v2/bgpvpn/test_router_association.py +297 -0
- openstackclient/tests/unit/network/v2/fwaas/__init__.py +0 -0
- openstackclient/tests/unit/network/v2/fwaas/test_group.py +897 -0
- openstackclient/tests/unit/network/v2/fwaas/test_policy.py +869 -0
- openstackclient/tests/unit/network/v2/fwaas/test_rule.py +980 -0
- openstackclient/tests/unit/network/v2/taas/{test_osc_tap_flow.py → test_tap_flow.py} +18 -25
- openstackclient/tests/unit/network/v2/taas/{test_osc_tap_mirror.py → test_tap_mirror.py} +19 -29
- openstackclient/tests/unit/network/v2/taas/{test_osc_tap_service.py → test_tap_service.py} +19 -29
- openstackclient/tests/unit/network/v2/test_address_group.py +2 -2
- openstackclient/tests/unit/network/v2/{test_floating_ip_network.py → test_floating_ip.py} +3 -2
- openstackclient/tests/unit/network/v2/test_floating_ip_port_forwarding.py +13 -13
- openstackclient/tests/unit/network/v2/test_network_agent.py +8 -4
- openstackclient/tests/unit/network/v2/test_network_auto_allocated_topology.py +3 -3
- openstackclient/tests/unit/network/v2/test_network_flavor.py +2 -2
- openstackclient/tests/unit/network/v2/test_network_qos_policy.py +1 -1
- openstackclient/tests/unit/network/v2/test_network_qos_rule.py +2 -2
- openstackclient/tests/unit/network/v2/test_network_rbac.py +1 -1
- openstackclient/tests/unit/network/v2/test_network_segment.py +1 -1
- openstackclient/tests/unit/network/v2/test_network_segment_range.py +7 -10
- openstackclient/tests/unit/network/v2/test_network_trunk.py +1 -1
- openstackclient/tests/unit/network/v2/test_router.py +8 -9
- openstackclient/tests/unit/network/v2/{test_security_group_network.py → test_security_group.py} +1 -20
- openstackclient/tests/unit/network/v2/{test_security_group_rule_network.py → test_security_group_rule.py} +7 -41
- openstackclient/tests/unit/network/v2/test_subnet.py +2 -1
- openstackclient/tests/unit/network/v2/test_subnet_pool.py +2 -1
- openstackclient/tests/unit/object/v1/fakes.py +8 -7
- openstackclient/tests/unit/object/v1/test_container.py +65 -101
- openstackclient/tests/unit/object/v1/test_container_all.py +8 -1
- openstackclient/tests/unit/object/v1/test_object.py +44 -84
- openstackclient/tests/unit/object/v1/test_object_all.py +8 -1
- openstackclient/tests/unit/test_hacking.py +108 -0
- openstackclient/tests/unit/volume/v2/fakes.py +1 -0
- openstackclient/tests/unit/volume/v2/test_volume_backup.py +1 -5
- openstackclient/tests/unit/volume/v2/test_volume_snapshot.py +2 -1
- openstackclient/tests/unit/volume/v2/test_volume_type.py +2 -4
- openstackclient/tests/unit/volume/v3/fakes.py +1 -0
- openstackclient/tests/unit/volume/v3/test_volume.py +60 -3
- openstackclient/tests/unit/volume/v3/test_volume_attachment.py +1 -1
- openstackclient/tests/unit/volume/v3/test_volume_backup.py +1 -5
- openstackclient/tests/unit/volume/v3/test_volume_snapshot.py +55 -1
- openstackclient/tests/unit/volume/v3/test_volume_type.py +2 -4
- openstackclient/volume/client.py +7 -3
- openstackclient/volume/v2/backup_record.py +15 -6
- openstackclient/volume/v2/consistency_group.py +29 -17
- openstackclient/volume/v2/consistency_group_snapshot.py +25 -10
- openstackclient/volume/v2/qos_specs.py +28 -17
- openstackclient/volume/v2/service.py +17 -6
- openstackclient/volume/v2/volume.py +57 -29
- openstackclient/volume/v2/volume_backend.py +19 -6
- openstackclient/volume/v2/volume_backup.py +46 -20
- openstackclient/volume/v2/volume_host.py +6 -4
- openstackclient/volume/v2/volume_snapshot.py +50 -24
- openstackclient/volume/v2/volume_transfer_request.py +31 -13
- openstackclient/volume/v2/volume_type.py +43 -24
- openstackclient/volume/v3/block_storage_cleanup.py +11 -3
- openstackclient/volume/v3/block_storage_cluster.py +19 -7
- openstackclient/volume/v3/block_storage_log_level.py +15 -6
- openstackclient/volume/v3/block_storage_manage.py +10 -4
- openstackclient/volume/v3/block_storage_resource_filter.py +17 -5
- openstackclient/volume/v3/service.py +16 -6
- openstackclient/volume/v3/volume.py +89 -39
- openstackclient/volume/v3/volume_attachment.py +43 -21
- openstackclient/volume/v3/volume_backup.py +53 -24
- openstackclient/volume/v3/volume_group.py +23 -13
- openstackclient/volume/v3/volume_group_snapshot.py +32 -13
- openstackclient/volume/v3/volume_group_type.py +26 -13
- openstackclient/volume/v3/volume_message.py +15 -7
- openstackclient/volume/v3/volume_snapshot.py +69 -32
- openstackclient/volume/v3/volume_transfer_request.py +31 -13
- openstackclient/volume/v3/volume_type.py +42 -24
- {python_openstackclient-9.0.0.dist-info → python_openstackclient-10.0.0.dist-info}/METADATA +6 -6
- {python_openstackclient-9.0.0.dist-info → python_openstackclient-10.0.0.dist-info}/RECORD +271 -260
- {python_openstackclient-9.0.0.dist-info → python_openstackclient-10.0.0.dist-info}/WHEEL +1 -1
- {python_openstackclient-9.0.0.dist-info → python_openstackclient-10.0.0.dist-info}/entry_points.txt +53 -1
- {python_openstackclient-9.0.0.dist-info → python_openstackclient-10.0.0.dist-info}/licenses/AUTHORS +4 -0
- python_openstackclient-10.0.0.dist-info/pbr.json +1 -0
- openstackclient/api/image_v1.py +0 -69
- openstackclient/api/image_v2.py +0 -79
- openstackclient/network/v2/floating_ip_pool.py +0 -38
- openstackclient/tests/functional/image/v1/test_image.py +0 -97
- openstackclient/tests/unit/api/test_image_v1.py +0 -96
- openstackclient/tests/unit/api/test_image_v2.py +0 -96
- openstackclient/tests/unit/network/v2/test_floating_ip_compute.py +0 -248
- openstackclient/tests/unit/network/v2/test_floating_ip_pool_compute.py +0 -49
- openstackclient/tests/unit/network/v2/test_floating_ip_pool_network.py +0 -39
- openstackclient/tests/unit/network/v2/test_network_compute.py +0 -404
- openstackclient/tests/unit/network/v2/test_security_group_compute.py +0 -392
- openstackclient/tests/unit/network/v2/test_security_group_rule_compute.py +0 -555
- python_openstackclient-9.0.0.dist-info/pbr.json +0 -1
- /openstackclient/{tests/functional/image/v1 → network/v2/bgpvpn}/__init__.py +0 -0
- {python_openstackclient-9.0.0.dist-info → python_openstackclient-10.0.0.dist-info}/licenses/LICENSE +0 -0
- {python_openstackclient-9.0.0.dist-info → python_openstackclient-10.0.0.dist-info}/top_level.txt +0 -0
|
@@ -14,21 +14,27 @@
|
|
|
14
14
|
"""Security Group action implementations"""
|
|
15
15
|
|
|
16
16
|
import argparse
|
|
17
|
-
import
|
|
17
|
+
from collections.abc import Iterable, Sequence
|
|
18
|
+
import logging
|
|
19
|
+
from typing import Any, cast
|
|
18
20
|
|
|
19
21
|
from cliff import columns as cliff_columns
|
|
22
|
+
from osc_lib import exceptions
|
|
20
23
|
from osc_lib import utils
|
|
21
24
|
from osc_lib.utils import tags as _tag
|
|
22
25
|
|
|
23
|
-
from openstackclient.api import compute_v2
|
|
24
26
|
from openstackclient import command
|
|
25
27
|
from openstackclient.i18n import _
|
|
26
28
|
from openstackclient.identity import common as identity_common
|
|
27
29
|
from openstackclient.network import common
|
|
28
30
|
from openstackclient.network import utils as network_utils
|
|
29
31
|
|
|
32
|
+
LOG = logging.getLogger(__name__)
|
|
30
33
|
|
|
31
|
-
|
|
34
|
+
|
|
35
|
+
def _format_network_security_group_rules(
|
|
36
|
+
sg_rules: list[dict[str, Any]],
|
|
37
|
+
) -> str:
|
|
32
38
|
# For readability and to align with formatting compute security group
|
|
33
39
|
# rules, trim keys with caller known (e.g. security group and tenant ID)
|
|
34
40
|
# or empty values.
|
|
@@ -39,10 +45,10 @@ def _format_network_security_group_rules(sg_rules):
|
|
|
39
45
|
sg_rule.pop('security_group_id', None)
|
|
40
46
|
sg_rule.pop('tenant_id', None)
|
|
41
47
|
sg_rule.pop('project_id', None)
|
|
42
|
-
return utils.format_list_of_dicts(sg_rules)
|
|
48
|
+
return utils.format_list_of_dicts(sg_rules) or ""
|
|
43
49
|
|
|
44
50
|
|
|
45
|
-
def _format_compute_security_group_rule(sg_rule):
|
|
51
|
+
def _format_compute_security_group_rule(sg_rule: dict[str, Any]) -> str:
|
|
46
52
|
info = network_utils.transform_compute_security_group_rule(sg_rule)
|
|
47
53
|
# Trim parent security group ID since caller has this information.
|
|
48
54
|
info.pop('parent_group_id', None)
|
|
@@ -59,20 +65,22 @@ def _format_compute_security_group_rule(sg_rule):
|
|
|
59
65
|
return utils.format_dict(info)
|
|
60
66
|
|
|
61
67
|
|
|
62
|
-
def _format_compute_security_group_rules(
|
|
68
|
+
def _format_compute_security_group_rules(
|
|
69
|
+
sg_rules: list[dict[str, Any]],
|
|
70
|
+
) -> str:
|
|
63
71
|
rules = []
|
|
64
72
|
for sg_rule in sg_rules:
|
|
65
73
|
rules.append(_format_compute_security_group_rule(sg_rule))
|
|
66
|
-
return utils.format_list(rules, separator='\n')
|
|
74
|
+
return utils.format_list(rules, separator='\n') or ""
|
|
67
75
|
|
|
68
76
|
|
|
69
|
-
class NetworkSecurityGroupRulesColumn(cliff_columns.FormattableColumn[
|
|
70
|
-
def human_readable(self):
|
|
77
|
+
class NetworkSecurityGroupRulesColumn(cliff_columns.FormattableColumn[Any]):
|
|
78
|
+
def human_readable(self) -> str:
|
|
71
79
|
return _format_network_security_group_rules(self._value)
|
|
72
80
|
|
|
73
81
|
|
|
74
|
-
class ComputeSecurityGroupRulesColumn(cliff_columns.FormattableColumn[
|
|
75
|
-
def human_readable(self):
|
|
82
|
+
class ComputeSecurityGroupRulesColumn(cliff_columns.FormattableColumn[Any]):
|
|
83
|
+
def human_readable(self) -> str:
|
|
76
84
|
return _format_compute_security_group_rules(self._value)
|
|
77
85
|
|
|
78
86
|
|
|
@@ -86,7 +94,7 @@ _formatters_compute = {
|
|
|
86
94
|
}
|
|
87
95
|
|
|
88
96
|
|
|
89
|
-
def _get_columns(item):
|
|
97
|
+
def _get_columns(item: Any) -> tuple[tuple[str, ...], tuple[str, ...]]:
|
|
90
98
|
# We still support Nova managed security groups, where we have tenant_id.
|
|
91
99
|
column_map = {
|
|
92
100
|
'security_group_rules': 'rules',
|
|
@@ -99,12 +107,11 @@ def _get_columns(item):
|
|
|
99
107
|
|
|
100
108
|
# TODO(abhiraut): Use the SDK resource mapped attribute names once the
|
|
101
109
|
# OSC minimum requirements include SDK 1.0.
|
|
102
|
-
class CreateSecurityGroup(
|
|
103
|
-
common.NetworkAndComputeShowOne, common.NeutronCommandWithExtraArgs
|
|
104
|
-
):
|
|
110
|
+
class CreateSecurityGroup(command.ShowOne, common.NeutronCommandWithExtraArgs):
|
|
105
111
|
_description = _("Create a new security group")
|
|
106
112
|
|
|
107
|
-
def
|
|
113
|
+
def get_parser(self, prog_name: str) -> argparse.ArgumentParser:
|
|
114
|
+
parser = super().get_parser(prog_name)
|
|
108
115
|
parser.add_argument(
|
|
109
116
|
"name", metavar="<name>", help=_("New security group name")
|
|
110
117
|
)
|
|
@@ -113,13 +120,10 @@ class CreateSecurityGroup(
|
|
|
113
120
|
metavar="<description>",
|
|
114
121
|
help=_("Security group description"),
|
|
115
122
|
)
|
|
116
|
-
return parser
|
|
117
|
-
|
|
118
|
-
def update_parser_network(self, parser):
|
|
119
123
|
parser.add_argument(
|
|
120
124
|
'--project',
|
|
121
125
|
metavar='<project>',
|
|
122
|
-
help=
|
|
126
|
+
help=_("Owner's project (name or ID)"),
|
|
123
127
|
)
|
|
124
128
|
stateful_group = parser.add_mutually_exclusive_group()
|
|
125
129
|
stateful_group.add_argument(
|
|
@@ -134,21 +138,20 @@ class CreateSecurityGroup(
|
|
|
134
138
|
default=None,
|
|
135
139
|
help=_("Security group is stateless"),
|
|
136
140
|
)
|
|
137
|
-
identity_common.add_project_domain_option_to_parser(
|
|
138
|
-
|
|
139
|
-
)
|
|
140
|
-
_tag.add_tag_option_to_parser_for_create(
|
|
141
|
-
parser, _('security group'), enhance_help=self.enhance_help_neutron
|
|
142
|
-
)
|
|
141
|
+
identity_common.add_project_domain_option_to_parser(parser)
|
|
142
|
+
_tag.add_tag_option_to_parser_for_create(parser, _('security group'))
|
|
143
143
|
return parser
|
|
144
144
|
|
|
145
|
-
def _get_description(self, parsed_args):
|
|
145
|
+
def _get_description(self, parsed_args: argparse.Namespace) -> str:
|
|
146
146
|
if parsed_args.description is not None:
|
|
147
|
-
return parsed_args.description
|
|
147
|
+
return cast(str, parsed_args.description)
|
|
148
148
|
else:
|
|
149
|
-
return parsed_args.name
|
|
149
|
+
return cast(str, parsed_args.name)
|
|
150
150
|
|
|
151
|
-
def
|
|
151
|
+
def take_action(
|
|
152
|
+
self, parsed_args: argparse.Namespace
|
|
153
|
+
) -> tuple[Sequence[str], Iterable[Any]]:
|
|
154
|
+
client = self.app.client_manager.network
|
|
152
155
|
# Build the create attributes.
|
|
153
156
|
attrs = {}
|
|
154
157
|
attrs['name'] = parsed_args.name
|
|
@@ -179,29 +182,12 @@ class CreateSecurityGroup(
|
|
|
179
182
|
)
|
|
180
183
|
return (display_columns, data)
|
|
181
184
|
|
|
182
|
-
def take_action_compute(self, client, parsed_args):
|
|
183
|
-
description = self._get_description(parsed_args)
|
|
184
|
-
obj = compute_v2.create_security_group(
|
|
185
|
-
client,
|
|
186
|
-
parsed_args.name,
|
|
187
|
-
description,
|
|
188
|
-
)
|
|
189
|
-
display_columns = ('description', 'id', 'name', 'project_id', 'rules')
|
|
190
|
-
property_columns = ('description', 'id', 'name', 'tenant_id', 'rules')
|
|
191
|
-
data = utils.get_dict_properties(
|
|
192
|
-
obj, property_columns, formatters=_formatters_compute
|
|
193
|
-
)
|
|
194
|
-
return (display_columns, data)
|
|
195
185
|
|
|
196
|
-
|
|
197
|
-
class DeleteSecurityGroup(common.NetworkAndComputeDelete):
|
|
186
|
+
class DeleteSecurityGroup(command.Command):
|
|
198
187
|
_description = _("Delete security group(s)")
|
|
199
188
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
r = None
|
|
203
|
-
|
|
204
|
-
def update_parser_common(self, parser):
|
|
189
|
+
def get_parser(self, prog_name: str) -> argparse.ArgumentParser:
|
|
190
|
+
parser = super().get_parser(prog_name)
|
|
205
191
|
parser.add_argument(
|
|
206
192
|
'group',
|
|
207
193
|
metavar='<group>',
|
|
@@ -210,18 +196,36 @@ class DeleteSecurityGroup(common.NetworkAndComputeDelete):
|
|
|
210
196
|
)
|
|
211
197
|
return parser
|
|
212
198
|
|
|
213
|
-
def
|
|
214
|
-
|
|
215
|
-
|
|
199
|
+
def take_action(self, parsed_args: argparse.Namespace) -> None:
|
|
200
|
+
client = self.app.client_manager.network
|
|
201
|
+
result = 0
|
|
202
|
+
|
|
203
|
+
for group in parsed_args.group:
|
|
204
|
+
try:
|
|
205
|
+
obj = client.find_security_group(group, ignore_missing=False)
|
|
206
|
+
client.delete_security_group(obj)
|
|
207
|
+
except Exception as e:
|
|
208
|
+
result += 1
|
|
209
|
+
LOG.error(
|
|
210
|
+
_(
|
|
211
|
+
"Failed to delete security group with "
|
|
212
|
+
"name or ID '%(group)s': %(e)s"
|
|
213
|
+
),
|
|
214
|
+
{'group': group, 'e': e},
|
|
215
|
+
)
|
|
216
216
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
217
|
+
if result > 0:
|
|
218
|
+
total = len(parsed_args.group)
|
|
219
|
+
msg = _("%(result)s of %(total)s groups failed to delete.") % {
|
|
220
|
+
'result': result,
|
|
221
|
+
'total': total,
|
|
222
|
+
}
|
|
223
|
+
raise exceptions.CommandError(msg)
|
|
220
224
|
|
|
221
225
|
|
|
222
226
|
# TODO(rauta): Use the SDK resource mapped attribute names once
|
|
223
227
|
# the OSC minimum requirements include SDK 1.0.
|
|
224
|
-
class ListSecurityGroup(
|
|
228
|
+
class ListSecurityGroup(command.Lister):
|
|
225
229
|
_description = _("List security groups")
|
|
226
230
|
FIELDS_TO_RETRIEVE = [
|
|
227
231
|
'id',
|
|
@@ -232,30 +236,17 @@ class ListSecurityGroup(common.NetworkAndComputeLister):
|
|
|
232
236
|
'shared',
|
|
233
237
|
]
|
|
234
238
|
|
|
235
|
-
def
|
|
236
|
-
|
|
237
|
-
# Maintain and hide the argument for backwards compatibility.
|
|
238
|
-
# Network will always return all projects for an admin.
|
|
239
|
-
parser.add_argument(
|
|
240
|
-
'--all-projects',
|
|
241
|
-
action='store_true',
|
|
242
|
-
default=False,
|
|
243
|
-
help=argparse.SUPPRESS,
|
|
244
|
-
)
|
|
245
|
-
|
|
239
|
+
def get_parser(self, prog_name: str) -> argparse.ArgumentParser:
|
|
240
|
+
parser = super().get_parser(prog_name)
|
|
246
241
|
parser.add_argument(
|
|
247
242
|
'--project',
|
|
248
243
|
metavar='<project>',
|
|
249
|
-
help=
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
"(name or ID)"
|
|
253
|
-
)
|
|
244
|
+
help=_(
|
|
245
|
+
"List only security groups with the specified project "
|
|
246
|
+
"(name or ID)"
|
|
254
247
|
),
|
|
255
248
|
)
|
|
256
|
-
identity_common.add_project_domain_option_to_parser(
|
|
257
|
-
parser, enhance_help=self.enhance_help_neutron
|
|
258
|
-
)
|
|
249
|
+
identity_common.add_project_domain_option_to_parser(parser)
|
|
259
250
|
|
|
260
251
|
shared_group = parser.add_mutually_exclusive_group()
|
|
261
252
|
shared_group.add_argument(
|
|
@@ -273,23 +264,13 @@ class ListSecurityGroup(common.NetworkAndComputeLister):
|
|
|
273
264
|
help=_("List only security groups not shared between projects"),
|
|
274
265
|
)
|
|
275
266
|
|
|
276
|
-
_tag.add_tag_filtering_option_to_parser(
|
|
277
|
-
parser, _('security group'), enhance_help=self.enhance_help_neutron
|
|
278
|
-
)
|
|
267
|
+
_tag.add_tag_filtering_option_to_parser(parser, _('security group'))
|
|
279
268
|
return parser
|
|
280
269
|
|
|
281
|
-
def
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
default=False,
|
|
286
|
-
help=self.enhance_help_nova_network(
|
|
287
|
-
_("Display information from all projects (admin only)")
|
|
288
|
-
),
|
|
289
|
-
)
|
|
290
|
-
return parser
|
|
291
|
-
|
|
292
|
-
def take_action_network(self, client, parsed_args):
|
|
270
|
+
def take_action(
|
|
271
|
+
self, parsed_args: argparse.Namespace
|
|
272
|
+
) -> tuple[Sequence[str], Iterable[Any]]:
|
|
273
|
+
client = self.app.client_manager.network
|
|
293
274
|
filters = {}
|
|
294
275
|
if parsed_args.project:
|
|
295
276
|
identity_client = self.app.client_manager.identity
|
|
@@ -335,36 +316,12 @@ class ListSecurityGroup(common.NetworkAndComputeLister):
|
|
|
335
316
|
),
|
|
336
317
|
)
|
|
337
318
|
|
|
338
|
-
def take_action_compute(self, client, parsed_args):
|
|
339
|
-
data = compute_v2.list_security_groups(
|
|
340
|
-
# TODO(dtroyer): add limit, marker
|
|
341
|
-
client,
|
|
342
|
-
all_projects=parsed_args.all_projects,
|
|
343
|
-
)
|
|
344
319
|
|
|
345
|
-
|
|
346
|
-
column_headers: tuple[str, ...] = ("ID", "Name", "Description")
|
|
347
|
-
if parsed_args.all_projects:
|
|
348
|
-
columns += ('tenant_id',)
|
|
349
|
-
column_headers += ('Project',)
|
|
350
|
-
return (
|
|
351
|
-
column_headers,
|
|
352
|
-
(
|
|
353
|
-
utils.get_dict_properties(
|
|
354
|
-
s,
|
|
355
|
-
columns,
|
|
356
|
-
)
|
|
357
|
-
for s in data
|
|
358
|
-
),
|
|
359
|
-
)
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
class SetSecurityGroup(
|
|
363
|
-
common.NetworkAndComputeCommand, common.NeutronCommandWithExtraArgs
|
|
364
|
-
):
|
|
320
|
+
class SetSecurityGroup(common.NeutronCommandWithExtraArgs):
|
|
365
321
|
_description = _("Set security group properties")
|
|
366
322
|
|
|
367
|
-
def
|
|
323
|
+
def get_parser(self, prog_name: str) -> argparse.ArgumentParser:
|
|
324
|
+
parser = super().get_parser(prog_name)
|
|
368
325
|
parser.add_argument(
|
|
369
326
|
'group',
|
|
370
327
|
metavar='<group>',
|
|
@@ -391,15 +348,11 @@ class SetSecurityGroup(
|
|
|
391
348
|
default=None,
|
|
392
349
|
help=_("Security group is stateless"),
|
|
393
350
|
)
|
|
351
|
+
_tag.add_tag_option_to_parser_for_set(parser, _('security group'))
|
|
394
352
|
return parser
|
|
395
353
|
|
|
396
|
-
def
|
|
397
|
-
|
|
398
|
-
parser, _('security group'), enhance_help=self.enhance_help_neutron
|
|
399
|
-
)
|
|
400
|
-
return parser
|
|
401
|
-
|
|
402
|
-
def take_action_network(self, client, parsed_args):
|
|
354
|
+
def take_action(self, parsed_args: argparse.Namespace) -> None:
|
|
355
|
+
client = self.app.client_manager.network
|
|
403
356
|
obj = client.find_security_group(
|
|
404
357
|
parsed_args.group, ignore_missing=False
|
|
405
358
|
)
|
|
@@ -423,29 +376,12 @@ class SetSecurityGroup(
|
|
|
423
376
|
# tags is a subresource and it needs to be updated separately.
|
|
424
377
|
_tag.update_tags_for_set(client, obj, parsed_args)
|
|
425
378
|
|
|
426
|
-
def take_action_compute(self, client, parsed_args):
|
|
427
|
-
security_group = compute_v2.find_security_group(
|
|
428
|
-
client, parsed_args.group
|
|
429
|
-
)
|
|
430
379
|
|
|
431
|
-
|
|
432
|
-
if parsed_args.name is not None:
|
|
433
|
-
params['name'] = parsed_args.name
|
|
434
|
-
if parsed_args.description is not None:
|
|
435
|
-
params['description'] = parsed_args.description
|
|
436
|
-
|
|
437
|
-
# NOTE(rtheis): Previous behavior did not raise a CommandError
|
|
438
|
-
# if there were no updates. Maintain this behavior and issue
|
|
439
|
-
# the update.
|
|
440
|
-
compute_v2.update_security_group(
|
|
441
|
-
client, security_group['id'], **params
|
|
442
|
-
)
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
class ShowSecurityGroup(common.NetworkAndComputeShowOne):
|
|
380
|
+
class ShowSecurityGroup(command.ShowOne):
|
|
446
381
|
_description = _("Display security group details")
|
|
447
382
|
|
|
448
|
-
def
|
|
383
|
+
def get_parser(self, prog_name: str) -> argparse.ArgumentParser:
|
|
384
|
+
parser = super().get_parser(prog_name)
|
|
449
385
|
parser.add_argument(
|
|
450
386
|
'group',
|
|
451
387
|
metavar='<group>',
|
|
@@ -453,7 +389,10 @@ class ShowSecurityGroup(common.NetworkAndComputeShowOne):
|
|
|
453
389
|
)
|
|
454
390
|
return parser
|
|
455
391
|
|
|
456
|
-
def
|
|
392
|
+
def take_action(
|
|
393
|
+
self, parsed_args: argparse.Namespace
|
|
394
|
+
) -> tuple[Sequence[str], Iterable[Any]]:
|
|
395
|
+
client = self.app.client_manager.network
|
|
457
396
|
obj = client.find_security_group(
|
|
458
397
|
parsed_args.group, ignore_missing=False
|
|
459
398
|
)
|
|
@@ -463,20 +402,11 @@ class ShowSecurityGroup(common.NetworkAndComputeShowOne):
|
|
|
463
402
|
)
|
|
464
403
|
return (display_columns, data)
|
|
465
404
|
|
|
466
|
-
def take_action_compute(self, client, parsed_args):
|
|
467
|
-
obj = compute_v2.find_security_group(client, parsed_args.group)
|
|
468
|
-
display_columns = ('description', 'id', 'name', 'project_id', 'rules')
|
|
469
|
-
property_columns = ('description', 'id', 'name', 'tenant_id', 'rules')
|
|
470
|
-
data = utils.get_dict_properties(
|
|
471
|
-
obj, property_columns, formatters=_formatters_compute
|
|
472
|
-
)
|
|
473
|
-
return (display_columns, data)
|
|
474
|
-
|
|
475
405
|
|
|
476
406
|
class UnsetSecurityGroup(command.Command):
|
|
477
407
|
_description = _("Unset security group properties")
|
|
478
408
|
|
|
479
|
-
def get_parser(self, prog_name):
|
|
409
|
+
def get_parser(self, prog_name: str) -> argparse.ArgumentParser:
|
|
480
410
|
parser = super().get_parser(prog_name)
|
|
481
411
|
parser.add_argument(
|
|
482
412
|
'group',
|
|
@@ -486,7 +416,7 @@ class UnsetSecurityGroup(command.Command):
|
|
|
486
416
|
_tag.add_tag_option_to_parser_for_unset(parser, _('security group'))
|
|
487
417
|
return parser
|
|
488
418
|
|
|
489
|
-
def take_action(self, parsed_args):
|
|
419
|
+
def take_action(self, parsed_args: argparse.Namespace) -> None:
|
|
490
420
|
client = self.app.client_manager.network
|
|
491
421
|
obj = client.find_security_group(
|
|
492
422
|
parsed_args.group, ignore_missing=False
|