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
@@ -17,6 +17,7 @@ from unittest import mock
17
17
  from openstack.block_storage.v3 import block_storage_summary as _summary
18
18
  from openstack.block_storage.v3 import snapshot as _snapshot
19
19
  from openstack.block_storage.v3 import volume as _volume
20
+ from openstack import exceptions as sdk_exceptions
20
21
  from openstack.test import fakes as sdk_fakes
21
22
  from osc_lib.cli import format_columns
22
23
  from osc_lib import exceptions
@@ -179,7 +180,7 @@ class TestVolumeCreateLegacy(volume_fakes.TestVolume):
179
180
  self.new_volume.name,
180
181
  ]
181
182
  verifylist = [
182
- ('property', {'Alpha': 'a', 'Beta': 'b'}),
183
+ ('properties', {'Alpha': 'a', 'Beta': 'b'}),
183
184
  ('size', self.new_volume.size),
184
185
  ('name', self.new_volume.name),
185
186
  ]
@@ -440,9 +441,7 @@ class TestVolumeCreateLegacy(volume_fakes.TestVolume):
440
441
  ]
441
442
  verifylist = [
442
443
  ('bootable', True),
443
- ('non_bootable', False),
444
444
  ('read_only', True),
445
- ('read_write', False),
446
445
  ('size', self.new_volume.size),
447
446
  ('name', self.new_volume.name),
448
447
  ]
@@ -486,9 +485,7 @@ class TestVolumeCreateLegacy(volume_fakes.TestVolume):
486
485
  ]
487
486
  verifylist = [
488
487
  ('bootable', False),
489
- ('non_bootable', True),
490
488
  ('read_only', False),
491
- ('read_write', True),
492
489
  ('size', self.new_volume.size),
493
490
  ('name', self.new_volume.name),
494
491
  ]
@@ -541,9 +538,7 @@ class TestVolumeCreateLegacy(volume_fakes.TestVolume):
541
538
  ]
542
539
  verifylist = [
543
540
  ('bootable', True),
544
- ('non_bootable', False),
545
541
  ('read_only', True),
546
- ('read_write', False),
547
542
  ('size', self.new_volume.size),
548
543
  ('name', self.new_volume.name),
549
544
  ]
@@ -593,9 +588,7 @@ class TestVolumeCreateLegacy(volume_fakes.TestVolume):
593
588
  ]
594
589
  verifylist = [
595
590
  ('bootable', False),
596
- ('non_bootable', True),
597
591
  ('read_only', True),
598
- ('read_write', False),
599
592
  ('size', self.new_volume.size),
600
593
  ('name', self.new_volume.name),
601
594
  ]
@@ -838,7 +831,7 @@ class TestVolumeCreate(volume_fakes.TestVolume):
838
831
  description=parsed_args.description,
839
832
  volume_type=parsed_args.type,
840
833
  availability_zone=parsed_args.availability_zone,
841
- metadata=parsed_args.property,
834
+ metadata=parsed_args.properties,
842
835
  bootable=parsed_args.bootable,
843
836
  cluster=getattr(parsed_args, 'cluster', None),
844
837
  )
@@ -962,16 +955,17 @@ class TestVolumeCreate(volume_fakes.TestVolume):
962
955
  )
963
956
 
964
957
 
965
- class TestVolumeDeleteLegacy(volume_fakes.TestVolume):
958
+ class TestVolumeDelete(volume_fakes.TestVolume):
966
959
  def setUp(self):
967
960
  super().setUp()
968
961
 
969
962
  self.volumes_mock = self.volume_client.volumes
970
963
  self.volumes_mock.reset_mock()
971
964
 
972
- self.volumes_mock.delete.return_value = None
973
- self.volumes = volume_fakes.create_volumes(count=1)
974
- self.volumes_mock.get = volume_fakes.get_volumes(self.volumes, 0)
965
+ self.volumes = list(sdk_fakes.generate_fake_resources(_volume.Volume))
966
+ self.volume_sdk_client.find_volume.side_effect = self.volumes
967
+ self.volume_sdk_client.delete_volume.return_value = None
968
+ self.volume_sdk_client.unmanage_volume.return_value = None
975
969
 
976
970
  # Get the command object to mock
977
971
  self.cmd = volume.DeleteVolume(self.app, None)
@@ -986,11 +980,14 @@ class TestVolumeDeleteLegacy(volume_fakes.TestVolume):
986
980
  parsed_args = self.check_parser(self.cmd, arglist, verifylist)
987
981
 
988
982
  result = self.cmd.take_action(parsed_args)
983
+ self.assertIsNone(result)
989
984
 
990
- self.volumes_mock.delete.assert_called_once_with(
991
- self.volumes[0].id, cascade=False
985
+ self.volume_sdk_client.find_volume.assert_called_once_with(
986
+ self.volumes[0].id, ignore_missing=False
987
+ )
988
+ self.volume_sdk_client.delete_volume.assert_called_once_with(
989
+ self.volumes[0].id, cascade=False, force=False
992
990
  )
993
- self.assertIsNone(result)
994
991
 
995
992
  def test_volume_delete_multi_volumes(self):
996
993
  arglist = [v.id for v in self.volumes]
@@ -1002,12 +999,21 @@ class TestVolumeDeleteLegacy(volume_fakes.TestVolume):
1002
999
  parsed_args = self.check_parser(self.cmd, arglist, verifylist)
1003
1000
 
1004
1001
  result = self.cmd.take_action(parsed_args)
1005
-
1006
- calls = [mock.call(v.id, cascade=False) for v in self.volumes]
1007
- self.volumes_mock.delete.assert_has_calls(calls)
1008
1002
  self.assertIsNone(result)
1009
1003
 
1004
+ self.volume_sdk_client.find_volume.assert_has_calls(
1005
+ [mock.call(v.id, ignore_missing=False) for v in self.volumes]
1006
+ )
1007
+ self.volume_sdk_client.delete_volume.assert_has_calls(
1008
+ [mock.call(v.id, cascade=False, force=False) for v in self.volumes]
1009
+ )
1010
+
1010
1011
  def test_volume_delete_multi_volumes_with_exception(self):
1012
+ self.volume_sdk_client.find_volume.side_effect = [
1013
+ self.volumes[0],
1014
+ sdk_exceptions.NotFoundException(),
1015
+ ]
1016
+
1011
1017
  arglist = [
1012
1018
  self.volumes[0].id,
1013
1019
  'unexist_volume',
@@ -1015,27 +1021,28 @@ class TestVolumeDeleteLegacy(volume_fakes.TestVolume):
1015
1021
  verifylist = [
1016
1022
  ('force', False),
1017
1023
  ('purge', False),
1018
- ('volumes', arglist),
1024
+ ('volumes', [self.volumes[0].id, 'unexist_volume']),
1019
1025
  ]
1020
1026
  parsed_args = self.check_parser(self.cmd, arglist, verifylist)
1021
1027
 
1022
- find_mock_result = [self.volumes[0], exceptions.CommandError]
1023
- with mock.patch.object(
1024
- utils, 'find_resource', side_effect=find_mock_result
1025
- ) as find_mock:
1026
- try:
1027
- self.cmd.take_action(parsed_args)
1028
- self.fail('CommandError should be raised.')
1029
- except exceptions.CommandError as e:
1030
- self.assertEqual('1 of 2 volumes failed to delete.', str(e))
1031
-
1032
- find_mock.assert_any_call(self.volumes_mock, self.volumes[0].id)
1033
- find_mock.assert_any_call(self.volumes_mock, 'unexist_volume')
1034
-
1035
- self.assertEqual(2, find_mock.call_count)
1036
- self.volumes_mock.delete.assert_called_once_with(
1037
- self.volumes[0].id, cascade=False
1038
- )
1028
+ exc = self.assertRaises(
1029
+ exceptions.CommandError,
1030
+ self.cmd.take_action,
1031
+ parsed_args,
1032
+ )
1033
+ self.assertEqual('1 of 2 volumes failed to delete.', str(exc))
1034
+
1035
+ self.volume_sdk_client.find_volume.assert_has_calls(
1036
+ [
1037
+ mock.call(self.volumes[0].id, ignore_missing=False),
1038
+ mock.call('unexist_volume', ignore_missing=False),
1039
+ ]
1040
+ )
1041
+ self.volume_sdk_client.delete_volume.assert_has_calls(
1042
+ [
1043
+ mock.call(self.volumes[0].id, cascade=False, force=False),
1044
+ ]
1045
+ )
1039
1046
 
1040
1047
  def test_volume_delete_with_purge(self):
1041
1048
  arglist = [
@@ -1050,11 +1057,14 @@ class TestVolumeDeleteLegacy(volume_fakes.TestVolume):
1050
1057
  parsed_args = self.check_parser(self.cmd, arglist, verifylist)
1051
1058
 
1052
1059
  result = self.cmd.take_action(parsed_args)
1060
+ self.assertIsNone(result)
1053
1061
 
1054
- self.volumes_mock.delete.assert_called_once_with(
1055
- self.volumes[0].id, cascade=True
1062
+ self.volume_sdk_client.find_volume.assert_called_once_with(
1063
+ self.volumes[0].id, ignore_missing=False
1064
+ )
1065
+ self.volume_sdk_client.delete_volume.assert_called_once_with(
1066
+ self.volumes[0].id, cascade=True, force=False
1056
1067
  )
1057
- self.assertIsNone(result)
1058
1068
 
1059
1069
  def test_volume_delete_with_force(self):
1060
1070
  arglist = [
@@ -1069,49 +1079,38 @@ class TestVolumeDeleteLegacy(volume_fakes.TestVolume):
1069
1079
  parsed_args = self.check_parser(self.cmd, arglist, verifylist)
1070
1080
 
1071
1081
  result = self.cmd.take_action(parsed_args)
1072
-
1073
- self.volumes_mock.force_delete.assert_called_once_with(
1074
- self.volumes[0].id
1075
- )
1076
1082
  self.assertIsNone(result)
1077
1083
 
1078
-
1079
- class TestVolumeDelete(volume_fakes.TestVolume):
1080
- def setUp(self):
1081
- super().setUp()
1082
-
1083
- self.volumes_mock = self.volume_client.volumes
1084
- self.volumes_mock.reset_mock()
1085
- self.volume_sdk_client.unmanage_volume.return_value = None
1086
-
1087
- # Get the command object to mock
1088
- self.cmd = volume.DeleteVolume(self.app, None)
1084
+ self.volume_sdk_client.find_volume.assert_called_once_with(
1085
+ self.volumes[0].id, ignore_missing=False
1086
+ )
1087
+ self.volume_sdk_client.delete_volume.assert_called_once_with(
1088
+ self.volumes[0].id, cascade=False, force=True
1089
+ )
1089
1090
 
1090
1091
  def test_volume_delete_remote(self):
1091
- vol = sdk_fakes.generate_fake_resource(_volume.Volume, **{'size': 1})
1092
- self.volumes_mock.get.return_value = vol
1093
-
1094
- arglist = ['--remote', vol.id]
1092
+ arglist = ['--remote', self.volumes[0].id]
1095
1093
  verifylist = [
1096
1094
  ("remote", True),
1097
1095
  ("force", False),
1098
1096
  ("purge", False),
1099
- ("volumes", [vol.id]),
1097
+ ("volumes", [self.volumes[0].id]),
1100
1098
  ]
1101
1099
  parsed_args = self.check_parser(self.cmd, arglist, verifylist)
1102
1100
 
1103
1101
  result = self.cmd.take_action(parsed_args)
1104
-
1105
- self.volume_sdk_client.unmanage_volume.assert_called_once_with(vol.id)
1106
1102
  self.assertIsNone(result)
1107
1103
 
1108
- def test_volume_delete_multi_volumes_remote(self):
1109
- volumes = sdk_fakes.generate_fake_resources(
1110
- _volume.Volume, count=3, attrs={'size': 1}
1104
+ self.volume_sdk_client.find_volume.assert_called_once_with(
1105
+ self.volumes[0].id, ignore_missing=False
1106
+ )
1107
+ self.volume_sdk_client.delete_volume.assert_not_called()
1108
+ self.volume_sdk_client.unmanage_volume.assert_called_once_with(
1109
+ self.volumes[0].id
1111
1110
  )
1112
1111
 
1113
- arglist = ['--remote']
1114
- arglist += [v.id for v in volumes]
1112
+ def test_volume_delete_multi_volumes_remote(self):
1113
+ arglist = ['--remote'] + [v.id for v in self.volumes]
1115
1114
  verifylist = [
1116
1115
  ('remote', True),
1117
1116
  ('force', False),
@@ -1121,24 +1120,27 @@ class TestVolumeDelete(volume_fakes.TestVolume):
1121
1120
  parsed_args = self.check_parser(self.cmd, arglist, verifylist)
1122
1121
 
1123
1122
  result = self.cmd.take_action(parsed_args)
1124
-
1125
- calls = [mock.call(v.id) for v in volumes]
1126
- self.volume_sdk_client.unmanage_volume.assert_has_calls(calls)
1127
1123
  self.assertIsNone(result)
1128
1124
 
1129
- def test_volume_delete_remote_with_purge(self):
1130
- vol = sdk_fakes.generate_fake_resource(_volume.Volume, **{'size': 1})
1125
+ self.volume_sdk_client.find_volume.assert_has_calls(
1126
+ [mock.call(v.id, ignore_missing=False) for v in self.volumes]
1127
+ )
1128
+ self.volume_sdk_client.delete_volume.assert_not_called()
1129
+ self.volume_sdk_client.unmanage_volume.assert_has_calls(
1130
+ [mock.call(v.id) for v in self.volumes]
1131
+ )
1131
1132
 
1133
+ def test_volume_delete_remote_with_purge(self):
1132
1134
  arglist = [
1133
1135
  '--remote',
1134
1136
  '--purge',
1135
- vol.id,
1137
+ self.volumes[0].id,
1136
1138
  ]
1137
1139
  verifylist = [
1138
1140
  ('remote', True),
1139
1141
  ('force', False),
1140
1142
  ('purge', True),
1141
- ('volumes', [vol.id]),
1143
+ ('volumes', [self.volumes[0].id]),
1142
1144
  ]
1143
1145
 
1144
1146
  parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -1151,19 +1153,21 @@ class TestVolumeDelete(volume_fakes.TestVolume):
1151
1153
  str(exc),
1152
1154
  )
1153
1155
 
1154
- def test_volume_delete_remote_with_force(self):
1155
- vol = sdk_fakes.generate_fake_resource(_volume.Volume, **{'size': 1})
1156
+ self.volume_sdk_client.find_volume.assert_not_called()
1157
+ self.volume_sdk_client.delete_volume.assert_not_called()
1158
+ self.volume_sdk_client.unmanage_volume.assert_not_called()
1156
1159
 
1160
+ def test_volume_delete_remote_with_force(self):
1157
1161
  arglist = [
1158
1162
  '--remote',
1159
1163
  '--force',
1160
- vol.id,
1164
+ self.volumes[0].id,
1161
1165
  ]
1162
1166
  verifylist = [
1163
1167
  ('remote', True),
1164
1168
  ('force', True),
1165
1169
  ('purge', False),
1166
- ('volumes', [vol.id]),
1170
+ ('volumes', [self.volumes[0].id]),
1167
1171
  ]
1168
1172
 
1169
1173
  parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -1176,6 +1180,10 @@ class TestVolumeDelete(volume_fakes.TestVolume):
1176
1180
  str(exc),
1177
1181
  )
1178
1182
 
1183
+ self.volume_sdk_client.find_volume.assert_not_called()
1184
+ self.volume_sdk_client.delete_volume.assert_not_called()
1185
+ self.volume_sdk_client.unmanage_volume.assert_not_called()
1186
+
1179
1187
 
1180
1188
  class TestVolumeList(volume_fakes.TestVolume):
1181
1189
  project = identity_fakes.FakeProject.create_one_project()
@@ -1815,16 +1823,16 @@ class TestVolumeSet(volume_fakes.TestVolume):
1815
1823
  self.new_volume.id,
1816
1824
  ]
1817
1825
  verifylist = [
1818
- ('property', {'a': 'b', 'c': 'd'}),
1826
+ ('properties', {'a': 'b', 'c': 'd'}),
1827
+ ('read_only', None),
1828
+ ('bootable', None),
1819
1829
  ('volume', self.new_volume.id),
1820
- ('bootable', False),
1821
- ('non_bootable', False),
1822
1830
  ]
1823
1831
  parsed_args = self.check_parser(self.cmd, arglist, verifylist)
1824
1832
 
1825
1833
  self.cmd.take_action(parsed_args)
1826
1834
  self.volumes_mock.set_metadata.assert_called_with(
1827
- self.new_volume.id, parsed_args.property
1835
+ self.new_volume.id, parsed_args.properties
1828
1836
  )
1829
1837
 
1830
1838
  def test_volume_set_image_property(self):
@@ -1836,10 +1844,10 @@ class TestVolumeSet(volume_fakes.TestVolume):
1836
1844
  self.new_volume.id,
1837
1845
  ]
1838
1846
  verifylist = [
1839
- ('image_property', {'Alpha': 'a', 'Beta': 'b'}),
1847
+ ('image_properties', {'Alpha': 'a', 'Beta': 'b'}),
1848
+ ('read_only', None),
1849
+ ('bootable', None),
1840
1850
  ('volume', self.new_volume.id),
1841
- ('bootable', False),
1842
- ('non_bootable', False),
1843
1851
  ]
1844
1852
  parsed_args = self.check_parser(self.cmd, arglist, verifylist)
1845
1853
 
@@ -1847,15 +1855,15 @@ class TestVolumeSet(volume_fakes.TestVolume):
1847
1855
  # returns nothing
1848
1856
  self.cmd.take_action(parsed_args)
1849
1857
  self.volumes_mock.set_image_metadata.assert_called_with(
1850
- self.new_volume.id, parsed_args.image_property
1858
+ self.new_volume.id, parsed_args.image_properties
1851
1859
  )
1852
1860
 
1853
1861
  def test_volume_set_state(self):
1854
1862
  arglist = ['--state', 'error', self.new_volume.id]
1855
1863
  verifylist = [
1856
- ('read_only', False),
1857
- ('read_write', False),
1858
1864
  ('state', 'error'),
1865
+ ('read_only', None),
1866
+ ('bootable', None),
1859
1867
  ('volume', self.new_volume.id),
1860
1868
  ]
1861
1869
 
@@ -1919,36 +1927,40 @@ class TestVolumeSet(volume_fakes.TestVolume):
1919
1927
 
1920
1928
  def test_volume_set_bootable(self):
1921
1929
  arglist = [
1922
- ['--bootable', self.new_volume.id],
1923
- ['--non-bootable', self.new_volume.id],
1930
+ '--bootable',
1931
+ self.new_volume.id,
1924
1932
  ]
1925
1933
  verifylist = [
1926
- [
1927
- ('bootable', True),
1928
- ('non_bootable', False),
1929
- ('volume', self.new_volume.id),
1930
- ],
1931
- [
1932
- ('bootable', False),
1933
- ('non_bootable', True),
1934
- ('volume', self.new_volume.id),
1935
- ],
1936
- ]
1937
- for index in range(len(arglist)):
1938
- parsed_args = self.check_parser(
1939
- self.cmd, arglist[index], verifylist[index]
1940
- )
1934
+ ('bootable', True),
1935
+ ('volume', self.new_volume.id),
1936
+ ]
1937
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
1941
1938
 
1942
- self.cmd.take_action(parsed_args)
1943
- self.volumes_mock.set_bootable.assert_called_with(
1944
- self.new_volume.id, verifylist[index][0][1]
1945
- )
1939
+ self.cmd.take_action(parsed_args)
1940
+ self.volumes_mock.set_bootable.assert_called_with(
1941
+ self.new_volume.id, verifylist[0][1]
1942
+ )
1943
+
1944
+ def test_volume_set_non_bootable(self):
1945
+ arglist = [
1946
+ '--non-bootable',
1947
+ self.new_volume.id,
1948
+ ]
1949
+ verifylist = [
1950
+ ('bootable', False),
1951
+ ('volume', self.new_volume.id),
1952
+ ]
1953
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
1954
+
1955
+ self.cmd.take_action(parsed_args)
1956
+ self.volumes_mock.set_bootable.assert_called_with(
1957
+ self.new_volume.id, verifylist[0][1]
1958
+ )
1946
1959
 
1947
1960
  def test_volume_set_readonly(self):
1948
1961
  arglist = ['--read-only', self.new_volume.id]
1949
1962
  verifylist = [
1950
1963
  ('read_only', True),
1951
- ('read_write', False),
1952
1964
  ('volume', self.new_volume.id),
1953
1965
  ]
1954
1966
 
@@ -1964,7 +1976,6 @@ class TestVolumeSet(volume_fakes.TestVolume):
1964
1976
  arglist = ['--read-write', self.new_volume.id]
1965
1977
  verifylist = [
1966
1978
  ('read_only', False),
1967
- ('read_write', True),
1968
1979
  ('volume', self.new_volume.id),
1969
1980
  ]
1970
1981
 
@@ -2027,7 +2038,7 @@ class TestVolumeSet(volume_fakes.TestVolume):
2027
2038
  result = self.cmd.take_action(parsed_args)
2028
2039
  self.volumes_mock.retype.assert_not_called()
2029
2040
  mock_warning.assert_called_with(
2030
- "'--retype-policy' option will " "not work without '--type' option"
2041
+ "'--retype-policy' option will not work without '--type' option"
2031
2042
  )
2032
2043
  self.assertIsNone(result)
2033
2044
 
@@ -2100,7 +2111,7 @@ class TestVolumeUnset(volume_fakes.TestVolume):
2100
2111
  self.new_volume.id,
2101
2112
  ]
2102
2113
  verifylist = [
2103
- ('image_property', {'Alpha': 'a', 'Beta': 'b'}),
2114
+ ('image_properties', {'Alpha': 'a', 'Beta': 'b'}),
2104
2115
  ('volume', self.new_volume.id),
2105
2116
  ]
2106
2117
  parsed_args = self.check_parser(self.cmd_set, arglist, verifylist)
@@ -2116,7 +2127,7 @@ class TestVolumeUnset(volume_fakes.TestVolume):
2116
2127
  self.new_volume.id,
2117
2128
  ]
2118
2129
  verifylist_unset = [
2119
- ('image_property', ['Alpha']),
2130
+ ('image_properties', ['Alpha']),
2120
2131
  ('volume', self.new_volume.id),
2121
2132
  ]
2122
2133
  parsed_args_unset = self.check_parser(
@@ -2128,7 +2139,7 @@ class TestVolumeUnset(volume_fakes.TestVolume):
2128
2139
  self.cmd_unset.take_action(parsed_args_unset)
2129
2140
 
2130
2141
  self.volumes_mock.delete_image_metadata.assert_called_with(
2131
- self.new_volume.id, parsed_args_unset.image_property
2142
+ self.new_volume.id, parsed_args_unset.image_properties
2132
2143
  )
2133
2144
 
2134
2145
  def test_volume_unset_image_property_fail(self):
@@ -2143,8 +2154,8 @@ class TestVolumeUnset(volume_fakes.TestVolume):
2143
2154
  self.new_volume.id,
2144
2155
  ]
2145
2156
  verifylist = [
2146
- ('image_property', ['Alpha']),
2147
- ('property', ['Beta']),
2157
+ ('image_properties', ['Alpha']),
2158
+ ('properties', ['Beta']),
2148
2159
  ('volume', self.new_volume.id),
2149
2160
  ]
2150
2161
  parsed_args = self.check_parser(self.cmd_unset, arglist, verifylist)
@@ -2157,10 +2168,10 @@ class TestVolumeUnset(volume_fakes.TestVolume):
2157
2168
  'One or more of the unset operations failed', str(e)
2158
2169
  )
2159
2170
  self.volumes_mock.delete_image_metadata.assert_called_with(
2160
- self.new_volume.id, parsed_args.image_property
2171
+ self.new_volume.id, parsed_args.image_properties
2161
2172
  )
2162
2173
  self.volumes_mock.delete_metadata.assert_called_with(
2163
- self.new_volume.id, parsed_args.property
2174
+ self.new_volume.id, parsed_args.properties
2164
2175
  )
2165
2176
 
2166
2177
 
@@ -28,7 +28,7 @@ class TestVolumeAttachment(volume_fakes.TestVolume):
28
28
 
29
29
  class TestVolumeAttachmentCreate(TestVolumeAttachment):
30
30
  volume = volume_fakes.create_one_volume()
31
- server = compute_fakes.create_one_sdk_server()
31
+ server = compute_fakes.create_one_server()
32
32
  volume_attachment = volume_fakes.create_one_volume_attachment(
33
33
  attrs={'instance': server.id, 'volume_id': volume.id},
34
34
  )
@@ -61,7 +61,7 @@ class TestVolumeAttachmentCreate(TestVolumeAttachment):
61
61
  self.volume_sdk_client.create_attachment.return_value = (
62
62
  self.volume_attachment.to_dict()
63
63
  )
64
- self.compute_sdk_client.find_server.return_value = self.server
64
+ self.compute_client.find_server.return_value = self.server
65
65
 
66
66
  self.cmd = volume_attachment.CreateVolumeAttachment(self.app, None)
67
67
 
@@ -92,7 +92,7 @@ class TestVolumeAttachmentCreate(TestVolumeAttachment):
92
92
  self.volume_sdk_client.find_volume.assert_called_once_with(
93
93
  self.volume.id, ignore_missing=False
94
94
  )
95
- self.compute_sdk_client.find_server.assert_called_once_with(
95
+ self.compute_client.find_server.assert_called_once_with(
96
96
  self.server.id, ignore_missing=False
97
97
  )
98
98
  self.volume_sdk_client.create_attachment.assert_called_once_with(
@@ -159,7 +159,7 @@ class TestVolumeAttachmentCreate(TestVolumeAttachment):
159
159
  self.volume_sdk_client.find_volume.assert_called_once_with(
160
160
  self.volume.id, ignore_missing=False
161
161
  )
162
- self.compute_sdk_client.find_server.assert_called_once_with(
162
+ self.compute_client.find_server.assert_called_once_with(
163
163
  self.server.id, ignore_missing=False
164
164
  )
165
165
  self.volume_sdk_client.create_attachment.assert_called_once_with(