python-openstackclient 7.4.0__py3-none-any.whl → 8.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/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 +2 -5
- openstackclient/compute/v2/agent.py +5 -5
- openstackclient/compute/v2/aggregate.py +17 -15
- openstackclient/compute/v2/console.py +3 -4
- 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 +8 -10
- openstackclient/compute/v2/server.py +70 -112
- openstackclient/compute/v2/server_backup.py +1 -1
- openstackclient/compute/v2/server_event.py +7 -16
- 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 +16 -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/consumer.py +4 -3
- openstackclient/identity/v3/credential.py +6 -7
- openstackclient/identity/v3/domain.py +1 -1
- 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 +3 -4
- 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 +6 -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 +9 -6
- openstackclient/image/client.py +2 -5
- openstackclient/image/v1/image.py +11 -15
- openstackclient/image/v2/cache.py +2 -4
- openstackclient/image/v2/image.py +30 -37
- 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 -10
- 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 +14 -21
- 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 +4 -5
- 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 +52 -41
- openstackclient/network/v2/security_group.py +8 -15
- openstackclient/network/v2/security_group_rule.py +9 -10
- 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 +2 -2
- openstackclient/tests/functional/common/test_quota.py +3 -1
- openstackclient/tests/functional/compute/v2/common.py +12 -6
- 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 +4 -10
- 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 +16 -16
- openstackclient/tests/unit/compute/v2/test_flavor.py +71 -71
- 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 +24 -24
- openstackclient/tests/unit/compute/v2/test_server.py +524 -560
- openstackclient/tests/unit/compute/v2/test_server_backup.py +5 -7
- openstackclient/tests/unit/compute/v2/test_server_event.py +16 -18
- openstackclient/tests/unit/compute/v2/test_server_group.py +25 -31
- openstackclient/tests/unit/compute/v2/test_server_image.py +6 -8
- openstackclient/tests/unit/compute/v2/test_server_migration.py +37 -37
- 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 +1 -1
- openstackclient/tests/unit/identity/v3/test_endpoint.py +167 -172
- openstackclient/tests/unit/identity/v3/test_mappings.py +2 -2
- openstackclient/tests/unit/identity/v3/test_trust.py +5 -2
- openstackclient/tests/unit/identity/v3/test_user.py +16 -0
- openstackclient/tests/unit/image/v1/fakes.py +2 -2
- openstackclient/tests/unit/image/v2/test_image.py +39 -1
- openstackclient/tests/unit/integ/cli/test_shell.py +1 -2
- openstackclient/tests/unit/network/test_common.py +2 -2
- openstackclient/tests/unit/network/v2/test_floating_ip_compute.py +8 -14
- openstackclient/tests/unit/network/v2/test_floating_ip_network.py +49 -35
- openstackclient/tests/unit/network/v2/test_floating_ip_pool_compute.py +1 -1
- openstackclient/tests/unit/network/v2/test_network_compute.py +11 -11
- openstackclient/tests/unit/network/v2/test_network_trunk.py +2 -2
- openstackclient/tests/unit/network/v2/test_port.py +4 -5
- openstackclient/tests/unit/network/v2/test_router.py +63 -0
- openstackclient/tests/unit/network/v2/test_security_group_compute.py +11 -19
- openstackclient/tests/unit/network/v2/test_security_group_rule_compute.py +14 -14
- openstackclient/tests/unit/object/v1/test_object_all.py +4 -3
- openstackclient/tests/unit/test_shell.py +16 -13
- openstackclient/tests/unit/volume/v2/test_volume.py +1 -1
- 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_volume.py +1 -1
- openstackclient/tests/unit/volume/v3/test_volume_attachment.py +3 -3
- openstackclient/tests/unit/volume/v3/test_volume_snapshot.py +1 -2
- 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/volume.py +8 -16
- openstackclient/volume/v2/volume_backup.py +6 -7
- openstackclient/volume/v2/volume_snapshot.py +8 -9
- 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_manage.py +1 -3
- openstackclient/volume/v3/volume.py +18 -19
- openstackclient/volume/v3/volume_attachment.py +3 -2
- openstackclient/volume/v3/volume_backup.py +7 -8
- openstackclient/volume/v3/volume_group.py +2 -1
- openstackclient/volume/v3/volume_group_snapshot.py +2 -1
- openstackclient/volume/v3/volume_snapshot.py +4 -3
- openstackclient/volume/v3/volume_type.py +10 -21
- {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.0.0.dist-info}/AUTHORS +3 -0
- {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.0.0.dist-info}/METADATA +7 -13
- {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.0.0.dist-info}/RECORD +209 -232
- {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.0.0.dist-info}/WHEEL +1 -1
- {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.0.0.dist-info}/entry_points.txt +0 -41
- python_openstackclient-8.0.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/pbr.json +0 -1
- {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.0.0.dist-info}/LICENSE +0 -0
- {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.0.0.dist-info}/top_level.txt +0 -0
|
@@ -1,302 +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 Backup 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.command import command
|
|
24
|
-
from osc_lib import exceptions
|
|
25
|
-
from osc_lib import utils
|
|
26
|
-
|
|
27
|
-
from openstackclient.i18n import _
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
LOG = logging.getLogger(__name__)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
class VolumeIdColumn(cliff_columns.FormattableColumn):
|
|
34
|
-
"""Formattable column for volume ID column.
|
|
35
|
-
|
|
36
|
-
Unlike the parent FormattableColumn class, the initializer of the
|
|
37
|
-
class takes volume_cache as the second argument.
|
|
38
|
-
osc_lib.utils.get_item_properties instantiate cliff FormattableColumn
|
|
39
|
-
object with a single parameter "column value", so you need to pass
|
|
40
|
-
a partially initialized class like
|
|
41
|
-
``functools.partial(VolumeIdColumn, volume_cache)``.
|
|
42
|
-
"""
|
|
43
|
-
|
|
44
|
-
def __init__(self, value, volume_cache=None):
|
|
45
|
-
super().__init__(value)
|
|
46
|
-
self._volume_cache = volume_cache or {}
|
|
47
|
-
|
|
48
|
-
def human_readable(self):
|
|
49
|
-
"""Return a volume name if available
|
|
50
|
-
|
|
51
|
-
:rtype: either the volume ID or name
|
|
52
|
-
"""
|
|
53
|
-
volume_id = self._value
|
|
54
|
-
volume = volume_id
|
|
55
|
-
if volume_id in self._volume_cache.keys():
|
|
56
|
-
volume = self._volume_cache[volume_id].display_name
|
|
57
|
-
return volume
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
class CreateVolumeBackup(command.ShowOne):
|
|
61
|
-
_description = _("Create new volume backup")
|
|
62
|
-
|
|
63
|
-
def get_parser(self, prog_name):
|
|
64
|
-
parser = super().get_parser(prog_name)
|
|
65
|
-
parser.add_argument(
|
|
66
|
-
'volume',
|
|
67
|
-
metavar='<volume>',
|
|
68
|
-
help=_('Volume to backup (name or ID)'),
|
|
69
|
-
)
|
|
70
|
-
parser.add_argument(
|
|
71
|
-
'--container',
|
|
72
|
-
metavar='<container>',
|
|
73
|
-
required=False,
|
|
74
|
-
help=_('Optional backup container name'),
|
|
75
|
-
)
|
|
76
|
-
parser.add_argument(
|
|
77
|
-
'--name',
|
|
78
|
-
metavar='<name>',
|
|
79
|
-
help=_('Name of the backup'),
|
|
80
|
-
)
|
|
81
|
-
parser.add_argument(
|
|
82
|
-
'--description',
|
|
83
|
-
metavar='<description>',
|
|
84
|
-
help=_('Description of the backup'),
|
|
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, parsed_args.volume
|
|
92
|
-
).id
|
|
93
|
-
backup = volume_client.backups.create(
|
|
94
|
-
volume_id,
|
|
95
|
-
parsed_args.container,
|
|
96
|
-
parsed_args.name,
|
|
97
|
-
parsed_args.description,
|
|
98
|
-
)
|
|
99
|
-
|
|
100
|
-
backup._info.pop('links')
|
|
101
|
-
return zip(*sorted(backup._info.items()))
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
class DeleteVolumeBackup(command.Command):
|
|
105
|
-
_description = _("Delete volume backup(s)")
|
|
106
|
-
|
|
107
|
-
def get_parser(self, prog_name):
|
|
108
|
-
parser = super().get_parser(prog_name)
|
|
109
|
-
parser.add_argument(
|
|
110
|
-
'backups',
|
|
111
|
-
metavar='<backup>',
|
|
112
|
-
nargs="+",
|
|
113
|
-
help=_('Backup(s) to delete (name or ID)'),
|
|
114
|
-
)
|
|
115
|
-
return parser
|
|
116
|
-
|
|
117
|
-
def take_action(self, parsed_args):
|
|
118
|
-
volume_client = self.app.client_manager.volume
|
|
119
|
-
result = 0
|
|
120
|
-
|
|
121
|
-
for i in parsed_args.backups:
|
|
122
|
-
try:
|
|
123
|
-
backup_id = utils.find_resource(volume_client.backups, i).id
|
|
124
|
-
volume_client.backups.delete(backup_id)
|
|
125
|
-
except Exception as e:
|
|
126
|
-
result += 1
|
|
127
|
-
LOG.error(
|
|
128
|
-
_(
|
|
129
|
-
"Failed to delete backup with "
|
|
130
|
-
"name or ID '%(backup)s': %(e)s"
|
|
131
|
-
),
|
|
132
|
-
{'backup': i, 'e': e},
|
|
133
|
-
)
|
|
134
|
-
|
|
135
|
-
if result > 0:
|
|
136
|
-
total = len(parsed_args.backups)
|
|
137
|
-
msg = _("%(result)s of %(total)s backups failed " "to delete.") % {
|
|
138
|
-
'result': result,
|
|
139
|
-
'total': total,
|
|
140
|
-
}
|
|
141
|
-
raise exceptions.CommandError(msg)
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
class ListVolumeBackup(command.Lister):
|
|
145
|
-
_description = _("List volume backups")
|
|
146
|
-
|
|
147
|
-
def get_parser(self, prog_name):
|
|
148
|
-
parser = super().get_parser(prog_name)
|
|
149
|
-
parser.add_argument(
|
|
150
|
-
'--long',
|
|
151
|
-
action='store_true',
|
|
152
|
-
default=False,
|
|
153
|
-
help=_('List additional fields in output'),
|
|
154
|
-
)
|
|
155
|
-
parser.add_argument(
|
|
156
|
-
"--name",
|
|
157
|
-
metavar="<name>",
|
|
158
|
-
help=_("Filters results by the backup name"),
|
|
159
|
-
)
|
|
160
|
-
parser.add_argument(
|
|
161
|
-
"--status",
|
|
162
|
-
metavar="<status>",
|
|
163
|
-
choices=[
|
|
164
|
-
'creating',
|
|
165
|
-
'available',
|
|
166
|
-
'deleting',
|
|
167
|
-
'error',
|
|
168
|
-
'restoring',
|
|
169
|
-
'error_restoring',
|
|
170
|
-
],
|
|
171
|
-
help=_(
|
|
172
|
-
"Filters results by the backup status "
|
|
173
|
-
"('creating', 'available', 'deleting', "
|
|
174
|
-
"'error', 'restoring' or 'error_restoring')"
|
|
175
|
-
),
|
|
176
|
-
)
|
|
177
|
-
parser.add_argument(
|
|
178
|
-
"--volume",
|
|
179
|
-
metavar="<volume>",
|
|
180
|
-
help=_(
|
|
181
|
-
"Filters results by the volume which they "
|
|
182
|
-
"backup (name or ID)"
|
|
183
|
-
),
|
|
184
|
-
)
|
|
185
|
-
parser.add_argument(
|
|
186
|
-
'--all-projects',
|
|
187
|
-
action='store_true',
|
|
188
|
-
default=False,
|
|
189
|
-
help=_('Include all projects (admin only)'),
|
|
190
|
-
)
|
|
191
|
-
return parser
|
|
192
|
-
|
|
193
|
-
def take_action(self, parsed_args):
|
|
194
|
-
volume_client = self.app.client_manager.volume
|
|
195
|
-
|
|
196
|
-
if parsed_args.long:
|
|
197
|
-
columns = [
|
|
198
|
-
'ID',
|
|
199
|
-
'Name',
|
|
200
|
-
'Description',
|
|
201
|
-
'Status',
|
|
202
|
-
'Size',
|
|
203
|
-
'Availability Zone',
|
|
204
|
-
'Volume ID',
|
|
205
|
-
'Container',
|
|
206
|
-
]
|
|
207
|
-
column_headers = copy.deepcopy(columns)
|
|
208
|
-
column_headers[6] = 'Volume'
|
|
209
|
-
else:
|
|
210
|
-
columns = ['ID', 'Name', 'Description', 'Status', 'Size']
|
|
211
|
-
column_headers = columns
|
|
212
|
-
|
|
213
|
-
# Cache the volume list
|
|
214
|
-
volume_cache = {}
|
|
215
|
-
try:
|
|
216
|
-
for s in volume_client.volumes.list():
|
|
217
|
-
volume_cache[s.id] = s
|
|
218
|
-
except Exception: # noqa: S110
|
|
219
|
-
# Just forget it if there's any trouble
|
|
220
|
-
pass
|
|
221
|
-
VolumeIdColumnWithCache = functools.partial(
|
|
222
|
-
VolumeIdColumn, volume_cache=volume_cache
|
|
223
|
-
)
|
|
224
|
-
|
|
225
|
-
filter_volume_id = None
|
|
226
|
-
if parsed_args.volume:
|
|
227
|
-
filter_volume_id = utils.find_resource(
|
|
228
|
-
volume_client.volumes, parsed_args.volume
|
|
229
|
-
).id
|
|
230
|
-
search_opts = {
|
|
231
|
-
'name': parsed_args.name,
|
|
232
|
-
'status': parsed_args.status,
|
|
233
|
-
'volume_id': filter_volume_id,
|
|
234
|
-
'all_tenants': parsed_args.all_projects,
|
|
235
|
-
}
|
|
236
|
-
data = volume_client.backups.list(
|
|
237
|
-
search_opts=search_opts,
|
|
238
|
-
)
|
|
239
|
-
|
|
240
|
-
return (
|
|
241
|
-
column_headers,
|
|
242
|
-
(
|
|
243
|
-
utils.get_item_properties(
|
|
244
|
-
s,
|
|
245
|
-
columns,
|
|
246
|
-
formatters={'Volume ID': VolumeIdColumnWithCache},
|
|
247
|
-
)
|
|
248
|
-
for s in data
|
|
249
|
-
),
|
|
250
|
-
)
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
class RestoreVolumeBackup(command.Command):
|
|
254
|
-
_description = _("Restore volume backup")
|
|
255
|
-
|
|
256
|
-
def get_parser(self, prog_name):
|
|
257
|
-
parser = super().get_parser(prog_name)
|
|
258
|
-
parser.add_argument(
|
|
259
|
-
'backup',
|
|
260
|
-
metavar='<backup>',
|
|
261
|
-
help=_('Backup to restore (name or ID)'),
|
|
262
|
-
)
|
|
263
|
-
parser.add_argument(
|
|
264
|
-
'volume',
|
|
265
|
-
metavar='<volume>',
|
|
266
|
-
nargs='?',
|
|
267
|
-
help=_('Volume to restore to (name or ID) (default to None)'),
|
|
268
|
-
)
|
|
269
|
-
return parser
|
|
270
|
-
|
|
271
|
-
def take_action(self, parsed_args):
|
|
272
|
-
volume_client = self.app.client_manager.volume
|
|
273
|
-
backup = utils.find_resource(
|
|
274
|
-
volume_client.backups,
|
|
275
|
-
parsed_args.backup,
|
|
276
|
-
)
|
|
277
|
-
volume_id = None
|
|
278
|
-
if parsed_args.volume is not None:
|
|
279
|
-
volume_id = utils.find_resource(
|
|
280
|
-
volume_client.volumes,
|
|
281
|
-
parsed_args.volume,
|
|
282
|
-
).id
|
|
283
|
-
return volume_client.restores.restore(backup.id, volume_id)
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
class ShowVolumeBackup(command.ShowOne):
|
|
287
|
-
_description = _("Display volume backup details")
|
|
288
|
-
|
|
289
|
-
def get_parser(self, prog_name):
|
|
290
|
-
parser = super().get_parser(prog_name)
|
|
291
|
-
parser.add_argument(
|
|
292
|
-
'backup',
|
|
293
|
-
metavar='<backup>',
|
|
294
|
-
help=_('Backup to display (name or ID)'),
|
|
295
|
-
)
|
|
296
|
-
return parser
|
|
297
|
-
|
|
298
|
-
def take_action(self, parsed_args):
|
|
299
|
-
volume_client = self.app.client_manager.volume
|
|
300
|
-
backup = utils.find_resource(volume_client.backups, parsed_args.backup)
|
|
301
|
-
backup._info.pop('links')
|
|
302
|
-
return zip(*sorted(backup._info.items()))
|