python-openstackclient 8.3.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 +126 -114
- 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 +251 -171
- 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 +103 -41
- 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 +26 -12
- 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 +71 -50
- 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 +115 -92
- openstackclient/identity/v3/mapping.py +26 -13
- openstackclient/identity/v3/policy.py +23 -12
- openstackclient/identity/v3/project.py +211 -122
- openstackclient/identity/v3/region.py +36 -16
- openstackclient/identity/v3/registered_limit.py +116 -109
- 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 -17
- 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 +76 -49
- 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_limit.py +47 -0
- 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/image/v2/test_metadef_objects.py +69 -0
- 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 +56 -138
- 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 +62 -23
- 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 +17 -104
- 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_limit.py +197 -145
- openstackclient/tests/unit/identity/v3/test_project.py +831 -512
- openstackclient/tests/unit/identity/v3/test_protocol.py +97 -88
- openstackclient/tests/unit/identity/v3/test_registered_limit.py +355 -220
- openstackclient/tests/unit/identity/v3/test_user.py +4 -4
- openstackclient/tests/unit/image/v2/test_image.py +16 -16
- 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_consistency_group.py +8 -2
- openstackclient/tests/unit/volume/v2/test_volume.py +7 -6
- 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 +94 -15
- 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 +37 -25
- openstackclient/volume/v2/consistency_group_snapshot.py +27 -12
- openstackclient/volume/v2/qos_specs.py +30 -19
- openstackclient/volume/v2/service.py +17 -6
- openstackclient/volume/v2/volume.py +69 -34
- openstackclient/volume/v2/volume_backend.py +19 -6
- openstackclient/volume/v2/volume_backup.py +48 -22
- openstackclient/volume/v2/volume_host.py +6 -4
- openstackclient/volume/v2/volume_snapshot.py +52 -26
- openstackclient/volume/v2/volume_transfer_request.py +33 -15
- openstackclient/volume/v2/volume_type.py +46 -27
- 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 +103 -46
- openstackclient/volume/v3/volume_attachment.py +43 -21
- openstackclient/volume/v3/volume_backup.py +55 -26
- 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 +71 -34
- openstackclient/volume/v3/volume_transfer_request.py +33 -15
- openstackclient/volume/v3/volume_type.py +45 -27
- {python_openstackclient-8.3.0.dist-info → python_openstackclient-10.0.0.dist-info}/METADATA +6 -6
- {python_openstackclient-8.3.0.dist-info → python_openstackclient-10.0.0.dist-info}/RECORD +279 -267
- {python_openstackclient-8.3.0.dist-info → python_openstackclient-10.0.0.dist-info}/WHEEL +1 -1
- {python_openstackclient-8.3.0.dist-info → python_openstackclient-10.0.0.dist-info}/entry_points.txt +53 -1
- {python_openstackclient-8.3.0.dist-info → python_openstackclient-10.0.0.dist-info}/licenses/AUTHORS +9 -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-8.3.0.dist-info/pbr.json +0 -1
- /openstackclient/{tests/functional/image/v1 → network/v2/bgpvpn}/__init__.py +0 -0
- {python_openstackclient-8.3.0.dist-info → python_openstackclient-10.0.0.dist-info}/licenses/LICENSE +0 -0
- {python_openstackclient-8.3.0.dist-info → python_openstackclient-10.0.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,466 @@
|
|
|
1
|
+
# Copyright 2016-2017 FUJITSU LIMITED
|
|
2
|
+
# All Rights Reserved
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
5
|
+
# not use this file except in compliance with the License. You may obtain
|
|
6
|
+
# a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
13
|
+
# License for the specific language governing permissions and limitations
|
|
14
|
+
# under the License.
|
|
15
|
+
|
|
16
|
+
import argparse
|
|
17
|
+
from collections.abc import Iterable, Sequence
|
|
18
|
+
import logging
|
|
19
|
+
from typing import Any
|
|
20
|
+
|
|
21
|
+
from cliff import columns as cliff_columns
|
|
22
|
+
from osc_lib.cli import identity as identity_utils
|
|
23
|
+
from osc_lib import exceptions
|
|
24
|
+
from osc_lib import utils
|
|
25
|
+
from osc_lib.utils import columns as column_util
|
|
26
|
+
|
|
27
|
+
from openstackclient import command
|
|
28
|
+
from openstackclient.i18n import _
|
|
29
|
+
from openstackclient.identity import common as identity_common
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
LOG = logging.getLogger(__name__)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class AdminStateColumn(cliff_columns.FormattableColumn[bool]):
|
|
36
|
+
def human_readable(self) -> str:
|
|
37
|
+
return 'UP' if self._value else 'DOWN'
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
_formatters = {
|
|
41
|
+
'admin_state_up': AdminStateColumn,
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
_attr_map = (
|
|
45
|
+
('id', 'ID', column_util.LIST_BOTH),
|
|
46
|
+
('name', 'Name', column_util.LIST_BOTH),
|
|
47
|
+
('ingress_firewall_policy_id', 'Ingress Policy ID', column_util.LIST_BOTH),
|
|
48
|
+
('egress_firewall_policy_id', 'Egress Policy ID', column_util.LIST_BOTH),
|
|
49
|
+
('description', 'Description', column_util.LIST_LONG_ONLY),
|
|
50
|
+
('status', 'Status', column_util.LIST_LONG_ONLY),
|
|
51
|
+
('ports', 'Ports', column_util.LIST_LONG_ONLY),
|
|
52
|
+
('admin_state_up', 'State', column_util.LIST_LONG_ONLY),
|
|
53
|
+
('shared', 'Shared', column_util.LIST_LONG_ONLY),
|
|
54
|
+
('project_id', 'Project', column_util.LIST_LONG_ONLY),
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
_attr_map_dict = {x[0]: x[1] for x in _attr_map}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def _get_common_parser(
|
|
61
|
+
parser: argparse.ArgumentParser,
|
|
62
|
+
) -> argparse.ArgumentParser:
|
|
63
|
+
parser.add_argument('--name', help=_('Name for the firewall group'))
|
|
64
|
+
parser.add_argument(
|
|
65
|
+
'--description',
|
|
66
|
+
metavar='<description>',
|
|
67
|
+
help=_('Description of the firewall group'),
|
|
68
|
+
)
|
|
69
|
+
ingress_group = parser.add_mutually_exclusive_group()
|
|
70
|
+
ingress_group.add_argument(
|
|
71
|
+
'--ingress-firewall-policy',
|
|
72
|
+
metavar='<ingress-firewall-policy>',
|
|
73
|
+
dest='ingress_firewall_policy',
|
|
74
|
+
help=_('Ingress firewall policy (name or ID)'),
|
|
75
|
+
)
|
|
76
|
+
ingress_group.add_argument(
|
|
77
|
+
'--no-ingress-firewall-policy',
|
|
78
|
+
dest='no_ingress_firewall_policy',
|
|
79
|
+
action='store_true',
|
|
80
|
+
help=_('Detach ingress firewall policy from the firewall group'),
|
|
81
|
+
)
|
|
82
|
+
egress_group = parser.add_mutually_exclusive_group()
|
|
83
|
+
egress_group.add_argument(
|
|
84
|
+
'--egress-firewall-policy',
|
|
85
|
+
metavar='<egress-firewall-policy>',
|
|
86
|
+
dest='egress_firewall_policy',
|
|
87
|
+
help=_('Egress firewall policy (name or ID)'),
|
|
88
|
+
)
|
|
89
|
+
egress_group.add_argument(
|
|
90
|
+
'--no-egress-firewall-policy',
|
|
91
|
+
dest='no_egress_firewall_policy',
|
|
92
|
+
action='store_true',
|
|
93
|
+
help=_('Detach egress firewall policy from the firewall group'),
|
|
94
|
+
)
|
|
95
|
+
shared_group = parser.add_mutually_exclusive_group()
|
|
96
|
+
shared_group.add_argument(
|
|
97
|
+
'--share',
|
|
98
|
+
action='store_true',
|
|
99
|
+
default=None,
|
|
100
|
+
dest='shared',
|
|
101
|
+
help=_(
|
|
102
|
+
'Share the firewall group to be used in all projects '
|
|
103
|
+
'(by default, it is restricted to be used by the '
|
|
104
|
+
'current project).'
|
|
105
|
+
),
|
|
106
|
+
)
|
|
107
|
+
shared_group.add_argument(
|
|
108
|
+
'--no-share',
|
|
109
|
+
action='store_false',
|
|
110
|
+
dest='shared',
|
|
111
|
+
help=_('Restrict use of the firewall group to the current project'),
|
|
112
|
+
)
|
|
113
|
+
admin_group = parser.add_mutually_exclusive_group()
|
|
114
|
+
admin_group.add_argument(
|
|
115
|
+
'--enable',
|
|
116
|
+
action='store_true',
|
|
117
|
+
default=None,
|
|
118
|
+
dest='admin_state_up',
|
|
119
|
+
help=_('Enable firewall group'),
|
|
120
|
+
)
|
|
121
|
+
admin_group.add_argument(
|
|
122
|
+
'--disable',
|
|
123
|
+
action='store_false',
|
|
124
|
+
dest='admin_state_up',
|
|
125
|
+
help=_('Disable firewall group'),
|
|
126
|
+
)
|
|
127
|
+
return parser
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def _get_common_attrs(
|
|
131
|
+
client_manager: Any,
|
|
132
|
+
parsed_args: argparse.Namespace,
|
|
133
|
+
is_create: bool = True,
|
|
134
|
+
) -> dict[str, Any]:
|
|
135
|
+
attrs: dict[str, Any] = {}
|
|
136
|
+
client = client_manager.network
|
|
137
|
+
|
|
138
|
+
if parsed_args.ingress_firewall_policy:
|
|
139
|
+
attrs['ingress_firewall_policy_id'] = client.find_firewall_policy(
|
|
140
|
+
parsed_args.ingress_firewall_policy, ignore_missing=False
|
|
141
|
+
).id
|
|
142
|
+
elif parsed_args.no_ingress_firewall_policy:
|
|
143
|
+
attrs['ingress_firewall_policy_id'] = None
|
|
144
|
+
|
|
145
|
+
if parsed_args.egress_firewall_policy:
|
|
146
|
+
attrs['egress_firewall_policy_id'] = client.find_firewall_policy(
|
|
147
|
+
parsed_args.egress_firewall_policy, ignore_missing=False
|
|
148
|
+
).id
|
|
149
|
+
elif parsed_args.no_egress_firewall_policy:
|
|
150
|
+
attrs['egress_firewall_policy_id'] = None
|
|
151
|
+
|
|
152
|
+
if parsed_args.shared is not None:
|
|
153
|
+
attrs['shared'] = parsed_args.shared
|
|
154
|
+
if parsed_args.admin_state_up is not None:
|
|
155
|
+
attrs['admin_state_up'] = parsed_args.admin_state_up
|
|
156
|
+
if parsed_args.name:
|
|
157
|
+
attrs['name'] = parsed_args.name
|
|
158
|
+
if parsed_args.description:
|
|
159
|
+
attrs['description'] = parsed_args.description
|
|
160
|
+
if parsed_args.port and parsed_args.no_port:
|
|
161
|
+
attrs['ports'] = sorted(
|
|
162
|
+
[
|
|
163
|
+
client.find_port(p, ignore_missing=False).id
|
|
164
|
+
for p in set(parsed_args.port)
|
|
165
|
+
]
|
|
166
|
+
)
|
|
167
|
+
elif parsed_args.port:
|
|
168
|
+
ports = []
|
|
169
|
+
for p in set(parsed_args.port):
|
|
170
|
+
ports.append(client.find_port(p, ignore_missing=False).id)
|
|
171
|
+
if not is_create:
|
|
172
|
+
ports += client.find_firewall_group(
|
|
173
|
+
parsed_args.firewall_group, ignore_missing=False
|
|
174
|
+
).ports
|
|
175
|
+
attrs['ports'] = sorted(set(ports))
|
|
176
|
+
elif parsed_args.no_port:
|
|
177
|
+
attrs['ports'] = []
|
|
178
|
+
return attrs
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
class CreateFirewallGroup(command.ShowOne):
|
|
182
|
+
_description = _("Create a new firewall group")
|
|
183
|
+
|
|
184
|
+
def get_parser(self, prog_name: str) -> argparse.ArgumentParser:
|
|
185
|
+
parser = super().get_parser(prog_name)
|
|
186
|
+
_get_common_parser(parser)
|
|
187
|
+
identity_utils.add_project_owner_option_to_parser(parser)
|
|
188
|
+
port_group = parser.add_mutually_exclusive_group()
|
|
189
|
+
port_group.add_argument(
|
|
190
|
+
'--port',
|
|
191
|
+
metavar='<port>',
|
|
192
|
+
action='append',
|
|
193
|
+
help=_(
|
|
194
|
+
'Port(s) (name or ID) to apply firewall group. This '
|
|
195
|
+
'option can be repeated'
|
|
196
|
+
),
|
|
197
|
+
)
|
|
198
|
+
port_group.add_argument(
|
|
199
|
+
'--no-port',
|
|
200
|
+
dest='no_port',
|
|
201
|
+
action='store_true',
|
|
202
|
+
help=_('Detach all port from the firewall group'),
|
|
203
|
+
)
|
|
204
|
+
return parser
|
|
205
|
+
|
|
206
|
+
def take_action(
|
|
207
|
+
self, parsed_args: argparse.Namespace
|
|
208
|
+
) -> tuple[Sequence[str], Iterable[Any]]:
|
|
209
|
+
client = self.app.client_manager.network
|
|
210
|
+
attrs = _get_common_attrs(self.app.client_manager, parsed_args)
|
|
211
|
+
if 'project' in parsed_args and parsed_args.project is not None:
|
|
212
|
+
attrs['project_id'] = identity_common.find_project(
|
|
213
|
+
self.app.client_manager.identity,
|
|
214
|
+
parsed_args.project,
|
|
215
|
+
parsed_args.project_domain,
|
|
216
|
+
).id
|
|
217
|
+
obj = client.create_firewall_group(**attrs)
|
|
218
|
+
display_columns, columns = utils.get_osc_show_columns_for_sdk_resource(
|
|
219
|
+
obj, _attr_map_dict, ['location', 'tenant_id']
|
|
220
|
+
)
|
|
221
|
+
data = utils.get_dict_properties(obj, columns, formatters=_formatters)
|
|
222
|
+
return (display_columns, data)
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
class DeleteFirewallGroup(command.Command):
|
|
226
|
+
_description = _("Delete firewall group(s)")
|
|
227
|
+
|
|
228
|
+
def get_parser(self, prog_name: str) -> argparse.ArgumentParser:
|
|
229
|
+
parser = super().get_parser(prog_name)
|
|
230
|
+
parser.add_argument(
|
|
231
|
+
'firewall_group',
|
|
232
|
+
metavar='<firewall-group>',
|
|
233
|
+
nargs='+',
|
|
234
|
+
help=_('Firewall group(s) to delete (name or ID)'),
|
|
235
|
+
)
|
|
236
|
+
return parser
|
|
237
|
+
|
|
238
|
+
def take_action(self, parsed_args: argparse.Namespace) -> None:
|
|
239
|
+
client = self.app.client_manager.network
|
|
240
|
+
result = 0
|
|
241
|
+
for fwg in parsed_args.firewall_group:
|
|
242
|
+
try:
|
|
243
|
+
fwg = client.find_firewall_group(fwg, ignore_missing=False)
|
|
244
|
+
client.delete_firewall_group(fwg.id)
|
|
245
|
+
except Exception as e:
|
|
246
|
+
result += 1
|
|
247
|
+
LOG.error(
|
|
248
|
+
_(
|
|
249
|
+
"Failed to delete firewall group with "
|
|
250
|
+
"name or ID '%(firewall_group)s': %(e)s"
|
|
251
|
+
),
|
|
252
|
+
{'firewall_group': fwg, 'e': e},
|
|
253
|
+
)
|
|
254
|
+
|
|
255
|
+
if result > 0:
|
|
256
|
+
total = len(parsed_args.firewall_group)
|
|
257
|
+
msg = _(
|
|
258
|
+
"%(result)s of %(total)s firewall group(s) failed to delete."
|
|
259
|
+
) % {'result': result, 'total': total}
|
|
260
|
+
raise exceptions.CommandError(msg)
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
class ListFirewallGroup(command.Lister):
|
|
264
|
+
_description = _("List firewall groups")
|
|
265
|
+
|
|
266
|
+
def get_parser(self, prog_name: str) -> argparse.ArgumentParser:
|
|
267
|
+
parser = super().get_parser(prog_name)
|
|
268
|
+
parser.add_argument(
|
|
269
|
+
'--long',
|
|
270
|
+
action='store_true',
|
|
271
|
+
help=_("List additional fields in output"),
|
|
272
|
+
)
|
|
273
|
+
return parser
|
|
274
|
+
|
|
275
|
+
def take_action(
|
|
276
|
+
self, parsed_args: argparse.Namespace
|
|
277
|
+
) -> tuple[Sequence[str], Iterable[tuple[Any, ...]]]:
|
|
278
|
+
client = self.app.client_manager.network
|
|
279
|
+
obj = client.firewall_groups()
|
|
280
|
+
headers, columns = column_util.get_column_definitions(
|
|
281
|
+
list(_attr_map), long_listing=parsed_args.long
|
|
282
|
+
)
|
|
283
|
+
return (
|
|
284
|
+
headers,
|
|
285
|
+
(
|
|
286
|
+
utils.get_dict_properties(s, columns, formatters=_formatters)
|
|
287
|
+
for s in obj
|
|
288
|
+
),
|
|
289
|
+
)
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
class SetFirewallGroup(command.Command):
|
|
293
|
+
_description = _("Set firewall group properties")
|
|
294
|
+
|
|
295
|
+
def get_parser(self, prog_name: str) -> argparse.ArgumentParser:
|
|
296
|
+
parser = super().get_parser(prog_name)
|
|
297
|
+
_get_common_parser(parser)
|
|
298
|
+
parser.add_argument(
|
|
299
|
+
'firewall_group',
|
|
300
|
+
metavar='<firewall-group>',
|
|
301
|
+
help=_('Firewall group to update (name or ID)'),
|
|
302
|
+
)
|
|
303
|
+
parser.add_argument(
|
|
304
|
+
'--port',
|
|
305
|
+
metavar='<port>',
|
|
306
|
+
action='append',
|
|
307
|
+
help=_(
|
|
308
|
+
'Port(s) (name or ID) to apply firewall group. This '
|
|
309
|
+
'option can be repeated'
|
|
310
|
+
),
|
|
311
|
+
)
|
|
312
|
+
parser.add_argument(
|
|
313
|
+
'--no-port',
|
|
314
|
+
dest='no_port',
|
|
315
|
+
action='store_true',
|
|
316
|
+
help=_('Detach all port from the firewall group'),
|
|
317
|
+
)
|
|
318
|
+
return parser
|
|
319
|
+
|
|
320
|
+
def take_action(self, parsed_args: argparse.Namespace) -> None:
|
|
321
|
+
client = self.app.client_manager.network
|
|
322
|
+
fwg_id = client.find_firewall_group(
|
|
323
|
+
parsed_args.firewall_group, ignore_missing=False
|
|
324
|
+
).id
|
|
325
|
+
attrs = _get_common_attrs(
|
|
326
|
+
self.app.client_manager, parsed_args, is_create=False
|
|
327
|
+
)
|
|
328
|
+
try:
|
|
329
|
+
client.update_firewall_group(fwg_id, **attrs)
|
|
330
|
+
except Exception as e:
|
|
331
|
+
msg = _("Failed to set firewall group '%(group)s': %(e)s") % {
|
|
332
|
+
'group': parsed_args.firewall_group,
|
|
333
|
+
'e': e,
|
|
334
|
+
}
|
|
335
|
+
raise exceptions.CommandError(msg)
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
class ShowFirewallGroup(command.ShowOne):
|
|
339
|
+
_description = _("Display firewall group details")
|
|
340
|
+
|
|
341
|
+
def get_parser(self, prog_name: str) -> argparse.ArgumentParser:
|
|
342
|
+
parser = super().get_parser(prog_name)
|
|
343
|
+
parser.add_argument(
|
|
344
|
+
'firewall_group',
|
|
345
|
+
metavar='<firewall-group>',
|
|
346
|
+
help=_('Firewall group to show (name or ID)'),
|
|
347
|
+
)
|
|
348
|
+
return parser
|
|
349
|
+
|
|
350
|
+
def take_action(
|
|
351
|
+
self, parsed_args: argparse.Namespace
|
|
352
|
+
) -> tuple[Sequence[str], Iterable[Any]]:
|
|
353
|
+
client = self.app.client_manager.network
|
|
354
|
+
fwg_id = client.find_firewall_group(
|
|
355
|
+
parsed_args.firewall_group, ignore_missing=False
|
|
356
|
+
).id
|
|
357
|
+
obj = client.get_firewall_group(fwg_id)
|
|
358
|
+
display_columns, columns = utils.get_osc_show_columns_for_sdk_resource(
|
|
359
|
+
obj, _attr_map_dict, ['location', 'tenant_id']
|
|
360
|
+
)
|
|
361
|
+
data = utils.get_dict_properties(obj, columns, formatters=_formatters)
|
|
362
|
+
return (display_columns, data)
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
class UnsetFirewallGroup(command.Command):
|
|
366
|
+
_description = _("Unset firewall group properties")
|
|
367
|
+
|
|
368
|
+
def get_parser(self, prog_name: str) -> argparse.ArgumentParser:
|
|
369
|
+
parser = super().get_parser(prog_name)
|
|
370
|
+
parser.add_argument(
|
|
371
|
+
'firewall_group',
|
|
372
|
+
metavar='<firewall-group>',
|
|
373
|
+
help=_('Firewall group to unset (name or ID)'),
|
|
374
|
+
)
|
|
375
|
+
port_group = parser.add_mutually_exclusive_group()
|
|
376
|
+
port_group.add_argument(
|
|
377
|
+
'--port',
|
|
378
|
+
metavar='<port>',
|
|
379
|
+
action='append',
|
|
380
|
+
help=_(
|
|
381
|
+
'Port(s) (name or ID) to apply firewall group. This '
|
|
382
|
+
'option can be repeated'
|
|
383
|
+
),
|
|
384
|
+
)
|
|
385
|
+
port_group.add_argument(
|
|
386
|
+
'--all-port',
|
|
387
|
+
action='store_true',
|
|
388
|
+
help=_('Remove all ports for this firewall group'),
|
|
389
|
+
)
|
|
390
|
+
parser.add_argument(
|
|
391
|
+
'--ingress-firewall-policy',
|
|
392
|
+
action='store_true',
|
|
393
|
+
help=_('Ingress firewall policy (name or ID) to delete'),
|
|
394
|
+
)
|
|
395
|
+
parser.add_argument(
|
|
396
|
+
'--egress-firewall-policy',
|
|
397
|
+
action='store_true',
|
|
398
|
+
dest='egress_firewall_policy',
|
|
399
|
+
help=_('Egress firewall policy (name or ID) to delete'),
|
|
400
|
+
)
|
|
401
|
+
shared_group = parser.add_mutually_exclusive_group()
|
|
402
|
+
shared_group.add_argument(
|
|
403
|
+
'--share',
|
|
404
|
+
action='store_true',
|
|
405
|
+
help=_(
|
|
406
|
+
'(Deprecated) Use "firewall group set --no-share" instead. '
|
|
407
|
+
'Restrict use of the firewall group to the current project'
|
|
408
|
+
),
|
|
409
|
+
)
|
|
410
|
+
parser.add_argument(
|
|
411
|
+
'--enable',
|
|
412
|
+
action='store_true',
|
|
413
|
+
help=_(
|
|
414
|
+
'(Deprecated) Use "firewall group set --disable" instead. '
|
|
415
|
+
'Disable firewall group'
|
|
416
|
+
),
|
|
417
|
+
)
|
|
418
|
+
return parser
|
|
419
|
+
|
|
420
|
+
def _get_attrs(
|
|
421
|
+
self, client: Any, parsed_args: argparse.Namespace
|
|
422
|
+
) -> dict[str, Any]:
|
|
423
|
+
attrs: dict[str, Any] = {}
|
|
424
|
+
if parsed_args.ingress_firewall_policy:
|
|
425
|
+
attrs['ingress_firewall_policy_id'] = None
|
|
426
|
+
if parsed_args.egress_firewall_policy:
|
|
427
|
+
attrs['egress_firewall_policy_id'] = None
|
|
428
|
+
if parsed_args.share:
|
|
429
|
+
LOG.warning(
|
|
430
|
+
'The --share option is deprecated, please use '
|
|
431
|
+
'"firewall group set --no-share" instead.'
|
|
432
|
+
)
|
|
433
|
+
attrs['shared'] = False
|
|
434
|
+
if parsed_args.enable:
|
|
435
|
+
LOG.warning(
|
|
436
|
+
'The --enable option is deprecated, please use '
|
|
437
|
+
'"firewall group set --disable" instead.'
|
|
438
|
+
)
|
|
439
|
+
attrs['admin_state_up'] = False
|
|
440
|
+
if parsed_args.port:
|
|
441
|
+
old = client.find_firewall_group(
|
|
442
|
+
parsed_args.firewall_group, ignore_missing=False
|
|
443
|
+
).ports
|
|
444
|
+
new = [
|
|
445
|
+
client.find_port(r, ignore_missing=False).id
|
|
446
|
+
for r in parsed_args.port
|
|
447
|
+
]
|
|
448
|
+
attrs['ports'] = sorted(list(set(old) - set(new)))
|
|
449
|
+
if parsed_args.all_port:
|
|
450
|
+
attrs['ports'] = []
|
|
451
|
+
return attrs
|
|
452
|
+
|
|
453
|
+
def take_action(self, parsed_args: argparse.Namespace) -> None:
|
|
454
|
+
client = self.app.client_manager.network
|
|
455
|
+
fwg_id = client.find_firewall_group(
|
|
456
|
+
parsed_args.firewall_group, ignore_missing=False
|
|
457
|
+
).id
|
|
458
|
+
attrs = self._get_attrs(client, parsed_args)
|
|
459
|
+
try:
|
|
460
|
+
client.update_firewall_group(fwg_id, **attrs)
|
|
461
|
+
except Exception as e:
|
|
462
|
+
msg = _("Failed to unset firewall group '%(group)s': %(e)s") % {
|
|
463
|
+
'group': parsed_args.firewall_group,
|
|
464
|
+
'e': e,
|
|
465
|
+
}
|
|
466
|
+
raise exceptions.CommandError(msg)
|