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.
Files changed (234) 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 +6 -7
  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 +28 -29
  91. openstackclient/network/v2/router.py +52 -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_endpoint.py +167 -172
  159. openstackclient/tests/unit/identity/v3/test_mappings.py +2 -2
  160. openstackclient/tests/unit/identity/v3/test_trust.py +5 -2
  161. openstackclient/tests/unit/identity/v3/test_user.py +16 -0
  162. openstackclient/tests/unit/image/v1/fakes.py +2 -2
  163. openstackclient/tests/unit/image/v2/test_image.py +39 -1
  164. openstackclient/tests/unit/integ/cli/test_shell.py +1 -2
  165. openstackclient/tests/unit/network/test_common.py +2 -2
  166. openstackclient/tests/unit/network/v2/test_floating_ip_compute.py +8 -14
  167. openstackclient/tests/unit/network/v2/test_floating_ip_network.py +49 -35
  168. openstackclient/tests/unit/network/v2/test_floating_ip_pool_compute.py +1 -1
  169. openstackclient/tests/unit/network/v2/test_network_compute.py +11 -11
  170. openstackclient/tests/unit/network/v2/test_network_trunk.py +2 -2
  171. openstackclient/tests/unit/network/v2/test_port.py +4 -5
  172. openstackclient/tests/unit/network/v2/test_router.py +63 -0
  173. openstackclient/tests/unit/network/v2/test_security_group_compute.py +11 -19
  174. openstackclient/tests/unit/network/v2/test_security_group_rule_compute.py +14 -14
  175. openstackclient/tests/unit/object/v1/test_object_all.py +4 -3
  176. openstackclient/tests/unit/test_shell.py +16 -13
  177. openstackclient/tests/unit/volume/v2/test_volume.py +1 -1
  178. openstackclient/tests/unit/volume/v2/test_volume_transfer_request.py +1 -1
  179. openstackclient/tests/unit/volume/v3/fakes.py +2 -8
  180. openstackclient/tests/unit/volume/v3/test_volume.py +1 -1
  181. openstackclient/tests/unit/volume/v3/test_volume_attachment.py +3 -3
  182. openstackclient/tests/unit/volume/v3/test_volume_snapshot.py +1 -2
  183. openstackclient/tests/unit/volume/v3/test_volume_transfer_request.py +1 -1
  184. openstackclient/volume/client.py +1 -3
  185. openstackclient/volume/v2/consistency_group.py +4 -8
  186. openstackclient/volume/v2/consistency_group_snapshot.py +1 -2
  187. openstackclient/volume/v2/qos_specs.py +1 -2
  188. openstackclient/volume/v2/volume.py +8 -16
  189. openstackclient/volume/v2/volume_backup.py +6 -7
  190. openstackclient/volume/v2/volume_snapshot.py +8 -9
  191. openstackclient/volume/v2/volume_transfer_request.py +0 -3
  192. openstackclient/volume/v2/volume_type.py +10 -21
  193. openstackclient/volume/v3/block_storage_cluster.py +3 -3
  194. openstackclient/volume/v3/block_storage_manage.py +1 -3
  195. openstackclient/volume/v3/volume.py +18 -19
  196. openstackclient/volume/v3/volume_attachment.py +3 -2
  197. openstackclient/volume/v3/volume_backup.py +7 -8
  198. openstackclient/volume/v3/volume_group.py +2 -1
  199. openstackclient/volume/v3/volume_group_snapshot.py +2 -1
  200. openstackclient/volume/v3/volume_snapshot.py +4 -3
  201. openstackclient/volume/v3/volume_type.py +10 -21
  202. {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.0.0.dist-info}/AUTHORS +3 -0
  203. {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.0.0.dist-info}/METADATA +7 -13
  204. {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.0.0.dist-info}/RECORD +209 -232
  205. {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.0.0.dist-info}/WHEEL +1 -1
  206. {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.0.0.dist-info}/entry_points.txt +0 -41
  207. python_openstackclient-8.0.0.dist-info/pbr.json +1 -0
  208. openstackclient/tests/functional/volume/v1/__init__.py +0 -0
  209. openstackclient/tests/functional/volume/v1/common.py +0 -35
  210. openstackclient/tests/functional/volume/v1/test_qos.py +0 -100
  211. openstackclient/tests/functional/volume/v1/test_service.py +0 -76
  212. openstackclient/tests/functional/volume/v1/test_snapshot.py +0 -232
  213. openstackclient/tests/functional/volume/v1/test_transfer_request.py +0 -111
  214. openstackclient/tests/functional/volume/v1/test_volume.py +0 -228
  215. openstackclient/tests/functional/volume/v1/test_volume_type.py +0 -213
  216. openstackclient/tests/unit/volume/v1/__init__.py +0 -0
  217. openstackclient/tests/unit/volume/v1/fakes.py +0 -615
  218. openstackclient/tests/unit/volume/v1/test_qos_specs.py +0 -471
  219. openstackclient/tests/unit/volume/v1/test_service.py +0 -295
  220. openstackclient/tests/unit/volume/v1/test_transfer_request.py +0 -380
  221. openstackclient/tests/unit/volume/v1/test_type.py +0 -633
  222. openstackclient/tests/unit/volume/v1/test_volume.py +0 -1447
  223. openstackclient/tests/unit/volume/v1/test_volume_backup.py +0 -435
  224. openstackclient/volume/v1/__init__.py +0 -0
  225. openstackclient/volume/v1/qos_specs.py +0 -377
  226. openstackclient/volume/v1/service.py +0 -136
  227. openstackclient/volume/v1/volume.py +0 -734
  228. openstackclient/volume/v1/volume_backup.py +0 -302
  229. openstackclient/volume/v1/volume_snapshot.py +0 -433
  230. openstackclient/volume/v1/volume_transfer_request.py +0 -200
  231. openstackclient/volume/v1/volume_type.py +0 -520
  232. python_openstackclient-7.4.0.dist-info/pbr.json +0 -1
  233. {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.0.0.dist-info}/LICENSE +0 -0
  234. {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.0.0.dist-info}/top_level.txt +0 -0
@@ -1,520 +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 Type action implementations"""
17
-
18
- import functools
19
- import logging
20
-
21
- from cliff import columns as cliff_columns
22
- from osc_lib.cli import format_columns
23
- from osc_lib.cli import parseractions
24
- from osc_lib.command import command
25
- from osc_lib import exceptions
26
- from osc_lib import utils
27
-
28
- from openstackclient.i18n import _
29
-
30
-
31
- LOG = logging.getLogger(__name__)
32
-
33
-
34
- class EncryptionInfoColumn(cliff_columns.FormattableColumn):
35
- """Formattable column for encryption info column.
36
-
37
- Unlike the parent FormattableColumn class, the initializer of the
38
- class takes encryption_data as the second argument.
39
- osc_lib.utils.get_item_properties instantiate cliff FormattableColumn
40
- object with a single parameter "column value", so you need to pass
41
- a partially initialized class like
42
- ``functools.partial(EncryptionInfoColumn encryption_data)``.
43
- """
44
-
45
- def __init__(self, value, encryption_data=None):
46
- super().__init__(value)
47
- self._encryption_data = encryption_data or {}
48
-
49
- def _get_encryption_info(self):
50
- type_id = self._value
51
- return self._encryption_data.get(type_id)
52
-
53
- def human_readable(self):
54
- encryption_info = self._get_encryption_info()
55
- if encryption_info:
56
- return utils.format_dict(encryption_info)
57
- else:
58
- return '-'
59
-
60
- def machine_readable(self):
61
- return self._get_encryption_info()
62
-
63
-
64
- def _create_encryption_type(volume_client, volume_type, parsed_args):
65
- if not parsed_args.encryption_provider:
66
- msg = _(
67
- "'--encryption-provider' should be specified while "
68
- "creating a new encryption type"
69
- )
70
- raise exceptions.CommandError(msg)
71
- # set the default of control location while creating
72
- control_location = 'front-end'
73
- if parsed_args.encryption_control_location:
74
- control_location = parsed_args.encryption_control_location
75
- body = {
76
- 'provider': parsed_args.encryption_provider,
77
- 'cipher': parsed_args.encryption_cipher,
78
- 'key_size': parsed_args.encryption_key_size,
79
- 'control_location': control_location,
80
- }
81
- encryption = volume_client.volume_encryption_types.create(
82
- volume_type, body
83
- )
84
- return encryption
85
-
86
-
87
- class CreateVolumeType(command.ShowOne):
88
- _description = _("Create new volume type")
89
-
90
- def get_parser(self, prog_name):
91
- parser = super().get_parser(prog_name)
92
- parser.add_argument(
93
- 'name',
94
- metavar='<name>',
95
- help=_('Volume type name'),
96
- )
97
- parser.add_argument(
98
- '--property',
99
- metavar='<key=value>',
100
- action=parseractions.KeyValueAction,
101
- help=_(
102
- 'Set a property on this volume type '
103
- '(repeat option to set multiple properties)'
104
- ),
105
- )
106
- # TODO(Huanxuan Ao): Add choices for each "--encryption-*" option.
107
- parser.add_argument(
108
- '--encryption-provider',
109
- metavar='<provider>',
110
- help=_(
111
- 'Set the encryption provider format for '
112
- 'this volume type (e.g "luks" or "plain") (admin only) '
113
- '(This option is required when setting encryption type '
114
- 'of a volume. Consider using other encryption options '
115
- 'such as: "--encryption-cipher", "--encryption-key-size" '
116
- 'and "--encryption-control-location")'
117
- ),
118
- )
119
- parser.add_argument(
120
- '--encryption-cipher',
121
- metavar='<cipher>',
122
- help=_(
123
- 'Set the encryption algorithm or mode for this '
124
- 'volume type (e.g "aes-xts-plain64") (admin only)'
125
- ),
126
- )
127
- parser.add_argument(
128
- '--encryption-key-size',
129
- metavar='<key-size>',
130
- type=int,
131
- help=_(
132
- 'Set the size of the encryption key of this '
133
- 'volume type (e.g "128" or "256") (admin only)'
134
- ),
135
- )
136
- parser.add_argument(
137
- '--encryption-control-location',
138
- metavar='<control-location>',
139
- choices=['front-end', 'back-end'],
140
- help=_(
141
- 'Set the notional service where the encryption is '
142
- 'performed ("front-end" or "back-end") (admin only) '
143
- '(The default value for this option is "front-end" '
144
- 'when setting encryption type of a volume. Consider '
145
- 'using other encryption options such as: '
146
- '"--encryption-cipher", "--encryption-key-size" and '
147
- '"--encryption-provider")'
148
- ),
149
- )
150
- return parser
151
-
152
- def take_action(self, parsed_args):
153
- volume_client = self.app.client_manager.volume
154
- volume_type = volume_client.volume_types.create(parsed_args.name)
155
- volume_type._info.pop('extra_specs')
156
- if parsed_args.property:
157
- result = volume_type.set_keys(parsed_args.property)
158
- volume_type._info.update(
159
- {'properties': format_columns.DictColumn(result)}
160
- )
161
- if (
162
- parsed_args.encryption_provider
163
- or parsed_args.encryption_cipher
164
- or parsed_args.encryption_key_size
165
- or parsed_args.encryption_control_location
166
- ):
167
- try:
168
- # create new encryption
169
- encryption = _create_encryption_type(
170
- volume_client, volume_type, parsed_args
171
- )
172
- except Exception as e:
173
- LOG.error(
174
- _(
175
- "Failed to set encryption information for this "
176
- "volume type: %s"
177
- ),
178
- e,
179
- )
180
- # add encryption info in result
181
- encryption._info.pop("volume_type_id", None)
182
- volume_type._info.update(
183
- {'encryption': format_columns.DictColumn(encryption._info)}
184
- )
185
- volume_type._info.pop("os-volume-type-access:is_public", None)
186
-
187
- return zip(*sorted(volume_type._info.items()))
188
-
189
-
190
- class DeleteVolumeType(command.Command):
191
- _description = _("Delete volume type(s)")
192
-
193
- def get_parser(self, prog_name):
194
- parser = super().get_parser(prog_name)
195
- parser.add_argument(
196
- 'volume_types',
197
- metavar='<volume-type>',
198
- nargs='+',
199
- help=_('Volume type(s) to delete (name or ID)'),
200
- )
201
- return parser
202
-
203
- def take_action(self, parsed_args):
204
- volume_client = self.app.client_manager.volume
205
- result = 0
206
-
207
- for volume_type in parsed_args.volume_types:
208
- try:
209
- vol_type = utils.find_resource(
210
- volume_client.volume_types, volume_type
211
- )
212
-
213
- volume_client.volume_types.delete(vol_type)
214
- except Exception as e:
215
- result += 1
216
- LOG.error(
217
- _(
218
- "Failed to delete volume type with "
219
- "name or ID '%(volume_type)s': %(e)s"
220
- )
221
- % {'volume_type': volume_type, 'e': e}
222
- )
223
-
224
- if result > 0:
225
- total = len(parsed_args.volume_types)
226
- msg = _(
227
- "%(result)s of %(total)s volume types failed " "to delete."
228
- ) % {'result': result, 'total': total}
229
- raise exceptions.CommandError(msg)
230
-
231
-
232
- class ListVolumeType(command.Lister):
233
- _description = _("List volume types")
234
-
235
- def get_parser(self, prog_name):
236
- parser = super().get_parser(prog_name)
237
- parser.add_argument(
238
- '--long',
239
- action='store_true',
240
- default=False,
241
- help=_('List additional fields in output'),
242
- )
243
- parser.add_argument(
244
- "--encryption-type",
245
- action="store_true",
246
- help=_(
247
- "Display encryption information for each volume type "
248
- "(admin only)"
249
- ),
250
- )
251
- return parser
252
-
253
- def take_action(self, parsed_args):
254
- volume_client = self.app.client_manager.volume
255
- if parsed_args.long:
256
- columns = ['ID', 'Name', 'Is Public', 'Extra Specs']
257
- column_headers = ['ID', 'Name', 'Is Public', 'Properties']
258
- else:
259
- columns = ['ID', 'Name', 'Is Public']
260
- column_headers = ['ID', 'Name', 'Is Public']
261
- data = volume_client.volume_types.list()
262
-
263
- formatters = {'Extra Specs': format_columns.DictColumn}
264
-
265
- if parsed_args.encryption_type:
266
- encryption = {}
267
- for d in volume_client.volume_encryption_types.list():
268
- volume_type_id = d._info['volume_type_id']
269
- # remove some redundant information
270
- del_key = [
271
- 'deleted',
272
- 'created_at',
273
- 'updated_at',
274
- 'deleted_at',
275
- 'volume_type_id',
276
- ]
277
- for key in del_key:
278
- d._info.pop(key, None)
279
- # save the encryption information with their volume type ID
280
- encryption[volume_type_id] = d._info
281
- # We need to get volume type ID, then show encryption
282
- # information according to the ID, so use "id" to keep
283
- # difference to the real "ID" column.
284
- columns += ['id']
285
- column_headers += ['Encryption']
286
-
287
- _EncryptionInfoColumn = functools.partial(
288
- EncryptionInfoColumn, encryption_data=encryption
289
- )
290
- formatters['id'] = _EncryptionInfoColumn
291
-
292
- return (
293
- column_headers,
294
- (
295
- utils.get_item_properties(
296
- s,
297
- columns,
298
- formatters=formatters,
299
- )
300
- for s in data
301
- ),
302
- )
303
-
304
-
305
- class SetVolumeType(command.Command):
306
- _description = _("Set volume type properties")
307
-
308
- def get_parser(self, prog_name):
309
- parser = super().get_parser(prog_name)
310
- parser.add_argument(
311
- 'volume_type',
312
- metavar='<volume-type>',
313
- help=_('Volume type to modify (name or ID)'),
314
- )
315
- parser.add_argument(
316
- '--property',
317
- metavar='<key=value>',
318
- action=parseractions.KeyValueAction,
319
- help=_(
320
- 'Set a property on this volume type '
321
- '(repeat option to set multiple properties)'
322
- ),
323
- )
324
- # TODO(Huanxuan Ao): Add choices for each "--encryption-*" option.
325
- parser.add_argument(
326
- '--encryption-provider',
327
- metavar='<provider>',
328
- help=_(
329
- 'Set the encryption provider format for '
330
- 'this volume type (e.g "luks" or "plain") (admin only) '
331
- '(This option is required when setting encryption type '
332
- 'of a volume. Consider using other encryption options '
333
- 'such as: "--encryption-cipher", "--encryption-key-size" '
334
- 'and "--encryption-control-location")'
335
- ),
336
- )
337
- parser.add_argument(
338
- '--encryption-cipher',
339
- metavar='<cipher>',
340
- help=_(
341
- 'Set the encryption algorithm or mode for this '
342
- 'volume type (e.g "aes-xts-plain64") (admin only)'
343
- ),
344
- )
345
- parser.add_argument(
346
- '--encryption-key-size',
347
- metavar='<key-size>',
348
- type=int,
349
- help=_(
350
- 'Set the size of the encryption key of this '
351
- 'volume type (e.g "128" or "256") (admin only)'
352
- ),
353
- )
354
- parser.add_argument(
355
- '--encryption-control-location',
356
- metavar='<control-location>',
357
- choices=['front-end', 'back-end'],
358
- help=_(
359
- 'Set the notional service where the encryption is '
360
- 'performed ("front-end" or "back-end") (admin only) '
361
- '(The default value for this option is "front-end" '
362
- 'when setting encryption type of a volume. Consider '
363
- 'using other encryption options such as: '
364
- '"--encryption-cipher", "--encryption-key-size" and '
365
- '"--encryption-provider")'
366
- ),
367
- )
368
- return parser
369
-
370
- def take_action(self, parsed_args):
371
- volume_client = self.app.client_manager.volume
372
- volume_type = utils.find_resource(
373
- volume_client.volume_types, parsed_args.volume_type
374
- )
375
-
376
- result = 0
377
- if parsed_args.property:
378
- try:
379
- volume_type.set_keys(parsed_args.property)
380
- except Exception as e:
381
- LOG.error(_("Failed to set volume type property: %s"), e)
382
- result += 1
383
-
384
- if (
385
- parsed_args.encryption_provider
386
- or parsed_args.encryption_cipher
387
- or parsed_args.encryption_key_size
388
- or parsed_args.encryption_control_location
389
- ):
390
- try:
391
- _create_encryption_type(
392
- volume_client, volume_type, parsed_args
393
- )
394
- except Exception as e:
395
- LOG.error(
396
- _(
397
- "Failed to set encryption information for this "
398
- "volume type: %s"
399
- ),
400
- e,
401
- )
402
- result += 1
403
-
404
- if result > 0:
405
- raise exceptions.CommandError(
406
- _("Command Failed: One or more of" " the operations failed")
407
- )
408
-
409
-
410
- class ShowVolumeType(command.ShowOne):
411
- _description = _("Display volume type details")
412
-
413
- def get_parser(self, prog_name):
414
- parser = super().get_parser(prog_name)
415
- parser.add_argument(
416
- "volume_type",
417
- metavar="<volume-type>",
418
- help=_("Volume type to display (name or ID)"),
419
- )
420
- parser.add_argument(
421
- "--encryption-type",
422
- action="store_true",
423
- help=_(
424
- "Display encryption information of this volume type "
425
- "(admin only)"
426
- ),
427
- )
428
- return parser
429
-
430
- def take_action(self, parsed_args):
431
- volume_client = self.app.client_manager.volume
432
- volume_type = utils.find_resource(
433
- volume_client.volume_types, parsed_args.volume_type
434
- )
435
- properties = format_columns.DictColumn(
436
- volume_type._info.pop('extra_specs')
437
- )
438
- volume_type._info.update({'properties': properties})
439
- if parsed_args.encryption_type:
440
- # show encryption type information for this volume type
441
- try:
442
- encryption = volume_client.volume_encryption_types.get(
443
- volume_type.id
444
- )
445
- encryption._info.pop("volume_type_id", None)
446
- volume_type._info.update(
447
- {'encryption': format_columns.DictColumn(encryption._info)}
448
- )
449
- except Exception as e:
450
- LOG.error(
451
- _(
452
- "Failed to display the encryption information "
453
- "of this volume type: %s"
454
- ),
455
- e,
456
- )
457
- volume_type._info.pop("os-volume-type-access:is_public", None)
458
- return zip(*sorted(volume_type._info.items()))
459
-
460
-
461
- class UnsetVolumeType(command.Command):
462
- _description = _("Unset volume type properties")
463
-
464
- def get_parser(self, prog_name):
465
- parser = super().get_parser(prog_name)
466
- parser.add_argument(
467
- 'volume_type',
468
- metavar='<volume-type>',
469
- help=_('Volume type to modify (name or ID)'),
470
- )
471
- parser.add_argument(
472
- '--property',
473
- metavar='<key>',
474
- action='append',
475
- help=_(
476
- 'Remove a property from this volume type '
477
- '(repeat option to remove multiple properties)'
478
- ),
479
- )
480
- parser.add_argument(
481
- "--encryption-type",
482
- action="store_true",
483
- help=_(
484
- "Remove the encryption type for this volume type "
485
- "(admin only)"
486
- ),
487
- )
488
- return parser
489
-
490
- def take_action(self, parsed_args):
491
- volume_client = self.app.client_manager.volume
492
- volume_type = utils.find_resource(
493
- volume_client.volume_types,
494
- parsed_args.volume_type,
495
- )
496
-
497
- result = 0
498
- if parsed_args.property:
499
- try:
500
- volume_type.unset_keys(parsed_args.property)
501
- except Exception as e:
502
- LOG.error(_("Failed to unset volume type property: %s"), e)
503
- result += 1
504
- if parsed_args.encryption_type:
505
- try:
506
- volume_client.volume_encryption_types.delete(volume_type)
507
- except Exception as e:
508
- LOG.error(
509
- _(
510
- "Failed to remove the encryption type for this "
511
- "volume type: %s"
512
- ),
513
- e,
514
- )
515
- result += 1
516
-
517
- if result > 0:
518
- raise exceptions.CommandError(
519
- _("Command Failed: One or more of" " the operations failed")
520
- )
@@ -1 +0,0 @@
1
- {"git_version": "4b7e32ca", "is_release": true}