python-openstackclient 8.1.0__py3-none-any.whl → 8.3.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 (241) hide show
  1. openstackclient/api/compute_v2.py +2 -2
  2. openstackclient/api/object_store_v1.py +4 -1
  3. openstackclient/api/volume_v2.py +60 -0
  4. openstackclient/api/volume_v3.py +60 -0
  5. openstackclient/command.py +27 -0
  6. openstackclient/common/availability_zone.py +1 -1
  7. openstackclient/common/clientmanager.py +59 -21
  8. openstackclient/common/configuration.py +1 -1
  9. openstackclient/common/extension.py +1 -1
  10. openstackclient/common/limits.py +1 -1
  11. openstackclient/common/module.py +4 -2
  12. openstackclient/common/project_cleanup.py +10 -8
  13. openstackclient/common/quota.py +23 -6
  14. openstackclient/common/versions.py +1 -2
  15. openstackclient/compute/v2/agent.py +1 -1
  16. openstackclient/compute/v2/aggregate.py +6 -5
  17. openstackclient/compute/v2/console.py +5 -3
  18. openstackclient/compute/v2/console_connection.py +1 -1
  19. openstackclient/compute/v2/flavor.py +15 -2
  20. openstackclient/compute/v2/host.py +1 -1
  21. openstackclient/compute/v2/hypervisor.py +1 -1
  22. openstackclient/compute/v2/hypervisor_stats.py +1 -1
  23. openstackclient/compute/v2/keypair.py +1 -1
  24. openstackclient/compute/v2/server.py +77 -30
  25. openstackclient/compute/v2/server_backup.py +1 -1
  26. openstackclient/compute/v2/server_event.py +1 -1
  27. openstackclient/compute/v2/server_group.py +4 -2
  28. openstackclient/compute/v2/server_image.py +1 -1
  29. openstackclient/compute/v2/server_migration.py +1 -1
  30. openstackclient/compute/v2/server_volume.py +1 -1
  31. openstackclient/compute/v2/service.py +1 -1
  32. openstackclient/compute/v2/usage.py +6 -4
  33. openstackclient/identity/common.py +10 -14
  34. openstackclient/identity/v2_0/catalog.py +3 -2
  35. openstackclient/identity/v2_0/ec2creds.py +1 -1
  36. openstackclient/identity/v2_0/endpoint.py +1 -1
  37. openstackclient/identity/v2_0/project.py +17 -7
  38. openstackclient/identity/v2_0/role.py +1 -1
  39. openstackclient/identity/v2_0/role_assignment.py +3 -3
  40. openstackclient/identity/v2_0/service.py +1 -1
  41. openstackclient/identity/v2_0/token.py +1 -1
  42. openstackclient/identity/v2_0/user.py +2 -2
  43. openstackclient/identity/v3/access_rule.py +16 -4
  44. openstackclient/identity/v3/application_credential.py +116 -95
  45. openstackclient/identity/v3/catalog.py +3 -3
  46. openstackclient/identity/v3/consumer.py +1 -1
  47. openstackclient/identity/v3/credential.py +1 -1
  48. openstackclient/identity/v3/domain.py +15 -10
  49. openstackclient/identity/v3/ec2creds.py +1 -1
  50. openstackclient/identity/v3/endpoint.py +33 -12
  51. openstackclient/identity/v3/endpoint_group.py +1 -1
  52. openstackclient/identity/v3/federation_protocol.py +1 -1
  53. openstackclient/identity/v3/group.py +11 -5
  54. openstackclient/identity/v3/identity_provider.py +12 -10
  55. openstackclient/identity/v3/implied_role.py +1 -1
  56. openstackclient/identity/v3/limit.py +1 -1
  57. openstackclient/identity/v3/mapping.py +1 -1
  58. openstackclient/identity/v3/policy.py +1 -1
  59. openstackclient/identity/v3/project.py +34 -22
  60. openstackclient/identity/v3/region.py +1 -1
  61. openstackclient/identity/v3/registered_limit.py +16 -11
  62. openstackclient/identity/v3/role.py +27 -41
  63. openstackclient/identity/v3/role_assignment.py +12 -23
  64. openstackclient/identity/v3/service.py +1 -1
  65. openstackclient/identity/v3/service_provider.py +1 -1
  66. openstackclient/identity/v3/tag.py +3 -2
  67. openstackclient/identity/v3/token.py +3 -2
  68. openstackclient/identity/v3/trust.py +4 -2
  69. openstackclient/identity/v3/unscoped_saml.py +1 -1
  70. openstackclient/identity/v3/user.py +22 -13
  71. openstackclient/image/v1/image.py +35 -17
  72. openstackclient/image/v2/cache.py +11 -7
  73. openstackclient/image/v2/image.py +62 -12
  74. openstackclient/image/v2/info.py +1 -1
  75. openstackclient/image/v2/metadef_namespaces.py +1 -1
  76. openstackclient/image/v2/metadef_objects.py +9 -3
  77. openstackclient/image/v2/metadef_properties.py +11 -3
  78. openstackclient/image/v2/metadef_resource_type_association.py +1 -1
  79. openstackclient/image/v2/metadef_resource_types.py +1 -1
  80. openstackclient/image/v2/task.py +1 -1
  81. openstackclient/network/common.py +10 -9
  82. openstackclient/network/v2/address_group.py +4 -3
  83. openstackclient/network/v2/address_scope.py +8 -6
  84. openstackclient/network/v2/default_security_group_rule.py +9 -8
  85. openstackclient/network/v2/floating_ip.py +16 -9
  86. openstackclient/network/v2/floating_ip_port_forwarding.py +9 -6
  87. openstackclient/network/v2/ip_availability.py +7 -4
  88. openstackclient/network/v2/l3_conntrack_helper.py +11 -4
  89. openstackclient/network/v2/local_ip.py +13 -7
  90. openstackclient/network/v2/local_ip_association.py +7 -4
  91. openstackclient/network/v2/ndp_proxy.py +13 -6
  92. openstackclient/network/v2/network.py +33 -16
  93. openstackclient/network/v2/network_agent.py +5 -5
  94. openstackclient/network/v2/network_auto_allocated_topology.py +1 -1
  95. openstackclient/network/v2/network_flavor.py +1 -1
  96. openstackclient/network/v2/network_flavor_profile.py +1 -1
  97. openstackclient/network/v2/network_meter.py +1 -1
  98. openstackclient/network/v2/network_meter_rule.py +1 -1
  99. openstackclient/network/v2/network_qos_policy.py +7 -5
  100. openstackclient/network/v2/network_qos_rule.py +1 -1
  101. openstackclient/network/v2/network_qos_rule_type.py +1 -1
  102. openstackclient/network/v2/network_rbac.py +8 -5
  103. openstackclient/network/v2/network_segment.py +2 -2
  104. openstackclient/network/v2/network_segment_range.py +13 -6
  105. openstackclient/network/v2/network_service_provider.py +1 -1
  106. openstackclient/network/v2/network_trunk.py +65 -42
  107. openstackclient/network/v2/port.py +38 -20
  108. openstackclient/network/v2/router.py +19 -8
  109. openstackclient/network/v2/security_group.py +52 -7
  110. openstackclient/network/v2/security_group_rule.py +27 -4
  111. openstackclient/network/v2/subnet.py +17 -18
  112. openstackclient/network/v2/subnet_pool.py +11 -9
  113. openstackclient/network/v2/taas/__init__.py +0 -0
  114. openstackclient/network/v2/taas/tap_flow.py +245 -0
  115. openstackclient/network/v2/taas/tap_mirror.py +237 -0
  116. openstackclient/network/v2/taas/tap_service.py +211 -0
  117. openstackclient/object/v1/account.py +1 -1
  118. openstackclient/object/v1/container.py +1 -1
  119. openstackclient/object/v1/object.py +1 -1
  120. openstackclient/shell.py +18 -8
  121. openstackclient/tests/functional/identity/v3/test_access_rule.py +1 -1
  122. openstackclient/tests/functional/identity/v3/test_application_credential.py +7 -7
  123. openstackclient/tests/functional/identity/v3/test_catalog.py +42 -23
  124. openstackclient/tests/functional/identity/v3/test_role_assignment.py +174 -0
  125. openstackclient/tests/functional/image/v2/test_cache.py +54 -0
  126. openstackclient/tests/functional/image/v2/test_image.py +36 -14
  127. openstackclient/tests/functional/image/v2/test_metadef_resource_type.py +55 -0
  128. openstackclient/tests/functional/volume/v2/test_volume.py +1 -1
  129. openstackclient/tests/functional/volume/v3/test_volume.py +2 -2
  130. openstackclient/tests/unit/api/test_volume_v2.py +124 -0
  131. openstackclient/tests/unit/api/test_volume_v3.py +124 -0
  132. openstackclient/tests/unit/common/test_command.py +1 -1
  133. openstackclient/tests/unit/common/test_extension.py +2 -3
  134. openstackclient/tests/unit/common/test_module.py +14 -7
  135. openstackclient/tests/unit/common/test_quota.py +20 -0
  136. openstackclient/tests/unit/compute/v2/test_aggregate.py +5 -3
  137. openstackclient/tests/unit/compute/v2/test_console.py +1 -4
  138. openstackclient/tests/unit/compute/v2/test_flavor.py +160 -177
  139. openstackclient/tests/unit/compute/v2/test_hypervisor_stats.py +1 -9
  140. openstackclient/tests/unit/compute/v2/test_server.py +406 -81
  141. openstackclient/tests/unit/compute/v2/test_server_backup.py +1 -3
  142. openstackclient/tests/unit/compute/v2/test_service.py +1 -3
  143. openstackclient/tests/unit/fakes.py +35 -134
  144. openstackclient/tests/unit/identity/test_common.py +100 -0
  145. openstackclient/tests/unit/identity/v2_0/test_project.py +4 -4
  146. openstackclient/tests/unit/identity/v3/fakes.py +10 -2
  147. openstackclient/tests/unit/identity/v3/test_application_credential.py +50 -44
  148. openstackclient/tests/unit/identity/v3/test_domain.py +3 -3
  149. openstackclient/tests/unit/identity/v3/test_endpoint.py +1 -1
  150. openstackclient/tests/unit/identity/v3/test_group.py +4 -2
  151. openstackclient/tests/unit/identity/v3/test_identity_provider.py +10 -10
  152. openstackclient/tests/unit/identity/v3/test_oauth.py +1 -1
  153. openstackclient/tests/unit/identity/v3/test_project.py +31 -54
  154. openstackclient/tests/unit/identity/v3/test_registered_limit.py +2 -2
  155. openstackclient/tests/unit/identity/v3/test_role.py +3 -90
  156. openstackclient/tests/unit/identity/v3/test_user.py +7 -51
  157. openstackclient/tests/unit/image/v1/test_image.py +47 -0
  158. openstackclient/tests/unit/image/v2/test_image.py +190 -9
  159. openstackclient/tests/unit/image/v2/test_metadef_objects.py +22 -0
  160. openstackclient/tests/unit/image/v2/test_metadef_properties.py +24 -10
  161. openstackclient/tests/unit/network/test_common.py +9 -13
  162. openstackclient/tests/unit/network/v2/fakes.py +1 -0
  163. openstackclient/tests/unit/network/v2/taas/__init__.py +0 -0
  164. openstackclient/tests/unit/network/v2/taas/test_osc_tap_flow.py +276 -0
  165. openstackclient/tests/unit/network/v2/taas/test_osc_tap_mirror.py +288 -0
  166. openstackclient/tests/unit/network/v2/taas/test_osc_tap_service.py +271 -0
  167. openstackclient/tests/unit/network/v2/test_address_group.py +19 -22
  168. openstackclient/tests/unit/network/v2/test_address_scope.py +10 -15
  169. openstackclient/tests/unit/network/v2/test_default_security_group_rule.py +38 -49
  170. openstackclient/tests/unit/network/v2/test_floating_ip_network.py +21 -27
  171. openstackclient/tests/unit/network/v2/test_floating_ip_port_forwarding.py +21 -18
  172. openstackclient/tests/unit/network/v2/test_ip_availability.py +6 -8
  173. openstackclient/tests/unit/network/v2/test_l3_conntrack_helper.py +6 -15
  174. openstackclient/tests/unit/network/v2/test_local_ip.py +12 -23
  175. openstackclient/tests/unit/network/v2/test_local_ip_association.py +13 -18
  176. openstackclient/tests/unit/network/v2/test_ndp_proxy.py +13 -23
  177. openstackclient/tests/unit/network/v2/test_network.py +41 -37
  178. openstackclient/tests/unit/network/v2/test_network_agent.py +13 -20
  179. openstackclient/tests/unit/network/v2/test_network_auto_allocated_topology.py +5 -8
  180. openstackclient/tests/unit/network/v2/test_network_flavor.py +14 -26
  181. openstackclient/tests/unit/network/v2/test_network_flavor_profile.py +14 -17
  182. openstackclient/tests/unit/network/v2/test_network_meter.py +7 -17
  183. openstackclient/tests/unit/network/v2/test_network_meter_rule.py +10 -20
  184. openstackclient/tests/unit/network/v2/test_network_qos_policy.py +7 -13
  185. openstackclient/tests/unit/network/v2/test_network_qos_rule.py +44 -54
  186. openstackclient/tests/unit/network/v2/test_network_qos_rule_type.py +2 -7
  187. openstackclient/tests/unit/network/v2/test_network_rbac.py +21 -36
  188. openstackclient/tests/unit/network/v2/test_network_segment.py +13 -29
  189. openstackclient/tests/unit/network/v2/test_network_segment_range.py +20 -19
  190. openstackclient/tests/unit/network/v2/test_network_service_provider.py +1 -4
  191. openstackclient/tests/unit/network/v2/test_network_trunk.py +52 -47
  192. openstackclient/tests/unit/network/v2/test_port.py +113 -84
  193. openstackclient/tests/unit/network/v2/test_router.py +104 -126
  194. openstackclient/tests/unit/network/v2/test_security_group_network.py +25 -26
  195. openstackclient/tests/unit/network/v2/test_security_group_rule_network.py +66 -18
  196. openstackclient/tests/unit/network/v2/test_subnet.py +35 -46
  197. openstackclient/tests/unit/network/v2/test_subnet_pool.py +21 -33
  198. openstackclient/tests/unit/volume/test_find_resource.py +4 -13
  199. openstackclient/tests/unit/volume/v2/test_volume.py +358 -305
  200. openstackclient/tests/unit/volume/v2/test_volume_backup.py +3 -1
  201. openstackclient/tests/unit/volume/v3/test_volume.py +443 -415
  202. openstackclient/tests/unit/volume/v3/test_volume_backup.py +9 -0
  203. openstackclient/volume/client.py +7 -17
  204. openstackclient/volume/v2/backup_record.py +1 -1
  205. openstackclient/volume/v2/consistency_group.py +1 -1
  206. openstackclient/volume/v2/consistency_group_snapshot.py +1 -1
  207. openstackclient/volume/v2/qos_specs.py +1 -1
  208. openstackclient/volume/v2/service.py +2 -2
  209. openstackclient/volume/v2/volume.py +80 -54
  210. openstackclient/volume/v2/volume_backend.py +1 -1
  211. openstackclient/volume/v2/volume_backup.py +5 -3
  212. openstackclient/volume/v2/volume_host.py +1 -2
  213. openstackclient/volume/v2/volume_snapshot.py +2 -2
  214. openstackclient/volume/v2/volume_transfer_request.py +1 -1
  215. openstackclient/volume/v2/volume_type.py +11 -6
  216. openstackclient/volume/v3/block_storage_cleanup.py +1 -1
  217. openstackclient/volume/v3/block_storage_cluster.py +1 -1
  218. openstackclient/volume/v3/block_storage_log_level.py +1 -1
  219. openstackclient/volume/v3/block_storage_manage.py +1 -1
  220. openstackclient/volume/v3/block_storage_resource_filter.py +1 -1
  221. openstackclient/volume/v3/service.py +2 -2
  222. openstackclient/volume/v3/volume.py +104 -77
  223. openstackclient/volume/v3/volume_attachment.py +6 -5
  224. openstackclient/volume/v3/volume_backup.py +18 -3
  225. openstackclient/volume/v3/volume_group.py +2 -2
  226. openstackclient/volume/v3/volume_group_snapshot.py +1 -1
  227. openstackclient/volume/v3/volume_group_type.py +1 -1
  228. openstackclient/volume/v3/volume_message.py +1 -1
  229. openstackclient/volume/v3/volume_snapshot.py +2 -2
  230. openstackclient/volume/v3/volume_transfer_request.py +1 -1
  231. openstackclient/volume/v3/volume_type.py +15 -9
  232. {python_openstackclient-8.1.0.dist-info → python_openstackclient-8.3.0.dist-info}/METADATA +19 -17
  233. {python_openstackclient-8.1.0.dist-info → python_openstackclient-8.3.0.dist-info}/RECORD +239 -224
  234. {python_openstackclient-8.1.0.dist-info → python_openstackclient-8.3.0.dist-info}/WHEEL +1 -1
  235. {python_openstackclient-8.1.0.dist-info → python_openstackclient-8.3.0.dist-info}/entry_points.txt +15 -0
  236. {python_openstackclient-8.1.0.dist-info → python_openstackclient-8.3.0.dist-info/licenses}/AUTHORS +15 -0
  237. python_openstackclient-8.3.0.dist-info/pbr.json +1 -0
  238. openstackclient/tests/unit/common/test_logs.py +0 -221
  239. python_openstackclient-8.1.0.dist-info/pbr.json +0 -1
  240. {python_openstackclient-8.1.0.dist-info → python_openstackclient-8.3.0.dist-info/licenses}/LICENSE +0 -0
  241. {python_openstackclient-8.1.0.dist-info → python_openstackclient-8.3.0.dist-info}/top_level.txt +0 -0
@@ -17,6 +17,7 @@ from openstack.block_storage.v3 import backup as _backup
17
17
  from openstack.block_storage.v3 import snapshot as _snapshot
18
18
  from openstack.block_storage.v3 import volume as _volume
19
19
  from openstack import exceptions as sdk_exceptions
20
+ from openstack.identity.v3 import project as _project
20
21
  from openstack.test import fakes as sdk_fakes
21
22
  from osc_lib import exceptions
22
23
 
@@ -381,6 +382,7 @@ class TestBackupList(volume_fakes.TestVolume):
381
382
  ("marker", None),
382
383
  ("limit", None),
383
384
  ('all_projects', False),
385
+ ("project", None),
384
386
  ]
385
387
 
386
388
  parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -395,11 +397,14 @@ class TestBackupList(volume_fakes.TestVolume):
395
397
  all_tenants=False,
396
398
  marker=None,
397
399
  limit=None,
400
+ project_id=None,
398
401
  )
399
402
  self.assertEqual(self.columns, columns)
400
403
  self.assertCountEqual(self.data, list(data))
401
404
 
402
405
  def test_backup_list_with_options(self):
406
+ project = sdk_fakes.generate_fake_resource(_project.Project)
407
+ self.identity_sdk_client.find_project.return_value = project
403
408
  arglist = [
404
409
  "--long",
405
410
  "--name",
@@ -413,6 +418,8 @@ class TestBackupList(volume_fakes.TestVolume):
413
418
  "--all-projects",
414
419
  "--limit",
415
420
  "3",
421
+ "--project",
422
+ project.id,
416
423
  ]
417
424
  verifylist = [
418
425
  ("long", True),
@@ -422,6 +429,7 @@ class TestBackupList(volume_fakes.TestVolume):
422
429
  ("marker", self.backups[0].id),
423
430
  ('all_projects', True),
424
431
  ("limit", 3),
432
+ ("project", project.id),
425
433
  ]
426
434
 
427
435
  parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -440,6 +448,7 @@ class TestBackupList(volume_fakes.TestVolume):
440
448
  all_tenants=True,
441
449
  marker=self.backups[0].id,
442
450
  limit=3,
451
+ project_id=project.id,
443
452
  )
444
453
  self.assertEqual(self.columns_long, columns)
445
454
  self.assertCountEqual(self.data_long, list(data))
@@ -20,16 +20,14 @@ from osc_lib import utils
20
20
 
21
21
  from openstackclient.i18n import _
22
22
 
23
-
24
23
  LOG = logging.getLogger(__name__)
25
24
 
26
25
  DEFAULT_API_VERSION = '3'
27
26
  API_VERSION_OPTION = 'os_volume_api_version'
28
- API_NAME = "volume"
27
+ API_NAME = 'volume'
29
28
  API_VERSIONS = {
30
- "1": "cinderclient.v1.client.Client",
31
- "2": "cinderclient.v2.client.Client",
32
- "3": "cinderclient.v3.client.Client",
29
+ '2': 'cinderclient.v2.client.Client',
30
+ '3': 'cinderclient.v3.client.Client',
33
31
  }
34
32
 
35
33
  # Save the microversion if in use
@@ -45,11 +43,6 @@ def make_client(instance):
45
43
  from cinderclient.v3 import volume_snapshots
46
44
  from cinderclient.v3 import volumes
47
45
 
48
- # Check whether the available cinderclient supports v1 or v2
49
- try:
50
- from cinderclient.v1 import services # noqa
51
- except Exception:
52
- del API_VERSIONS['1']
53
46
  try:
54
47
  from cinderclient.v2 import services # noqa
55
48
  except Exception:
@@ -127,21 +120,18 @@ def check_api_version(check_version):
127
120
 
128
121
  global _volume_api_version
129
122
 
130
- # Copy some logic from novaclient 3.3.0 for basic version detection
131
- # NOTE(dtroyer): This is only enough to resume operations using API
132
- # version 3.0 or any valid version supplied by the user.
133
123
  _volume_api_version = api_versions.get_api_version(check_version)
134
124
 
135
125
  # Bypass X.latest format microversion
136
126
  if not _volume_api_version.is_latest():
137
- if _volume_api_version > api_versions.APIVersion("3.0"):
127
+ if _volume_api_version > api_versions.APIVersion('3.0'):
138
128
  if not _volume_api_version.matches(
139
129
  api_versions.MIN_VERSION,
140
130
  api_versions.MAX_VERSION,
141
131
  ):
142
- msg = _("versions supported by client: %(min)s - %(max)s") % {
143
- "min": api_versions.MIN_VERSION,
144
- "max": api_versions.MAX_VERSION,
132
+ msg = _('versions supported by client: %(min)s - %(max)s') % {
133
+ 'min': api_versions.MIN_VERSION,
134
+ 'max': api_versions.MAX_VERSION,
145
135
  }
146
136
  raise exceptions.CommandError(msg)
147
137
 
@@ -16,9 +16,9 @@
16
16
 
17
17
  import logging
18
18
 
19
- from osc_lib.command import command
20
19
  from osc_lib import utils
21
20
 
21
+ from openstackclient import command
22
22
  from openstackclient.i18n import _
23
23
 
24
24
 
@@ -18,10 +18,10 @@ import argparse
18
18
  import logging
19
19
 
20
20
  from osc_lib.cli import format_columns
21
- from osc_lib.command import command
22
21
  from osc_lib import exceptions
23
22
  from osc_lib import utils
24
23
 
24
+ from openstackclient import command
25
25
  from openstackclient.i18n import _
26
26
 
27
27
 
@@ -16,10 +16,10 @@
16
16
 
17
17
  import logging
18
18
 
19
- from osc_lib.command import command
20
19
  from osc_lib import exceptions
21
20
  from osc_lib import utils
22
21
 
22
+ from openstackclient import command
23
23
  from openstackclient.i18n import _
24
24
 
25
25
 
@@ -19,10 +19,10 @@ import logging
19
19
 
20
20
  from osc_lib.cli import format_columns
21
21
  from osc_lib.cli import parseractions
22
- from osc_lib.command import command
23
22
  from osc_lib import exceptions
24
23
  from osc_lib import utils
25
24
 
25
+ from openstackclient import command
26
26
  from openstackclient.i18n import _
27
27
 
28
28
 
@@ -14,10 +14,10 @@
14
14
 
15
15
  """Service action implementations"""
16
16
 
17
- from osc_lib.command import command
18
17
  from osc_lib import exceptions
19
18
  from osc_lib import utils
20
19
 
20
+ from openstackclient import command
21
21
  from openstackclient.i18n import _
22
22
 
23
23
 
@@ -126,7 +126,7 @@ class SetService(command.Command):
126
126
  volume_client = self.app.client_manager.sdk_connection.volume
127
127
 
128
128
  service = volume_client.find_service(
129
- host=parsed_args.host, service=parsed_args.service
129
+ parsed_args.service, ignore_missing=False, host=parsed_args.host
130
130
  )
131
131
 
132
132
  if parsed_args.enable:
@@ -18,15 +18,18 @@ import argparse
18
18
  import copy
19
19
  import functools
20
20
  import logging
21
+ import typing as ty
21
22
 
22
23
  from cliff import columns as cliff_columns
24
+ from openstack.block_storage.v2 import volume as _volume
23
25
  from openstack import exceptions as sdk_exceptions
24
26
  from osc_lib.cli import format_columns
25
27
  from osc_lib.cli import parseractions
26
- from osc_lib.command import command
27
28
  from osc_lib import exceptions
28
29
  from osc_lib import utils
29
30
 
31
+ from openstackclient.api import volume_v2
32
+ from openstackclient import command
30
33
  from openstackclient.common import pagination
31
34
  from openstackclient.i18n import _
32
35
  from openstackclient.identity import common as identity_common
@@ -58,7 +61,7 @@ class KeyValueHintAction(argparse.Action):
58
61
  )
59
62
 
60
63
 
61
- class AttachmentsColumn(cliff_columns.FormattableColumn):
64
+ class AttachmentsColumn(cliff_columns.FormattableColumn[list[ty.Any]]):
62
65
  """Formattable column for attachments column.
63
66
 
64
67
  Unlike the parent FormattableColumn class, the initializer of the
@@ -89,6 +92,47 @@ class AttachmentsColumn(cliff_columns.FormattableColumn):
89
92
  return msg
90
93
 
91
94
 
95
+ def _format_volume(volume: _volume.Volume) -> dict[str, ty.Any]:
96
+ # Some columns returned by openstacksdk should not be shown because they're
97
+ # either irrelevant or duplicates
98
+ ignored_columns = {
99
+ # computed columns
100
+ 'location',
101
+ # create-only columns
102
+ 'OS-SCH-HNT:scheduler_hints',
103
+ 'imageRef',
104
+ # unnecessary columns
105
+ 'links',
106
+ }
107
+ optional_columns = {
108
+ # only present if part of a consistency group
109
+ 'consistencygroup_id',
110
+ # only present if there are image properties associated
111
+ 'volume_image_metadata',
112
+ }
113
+
114
+ info = volume.to_dict(original_names=True)
115
+ data = {}
116
+ for key, value in info.items():
117
+ if key in ignored_columns:
118
+ continue
119
+
120
+ if key in optional_columns:
121
+ if info[key] is None:
122
+ continue
123
+
124
+ data[key] = value
125
+
126
+ data.update(
127
+ {
128
+ 'properties': format_columns.DictColumn(data.pop('metadata')),
129
+ 'type': data.pop('volume_type'),
130
+ }
131
+ )
132
+
133
+ return data
134
+
135
+
92
136
  class CreateVolume(command.ShowOne):
93
137
  _description = _("Create new volume")
94
138
 
@@ -226,22 +270,22 @@ class CreateVolume(command.ShowOne):
226
270
  # volume from snapshot or source volume
227
271
  size = parsed_args.size
228
272
 
229
- volume_client = self.app.client_manager.volume
273
+ volume_client = self.app.client_manager.sdk_connection.volume
230
274
  image_client = self.app.client_manager.image
231
275
 
232
276
  source_volume = None
233
277
  if parsed_args.source:
234
- source_volume_obj = utils.find_resource(
235
- volume_client.volumes, parsed_args.source
278
+ source_volume_obj = volume_client.find_volume(
279
+ parsed_args.source, ignore_missing=False
236
280
  )
237
281
  source_volume = source_volume_obj.id
238
282
  size = max(size or 0, source_volume_obj.size)
239
283
 
240
284
  consistency_group = None
241
285
  if parsed_args.consistency_group:
242
- consistency_group = utils.find_resource(
243
- volume_client.consistencygroups, parsed_args.consistency_group
244
- ).id
286
+ consistency_group = volume_v2.find_consistency_group(
287
+ volume_client, parsed_args.consistency_group
288
+ )['id']
245
289
 
246
290
  image = None
247
291
  if parsed_args.image:
@@ -251,8 +295,8 @@ class CreateVolume(command.ShowOne):
251
295
 
252
296
  snapshot = None
253
297
  if parsed_args.snapshot:
254
- snapshot_obj = utils.find_resource(
255
- volume_client.volume_snapshots, parsed_args.snapshot
298
+ snapshot_obj = volume_client.find_snapshot(
299
+ parsed_args.snapshot, ignore_missing=False
256
300
  )
257
301
  snapshot = snapshot_obj.id
258
302
  # Cinder requires a value for size when creating a volume
@@ -263,7 +307,7 @@ class CreateVolume(command.ShowOne):
263
307
  # snapshot size.
264
308
  size = max(size or 0, snapshot_obj.size)
265
309
 
266
- volume = volume_client.volumes.create(
310
+ volume = volume_client.create_volume(
267
311
  size=size,
268
312
  snapshot_id=snapshot,
269
313
  name=parsed_args.name,
@@ -271,23 +315,23 @@ class CreateVolume(command.ShowOne):
271
315
  volume_type=parsed_args.type,
272
316
  availability_zone=parsed_args.availability_zone,
273
317
  metadata=parsed_args.properties,
274
- imageRef=image,
275
- source_volid=source_volume,
276
- consistencygroup_id=consistency_group,
318
+ image_id=image,
319
+ source_volume_id=source_volume,
320
+ consistency_group_id=consistency_group,
277
321
  scheduler_hints=parsed_args.hint,
278
322
  )
279
323
 
280
324
  if parsed_args.bootable is not None:
281
325
  try:
282
326
  if utils.wait_for_status(
283
- volume_client.volumes.get,
327
+ volume_client.get_volume,
284
328
  volume.id,
285
329
  success_status=['available'],
286
330
  error_status=['error'],
287
331
  sleep_time=1,
288
332
  ):
289
- volume_client.volumes.set_bootable(
290
- volume.id, parsed_args.bootable
333
+ volume_client.set_volume_bootable_status(
334
+ volume, parsed_args.bootable
291
335
  )
292
336
  else:
293
337
  msg = _(
@@ -300,14 +344,14 @@ class CreateVolume(command.ShowOne):
300
344
  if parsed_args.read_only is not None:
301
345
  try:
302
346
  if utils.wait_for_status(
303
- volume_client.volumes.get,
347
+ volume_client.get_volume,
304
348
  volume.id,
305
349
  success_status=['available'],
306
350
  error_status=['error'],
307
351
  sleep_time=1,
308
352
  ):
309
- volume_client.volumes.update_readonly_flag(
310
- volume.id, parsed_args.read_only
353
+ volume_client.set_volume_readonly(
354
+ volume, parsed_args.read_only
311
355
  )
312
356
  else:
313
357
  msg = _(
@@ -321,17 +365,8 @@ class CreateVolume(command.ShowOne):
321
365
  e,
322
366
  )
323
367
 
324
- # Remove key links from being displayed
325
- volume._info.update(
326
- {
327
- 'properties': format_columns.DictColumn(
328
- volume._info.pop('metadata')
329
- ),
330
- 'type': volume._info.pop('volume_type'),
331
- }
332
- )
333
- volume._info.pop("links", None)
334
- return zip(*sorted(volume._info.items()))
368
+ data = _format_volume(volume)
369
+ return zip(*sorted(data.items()))
335
370
 
336
371
 
337
372
  class DeleteVolume(command.Command):
@@ -578,13 +613,15 @@ class MigrateVolume(command.Command):
578
613
  return parser
579
614
 
580
615
  def take_action(self, parsed_args):
581
- volume_client = self.app.client_manager.volume
582
- volume = utils.find_resource(volume_client.volumes, parsed_args.volume)
583
- volume_client.volumes.migrate_volume(
616
+ volume_client = self.app.client_manager.sdk_connection.volume
617
+ volume = volume_client.find_volume(
618
+ parsed_args.volume, ignore_missing=False
619
+ )
620
+ volume_client.migrate_volume(
584
621
  volume.id,
585
- parsed_args.host,
586
- parsed_args.force_host_copy,
587
- parsed_args.lock_volume,
622
+ host=parsed_args.host,
623
+ force_host_copy=parsed_args.force_host_copy,
624
+ lock_volume=parsed_args.lock_volume,
588
625
  )
589
626
 
590
627
 
@@ -918,24 +955,13 @@ class ShowVolume(command.ShowOne):
918
955
  return parser
919
956
 
920
957
  def take_action(self, parsed_args):
921
- volume_client = self.app.client_manager.volume
922
- volume = utils.find_resource(volume_client.volumes, parsed_args.volume)
958
+ volume_client = self.app.client_manager.sdk_connection.volume
959
+ volume = volume_client.find_volume(
960
+ parsed_args.volume, ignore_missing=False
961
+ )
923
962
 
924
- # Special mapping for columns to make the output easier to read:
925
- # 'metadata' --> 'properties'
926
- # 'volume_type' --> 'type'
927
- volume._info.update(
928
- {
929
- 'properties': format_columns.DictColumn(
930
- volume._info.pop('metadata')
931
- ),
932
- 'type': volume._info.pop('volume_type'),
933
- },
934
- )
935
-
936
- # Remove key links from being displayed
937
- volume._info.pop("links", None)
938
- return zip(*sorted(volume._info.items()))
963
+ data = _format_volume(volume)
964
+ return zip(*sorted(data.items()))
939
965
 
940
966
 
941
967
  class UnsetVolume(command.Command):
@@ -15,9 +15,9 @@
15
15
  """Storage backend action implementations"""
16
16
 
17
17
  from osc_lib.cli import format_columns
18
- from osc_lib.command import command
19
18
  from osc_lib import utils
20
19
 
20
+ from openstackclient import command
21
21
  from openstackclient.i18n import _
22
22
 
23
23
 
@@ -18,17 +18,17 @@ import functools
18
18
  import logging
19
19
 
20
20
  from cliff import columns as cliff_columns
21
- from osc_lib.command import command
22
21
  from osc_lib import exceptions
23
22
  from osc_lib import utils
24
23
 
24
+ from openstackclient import command
25
25
  from openstackclient.common import pagination
26
26
  from openstackclient.i18n import _
27
27
 
28
28
  LOG = logging.getLogger(__name__)
29
29
 
30
30
 
31
- class VolumeIdColumn(cliff_columns.FormattableColumn):
31
+ class VolumeIdColumn(cliff_columns.FormattableColumn[str]):
32
32
  """Formattable column for volume ID column.
33
33
 
34
34
  Unlike the parent FormattableColumn class, the initializer of the
@@ -453,7 +453,9 @@ class ShowVolumeBackup(command.ShowOne):
453
453
 
454
454
  def take_action(self, parsed_args):
455
455
  volume_client = self.app.client_manager.sdk_connection.volume
456
- backup = volume_client.find_backup(parsed_args.backup)
456
+ backup = volume_client.find_backup(
457
+ parsed_args.backup, ignore_missing=False
458
+ )
457
459
  columns: tuple[str, ...] = (
458
460
  "availability_zone",
459
461
  "container",
@@ -14,8 +14,7 @@
14
14
 
15
15
  """Volume v2 host action implementations"""
16
16
 
17
- from osc_lib.command import command
18
-
17
+ from openstackclient import command
19
18
  from openstackclient.i18n import _
20
19
 
21
20
 
@@ -22,10 +22,10 @@ from cliff import columns as cliff_columns
22
22
  from openstack.block_storage.v2 import snapshot as _snapshot
23
23
  from osc_lib.cli import format_columns
24
24
  from osc_lib.cli import parseractions
25
- from osc_lib.command import command
26
25
  from osc_lib import exceptions
27
26
  from osc_lib import utils
28
27
 
28
+ from openstackclient import command
29
29
  from openstackclient.common import pagination
30
30
  from openstackclient.i18n import _
31
31
  from openstackclient.identity import common as identity_common
@@ -34,7 +34,7 @@ from openstackclient.identity import common as identity_common
34
34
  LOG = logging.getLogger(__name__)
35
35
 
36
36
 
37
- class VolumeIdColumn(cliff_columns.FormattableColumn):
37
+ class VolumeIdColumn(cliff_columns.FormattableColumn[str]):
38
38
  """Formattable column for volume ID column.
39
39
 
40
40
  Unlike the parent FormattableColumn class, the initializer of the
@@ -16,10 +16,10 @@
16
16
 
17
17
  import logging
18
18
 
19
- from osc_lib.command import command
20
19
  from osc_lib import exceptions
21
20
  from osc_lib import utils
22
21
 
22
+ from openstackclient import command
23
23
  from openstackclient.i18n import _
24
24
 
25
25
 
@@ -16,14 +16,15 @@
16
16
 
17
17
  import functools
18
18
  import logging
19
+ import typing as ty
19
20
 
20
21
  from cliff import columns as cliff_columns
21
22
  from osc_lib.cli import format_columns
22
23
  from osc_lib.cli import parseractions
23
- from osc_lib.command import command
24
24
  from osc_lib import exceptions
25
25
  from osc_lib import utils
26
26
 
27
+ from openstackclient import command
27
28
  from openstackclient.i18n import _
28
29
  from openstackclient.identity import common as identity_common
29
30
 
@@ -31,7 +32,7 @@ from openstackclient.identity import common as identity_common
31
32
  LOG = logging.getLogger(__name__)
32
33
 
33
34
 
34
- class EncryptionInfoColumn(cliff_columns.FormattableColumn):
35
+ class EncryptionInfoColumn(cliff_columns.FormattableColumn[ty.Any]):
35
36
  """Formattable column for encryption info column.
36
37
 
37
38
  Unlike the parent FormattableColumn class, the initializer of the
@@ -171,7 +172,8 @@ class CreateVolumeType(command.ShowOne):
171
172
  default=False,
172
173
  help=_(
173
174
  "Enabled replication for this volume type "
174
- "(this is an alias for '--property replication_enabled=<is> True') "
175
+ "(this is an alias for "
176
+ "'--property replication_enabled=<is> True') "
175
177
  "(requires driver support)"
176
178
  ),
177
179
  )
@@ -181,7 +183,8 @@ class CreateVolumeType(command.ShowOne):
181
183
  dest='availability_zones',
182
184
  help=_(
183
185
  "Set an availability zone for this volume type "
184
- "(this is an alias for '--property RESKEY:availability_zones:<az>') "
186
+ "(this is an alias for "
187
+ "'--property RESKEY:availability_zones:<az>') "
185
188
  "(repeat option to set multiple availability zones)"
186
189
  ),
187
190
  )
@@ -534,7 +537,8 @@ class SetVolumeType(command.Command):
534
537
  default=False,
535
538
  help=_(
536
539
  "Enabled replication for this volume type "
537
- "(this is an alias for '--property replication_enabled=<is> True') "
540
+ "(this is an alias for "
541
+ "'--property replication_enabled=<is> True') "
538
542
  "(requires driver support)"
539
543
  ),
540
544
  )
@@ -544,7 +548,8 @@ class SetVolumeType(command.Command):
544
548
  dest='availability_zones',
545
549
  help=_(
546
550
  "Set an availability zone for this volume type "
547
- "(this is an alias for '--property RESKEY:availability_zones:<az>') "
551
+ "(this is an alias for "
552
+ "'--property RESKEY:availability_zones:<az>') "
548
553
  "(repeat option to set multiple availability zones)"
549
554
  ),
550
555
  )
@@ -11,9 +11,9 @@
11
11
  # under the License.
12
12
 
13
13
  from cinderclient import api_versions
14
- from osc_lib.command import command
15
14
  from osc_lib import exceptions
16
15
 
16
+ from openstackclient import command
17
17
  from openstackclient.i18n import _
18
18
 
19
19
 
@@ -11,10 +11,10 @@
11
11
  # under the License.
12
12
 
13
13
  from cinderclient import api_versions
14
- from osc_lib.command import command
15
14
  from osc_lib import exceptions
16
15
  from osc_lib import utils
17
16
 
17
+ from openstackclient import command
18
18
  from openstackclient.i18n import _
19
19
 
20
20
 
@@ -15,9 +15,9 @@
15
15
  """Block Storage Service action implementations"""
16
16
 
17
17
  from openstack import utils as sdk_utils
18
- from osc_lib.command import command
19
18
  from osc_lib import exceptions
20
19
 
20
+ from openstackclient import command
21
21
  from openstackclient.i18n import _
22
22
 
23
23
 
@@ -16,10 +16,10 @@
16
16
  import argparse
17
17
 
18
18
  from cinderclient import api_versions
19
- from osc_lib.command import command
20
19
  from osc_lib import exceptions
21
20
  from osc_lib import utils
22
21
 
22
+ from openstackclient import command
23
23
  from openstackclient.i18n import _
24
24
 
25
25
 
@@ -14,10 +14,10 @@
14
14
 
15
15
  from openstack import utils as sdk_utils
16
16
  from osc_lib.cli import format_columns
17
- from osc_lib.command import command
18
17
  from osc_lib import exceptions
19
18
  from osc_lib import utils
20
19
 
20
+ from openstackclient import command
21
21
  from openstackclient.i18n import _
22
22
 
23
23
 
@@ -15,10 +15,10 @@
15
15
  """Service action implementations"""
16
16
 
17
17
  from openstack import utils as sdk_utils
18
- from osc_lib.command import command
19
18
  from osc_lib import exceptions
20
19
  from osc_lib import utils
21
20
 
21
+ from openstackclient import command
22
22
  from openstackclient.i18n import _
23
23
 
24
24
 
@@ -133,7 +133,7 @@ class SetService(command.Command):
133
133
  volume_client = self.app.client_manager.sdk_connection.volume
134
134
 
135
135
  service = volume_client.find_service(
136
- host=parsed_args.host, service=parsed_args.service
136
+ parsed_args.service, ignore_missing=False, host=parsed_args.host
137
137
  )
138
138
 
139
139
  if parsed_args.enable: