python-openstackclient 7.3.1__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.
Files changed (235) hide show
  1. openstackclient/common/availability_zone.py +3 -6
  2. openstackclient/common/clientmanager.py +2 -1
  3. openstackclient/common/envvars.py +57 -0
  4. openstackclient/common/extension.py +3 -11
  5. openstackclient/common/limits.py +1 -1
  6. openstackclient/common/project_cleanup.py +3 -2
  7. openstackclient/common/quota.py +54 -28
  8. openstackclient/compute/client.py +2 -5
  9. openstackclient/compute/v2/agent.py +5 -5
  10. openstackclient/compute/v2/aggregate.py +17 -15
  11. openstackclient/compute/v2/console.py +3 -4
  12. openstackclient/compute/v2/flavor.py +14 -18
  13. openstackclient/compute/v2/host.py +3 -3
  14. openstackclient/compute/v2/hypervisor.py +10 -4
  15. openstackclient/compute/v2/hypervisor_stats.py +1 -1
  16. openstackclient/compute/v2/keypair.py +8 -10
  17. openstackclient/compute/v2/server.py +70 -112
  18. openstackclient/compute/v2/server_backup.py +1 -1
  19. openstackclient/compute/v2/server_event.py +7 -16
  20. openstackclient/compute/v2/server_group.py +6 -6
  21. openstackclient/compute/v2/server_image.py +1 -1
  22. openstackclient/compute/v2/server_migration.py +6 -6
  23. openstackclient/compute/v2/server_volume.py +4 -4
  24. openstackclient/compute/v2/service.py +9 -13
  25. openstackclient/compute/v2/usage.py +4 -6
  26. openstackclient/identity/client.py +2 -4
  27. openstackclient/identity/common.py +16 -17
  28. openstackclient/identity/v2_0/ec2creds.py +4 -3
  29. openstackclient/identity/v2_0/endpoint.py +12 -10
  30. openstackclient/identity/v2_0/project.py +6 -6
  31. openstackclient/identity/v2_0/role.py +1 -1
  32. openstackclient/identity/v2_0/service.py +7 -7
  33. openstackclient/identity/v2_0/user.py +6 -21
  34. openstackclient/identity/v3/access_rule.py +2 -5
  35. openstackclient/identity/v3/consumer.py +4 -3
  36. openstackclient/identity/v3/credential.py +8 -9
  37. openstackclient/identity/v3/domain.py +1 -1
  38. openstackclient/identity/v3/ec2creds.py +4 -3
  39. openstackclient/identity/v3/endpoint.py +104 -88
  40. openstackclient/identity/v3/endpoint_group.py +1 -1
  41. openstackclient/identity/v3/group.py +3 -4
  42. openstackclient/identity/v3/identity_provider.py +1 -2
  43. openstackclient/identity/v3/limit.py +4 -9
  44. openstackclient/identity/v3/mapping.py +4 -3
  45. openstackclient/identity/v3/policy.py +5 -8
  46. openstackclient/identity/v3/project.py +6 -6
  47. openstackclient/identity/v3/region.py +2 -5
  48. openstackclient/identity/v3/registered_limit.py +4 -8
  49. openstackclient/identity/v3/role.py +15 -16
  50. openstackclient/identity/v3/service.py +8 -8
  51. openstackclient/identity/v3/service_provider.py +3 -6
  52. openstackclient/identity/v3/tag.py +2 -2
  53. openstackclient/identity/v3/token.py +1 -2
  54. openstackclient/identity/v3/trust.py +74 -25
  55. openstackclient/identity/v3/user.py +9 -6
  56. openstackclient/image/client.py +2 -5
  57. openstackclient/image/v1/image.py +11 -15
  58. openstackclient/image/v2/cache.py +2 -4
  59. openstackclient/image/v2/image.py +30 -37
  60. openstackclient/image/v2/metadef_namespaces.py +4 -3
  61. openstackclient/image/v2/metadef_resource_type_association.py +1 -2
  62. openstackclient/image/v2/metadef_resource_types.py +1 -2
  63. openstackclient/locale/tr_TR/LC_MESSAGES/openstackclient.po +9 -1370
  64. openstackclient/network/client.py +4 -10
  65. openstackclient/network/common.py +16 -12
  66. openstackclient/network/utils.py +3 -3
  67. openstackclient/network/v2/address_group.py +5 -9
  68. openstackclient/network/v2/address_scope.py +2 -3
  69. openstackclient/network/v2/default_security_group_rule.py +1 -2
  70. openstackclient/network/v2/floating_ip.py +14 -21
  71. openstackclient/network/v2/floating_ip_port_forwarding.py +7 -7
  72. openstackclient/network/v2/ip_availability.py +1 -2
  73. openstackclient/network/v2/l3_conntrack_helper.py +8 -12
  74. openstackclient/network/v2/local_ip.py +24 -26
  75. openstackclient/network/v2/local_ip_association.py +4 -5
  76. openstackclient/network/v2/ndp_proxy.py +9 -10
  77. openstackclient/network/v2/network.py +12 -16
  78. openstackclient/network/v2/network_agent.py +29 -37
  79. openstackclient/network/v2/network_auto_allocated_topology.py +4 -5
  80. openstackclient/network/v2/network_flavor.py +1 -1
  81. openstackclient/network/v2/network_flavor_profile.py +5 -5
  82. openstackclient/network/v2/network_meter.py +3 -3
  83. openstackclient/network/v2/network_meter_rule.py +5 -8
  84. openstackclient/network/v2/network_qos_policy.py +4 -4
  85. openstackclient/network/v2/network_qos_rule.py +4 -5
  86. openstackclient/network/v2/network_rbac.py +4 -4
  87. openstackclient/network/v2/network_segment.py +6 -7
  88. openstackclient/network/v2/network_segment_range.py +16 -20
  89. openstackclient/network/v2/network_trunk.py +24 -16
  90. openstackclient/network/v2/port.py +42 -31
  91. openstackclient/network/v2/router.py +55 -41
  92. openstackclient/network/v2/security_group.py +8 -15
  93. openstackclient/network/v2/security_group_rule.py +9 -10
  94. openstackclient/network/v2/subnet.py +31 -30
  95. openstackclient/network/v2/subnet_pool.py +4 -4
  96. openstackclient/object/client.py +2 -3
  97. openstackclient/object/v1/container.py +2 -3
  98. openstackclient/object/v1/object.py +2 -9
  99. openstackclient/shell.py +22 -5
  100. openstackclient/tests/functional/base.py +2 -2
  101. openstackclient/tests/functional/common/test_quota.py +3 -1
  102. openstackclient/tests/functional/compute/v2/common.py +12 -6
  103. openstackclient/tests/functional/compute/v2/test_server.py +2 -3
  104. openstackclient/tests/functional/compute/v2/test_server_event.py +1 -1
  105. openstackclient/tests/functional/identity/v2/test_user.py +1 -1
  106. openstackclient/tests/functional/identity/v3/common.py +3 -8
  107. openstackclient/tests/functional/identity/v3/test_application_credential.py +10 -10
  108. openstackclient/tests/functional/identity/v3/test_endpoint.py +3 -3
  109. openstackclient/tests/functional/identity/v3/test_group.py +3 -3
  110. openstackclient/tests/functional/identity/v3/test_idp.py +3 -7
  111. openstackclient/tests/functional/identity/v3/test_limit.py +4 -4
  112. openstackclient/tests/functional/identity/v3/test_project.py +5 -14
  113. openstackclient/tests/functional/identity/v3/test_region.py +1 -3
  114. openstackclient/tests/functional/identity/v3/test_registered_limit.py +3 -3
  115. openstackclient/tests/functional/identity/v3/test_role.py +1 -1
  116. openstackclient/tests/functional/identity/v3/test_role_assignment.py +13 -31
  117. openstackclient/tests/functional/identity/v3/test_service_provider.py +3 -7
  118. openstackclient/tests/functional/identity/v3/test_user.py +8 -8
  119. openstackclient/tests/functional/network/v2/common.py +7 -3
  120. openstackclient/tests/functional/network/v2/test_address_group.py +4 -0
  121. openstackclient/tests/functional/network/v2/test_l3_conntrack_helper.py +15 -11
  122. openstackclient/tests/functional/network/v2/test_local_ip.py +4 -0
  123. openstackclient/tests/functional/network/v2/test_network_meter_rule.py +2 -2
  124. openstackclient/tests/functional/network/v2/test_network_ndp_proxy.py +2 -3
  125. openstackclient/tests/functional/network/v2/test_network_rbac.py +2 -2
  126. openstackclient/tests/functional/network/v2/test_network_trunk.py +1 -1
  127. openstackclient/tests/functional/network/v2/test_port.py +17 -7
  128. openstackclient/tests/functional/network/v2/test_router.py +42 -0
  129. openstackclient/tests/functional/network/v2/test_subnet_pool.py +4 -0
  130. openstackclient/tests/unit/api/test_compute_v2.py +67 -87
  131. openstackclient/tests/unit/common/test_availability_zone.py +6 -14
  132. openstackclient/tests/unit/common/test_command.py +1 -1
  133. openstackclient/tests/unit/common/test_extension.py +5 -7
  134. openstackclient/tests/unit/common/test_limits.py +1 -1
  135. openstackclient/tests/unit/common/test_project_cleanup.py +5 -6
  136. openstackclient/tests/unit/common/test_quota.py +51 -28
  137. openstackclient/tests/unit/compute/v2/fakes.py +4 -10
  138. openstackclient/tests/unit/compute/v2/test_agent.py +16 -16
  139. openstackclient/tests/unit/compute/v2/test_aggregate.py +56 -60
  140. openstackclient/tests/unit/compute/v2/test_console.py +16 -16
  141. openstackclient/tests/unit/compute/v2/test_flavor.py +71 -71
  142. openstackclient/tests/unit/compute/v2/test_host.py +8 -8
  143. openstackclient/tests/unit/compute/v2/test_hypervisor.py +22 -30
  144. openstackclient/tests/unit/compute/v2/test_hypervisor_stats.py +2 -2
  145. openstackclient/tests/unit/compute/v2/test_keypair.py +24 -24
  146. openstackclient/tests/unit/compute/v2/test_server.py +524 -560
  147. openstackclient/tests/unit/compute/v2/test_server_backup.py +5 -7
  148. openstackclient/tests/unit/compute/v2/test_server_event.py +16 -18
  149. openstackclient/tests/unit/compute/v2/test_server_group.py +25 -31
  150. openstackclient/tests/unit/compute/v2/test_server_image.py +6 -8
  151. openstackclient/tests/unit/compute/v2/test_server_migration.py +37 -37
  152. openstackclient/tests/unit/compute/v2/test_server_volume.py +12 -12
  153. openstackclient/tests/unit/compute/v2/test_service.py +39 -45
  154. openstackclient/tests/unit/compute/v2/test_usage.py +5 -5
  155. openstackclient/tests/unit/identity/v2_0/fakes.py +1 -1
  156. openstackclient/tests/unit/identity/v3/test_access_rule.py +1 -3
  157. openstackclient/tests/unit/identity/v3/test_application_credential.py +1 -1
  158. openstackclient/tests/unit/identity/v3/test_credential.py +4 -4
  159. openstackclient/tests/unit/identity/v3/test_endpoint.py +167 -172
  160. openstackclient/tests/unit/identity/v3/test_mappings.py +2 -2
  161. openstackclient/tests/unit/identity/v3/test_trust.py +5 -2
  162. openstackclient/tests/unit/identity/v3/test_user.py +16 -0
  163. openstackclient/tests/unit/image/v1/fakes.py +2 -2
  164. openstackclient/tests/unit/image/v2/test_image.py +39 -1
  165. openstackclient/tests/unit/integ/cli/test_shell.py +1 -2
  166. openstackclient/tests/unit/network/test_common.py +2 -2
  167. openstackclient/tests/unit/network/v2/test_floating_ip_compute.py +8 -14
  168. openstackclient/tests/unit/network/v2/test_floating_ip_network.py +49 -35
  169. openstackclient/tests/unit/network/v2/test_floating_ip_pool_compute.py +1 -1
  170. openstackclient/tests/unit/network/v2/test_network_compute.py +11 -11
  171. openstackclient/tests/unit/network/v2/test_network_trunk.py +2 -2
  172. openstackclient/tests/unit/network/v2/test_port.py +33 -5
  173. openstackclient/tests/unit/network/v2/test_router.py +120 -7
  174. openstackclient/tests/unit/network/v2/test_security_group_compute.py +11 -19
  175. openstackclient/tests/unit/network/v2/test_security_group_rule_compute.py +14 -14
  176. openstackclient/tests/unit/object/v1/test_object_all.py +4 -3
  177. openstackclient/tests/unit/test_shell.py +16 -13
  178. openstackclient/tests/unit/volume/v2/test_volume.py +1 -1
  179. openstackclient/tests/unit/volume/v2/test_volume_transfer_request.py +1 -1
  180. openstackclient/tests/unit/volume/v3/fakes.py +2 -8
  181. openstackclient/tests/unit/volume/v3/test_volume.py +1 -1
  182. openstackclient/tests/unit/volume/v3/test_volume_attachment.py +3 -3
  183. openstackclient/tests/unit/volume/v3/test_volume_snapshot.py +1 -2
  184. openstackclient/tests/unit/volume/v3/test_volume_transfer_request.py +1 -1
  185. openstackclient/volume/client.py +1 -3
  186. openstackclient/volume/v2/consistency_group.py +4 -8
  187. openstackclient/volume/v2/consistency_group_snapshot.py +1 -2
  188. openstackclient/volume/v2/qos_specs.py +1 -2
  189. openstackclient/volume/v2/volume.py +8 -16
  190. openstackclient/volume/v2/volume_backup.py +6 -7
  191. openstackclient/volume/v2/volume_snapshot.py +8 -9
  192. openstackclient/volume/v2/volume_transfer_request.py +0 -3
  193. openstackclient/volume/v2/volume_type.py +10 -21
  194. openstackclient/volume/v3/block_storage_cluster.py +3 -3
  195. openstackclient/volume/v3/block_storage_manage.py +1 -3
  196. openstackclient/volume/v3/volume.py +18 -19
  197. openstackclient/volume/v3/volume_attachment.py +3 -2
  198. openstackclient/volume/v3/volume_backup.py +7 -8
  199. openstackclient/volume/v3/volume_group.py +2 -1
  200. openstackclient/volume/v3/volume_group_snapshot.py +2 -1
  201. openstackclient/volume/v3/volume_snapshot.py +4 -3
  202. openstackclient/volume/v3/volume_type.py +10 -21
  203. {python_openstackclient-7.3.1.dist-info → python_openstackclient-8.0.0.dist-info}/AUTHORS +4 -0
  204. {python_openstackclient-7.3.1.dist-info → python_openstackclient-8.0.0.dist-info}/METADATA +7 -13
  205. {python_openstackclient-7.3.1.dist-info → python_openstackclient-8.0.0.dist-info}/RECORD +210 -233
  206. {python_openstackclient-7.3.1.dist-info → python_openstackclient-8.0.0.dist-info}/WHEEL +1 -1
  207. {python_openstackclient-7.3.1.dist-info → python_openstackclient-8.0.0.dist-info}/entry_points.txt +0 -41
  208. python_openstackclient-8.0.0.dist-info/pbr.json +1 -0
  209. openstackclient/tests/functional/volume/v1/__init__.py +0 -0
  210. openstackclient/tests/functional/volume/v1/common.py +0 -35
  211. openstackclient/tests/functional/volume/v1/test_qos.py +0 -100
  212. openstackclient/tests/functional/volume/v1/test_service.py +0 -76
  213. openstackclient/tests/functional/volume/v1/test_snapshot.py +0 -232
  214. openstackclient/tests/functional/volume/v1/test_transfer_request.py +0 -111
  215. openstackclient/tests/functional/volume/v1/test_volume.py +0 -228
  216. openstackclient/tests/functional/volume/v1/test_volume_type.py +0 -213
  217. openstackclient/tests/unit/volume/v1/__init__.py +0 -0
  218. openstackclient/tests/unit/volume/v1/fakes.py +0 -615
  219. openstackclient/tests/unit/volume/v1/test_qos_specs.py +0 -471
  220. openstackclient/tests/unit/volume/v1/test_service.py +0 -295
  221. openstackclient/tests/unit/volume/v1/test_transfer_request.py +0 -380
  222. openstackclient/tests/unit/volume/v1/test_type.py +0 -633
  223. openstackclient/tests/unit/volume/v1/test_volume.py +0 -1447
  224. openstackclient/tests/unit/volume/v1/test_volume_backup.py +0 -435
  225. openstackclient/volume/v1/__init__.py +0 -0
  226. openstackclient/volume/v1/qos_specs.py +0 -377
  227. openstackclient/volume/v1/service.py +0 -136
  228. openstackclient/volume/v1/volume.py +0 -734
  229. openstackclient/volume/v1/volume_backup.py +0 -302
  230. openstackclient/volume/v1/volume_snapshot.py +0 -433
  231. openstackclient/volume/v1/volume_transfer_request.py +0 -200
  232. openstackclient/volume/v1/volume_type.py +0 -520
  233. python_openstackclient-7.3.1.dist-info/pbr.json +0 -1
  234. {python_openstackclient-7.3.1.dist-info → python_openstackclient-8.0.0.dist-info}/LICENSE +0 -0
  235. {python_openstackclient-7.3.1.dist-info → python_openstackclient-8.0.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()))