python-openstackclient 7.4.0__py3-none-any.whl → 8.1.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/common/availability_zone.py +3 -6
- openstackclient/common/clientmanager.py +2 -1
- openstackclient/common/envvars.py +57 -0
- openstackclient/common/extension.py +3 -11
- openstackclient/common/limits.py +1 -1
- openstackclient/common/project_cleanup.py +3 -2
- openstackclient/common/quota.py +54 -28
- openstackclient/compute/client.py +7 -5
- openstackclient/compute/v2/agent.py +5 -5
- openstackclient/compute/v2/aggregate.py +17 -15
- openstackclient/compute/v2/console.py +10 -4
- openstackclient/compute/v2/console_connection.py +48 -0
- openstackclient/compute/v2/flavor.py +14 -18
- openstackclient/compute/v2/host.py +3 -3
- openstackclient/compute/v2/hypervisor.py +10 -4
- openstackclient/compute/v2/hypervisor_stats.py +1 -1
- openstackclient/compute/v2/keypair.py +18 -13
- openstackclient/compute/v2/server.py +144 -121
- openstackclient/compute/v2/server_backup.py +1 -1
- openstackclient/compute/v2/server_event.py +8 -17
- openstackclient/compute/v2/server_group.py +6 -6
- openstackclient/compute/v2/server_image.py +1 -1
- openstackclient/compute/v2/server_migration.py +6 -6
- openstackclient/compute/v2/server_volume.py +4 -4
- openstackclient/compute/v2/service.py +9 -13
- openstackclient/compute/v2/usage.py +4 -6
- openstackclient/identity/client.py +2 -4
- openstackclient/identity/common.py +95 -17
- openstackclient/identity/v2_0/ec2creds.py +4 -3
- openstackclient/identity/v2_0/endpoint.py +12 -10
- openstackclient/identity/v2_0/project.py +6 -6
- openstackclient/identity/v2_0/role.py +1 -1
- openstackclient/identity/v2_0/service.py +7 -7
- openstackclient/identity/v2_0/user.py +6 -21
- openstackclient/identity/v3/access_rule.py +2 -5
- openstackclient/identity/v3/application_credential.py +2 -2
- openstackclient/identity/v3/consumer.py +4 -3
- openstackclient/identity/v3/credential.py +6 -7
- openstackclient/identity/v3/domain.py +63 -44
- openstackclient/identity/v3/ec2creds.py +4 -3
- openstackclient/identity/v3/endpoint.py +104 -88
- openstackclient/identity/v3/endpoint_group.py +1 -1
- openstackclient/identity/v3/group.py +116 -72
- openstackclient/identity/v3/identity_provider.py +1 -2
- openstackclient/identity/v3/limit.py +4 -9
- openstackclient/identity/v3/mapping.py +4 -3
- openstackclient/identity/v3/policy.py +5 -8
- openstackclient/identity/v3/project.py +23 -6
- openstackclient/identity/v3/region.py +2 -5
- openstackclient/identity/v3/registered_limit.py +4 -8
- openstackclient/identity/v3/role.py +15 -16
- openstackclient/identity/v3/service.py +8 -8
- openstackclient/identity/v3/service_provider.py +3 -6
- openstackclient/identity/v3/tag.py +2 -2
- openstackclient/identity/v3/token.py +1 -2
- openstackclient/identity/v3/trust.py +74 -25
- openstackclient/identity/v3/user.py +47 -11
- openstackclient/image/client.py +7 -5
- openstackclient/image/v1/image.py +11 -15
- openstackclient/image/v2/cache.py +2 -4
- openstackclient/image/v2/image.py +41 -48
- openstackclient/image/v2/metadef_namespaces.py +4 -3
- openstackclient/image/v2/metadef_resource_type_association.py +1 -2
- openstackclient/image/v2/metadef_resource_types.py +1 -2
- openstackclient/locale/tr_TR/LC_MESSAGES/openstackclient.po +9 -1370
- openstackclient/network/client.py +4 -16
- openstackclient/network/common.py +16 -12
- openstackclient/network/utils.py +3 -3
- openstackclient/network/v2/address_group.py +5 -9
- openstackclient/network/v2/address_scope.py +2 -3
- openstackclient/network/v2/default_security_group_rule.py +1 -2
- openstackclient/network/v2/floating_ip.py +69 -47
- openstackclient/network/v2/floating_ip_port_forwarding.py +7 -7
- openstackclient/network/v2/ip_availability.py +1 -2
- openstackclient/network/v2/l3_conntrack_helper.py +8 -12
- openstackclient/network/v2/local_ip.py +24 -26
- openstackclient/network/v2/local_ip_association.py +4 -5
- openstackclient/network/v2/ndp_proxy.py +9 -10
- openstackclient/network/v2/network.py +12 -16
- openstackclient/network/v2/network_agent.py +29 -37
- openstackclient/network/v2/network_auto_allocated_topology.py +4 -5
- openstackclient/network/v2/network_flavor.py +1 -1
- openstackclient/network/v2/network_flavor_profile.py +5 -5
- openstackclient/network/v2/network_meter.py +3 -3
- openstackclient/network/v2/network_meter_rule.py +5 -8
- openstackclient/network/v2/network_qos_policy.py +4 -4
- openstackclient/network/v2/network_qos_rule.py +7 -16
- openstackclient/network/v2/network_rbac.py +4 -4
- openstackclient/network/v2/network_segment.py +6 -7
- openstackclient/network/v2/network_segment_range.py +16 -20
- openstackclient/network/v2/network_trunk.py +24 -16
- openstackclient/network/v2/port.py +28 -29
- openstackclient/network/v2/router.py +53 -42
- openstackclient/network/v2/security_group.py +13 -19
- openstackclient/network/v2/security_group_rule.py +10 -11
- openstackclient/network/v2/subnet.py +31 -30
- openstackclient/network/v2/subnet_pool.py +4 -4
- openstackclient/object/client.py +2 -3
- openstackclient/object/v1/container.py +2 -3
- openstackclient/object/v1/object.py +2 -9
- openstackclient/shell.py +22 -5
- openstackclient/tests/functional/base.py +7 -3
- openstackclient/tests/functional/common/test_quota.py +3 -1
- openstackclient/tests/functional/compute/v2/common.py +12 -6
- openstackclient/tests/functional/compute/v2/test_keypair.py +41 -5
- openstackclient/tests/functional/compute/v2/test_server.py +2 -3
- openstackclient/tests/functional/compute/v2/test_server_event.py +1 -1
- openstackclient/tests/functional/identity/v2/test_user.py +1 -1
- openstackclient/tests/functional/identity/v3/common.py +3 -8
- openstackclient/tests/functional/identity/v3/test_application_credential.py +10 -10
- openstackclient/tests/functional/identity/v3/test_endpoint.py +3 -3
- openstackclient/tests/functional/identity/v3/test_group.py +3 -3
- openstackclient/tests/functional/identity/v3/test_idp.py +3 -7
- openstackclient/tests/functional/identity/v3/test_limit.py +4 -4
- openstackclient/tests/functional/identity/v3/test_project.py +5 -14
- openstackclient/tests/functional/identity/v3/test_region.py +1 -3
- openstackclient/tests/functional/identity/v3/test_registered_limit.py +3 -3
- openstackclient/tests/functional/identity/v3/test_role.py +1 -1
- openstackclient/tests/functional/identity/v3/test_role_assignment.py +13 -31
- openstackclient/tests/functional/identity/v3/test_service_provider.py +3 -7
- openstackclient/tests/functional/identity/v3/test_user.py +8 -8
- openstackclient/tests/functional/network/v2/common.py +7 -3
- openstackclient/tests/functional/network/v2/test_address_group.py +4 -0
- openstackclient/tests/functional/network/v2/test_l3_conntrack_helper.py +15 -11
- openstackclient/tests/functional/network/v2/test_local_ip.py +4 -0
- openstackclient/tests/functional/network/v2/test_network_meter_rule.py +2 -2
- openstackclient/tests/functional/network/v2/test_network_ndp_proxy.py +2 -3
- openstackclient/tests/functional/network/v2/test_network_rbac.py +2 -2
- openstackclient/tests/functional/network/v2/test_network_trunk.py +1 -1
- openstackclient/tests/functional/network/v2/test_port.py +17 -7
- openstackclient/tests/functional/network/v2/test_router.py +42 -0
- openstackclient/tests/functional/network/v2/test_subnet_pool.py +4 -0
- openstackclient/tests/unit/api/test_compute_v2.py +67 -87
- openstackclient/tests/unit/common/test_availability_zone.py +6 -14
- openstackclient/tests/unit/common/test_command.py +1 -1
- openstackclient/tests/unit/common/test_extension.py +5 -7
- openstackclient/tests/unit/common/test_limits.py +1 -1
- openstackclient/tests/unit/common/test_project_cleanup.py +5 -6
- openstackclient/tests/unit/common/test_quota.py +51 -28
- openstackclient/tests/unit/compute/v2/fakes.py +85 -315
- openstackclient/tests/unit/compute/v2/test_agent.py +16 -16
- openstackclient/tests/unit/compute/v2/test_aggregate.py +56 -60
- openstackclient/tests/unit/compute/v2/test_console.py +34 -17
- openstackclient/tests/unit/compute/v2/test_console_connection.py +72 -0
- openstackclient/tests/unit/compute/v2/test_flavor.py +72 -72
- openstackclient/tests/unit/compute/v2/test_host.py +8 -8
- openstackclient/tests/unit/compute/v2/test_hypervisor.py +22 -30
- openstackclient/tests/unit/compute/v2/test_hypervisor_stats.py +2 -2
- openstackclient/tests/unit/compute/v2/test_keypair.py +36 -29
- openstackclient/tests/unit/compute/v2/test_server.py +693 -606
- openstackclient/tests/unit/compute/v2/test_server_backup.py +36 -77
- openstackclient/tests/unit/compute/v2/test_server_event.py +18 -20
- openstackclient/tests/unit/compute/v2/test_server_group.py +25 -31
- openstackclient/tests/unit/compute/v2/test_server_image.py +37 -78
- openstackclient/tests/unit/compute/v2/test_server_migration.py +41 -41
- openstackclient/tests/unit/compute/v2/test_server_volume.py +12 -12
- openstackclient/tests/unit/compute/v2/test_service.py +39 -45
- openstackclient/tests/unit/compute/v2/test_usage.py +5 -5
- openstackclient/tests/unit/identity/v2_0/fakes.py +1 -1
- openstackclient/tests/unit/identity/v3/test_access_rule.py +1 -3
- openstackclient/tests/unit/identity/v3/test_application_credential.py +48 -26
- openstackclient/tests/unit/identity/v3/test_domain.py +115 -105
- openstackclient/tests/unit/identity/v3/test_endpoint.py +167 -172
- openstackclient/tests/unit/identity/v3/test_group.py +353 -202
- openstackclient/tests/unit/identity/v3/test_mappings.py +2 -2
- openstackclient/tests/unit/identity/v3/test_project.py +16 -0
- openstackclient/tests/unit/identity/v3/test_trust.py +5 -2
- openstackclient/tests/unit/identity/v3/test_user.py +102 -6
- openstackclient/tests/unit/image/v1/fakes.py +2 -2
- openstackclient/tests/unit/image/v1/test_image.py +8 -9
- openstackclient/tests/unit/image/v2/test_image.py +84 -46
- openstackclient/tests/unit/integ/cli/test_shell.py +1 -2
- openstackclient/tests/unit/network/test_common.py +2 -2
- openstackclient/tests/unit/network/v2/fakes.py +405 -485
- openstackclient/tests/unit/network/v2/test_floating_ip_compute.py +8 -14
- openstackclient/tests/unit/network/v2/test_floating_ip_network.py +62 -54
- openstackclient/tests/unit/network/v2/test_floating_ip_pool_compute.py +1 -1
- openstackclient/tests/unit/network/v2/test_l3_conntrack_helper.py +2 -2
- openstackclient/tests/unit/network/v2/test_ndp_proxy.py +1 -3
- openstackclient/tests/unit/network/v2/test_network.py +4 -4
- openstackclient/tests/unit/network/v2/test_network_agent.py +15 -29
- openstackclient/tests/unit/network/v2/test_network_compute.py +11 -11
- openstackclient/tests/unit/network/v2/test_network_qos_policy.py +16 -19
- openstackclient/tests/unit/network/v2/test_network_qos_rule.py +79 -152
- openstackclient/tests/unit/network/v2/test_network_qos_rule_type.py +4 -6
- openstackclient/tests/unit/network/v2/test_network_rbac.py +2 -2
- openstackclient/tests/unit/network/v2/test_network_trunk.py +2 -2
- openstackclient/tests/unit/network/v2/test_port.py +21 -22
- openstackclient/tests/unit/network/v2/test_router.py +130 -51
- openstackclient/tests/unit/network/v2/test_security_group_compute.py +11 -19
- openstackclient/tests/unit/network/v2/test_security_group_network.py +25 -27
- openstackclient/tests/unit/network/v2/test_security_group_rule_compute.py +15 -17
- openstackclient/tests/unit/network/v2/test_security_group_rule_network.py +33 -39
- openstackclient/tests/unit/object/v1/test_object_all.py +4 -3
- openstackclient/tests/unit/test_shell.py +16 -13
- openstackclient/tests/unit/volume/v2/fakes.py +1 -2
- openstackclient/tests/unit/volume/v2/test_service.py +57 -91
- openstackclient/tests/unit/volume/v2/test_volume.py +109 -106
- openstackclient/tests/unit/volume/v2/test_volume_backup.py +141 -148
- openstackclient/tests/unit/volume/v2/test_volume_snapshot.py +293 -283
- openstackclient/tests/unit/volume/v2/test_volume_transfer_request.py +1 -1
- openstackclient/tests/unit/volume/v3/fakes.py +2 -8
- openstackclient/tests/unit/volume/v3/test_block_storage_log_level.py +61 -71
- openstackclient/tests/unit/volume/v3/test_service.py +221 -141
- openstackclient/tests/unit/volume/v3/test_volume.py +131 -120
- openstackclient/tests/unit/volume/v3/test_volume_attachment.py +4 -4
- openstackclient/tests/unit/volume/v3/test_volume_backup.py +198 -203
- openstackclient/tests/unit/volume/v3/test_volume_snapshot.py +683 -49
- openstackclient/tests/unit/volume/v3/test_volume_transfer_request.py +1 -1
- openstackclient/volume/client.py +1 -3
- openstackclient/volume/v2/consistency_group.py +4 -8
- openstackclient/volume/v2/consistency_group_snapshot.py +1 -2
- openstackclient/volume/v2/qos_specs.py +1 -2
- openstackclient/volume/v2/service.py +41 -38
- openstackclient/volume/v2/volume.py +71 -53
- openstackclient/volume/v2/volume_backup.py +15 -10
- openstackclient/volume/v2/volume_snapshot.py +129 -93
- openstackclient/volume/v2/volume_transfer_request.py +0 -3
- openstackclient/volume/v2/volume_type.py +10 -21
- openstackclient/volume/v3/block_storage_cluster.py +3 -3
- openstackclient/volume/v3/block_storage_log_level.py +22 -28
- openstackclient/volume/v3/block_storage_manage.py +1 -3
- openstackclient/volume/v3/service.py +105 -14
- openstackclient/volume/v3/volume.py +218 -58
- openstackclient/volume/v3/volume_attachment.py +3 -2
- openstackclient/volume/v3/volume_backup.py +31 -27
- openstackclient/volume/v3/volume_group.py +2 -1
- openstackclient/volume/v3/volume_group_snapshot.py +2 -1
- openstackclient/volume/v3/volume_snapshot.py +489 -13
- openstackclient/volume/v3/volume_type.py +10 -21
- {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.1.0.dist-info}/AUTHORS +11 -0
- python_openstackclient-8.1.0.dist-info/METADATA +264 -0
- {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.1.0.dist-info}/RECORD +238 -259
- {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.1.0.dist-info}/WHEEL +1 -1
- {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.1.0.dist-info}/entry_points.txt +7 -47
- python_openstackclient-8.1.0.dist-info/pbr.json +1 -0
- openstackclient/tests/functional/volume/v1/__init__.py +0 -0
- openstackclient/tests/functional/volume/v1/common.py +0 -35
- openstackclient/tests/functional/volume/v1/test_qos.py +0 -100
- openstackclient/tests/functional/volume/v1/test_service.py +0 -76
- openstackclient/tests/functional/volume/v1/test_snapshot.py +0 -232
- openstackclient/tests/functional/volume/v1/test_transfer_request.py +0 -111
- openstackclient/tests/functional/volume/v1/test_volume.py +0 -228
- openstackclient/tests/functional/volume/v1/test_volume_type.py +0 -213
- openstackclient/tests/unit/volume/v1/__init__.py +0 -0
- openstackclient/tests/unit/volume/v1/fakes.py +0 -615
- openstackclient/tests/unit/volume/v1/test_qos_specs.py +0 -471
- openstackclient/tests/unit/volume/v1/test_service.py +0 -295
- openstackclient/tests/unit/volume/v1/test_transfer_request.py +0 -380
- openstackclient/tests/unit/volume/v1/test_type.py +0 -633
- openstackclient/tests/unit/volume/v1/test_volume.py +0 -1447
- openstackclient/tests/unit/volume/v1/test_volume_backup.py +0 -435
- openstackclient/volume/v1/__init__.py +0 -0
- openstackclient/volume/v1/qos_specs.py +0 -377
- openstackclient/volume/v1/service.py +0 -136
- openstackclient/volume/v1/volume.py +0 -734
- openstackclient/volume/v1/volume_backup.py +0 -302
- openstackclient/volume/v1/volume_snapshot.py +0 -433
- openstackclient/volume/v1/volume_transfer_request.py +0 -200
- openstackclient/volume/v1/volume_type.py +0 -520
- python_openstackclient-7.4.0.dist-info/METADATA +0 -172
- python_openstackclient-7.4.0.dist-info/pbr.json +0 -1
- {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.1.0.dist-info}/LICENSE +0 -0
- {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.1.0.dist-info}/top_level.txt +0 -0
|
@@ -1,433 +0,0 @@
|
|
|
1
|
-
# Copyright 2012-2013 OpenStack Foundation
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
4
|
-
# not use this file except in compliance with the License. You may obtain
|
|
5
|
-
# a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
11
|
-
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
12
|
-
# License for the specific language governing permissions and limitations
|
|
13
|
-
# under the License.
|
|
14
|
-
#
|
|
15
|
-
|
|
16
|
-
"""Volume v1 Snapshot action implementations"""
|
|
17
|
-
|
|
18
|
-
import copy
|
|
19
|
-
import functools
|
|
20
|
-
import logging
|
|
21
|
-
|
|
22
|
-
from cliff import columns as cliff_columns
|
|
23
|
-
from osc_lib.cli import format_columns
|
|
24
|
-
from osc_lib.cli import parseractions
|
|
25
|
-
from osc_lib.command import command
|
|
26
|
-
from osc_lib import exceptions
|
|
27
|
-
from osc_lib import utils
|
|
28
|
-
|
|
29
|
-
from openstackclient.i18n import _
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
LOG = logging.getLogger(__name__)
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
class VolumeIdColumn(cliff_columns.FormattableColumn):
|
|
36
|
-
"""Formattable column for volume ID column.
|
|
37
|
-
|
|
38
|
-
Unlike the parent FormattableColumn class, the initializer of the
|
|
39
|
-
class takes volume_cache as the second argument.
|
|
40
|
-
osc_lib.utils.get_item_properties instantiate cliff FormattableColumn
|
|
41
|
-
object with a single parameter "column value", so you need to pass
|
|
42
|
-
a partially initialized class like
|
|
43
|
-
``functools.partial(VolumeIdColumn, volume_cache)``.
|
|
44
|
-
"""
|
|
45
|
-
|
|
46
|
-
def __init__(self, value, volume_cache=None):
|
|
47
|
-
super().__init__(value)
|
|
48
|
-
self._volume_cache = volume_cache or {}
|
|
49
|
-
|
|
50
|
-
def human_readable(self):
|
|
51
|
-
"""Return a volume name if available
|
|
52
|
-
|
|
53
|
-
:rtype: either the volume ID or name
|
|
54
|
-
"""
|
|
55
|
-
volume_id = self._value
|
|
56
|
-
volume = volume_id
|
|
57
|
-
if volume_id in self._volume_cache.keys():
|
|
58
|
-
volume = self._volume_cache[volume_id].display_name
|
|
59
|
-
return volume
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
class CreateVolumeSnapshot(command.ShowOne):
|
|
63
|
-
_description = _("Create new volume snapshot")
|
|
64
|
-
|
|
65
|
-
def get_parser(self, prog_name):
|
|
66
|
-
parser = super().get_parser(prog_name)
|
|
67
|
-
parser.add_argument(
|
|
68
|
-
'snapshot_name',
|
|
69
|
-
metavar='<snapshot-name>',
|
|
70
|
-
help=_('Name of the new snapshot'),
|
|
71
|
-
)
|
|
72
|
-
parser.add_argument(
|
|
73
|
-
'--volume',
|
|
74
|
-
metavar='<volume>',
|
|
75
|
-
help=_(
|
|
76
|
-
'Volume to snapshot (name or ID) '
|
|
77
|
-
'(default is <snapshot-name>)'
|
|
78
|
-
),
|
|
79
|
-
)
|
|
80
|
-
parser.add_argument(
|
|
81
|
-
'--description',
|
|
82
|
-
metavar='<description>',
|
|
83
|
-
help=_('Description of the snapshot'),
|
|
84
|
-
)
|
|
85
|
-
parser.add_argument(
|
|
86
|
-
'--force',
|
|
87
|
-
dest='force',
|
|
88
|
-
action='store_true',
|
|
89
|
-
default=False,
|
|
90
|
-
help=_(
|
|
91
|
-
'Create a snapshot attached to an instance. '
|
|
92
|
-
'Default is False'
|
|
93
|
-
),
|
|
94
|
-
)
|
|
95
|
-
return parser
|
|
96
|
-
|
|
97
|
-
def take_action(self, parsed_args):
|
|
98
|
-
volume_client = self.app.client_manager.volume
|
|
99
|
-
volume = parsed_args.volume
|
|
100
|
-
if not parsed_args.volume:
|
|
101
|
-
volume = parsed_args.snapshot_name
|
|
102
|
-
volume_id = utils.find_resource(volume_client.volumes, volume).id
|
|
103
|
-
snapshot = volume_client.volume_snapshots.create(
|
|
104
|
-
volume_id,
|
|
105
|
-
parsed_args.force,
|
|
106
|
-
parsed_args.snapshot_name,
|
|
107
|
-
parsed_args.description,
|
|
108
|
-
)
|
|
109
|
-
|
|
110
|
-
snapshot._info.update(
|
|
111
|
-
{
|
|
112
|
-
'properties': format_columns.DictColumn(
|
|
113
|
-
snapshot._info.pop('metadata')
|
|
114
|
-
)
|
|
115
|
-
}
|
|
116
|
-
)
|
|
117
|
-
|
|
118
|
-
return zip(*sorted(snapshot._info.items()))
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
class DeleteVolumeSnapshot(command.Command):
|
|
122
|
-
_description = _("Delete volume snapshot(s)")
|
|
123
|
-
|
|
124
|
-
def get_parser(self, prog_name):
|
|
125
|
-
parser = super().get_parser(prog_name)
|
|
126
|
-
parser.add_argument(
|
|
127
|
-
'snapshots',
|
|
128
|
-
metavar='<snapshot>',
|
|
129
|
-
nargs="+",
|
|
130
|
-
help=_('Snapshot(s) to delete (name or ID)'),
|
|
131
|
-
)
|
|
132
|
-
return parser
|
|
133
|
-
|
|
134
|
-
def take_action(self, parsed_args):
|
|
135
|
-
volume_client = self.app.client_manager.volume
|
|
136
|
-
result = 0
|
|
137
|
-
|
|
138
|
-
for i in parsed_args.snapshots:
|
|
139
|
-
try:
|
|
140
|
-
snapshot_id = utils.find_resource(
|
|
141
|
-
volume_client.volume_snapshots, i
|
|
142
|
-
).id
|
|
143
|
-
volume_client.volume_snapshots.delete(snapshot_id)
|
|
144
|
-
except Exception as e:
|
|
145
|
-
result += 1
|
|
146
|
-
LOG.error(
|
|
147
|
-
_(
|
|
148
|
-
"Failed to delete snapshot with "
|
|
149
|
-
"name or ID '%(snapshot)s': %(e)s"
|
|
150
|
-
),
|
|
151
|
-
{'snapshot': i, 'e': e},
|
|
152
|
-
)
|
|
153
|
-
|
|
154
|
-
if result > 0:
|
|
155
|
-
total = len(parsed_args.snapshots)
|
|
156
|
-
msg = _(
|
|
157
|
-
"%(result)s of %(total)s snapshots failed " "to delete."
|
|
158
|
-
) % {'result': result, 'total': total}
|
|
159
|
-
raise exceptions.CommandError(msg)
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
class ListVolumeSnapshot(command.Lister):
|
|
163
|
-
_description = _("List volume snapshots")
|
|
164
|
-
|
|
165
|
-
def get_parser(self, prog_name):
|
|
166
|
-
parser = super().get_parser(prog_name)
|
|
167
|
-
parser.add_argument(
|
|
168
|
-
'--all-projects',
|
|
169
|
-
action='store_true',
|
|
170
|
-
default=False,
|
|
171
|
-
help=_('Include all projects (admin only)'),
|
|
172
|
-
)
|
|
173
|
-
parser.add_argument(
|
|
174
|
-
'--long',
|
|
175
|
-
action='store_true',
|
|
176
|
-
default=False,
|
|
177
|
-
help=_('List additional fields in output'),
|
|
178
|
-
)
|
|
179
|
-
parser.add_argument(
|
|
180
|
-
'--name',
|
|
181
|
-
metavar='<name>',
|
|
182
|
-
default=None,
|
|
183
|
-
help=_('Filters results by a name.'),
|
|
184
|
-
)
|
|
185
|
-
parser.add_argument(
|
|
186
|
-
'--status',
|
|
187
|
-
metavar='<status>',
|
|
188
|
-
choices=[
|
|
189
|
-
'available',
|
|
190
|
-
'error',
|
|
191
|
-
'creating',
|
|
192
|
-
'deleting',
|
|
193
|
-
'error_deleting',
|
|
194
|
-
],
|
|
195
|
-
help=_(
|
|
196
|
-
"Filters results by a status. "
|
|
197
|
-
"('available', 'error', 'creating', 'deleting'"
|
|
198
|
-
" or 'error_deleting')"
|
|
199
|
-
),
|
|
200
|
-
)
|
|
201
|
-
parser.add_argument(
|
|
202
|
-
'--volume',
|
|
203
|
-
metavar='<volume>',
|
|
204
|
-
default=None,
|
|
205
|
-
help=_('Filters results by a volume (name or ID).'),
|
|
206
|
-
)
|
|
207
|
-
return parser
|
|
208
|
-
|
|
209
|
-
def take_action(self, parsed_args):
|
|
210
|
-
volume_client = self.app.client_manager.volume
|
|
211
|
-
|
|
212
|
-
if parsed_args.long:
|
|
213
|
-
columns = [
|
|
214
|
-
'ID',
|
|
215
|
-
'Display Name',
|
|
216
|
-
'Display Description',
|
|
217
|
-
'Status',
|
|
218
|
-
'Size',
|
|
219
|
-
'Created At',
|
|
220
|
-
'Volume ID',
|
|
221
|
-
'Metadata',
|
|
222
|
-
]
|
|
223
|
-
column_headers = copy.deepcopy(columns)
|
|
224
|
-
column_headers[6] = 'Volume'
|
|
225
|
-
column_headers[7] = 'Properties'
|
|
226
|
-
else:
|
|
227
|
-
columns = [
|
|
228
|
-
'ID',
|
|
229
|
-
'Display Name',
|
|
230
|
-
'Display Description',
|
|
231
|
-
'Status',
|
|
232
|
-
'Size',
|
|
233
|
-
]
|
|
234
|
-
column_headers = copy.deepcopy(columns)
|
|
235
|
-
|
|
236
|
-
# Always update Name and Description
|
|
237
|
-
column_headers[1] = 'Name'
|
|
238
|
-
column_headers[2] = 'Description'
|
|
239
|
-
|
|
240
|
-
# Cache the volume list
|
|
241
|
-
volume_cache = {}
|
|
242
|
-
try:
|
|
243
|
-
for s in volume_client.volumes.list():
|
|
244
|
-
volume_cache[s.id] = s
|
|
245
|
-
except Exception: # noqa: S110
|
|
246
|
-
# Just forget it if there's any trouble
|
|
247
|
-
pass
|
|
248
|
-
VolumeIdColumnWithCache = functools.partial(
|
|
249
|
-
VolumeIdColumn, volume_cache=volume_cache
|
|
250
|
-
)
|
|
251
|
-
|
|
252
|
-
volume_id = None
|
|
253
|
-
if parsed_args.volume:
|
|
254
|
-
volume_id = utils.find_resource(
|
|
255
|
-
volume_client.volumes, parsed_args.volume
|
|
256
|
-
).id
|
|
257
|
-
|
|
258
|
-
search_opts = {
|
|
259
|
-
'all_tenants': parsed_args.all_projects,
|
|
260
|
-
'display_name': parsed_args.name,
|
|
261
|
-
'status': parsed_args.status,
|
|
262
|
-
'volume_id': volume_id,
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
data = volume_client.volume_snapshots.list(search_opts=search_opts)
|
|
266
|
-
return (
|
|
267
|
-
column_headers,
|
|
268
|
-
(
|
|
269
|
-
utils.get_item_properties(
|
|
270
|
-
s,
|
|
271
|
-
columns,
|
|
272
|
-
formatters={
|
|
273
|
-
'Metadata': format_columns.DictColumn,
|
|
274
|
-
'Volume ID': VolumeIdColumnWithCache,
|
|
275
|
-
},
|
|
276
|
-
)
|
|
277
|
-
for s in data
|
|
278
|
-
),
|
|
279
|
-
)
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
class SetVolumeSnapshot(command.Command):
|
|
283
|
-
_description = _("Set volume snapshot properties")
|
|
284
|
-
|
|
285
|
-
def get_parser(self, prog_name):
|
|
286
|
-
parser = super().get_parser(prog_name)
|
|
287
|
-
parser.add_argument(
|
|
288
|
-
'snapshot',
|
|
289
|
-
metavar='<snapshot>',
|
|
290
|
-
help=_('Snapshot to modify (name or ID)'),
|
|
291
|
-
)
|
|
292
|
-
parser.add_argument(
|
|
293
|
-
'--name', metavar='<name>', help=_('New snapshot name')
|
|
294
|
-
)
|
|
295
|
-
parser.add_argument(
|
|
296
|
-
'--description',
|
|
297
|
-
metavar='<description>',
|
|
298
|
-
help=_('New snapshot description'),
|
|
299
|
-
)
|
|
300
|
-
parser.add_argument(
|
|
301
|
-
"--no-property",
|
|
302
|
-
dest="no_property",
|
|
303
|
-
action="store_true",
|
|
304
|
-
help=_(
|
|
305
|
-
"Remove all properties from <snapshot> "
|
|
306
|
-
"(specify both --no-property and --property to "
|
|
307
|
-
"remove the current properties before setting "
|
|
308
|
-
"new properties.)"
|
|
309
|
-
),
|
|
310
|
-
)
|
|
311
|
-
parser.add_argument(
|
|
312
|
-
'--property',
|
|
313
|
-
metavar='<key=value>',
|
|
314
|
-
action=parseractions.KeyValueAction,
|
|
315
|
-
help=_(
|
|
316
|
-
'Property to add/change for this snapshot '
|
|
317
|
-
'(repeat option to set multiple properties)'
|
|
318
|
-
),
|
|
319
|
-
)
|
|
320
|
-
return parser
|
|
321
|
-
|
|
322
|
-
def take_action(self, parsed_args):
|
|
323
|
-
volume_client = self.app.client_manager.volume
|
|
324
|
-
snapshot = utils.find_resource(
|
|
325
|
-
volume_client.volume_snapshots, parsed_args.snapshot
|
|
326
|
-
)
|
|
327
|
-
|
|
328
|
-
result = 0
|
|
329
|
-
if parsed_args.no_property:
|
|
330
|
-
try:
|
|
331
|
-
key_list = snapshot.metadata.keys()
|
|
332
|
-
volume_client.volume_snapshots.delete_metadata(
|
|
333
|
-
snapshot.id,
|
|
334
|
-
list(key_list),
|
|
335
|
-
)
|
|
336
|
-
except Exception as e:
|
|
337
|
-
LOG.error(_("Failed to clean snapshot properties: %s"), e)
|
|
338
|
-
result += 1
|
|
339
|
-
|
|
340
|
-
if parsed_args.property:
|
|
341
|
-
try:
|
|
342
|
-
volume_client.volume_snapshots.set_metadata(
|
|
343
|
-
snapshot.id, parsed_args.property
|
|
344
|
-
)
|
|
345
|
-
except Exception as e:
|
|
346
|
-
LOG.error(_("Failed to set snapshot property: %s"), e)
|
|
347
|
-
result += 1
|
|
348
|
-
|
|
349
|
-
kwargs = {}
|
|
350
|
-
if parsed_args.name:
|
|
351
|
-
kwargs['display_name'] = parsed_args.name
|
|
352
|
-
if parsed_args.description:
|
|
353
|
-
kwargs['display_description'] = parsed_args.description
|
|
354
|
-
if kwargs:
|
|
355
|
-
try:
|
|
356
|
-
snapshot.update(**kwargs)
|
|
357
|
-
except Exception as e:
|
|
358
|
-
LOG.error(
|
|
359
|
-
_(
|
|
360
|
-
"Failed to update snapshot display name "
|
|
361
|
-
"or display description: %s"
|
|
362
|
-
),
|
|
363
|
-
e,
|
|
364
|
-
)
|
|
365
|
-
result += 1
|
|
366
|
-
|
|
367
|
-
if result > 0:
|
|
368
|
-
raise exceptions.CommandError(
|
|
369
|
-
_("One or more of the " "set operations failed")
|
|
370
|
-
)
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
class ShowVolumeSnapshot(command.ShowOne):
|
|
374
|
-
_description = _("Display volume snapshot details")
|
|
375
|
-
|
|
376
|
-
def get_parser(self, prog_name):
|
|
377
|
-
parser = super().get_parser(prog_name)
|
|
378
|
-
parser.add_argument(
|
|
379
|
-
'snapshot',
|
|
380
|
-
metavar='<snapshot>',
|
|
381
|
-
help=_('Snapshot to display (name or ID)'),
|
|
382
|
-
)
|
|
383
|
-
return parser
|
|
384
|
-
|
|
385
|
-
def take_action(self, parsed_args):
|
|
386
|
-
volume_client = self.app.client_manager.volume
|
|
387
|
-
snapshot = utils.find_resource(
|
|
388
|
-
volume_client.volume_snapshots, parsed_args.snapshot
|
|
389
|
-
)
|
|
390
|
-
|
|
391
|
-
snapshot._info.update(
|
|
392
|
-
{
|
|
393
|
-
'properties': format_columns.DictColumn(
|
|
394
|
-
snapshot._info.pop('metadata')
|
|
395
|
-
)
|
|
396
|
-
}
|
|
397
|
-
)
|
|
398
|
-
|
|
399
|
-
return zip(*sorted(snapshot._info.items()))
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
class UnsetVolumeSnapshot(command.Command):
|
|
403
|
-
_description = _("Unset volume snapshot properties")
|
|
404
|
-
|
|
405
|
-
def get_parser(self, prog_name):
|
|
406
|
-
parser = super().get_parser(prog_name)
|
|
407
|
-
parser.add_argument(
|
|
408
|
-
'snapshot',
|
|
409
|
-
metavar='<snapshot>',
|
|
410
|
-
help=_('Snapshot to modify (name or ID)'),
|
|
411
|
-
)
|
|
412
|
-
parser.add_argument(
|
|
413
|
-
'--property',
|
|
414
|
-
metavar='<key>',
|
|
415
|
-
action='append',
|
|
416
|
-
help=_(
|
|
417
|
-
'Property to remove from snapshot '
|
|
418
|
-
'(repeat option to remove multiple properties)'
|
|
419
|
-
),
|
|
420
|
-
)
|
|
421
|
-
return parser
|
|
422
|
-
|
|
423
|
-
def take_action(self, parsed_args):
|
|
424
|
-
volume_client = self.app.client_manager.volume
|
|
425
|
-
snapshot = utils.find_resource(
|
|
426
|
-
volume_client.volume_snapshots, parsed_args.snapshot
|
|
427
|
-
)
|
|
428
|
-
|
|
429
|
-
if parsed_args.property:
|
|
430
|
-
volume_client.volume_snapshots.delete_metadata(
|
|
431
|
-
snapshot.id,
|
|
432
|
-
parsed_args.property,
|
|
433
|
-
)
|
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
#
|
|
2
|
-
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
3
|
-
# not use this file except in compliance with the License. You may obtain
|
|
4
|
-
# a copy of the License at
|
|
5
|
-
#
|
|
6
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
#
|
|
8
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
10
|
-
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
11
|
-
# License for the specific language governing permissions and limitations
|
|
12
|
-
# under the License.
|
|
13
|
-
#
|
|
14
|
-
|
|
15
|
-
"""Volume v1 transfer action implementations"""
|
|
16
|
-
|
|
17
|
-
import logging
|
|
18
|
-
|
|
19
|
-
from osc_lib.command import command
|
|
20
|
-
from osc_lib import exceptions
|
|
21
|
-
from osc_lib import utils
|
|
22
|
-
|
|
23
|
-
from openstackclient.i18n import _
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
LOG = logging.getLogger(__name__)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
class AcceptTransferRequest(command.ShowOne):
|
|
30
|
-
_description = _("Accept volume transfer request.")
|
|
31
|
-
|
|
32
|
-
def get_parser(self, prog_name):
|
|
33
|
-
parser = super().get_parser(prog_name)
|
|
34
|
-
parser.add_argument(
|
|
35
|
-
'transfer_request',
|
|
36
|
-
metavar="<transfer-request-id>",
|
|
37
|
-
help=_('Volume transfer request to accept (ID only)'),
|
|
38
|
-
)
|
|
39
|
-
parser.add_argument(
|
|
40
|
-
'--auth-key',
|
|
41
|
-
metavar="<key>",
|
|
42
|
-
help=_('Volume transfer request authentication key'),
|
|
43
|
-
)
|
|
44
|
-
return parser
|
|
45
|
-
|
|
46
|
-
def take_action(self, parsed_args):
|
|
47
|
-
volume_client = self.app.client_manager.volume
|
|
48
|
-
|
|
49
|
-
try:
|
|
50
|
-
transfer_request_id = utils.find_resource(
|
|
51
|
-
volume_client.transfers, parsed_args.transfer_request
|
|
52
|
-
).id
|
|
53
|
-
except exceptions.CommandError:
|
|
54
|
-
# Non-admin users will fail to lookup name -> ID so we just
|
|
55
|
-
# move on and attempt with the user-supplied information
|
|
56
|
-
transfer_request_id = parsed_args.transfer_request
|
|
57
|
-
|
|
58
|
-
if not parsed_args.auth_key:
|
|
59
|
-
msg = _("argument --auth-key is required")
|
|
60
|
-
raise exceptions.CommandError(msg)
|
|
61
|
-
|
|
62
|
-
transfer_accept = volume_client.transfers.accept(
|
|
63
|
-
transfer_request_id,
|
|
64
|
-
parsed_args.auth_key,
|
|
65
|
-
)
|
|
66
|
-
transfer_accept._info.pop("links", None)
|
|
67
|
-
|
|
68
|
-
return zip(*sorted(transfer_accept._info.items()))
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
class CreateTransferRequest(command.ShowOne):
|
|
72
|
-
_description = _("Create volume transfer request.")
|
|
73
|
-
|
|
74
|
-
def get_parser(self, prog_name):
|
|
75
|
-
parser = super().get_parser(prog_name)
|
|
76
|
-
parser.add_argument(
|
|
77
|
-
'--name',
|
|
78
|
-
metavar="<name>",
|
|
79
|
-
help=_('New transfer request name (default to None)'),
|
|
80
|
-
)
|
|
81
|
-
parser.add_argument(
|
|
82
|
-
'volume',
|
|
83
|
-
metavar="<volume>",
|
|
84
|
-
help=_('Volume to transfer (name or ID)'),
|
|
85
|
-
)
|
|
86
|
-
return parser
|
|
87
|
-
|
|
88
|
-
def take_action(self, parsed_args):
|
|
89
|
-
volume_client = self.app.client_manager.volume
|
|
90
|
-
volume_id = utils.find_resource(
|
|
91
|
-
volume_client.volumes,
|
|
92
|
-
parsed_args.volume,
|
|
93
|
-
).id
|
|
94
|
-
volume_transfer_request = volume_client.transfers.create(
|
|
95
|
-
volume_id,
|
|
96
|
-
parsed_args.name,
|
|
97
|
-
)
|
|
98
|
-
volume_transfer_request._info.pop("links", None)
|
|
99
|
-
|
|
100
|
-
return zip(*sorted(volume_transfer_request._info.items()))
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
class DeleteTransferRequest(command.Command):
|
|
104
|
-
_description = _("Delete volume transfer request(s).")
|
|
105
|
-
|
|
106
|
-
def get_parser(self, prog_name):
|
|
107
|
-
parser = super().get_parser(prog_name)
|
|
108
|
-
parser.add_argument(
|
|
109
|
-
'transfer_request',
|
|
110
|
-
metavar="<transfer-request>",
|
|
111
|
-
nargs="+",
|
|
112
|
-
help=_('Volume transfer request(s) to delete (name or ID)'),
|
|
113
|
-
)
|
|
114
|
-
return parser
|
|
115
|
-
|
|
116
|
-
def take_action(self, parsed_args):
|
|
117
|
-
volume_client = self.app.client_manager.volume
|
|
118
|
-
result = 0
|
|
119
|
-
|
|
120
|
-
for t in parsed_args.transfer_request:
|
|
121
|
-
try:
|
|
122
|
-
transfer_request_id = utils.find_resource(
|
|
123
|
-
volume_client.transfers,
|
|
124
|
-
t,
|
|
125
|
-
).id
|
|
126
|
-
volume_client.transfers.delete(transfer_request_id)
|
|
127
|
-
except Exception as e:
|
|
128
|
-
result += 1
|
|
129
|
-
LOG.error(
|
|
130
|
-
_(
|
|
131
|
-
"Failed to delete volume transfer request "
|
|
132
|
-
"with name or ID '%(transfer)s': %(e)s"
|
|
133
|
-
)
|
|
134
|
-
% {'transfer': t, 'e': e}
|
|
135
|
-
)
|
|
136
|
-
|
|
137
|
-
if result > 0:
|
|
138
|
-
total = len(parsed_args.transfer_request)
|
|
139
|
-
msg = _(
|
|
140
|
-
"%(result)s of %(total)s volume transfer requests failed"
|
|
141
|
-
" to delete"
|
|
142
|
-
) % {'result': result, 'total': total}
|
|
143
|
-
raise exceptions.CommandError(msg)
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
class ListTransferRequest(command.Lister):
|
|
147
|
-
_description = _("Lists all volume transfer requests.")
|
|
148
|
-
|
|
149
|
-
def get_parser(self, prog_name):
|
|
150
|
-
parser = super().get_parser(prog_name)
|
|
151
|
-
parser.add_argument(
|
|
152
|
-
'--all-projects',
|
|
153
|
-
dest='all_projects',
|
|
154
|
-
action="store_true",
|
|
155
|
-
default=False,
|
|
156
|
-
help=_('Include all projects (admin only)'),
|
|
157
|
-
)
|
|
158
|
-
return parser
|
|
159
|
-
|
|
160
|
-
def take_action(self, parsed_args):
|
|
161
|
-
columns = ['ID', 'Name', 'Volume ID']
|
|
162
|
-
column_headers = ['ID', 'Name', 'Volume']
|
|
163
|
-
|
|
164
|
-
volume_client = self.app.client_manager.volume
|
|
165
|
-
|
|
166
|
-
volume_transfer_result = volume_client.transfers.list(
|
|
167
|
-
detailed=True,
|
|
168
|
-
search_opts={'all_tenants': parsed_args.all_projects},
|
|
169
|
-
)
|
|
170
|
-
|
|
171
|
-
return (
|
|
172
|
-
column_headers,
|
|
173
|
-
(
|
|
174
|
-
utils.get_item_properties(s, columns)
|
|
175
|
-
for s in volume_transfer_result
|
|
176
|
-
),
|
|
177
|
-
)
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
class ShowTransferRequest(command.ShowOne):
|
|
181
|
-
_description = _("Show volume transfer request details.")
|
|
182
|
-
|
|
183
|
-
def get_parser(self, prog_name):
|
|
184
|
-
parser = super().get_parser(prog_name)
|
|
185
|
-
parser.add_argument(
|
|
186
|
-
'transfer_request',
|
|
187
|
-
metavar="<transfer-request>",
|
|
188
|
-
help=_('Volume transfer request to display (name or ID)'),
|
|
189
|
-
)
|
|
190
|
-
return parser
|
|
191
|
-
|
|
192
|
-
def take_action(self, parsed_args):
|
|
193
|
-
volume_client = self.app.client_manager.volume
|
|
194
|
-
volume_transfer_request = utils.find_resource(
|
|
195
|
-
volume_client.transfers,
|
|
196
|
-
parsed_args.transfer_request,
|
|
197
|
-
)
|
|
198
|
-
volume_transfer_request._info.pop("links", None)
|
|
199
|
-
|
|
200
|
-
return zip(*sorted(volume_transfer_request._info.items()))
|