python-openstackclient 7.4.0__py3-none-any.whl → 8.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (264) 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 +7 -5
  9. openstackclient/compute/v2/agent.py +5 -5
  10. openstackclient/compute/v2/aggregate.py +17 -15
  11. openstackclient/compute/v2/console.py +10 -4
  12. openstackclient/compute/v2/console_connection.py +48 -0
  13. openstackclient/compute/v2/flavor.py +14 -18
  14. openstackclient/compute/v2/host.py +3 -3
  15. openstackclient/compute/v2/hypervisor.py +10 -4
  16. openstackclient/compute/v2/hypervisor_stats.py +1 -1
  17. openstackclient/compute/v2/keypair.py +18 -13
  18. openstackclient/compute/v2/server.py +144 -121
  19. openstackclient/compute/v2/server_backup.py +1 -1
  20. openstackclient/compute/v2/server_event.py +8 -17
  21. openstackclient/compute/v2/server_group.py +6 -6
  22. openstackclient/compute/v2/server_image.py +1 -1
  23. openstackclient/compute/v2/server_migration.py +6 -6
  24. openstackclient/compute/v2/server_volume.py +4 -4
  25. openstackclient/compute/v2/service.py +9 -13
  26. openstackclient/compute/v2/usage.py +4 -6
  27. openstackclient/identity/client.py +2 -4
  28. openstackclient/identity/common.py +95 -17
  29. openstackclient/identity/v2_0/ec2creds.py +4 -3
  30. openstackclient/identity/v2_0/endpoint.py +12 -10
  31. openstackclient/identity/v2_0/project.py +6 -6
  32. openstackclient/identity/v2_0/role.py +1 -1
  33. openstackclient/identity/v2_0/service.py +7 -7
  34. openstackclient/identity/v2_0/user.py +6 -21
  35. openstackclient/identity/v3/access_rule.py +2 -5
  36. openstackclient/identity/v3/application_credential.py +2 -2
  37. openstackclient/identity/v3/consumer.py +4 -3
  38. openstackclient/identity/v3/credential.py +6 -7
  39. openstackclient/identity/v3/domain.py +63 -44
  40. openstackclient/identity/v3/ec2creds.py +4 -3
  41. openstackclient/identity/v3/endpoint.py +104 -88
  42. openstackclient/identity/v3/endpoint_group.py +1 -1
  43. openstackclient/identity/v3/group.py +116 -72
  44. openstackclient/identity/v3/identity_provider.py +1 -2
  45. openstackclient/identity/v3/limit.py +4 -9
  46. openstackclient/identity/v3/mapping.py +4 -3
  47. openstackclient/identity/v3/policy.py +5 -8
  48. openstackclient/identity/v3/project.py +23 -6
  49. openstackclient/identity/v3/region.py +2 -5
  50. openstackclient/identity/v3/registered_limit.py +4 -8
  51. openstackclient/identity/v3/role.py +15 -16
  52. openstackclient/identity/v3/service.py +8 -8
  53. openstackclient/identity/v3/service_provider.py +3 -6
  54. openstackclient/identity/v3/tag.py +2 -2
  55. openstackclient/identity/v3/token.py +1 -2
  56. openstackclient/identity/v3/trust.py +74 -25
  57. openstackclient/identity/v3/user.py +47 -11
  58. openstackclient/image/client.py +7 -5
  59. openstackclient/image/v1/image.py +11 -15
  60. openstackclient/image/v2/cache.py +2 -4
  61. openstackclient/image/v2/image.py +41 -48
  62. openstackclient/image/v2/metadef_namespaces.py +4 -3
  63. openstackclient/image/v2/metadef_resource_type_association.py +1 -2
  64. openstackclient/image/v2/metadef_resource_types.py +1 -2
  65. openstackclient/locale/tr_TR/LC_MESSAGES/openstackclient.po +9 -1370
  66. openstackclient/network/client.py +4 -16
  67. openstackclient/network/common.py +16 -12
  68. openstackclient/network/utils.py +3 -3
  69. openstackclient/network/v2/address_group.py +5 -9
  70. openstackclient/network/v2/address_scope.py +2 -3
  71. openstackclient/network/v2/default_security_group_rule.py +1 -2
  72. openstackclient/network/v2/floating_ip.py +69 -47
  73. openstackclient/network/v2/floating_ip_port_forwarding.py +7 -7
  74. openstackclient/network/v2/ip_availability.py +1 -2
  75. openstackclient/network/v2/l3_conntrack_helper.py +8 -12
  76. openstackclient/network/v2/local_ip.py +24 -26
  77. openstackclient/network/v2/local_ip_association.py +4 -5
  78. openstackclient/network/v2/ndp_proxy.py +9 -10
  79. openstackclient/network/v2/network.py +12 -16
  80. openstackclient/network/v2/network_agent.py +29 -37
  81. openstackclient/network/v2/network_auto_allocated_topology.py +4 -5
  82. openstackclient/network/v2/network_flavor.py +1 -1
  83. openstackclient/network/v2/network_flavor_profile.py +5 -5
  84. openstackclient/network/v2/network_meter.py +3 -3
  85. openstackclient/network/v2/network_meter_rule.py +5 -8
  86. openstackclient/network/v2/network_qos_policy.py +4 -4
  87. openstackclient/network/v2/network_qos_rule.py +7 -16
  88. openstackclient/network/v2/network_rbac.py +4 -4
  89. openstackclient/network/v2/network_segment.py +6 -7
  90. openstackclient/network/v2/network_segment_range.py +16 -20
  91. openstackclient/network/v2/network_trunk.py +24 -16
  92. openstackclient/network/v2/port.py +28 -29
  93. openstackclient/network/v2/router.py +53 -42
  94. openstackclient/network/v2/security_group.py +13 -19
  95. openstackclient/network/v2/security_group_rule.py +10 -11
  96. openstackclient/network/v2/subnet.py +31 -30
  97. openstackclient/network/v2/subnet_pool.py +4 -4
  98. openstackclient/object/client.py +2 -3
  99. openstackclient/object/v1/container.py +2 -3
  100. openstackclient/object/v1/object.py +2 -9
  101. openstackclient/shell.py +22 -5
  102. openstackclient/tests/functional/base.py +7 -3
  103. openstackclient/tests/functional/common/test_quota.py +3 -1
  104. openstackclient/tests/functional/compute/v2/common.py +12 -6
  105. openstackclient/tests/functional/compute/v2/test_keypair.py +41 -5
  106. openstackclient/tests/functional/compute/v2/test_server.py +2 -3
  107. openstackclient/tests/functional/compute/v2/test_server_event.py +1 -1
  108. openstackclient/tests/functional/identity/v2/test_user.py +1 -1
  109. openstackclient/tests/functional/identity/v3/common.py +3 -8
  110. openstackclient/tests/functional/identity/v3/test_application_credential.py +10 -10
  111. openstackclient/tests/functional/identity/v3/test_endpoint.py +3 -3
  112. openstackclient/tests/functional/identity/v3/test_group.py +3 -3
  113. openstackclient/tests/functional/identity/v3/test_idp.py +3 -7
  114. openstackclient/tests/functional/identity/v3/test_limit.py +4 -4
  115. openstackclient/tests/functional/identity/v3/test_project.py +5 -14
  116. openstackclient/tests/functional/identity/v3/test_region.py +1 -3
  117. openstackclient/tests/functional/identity/v3/test_registered_limit.py +3 -3
  118. openstackclient/tests/functional/identity/v3/test_role.py +1 -1
  119. openstackclient/tests/functional/identity/v3/test_role_assignment.py +13 -31
  120. openstackclient/tests/functional/identity/v3/test_service_provider.py +3 -7
  121. openstackclient/tests/functional/identity/v3/test_user.py +8 -8
  122. openstackclient/tests/functional/network/v2/common.py +7 -3
  123. openstackclient/tests/functional/network/v2/test_address_group.py +4 -0
  124. openstackclient/tests/functional/network/v2/test_l3_conntrack_helper.py +15 -11
  125. openstackclient/tests/functional/network/v2/test_local_ip.py +4 -0
  126. openstackclient/tests/functional/network/v2/test_network_meter_rule.py +2 -2
  127. openstackclient/tests/functional/network/v2/test_network_ndp_proxy.py +2 -3
  128. openstackclient/tests/functional/network/v2/test_network_rbac.py +2 -2
  129. openstackclient/tests/functional/network/v2/test_network_trunk.py +1 -1
  130. openstackclient/tests/functional/network/v2/test_port.py +17 -7
  131. openstackclient/tests/functional/network/v2/test_router.py +42 -0
  132. openstackclient/tests/functional/network/v2/test_subnet_pool.py +4 -0
  133. openstackclient/tests/unit/api/test_compute_v2.py +67 -87
  134. openstackclient/tests/unit/common/test_availability_zone.py +6 -14
  135. openstackclient/tests/unit/common/test_command.py +1 -1
  136. openstackclient/tests/unit/common/test_extension.py +5 -7
  137. openstackclient/tests/unit/common/test_limits.py +1 -1
  138. openstackclient/tests/unit/common/test_project_cleanup.py +5 -6
  139. openstackclient/tests/unit/common/test_quota.py +51 -28
  140. openstackclient/tests/unit/compute/v2/fakes.py +85 -315
  141. openstackclient/tests/unit/compute/v2/test_agent.py +16 -16
  142. openstackclient/tests/unit/compute/v2/test_aggregate.py +56 -60
  143. openstackclient/tests/unit/compute/v2/test_console.py +34 -17
  144. openstackclient/tests/unit/compute/v2/test_console_connection.py +72 -0
  145. openstackclient/tests/unit/compute/v2/test_flavor.py +72 -72
  146. openstackclient/tests/unit/compute/v2/test_host.py +8 -8
  147. openstackclient/tests/unit/compute/v2/test_hypervisor.py +22 -30
  148. openstackclient/tests/unit/compute/v2/test_hypervisor_stats.py +2 -2
  149. openstackclient/tests/unit/compute/v2/test_keypair.py +36 -29
  150. openstackclient/tests/unit/compute/v2/test_server.py +693 -606
  151. openstackclient/tests/unit/compute/v2/test_server_backup.py +36 -77
  152. openstackclient/tests/unit/compute/v2/test_server_event.py +18 -20
  153. openstackclient/tests/unit/compute/v2/test_server_group.py +25 -31
  154. openstackclient/tests/unit/compute/v2/test_server_image.py +37 -78
  155. openstackclient/tests/unit/compute/v2/test_server_migration.py +41 -41
  156. openstackclient/tests/unit/compute/v2/test_server_volume.py +12 -12
  157. openstackclient/tests/unit/compute/v2/test_service.py +39 -45
  158. openstackclient/tests/unit/compute/v2/test_usage.py +5 -5
  159. openstackclient/tests/unit/identity/v2_0/fakes.py +1 -1
  160. openstackclient/tests/unit/identity/v3/test_access_rule.py +1 -3
  161. openstackclient/tests/unit/identity/v3/test_application_credential.py +48 -26
  162. openstackclient/tests/unit/identity/v3/test_domain.py +115 -105
  163. openstackclient/tests/unit/identity/v3/test_endpoint.py +167 -172
  164. openstackclient/tests/unit/identity/v3/test_group.py +353 -202
  165. openstackclient/tests/unit/identity/v3/test_mappings.py +2 -2
  166. openstackclient/tests/unit/identity/v3/test_project.py +16 -0
  167. openstackclient/tests/unit/identity/v3/test_trust.py +5 -2
  168. openstackclient/tests/unit/identity/v3/test_user.py +102 -6
  169. openstackclient/tests/unit/image/v1/fakes.py +2 -2
  170. openstackclient/tests/unit/image/v1/test_image.py +8 -9
  171. openstackclient/tests/unit/image/v2/test_image.py +84 -46
  172. openstackclient/tests/unit/integ/cli/test_shell.py +1 -2
  173. openstackclient/tests/unit/network/test_common.py +2 -2
  174. openstackclient/tests/unit/network/v2/fakes.py +405 -485
  175. openstackclient/tests/unit/network/v2/test_floating_ip_compute.py +8 -14
  176. openstackclient/tests/unit/network/v2/test_floating_ip_network.py +62 -54
  177. openstackclient/tests/unit/network/v2/test_floating_ip_pool_compute.py +1 -1
  178. openstackclient/tests/unit/network/v2/test_l3_conntrack_helper.py +2 -2
  179. openstackclient/tests/unit/network/v2/test_ndp_proxy.py +1 -3
  180. openstackclient/tests/unit/network/v2/test_network.py +4 -4
  181. openstackclient/tests/unit/network/v2/test_network_agent.py +15 -29
  182. openstackclient/tests/unit/network/v2/test_network_compute.py +11 -11
  183. openstackclient/tests/unit/network/v2/test_network_qos_policy.py +16 -19
  184. openstackclient/tests/unit/network/v2/test_network_qos_rule.py +79 -152
  185. openstackclient/tests/unit/network/v2/test_network_qos_rule_type.py +4 -6
  186. openstackclient/tests/unit/network/v2/test_network_rbac.py +2 -2
  187. openstackclient/tests/unit/network/v2/test_network_trunk.py +2 -2
  188. openstackclient/tests/unit/network/v2/test_port.py +21 -22
  189. openstackclient/tests/unit/network/v2/test_router.py +130 -51
  190. openstackclient/tests/unit/network/v2/test_security_group_compute.py +11 -19
  191. openstackclient/tests/unit/network/v2/test_security_group_network.py +25 -27
  192. openstackclient/tests/unit/network/v2/test_security_group_rule_compute.py +15 -17
  193. openstackclient/tests/unit/network/v2/test_security_group_rule_network.py +33 -39
  194. openstackclient/tests/unit/object/v1/test_object_all.py +4 -3
  195. openstackclient/tests/unit/test_shell.py +16 -13
  196. openstackclient/tests/unit/volume/v2/fakes.py +1 -2
  197. openstackclient/tests/unit/volume/v2/test_service.py +57 -91
  198. openstackclient/tests/unit/volume/v2/test_volume.py +109 -106
  199. openstackclient/tests/unit/volume/v2/test_volume_backup.py +141 -148
  200. openstackclient/tests/unit/volume/v2/test_volume_snapshot.py +293 -283
  201. openstackclient/tests/unit/volume/v2/test_volume_transfer_request.py +1 -1
  202. openstackclient/tests/unit/volume/v3/fakes.py +2 -8
  203. openstackclient/tests/unit/volume/v3/test_block_storage_log_level.py +61 -71
  204. openstackclient/tests/unit/volume/v3/test_service.py +221 -141
  205. openstackclient/tests/unit/volume/v3/test_volume.py +131 -120
  206. openstackclient/tests/unit/volume/v3/test_volume_attachment.py +4 -4
  207. openstackclient/tests/unit/volume/v3/test_volume_backup.py +198 -203
  208. openstackclient/tests/unit/volume/v3/test_volume_snapshot.py +683 -49
  209. openstackclient/tests/unit/volume/v3/test_volume_transfer_request.py +1 -1
  210. openstackclient/volume/client.py +1 -3
  211. openstackclient/volume/v2/consistency_group.py +4 -8
  212. openstackclient/volume/v2/consistency_group_snapshot.py +1 -2
  213. openstackclient/volume/v2/qos_specs.py +1 -2
  214. openstackclient/volume/v2/service.py +41 -38
  215. openstackclient/volume/v2/volume.py +71 -53
  216. openstackclient/volume/v2/volume_backup.py +15 -10
  217. openstackclient/volume/v2/volume_snapshot.py +129 -93
  218. openstackclient/volume/v2/volume_transfer_request.py +0 -3
  219. openstackclient/volume/v2/volume_type.py +10 -21
  220. openstackclient/volume/v3/block_storage_cluster.py +3 -3
  221. openstackclient/volume/v3/block_storage_log_level.py +22 -28
  222. openstackclient/volume/v3/block_storage_manage.py +1 -3
  223. openstackclient/volume/v3/service.py +105 -14
  224. openstackclient/volume/v3/volume.py +218 -58
  225. openstackclient/volume/v3/volume_attachment.py +3 -2
  226. openstackclient/volume/v3/volume_backup.py +31 -27
  227. openstackclient/volume/v3/volume_group.py +2 -1
  228. openstackclient/volume/v3/volume_group_snapshot.py +2 -1
  229. openstackclient/volume/v3/volume_snapshot.py +489 -13
  230. openstackclient/volume/v3/volume_type.py +10 -21
  231. {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.1.0.dist-info}/AUTHORS +11 -0
  232. python_openstackclient-8.1.0.dist-info/METADATA +264 -0
  233. {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.1.0.dist-info}/RECORD +238 -259
  234. {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.1.0.dist-info}/WHEEL +1 -1
  235. {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.1.0.dist-info}/entry_points.txt +7 -47
  236. python_openstackclient-8.1.0.dist-info/pbr.json +1 -0
  237. openstackclient/tests/functional/volume/v1/__init__.py +0 -0
  238. openstackclient/tests/functional/volume/v1/common.py +0 -35
  239. openstackclient/tests/functional/volume/v1/test_qos.py +0 -100
  240. openstackclient/tests/functional/volume/v1/test_service.py +0 -76
  241. openstackclient/tests/functional/volume/v1/test_snapshot.py +0 -232
  242. openstackclient/tests/functional/volume/v1/test_transfer_request.py +0 -111
  243. openstackclient/tests/functional/volume/v1/test_volume.py +0 -228
  244. openstackclient/tests/functional/volume/v1/test_volume_type.py +0 -213
  245. openstackclient/tests/unit/volume/v1/__init__.py +0 -0
  246. openstackclient/tests/unit/volume/v1/fakes.py +0 -615
  247. openstackclient/tests/unit/volume/v1/test_qos_specs.py +0 -471
  248. openstackclient/tests/unit/volume/v1/test_service.py +0 -295
  249. openstackclient/tests/unit/volume/v1/test_transfer_request.py +0 -380
  250. openstackclient/tests/unit/volume/v1/test_type.py +0 -633
  251. openstackclient/tests/unit/volume/v1/test_volume.py +0 -1447
  252. openstackclient/tests/unit/volume/v1/test_volume_backup.py +0 -435
  253. openstackclient/volume/v1/__init__.py +0 -0
  254. openstackclient/volume/v1/qos_specs.py +0 -377
  255. openstackclient/volume/v1/service.py +0 -136
  256. openstackclient/volume/v1/volume.py +0 -734
  257. openstackclient/volume/v1/volume_backup.py +0 -302
  258. openstackclient/volume/v1/volume_snapshot.py +0 -433
  259. openstackclient/volume/v1/volume_transfer_request.py +0 -200
  260. openstackclient/volume/v1/volume_type.py +0 -520
  261. python_openstackclient-7.4.0.dist-info/METADATA +0 -172
  262. python_openstackclient-7.4.0.dist-info/pbr.json +0 -1
  263. {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.1.0.dist-info}/LICENSE +0 -0
  264. {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.1.0.dist-info}/top_level.txt +0 -0
@@ -13,6 +13,9 @@
13
13
 
14
14
  from unittest import mock
15
15
 
16
+ from openstack.block_storage.v2 import volume as _volume
17
+ from openstack import exceptions as sdk_exceptions
18
+ from openstack.test import fakes as sdk_fakes
16
19
  from osc_lib.cli import format_columns
17
20
  from osc_lib import exceptions
18
21
  from osc_lib import utils
@@ -46,12 +49,6 @@ class TestVolume(volume_fakes.TestVolume):
46
49
  self.consistencygroups_mock = self.volume_client.consistencygroups
47
50
  self.consistencygroups_mock.reset_mock()
48
51
 
49
- def setup_volumes_mock(self, count):
50
- volumes = volume_fakes.create_volumes(count=count)
51
-
52
- self.volumes_mock.get = volume_fakes.get_volumes(volumes, 0)
53
- return volumes
54
-
55
52
 
56
53
  class TestVolumeCreate(TestVolume):
57
54
  project = identity_fakes.FakeProject.create_one_project()
@@ -188,7 +185,7 @@ class TestVolumeCreate(TestVolume):
188
185
  self.new_volume.name,
189
186
  ]
190
187
  verifylist = [
191
- ('property', {'Alpha': 'a', 'Beta': 'b'}),
188
+ ('properties', {'Alpha': 'a', 'Beta': 'b'}),
192
189
  ('size', self.new_volume.size),
193
190
  ('name', self.new_volume.name),
194
191
  ]
@@ -382,9 +379,7 @@ class TestVolumeCreate(TestVolume):
382
379
  ]
383
380
  verifylist = [
384
381
  ('bootable', True),
385
- ('non_bootable', False),
386
382
  ('read_only', True),
387
- ('read_write', False),
388
383
  ('size', self.new_volume.size),
389
384
  ('name', self.new_volume.name),
390
385
  ]
@@ -427,9 +422,7 @@ class TestVolumeCreate(TestVolume):
427
422
  ]
428
423
  verifylist = [
429
424
  ('bootable', False),
430
- ('non_bootable', True),
431
425
  ('read_only', False),
432
- ('read_write', True),
433
426
  ('size', self.new_volume.size),
434
427
  ('name', self.new_volume.name),
435
428
  ]
@@ -481,9 +474,7 @@ class TestVolumeCreate(TestVolume):
481
474
  ]
482
475
  verifylist = [
483
476
  ('bootable', True),
484
- ('non_bootable', False),
485
477
  ('read_only', True),
486
- ('read_write', False),
487
478
  ('size', self.new_volume.size),
488
479
  ('name', self.new_volume.name),
489
480
  ]
@@ -532,9 +523,7 @@ class TestVolumeCreate(TestVolume):
532
523
  ]
533
524
  verifylist = [
534
525
  ('bootable', False),
535
- ('non_bootable', True),
536
526
  ('read_only', True),
537
- ('read_write', False),
538
527
  ('size', self.new_volume.size),
539
528
  ('name', self.new_volume.name),
540
529
  ]
@@ -670,37 +659,37 @@ class TestVolumeCreate(TestVolume):
670
659
  self.assertCountEqual(self.datalist, data)
671
660
 
672
661
 
673
- class TestVolumeDelete(TestVolume):
662
+ class TestVolumeDelete(volume_fakes.TestVolume):
674
663
  def setUp(self):
675
664
  super().setUp()
676
665
 
677
- self.volumes_mock.delete.return_value = None
666
+ self.volumes = list(sdk_fakes.generate_fake_resources(_volume.Volume))
667
+ self.volume_sdk_client.find_volume.side_effect = self.volumes
668
+ self.volume_sdk_client.delete_volume.return_value = None
678
669
 
679
- # Get the command object to mock
680
670
  self.cmd = volume.DeleteVolume(self.app, None)
681
671
 
682
672
  def test_volume_delete_one_volume(self):
683
- volumes = self.setup_volumes_mock(count=1)
684
-
685
- arglist = [volumes[0].id]
673
+ arglist = [self.volumes[0].id]
686
674
  verifylist = [
687
675
  ("force", False),
688
676
  ("purge", False),
689
- ("volumes", [volumes[0].id]),
677
+ ("volumes", [self.volumes[0].id]),
690
678
  ]
691
679
  parsed_args = self.check_parser(self.cmd, arglist, verifylist)
692
680
 
693
681
  result = self.cmd.take_action(parsed_args)
682
+ self.assertIsNone(result)
694
683
 
695
- self.volumes_mock.delete.assert_called_once_with(
696
- volumes[0].id, cascade=False
684
+ self.volume_sdk_client.find_volume.assert_called_once_with(
685
+ self.volumes[0].id, ignore_missing=False
686
+ )
687
+ self.volume_sdk_client.delete_volume.assert_called_once_with(
688
+ self.volumes[0].id, cascade=False, force=False
697
689
  )
698
- self.assertIsNone(result)
699
690
 
700
691
  def test_volume_delete_multi_volumes(self):
701
- volumes = self.setup_volumes_mock(count=3)
702
-
703
- arglist = [v.id for v in volumes]
692
+ arglist = [v.id for v in self.volumes]
704
693
  verifylist = [
705
694
  ('force', False),
706
695
  ('purge', False),
@@ -709,83 +698,95 @@ class TestVolumeDelete(TestVolume):
709
698
  parsed_args = self.check_parser(self.cmd, arglist, verifylist)
710
699
 
711
700
  result = self.cmd.take_action(parsed_args)
712
-
713
- calls = [mock.call(v.id, cascade=False) for v in volumes]
714
- self.volumes_mock.delete.assert_has_calls(calls)
715
701
  self.assertIsNone(result)
716
702
 
703
+ self.volume_sdk_client.find_volume.assert_has_calls(
704
+ [mock.call(v.id, ignore_missing=False) for v in self.volumes]
705
+ )
706
+ self.volume_sdk_client.delete_volume.assert_has_calls(
707
+ [mock.call(v.id, cascade=False, force=False) for v in self.volumes]
708
+ )
709
+
717
710
  def test_volume_delete_multi_volumes_with_exception(self):
718
- volumes = self.setup_volumes_mock(count=2)
711
+ self.volume_sdk_client.find_volume.side_effect = [
712
+ self.volumes[0],
713
+ sdk_exceptions.NotFoundException(),
714
+ ]
719
715
 
720
716
  arglist = [
721
- volumes[0].id,
717
+ self.volumes[0].id,
722
718
  'unexist_volume',
723
719
  ]
724
720
  verifylist = [
725
721
  ('force', False),
726
722
  ('purge', False),
727
- ('volumes', arglist),
723
+ ('volumes', [self.volumes[0].id, 'unexist_volume']),
728
724
  ]
729
725
  parsed_args = self.check_parser(self.cmd, arglist, verifylist)
730
726
 
731
- find_mock_result = [volumes[0], exceptions.CommandError]
732
- with mock.patch.object(
733
- utils, 'find_resource', side_effect=find_mock_result
734
- ) as find_mock:
735
- try:
736
- self.cmd.take_action(parsed_args)
737
- self.fail('CommandError should be raised.')
738
- except exceptions.CommandError as e:
739
- self.assertEqual('1 of 2 volumes failed to delete.', str(e))
740
-
741
- find_mock.assert_any_call(self.volumes_mock, volumes[0].id)
742
- find_mock.assert_any_call(self.volumes_mock, 'unexist_volume')
743
-
744
- self.assertEqual(2, find_mock.call_count)
745
- self.volumes_mock.delete.assert_called_once_with(
746
- volumes[0].id, cascade=False
747
- )
727
+ exc = self.assertRaises(
728
+ exceptions.CommandError,
729
+ self.cmd.take_action,
730
+ parsed_args,
731
+ )
732
+ self.assertEqual('1 of 2 volumes failed to delete.', str(exc))
748
733
 
749
- def test_volume_delete_with_purge(self):
750
- volumes = self.setup_volumes_mock(count=1)
734
+ self.volume_sdk_client.find_volume.assert_has_calls(
735
+ [
736
+ mock.call(self.volumes[0].id, ignore_missing=False),
737
+ mock.call('unexist_volume', ignore_missing=False),
738
+ ]
739
+ )
740
+ self.volume_sdk_client.delete_volume.assert_has_calls(
741
+ [
742
+ mock.call(self.volumes[0].id, cascade=False, force=False),
743
+ ]
744
+ )
751
745
 
746
+ def test_volume_delete_with_purge(self):
752
747
  arglist = [
753
748
  '--purge',
754
- volumes[0].id,
749
+ self.volumes[0].id,
755
750
  ]
756
751
  verifylist = [
757
752
  ('force', False),
758
753
  ('purge', True),
759
- ('volumes', [volumes[0].id]),
754
+ ('volumes', [self.volumes[0].id]),
760
755
  ]
761
756
  parsed_args = self.check_parser(self.cmd, arglist, verifylist)
762
757
 
763
758
  result = self.cmd.take_action(parsed_args)
759
+ self.assertIsNone(result)
764
760
 
765
- self.volumes_mock.delete.assert_called_once_with(
766
- volumes[0].id, cascade=True
761
+ self.volume_sdk_client.find_volume.assert_called_once_with(
762
+ self.volumes[0].id, ignore_missing=False
763
+ )
764
+ self.volume_sdk_client.delete_volume.assert_called_once_with(
765
+ self.volumes[0].id, cascade=True, force=False
767
766
  )
768
- self.assertIsNone(result)
769
767
 
770
768
  def test_volume_delete_with_force(self):
771
- volumes = self.setup_volumes_mock(count=1)
772
-
773
769
  arglist = [
774
770
  '--force',
775
- volumes[0].id,
771
+ self.volumes[0].id,
776
772
  ]
777
773
  verifylist = [
778
774
  ('force', True),
779
775
  ('purge', False),
780
- ('volumes', [volumes[0].id]),
776
+ ('volumes', [self.volumes[0].id]),
781
777
  ]
782
778
  parsed_args = self.check_parser(self.cmd, arglist, verifylist)
783
779
 
784
780
  result = self.cmd.take_action(parsed_args)
785
-
786
- self.volumes_mock.force_delete.assert_called_once_with(volumes[0].id)
787
781
  self.assertIsNone(result)
788
782
 
783
+ self.volume_sdk_client.find_volume.assert_called_once_with(
784
+ self.volumes[0].id, ignore_missing=False
785
+ )
786
+ self.volume_sdk_client.delete_volume.assert_called_once_with(
787
+ self.volumes[0].id, cascade=False, force=True
788
+ )
789
+
789
790
 
790
791
  class TestVolumeList(TestVolume):
791
792
  project = identity_fakes.FakeProject.create_one_project()
@@ -1407,16 +1408,16 @@ class TestVolumeSet(TestVolume):
1407
1408
  self.new_volume.id,
1408
1409
  ]
1409
1410
  verifylist = [
1410
- ('property', {'a': 'b', 'c': 'd'}),
1411
+ ('properties', {'a': 'b', 'c': 'd'}),
1411
1412
  ('volume', self.new_volume.id),
1412
- ('bootable', False),
1413
- ('non_bootable', False),
1413
+ ('bootable', None),
1414
+ ('read_only', None),
1414
1415
  ]
1415
1416
  parsed_args = self.check_parser(self.cmd, arglist, verifylist)
1416
1417
 
1417
1418
  self.cmd.take_action(parsed_args)
1418
1419
  self.volumes_mock.set_metadata.assert_called_with(
1419
- self.new_volume.id, parsed_args.property
1420
+ self.new_volume.id, parsed_args.properties
1420
1421
  )
1421
1422
 
1422
1423
  def test_volume_set_image_property(self):
@@ -1428,10 +1429,10 @@ class TestVolumeSet(TestVolume):
1428
1429
  self.new_volume.id,
1429
1430
  ]
1430
1431
  verifylist = [
1431
- ('image_property', {'Alpha': 'a', 'Beta': 'b'}),
1432
+ ('image_properties', {'Alpha': 'a', 'Beta': 'b'}),
1432
1433
  ('volume', self.new_volume.id),
1433
- ('bootable', False),
1434
- ('non_bootable', False),
1434
+ ('bootable', None),
1435
+ ('read_only', None),
1435
1436
  ]
1436
1437
  parsed_args = self.check_parser(self.cmd, arglist, verifylist)
1437
1438
 
@@ -1439,14 +1440,13 @@ class TestVolumeSet(TestVolume):
1439
1440
  # returns nothing
1440
1441
  self.cmd.take_action(parsed_args)
1441
1442
  self.volumes_mock.set_image_metadata.assert_called_with(
1442
- self.new_volume.id, parsed_args.image_property
1443
+ self.new_volume.id, parsed_args.image_properties
1443
1444
  )
1444
1445
 
1445
1446
  def test_volume_set_state(self):
1446
1447
  arglist = ['--state', 'error', self.new_volume.id]
1447
1448
  verifylist = [
1448
- ('read_only', False),
1449
- ('read_write', False),
1449
+ ('read_only', None),
1450
1450
  ('state', 'error'),
1451
1451
  ('volume', self.new_volume.id),
1452
1452
  ]
@@ -1511,36 +1511,40 @@ class TestVolumeSet(TestVolume):
1511
1511
 
1512
1512
  def test_volume_set_bootable(self):
1513
1513
  arglist = [
1514
- ['--bootable', self.new_volume.id],
1515
- ['--non-bootable', self.new_volume.id],
1514
+ '--bootable',
1515
+ self.new_volume.id,
1516
1516
  ]
1517
1517
  verifylist = [
1518
- [
1519
- ('bootable', True),
1520
- ('non_bootable', False),
1521
- ('volume', self.new_volume.id),
1522
- ],
1523
- [
1524
- ('bootable', False),
1525
- ('non_bootable', True),
1526
- ('volume', self.new_volume.id),
1527
- ],
1528
- ]
1529
- for index in range(len(arglist)):
1530
- parsed_args = self.check_parser(
1531
- self.cmd, arglist[index], verifylist[index]
1532
- )
1518
+ ('bootable', True),
1519
+ ('volume', self.new_volume.id),
1520
+ ]
1521
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
1533
1522
 
1534
- self.cmd.take_action(parsed_args)
1535
- self.volumes_mock.set_bootable.assert_called_with(
1536
- self.new_volume.id, verifylist[index][0][1]
1537
- )
1523
+ self.cmd.take_action(parsed_args)
1524
+ self.volumes_mock.set_bootable.assert_called_with(
1525
+ self.new_volume.id, verifylist[0][1]
1526
+ )
1527
+
1528
+ def test_volume_set_non_bootable(self):
1529
+ arglist = [
1530
+ '--non-bootable',
1531
+ self.new_volume.id,
1532
+ ]
1533
+ verifylist = [
1534
+ ('bootable', False),
1535
+ ('volume', self.new_volume.id),
1536
+ ]
1537
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
1538
+
1539
+ self.cmd.take_action(parsed_args)
1540
+ self.volumes_mock.set_bootable.assert_called_with(
1541
+ self.new_volume.id, verifylist[0][1]
1542
+ )
1538
1543
 
1539
- def test_volume_set_readonly(self):
1544
+ def test_volume_set_read_only(self):
1540
1545
  arglist = ['--read-only', self.new_volume.id]
1541
1546
  verifylist = [
1542
1547
  ('read_only', True),
1543
- ('read_write', False),
1544
1548
  ('volume', self.new_volume.id),
1545
1549
  ]
1546
1550
 
@@ -1556,7 +1560,6 @@ class TestVolumeSet(TestVolume):
1556
1560
  arglist = ['--read-write', self.new_volume.id]
1557
1561
  verifylist = [
1558
1562
  ('read_only', False),
1559
- ('read_write', True),
1560
1563
  ('volume', self.new_volume.id),
1561
1564
  ]
1562
1565
 
@@ -1619,7 +1622,7 @@ class TestVolumeSet(TestVolume):
1619
1622
  result = self.cmd.take_action(parsed_args)
1620
1623
  self.volumes_mock.retype.assert_not_called()
1621
1624
  mock_warning.assert_called_with(
1622
- "'--retype-policy' option will " "not work without '--type' option"
1625
+ "'--retype-policy' option will not work without '--type' option"
1623
1626
  )
1624
1627
  self.assertIsNone(result)
1625
1628
 
@@ -1686,7 +1689,7 @@ class TestVolumeUnset(TestVolume):
1686
1689
  self.new_volume.id,
1687
1690
  ]
1688
1691
  verifylist = [
1689
- ('image_property', {'Alpha': 'a', 'Beta': 'b'}),
1692
+ ('image_properties', {'Alpha': 'a', 'Beta': 'b'}),
1690
1693
  ('volume', self.new_volume.id),
1691
1694
  ]
1692
1695
  parsed_args = self.check_parser(self.cmd_set, arglist, verifylist)
@@ -1702,7 +1705,7 @@ class TestVolumeUnset(TestVolume):
1702
1705
  self.new_volume.id,
1703
1706
  ]
1704
1707
  verifylist_unset = [
1705
- ('image_property', ['Alpha']),
1708
+ ('image_properties', ['Alpha']),
1706
1709
  ('volume', self.new_volume.id),
1707
1710
  ]
1708
1711
  parsed_args_unset = self.check_parser(
@@ -1714,7 +1717,7 @@ class TestVolumeUnset(TestVolume):
1714
1717
  self.cmd_unset.take_action(parsed_args_unset)
1715
1718
 
1716
1719
  self.volumes_mock.delete_image_metadata.assert_called_with(
1717
- self.new_volume.id, parsed_args_unset.image_property
1720
+ self.new_volume.id, parsed_args_unset.image_properties
1718
1721
  )
1719
1722
 
1720
1723
  def test_volume_unset_image_property_fail(self):
@@ -1729,8 +1732,8 @@ class TestVolumeUnset(TestVolume):
1729
1732
  self.new_volume.id,
1730
1733
  ]
1731
1734
  verifylist = [
1732
- ('image_property', ['Alpha']),
1733
- ('property', ['Beta']),
1735
+ ('image_properties', ['Alpha']),
1736
+ ('properties', ['Beta']),
1734
1737
  ('volume', self.new_volume.id),
1735
1738
  ]
1736
1739
  parsed_args = self.check_parser(self.cmd_unset, arglist, verifylist)
@@ -1743,10 +1746,10 @@ class TestVolumeUnset(TestVolume):
1743
1746
  'One or more of the unset operations failed', str(e)
1744
1747
  )
1745
1748
  self.volumes_mock.delete_image_metadata.assert_called_with(
1746
- self.new_volume.id, parsed_args.image_property
1749
+ self.new_volume.id, parsed_args.image_properties
1747
1750
  )
1748
1751
  self.volumes_mock.delete_metadata.assert_called_with(
1749
- self.new_volume.id, parsed_args.property
1752
+ self.new_volume.id, parsed_args.properties
1750
1753
  )
1751
1754
 
1752
1755