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
@@ -218,17 +218,39 @@ class ImageTests(base.BaseImageTests):
218
218
  'image remove project ' + self.name + ' ' + my_project_id
219
219
  )
220
220
 
221
- # else:
222
- # # Test not shared
223
- # self.assertRaises(
224
- # image_exceptions.HTTPForbidden,
225
- # self.openstack,
226
- # 'image add project ' +
227
- # self.name + ' ' +
228
- # my_project_id
229
- # )
230
- # self.openstack(
231
- # 'image set ' +
232
- # '--share ' +
233
- # self.name
234
- # )
221
+ def test_image_hidden(self):
222
+ # Test image is shown in list
223
+ output = self.openstack(
224
+ 'image list',
225
+ parse_output=True,
226
+ )
227
+ self.assertIn(
228
+ self.name,
229
+ [img['Name'] for img in output],
230
+ )
231
+
232
+ # Hide the image and test image not show in the list
233
+ self.openstack('image set ' + '--hidden ' + self.name)
234
+ output = self.openstack(
235
+ 'image list',
236
+ parse_output=True,
237
+ )
238
+ self.assertNotIn(self.name, [img['Name'] for img in output])
239
+
240
+ # Test image show in the list with flag
241
+ output = self.openstack(
242
+ 'image list',
243
+ parse_output=True,
244
+ )
245
+ self.assertNotIn(self.name, [img['Name'] for img in output])
246
+
247
+ # Unhide the image and test image is again visible in regular list
248
+ self.openstack('image set ' + '--unhidden ' + self.name)
249
+ output = self.openstack(
250
+ 'image list',
251
+ parse_output=True,
252
+ )
253
+ self.assertIn(
254
+ self.name,
255
+ [img['Name'] for img in output],
256
+ )
@@ -0,0 +1,55 @@
1
+ # Licensed under the Apache License, Version 2.0 (the "License"); you may
2
+ # not use this file except in compliance with the License. You may obtain
3
+ # a copy of the License at
4
+ #
5
+ # http://www.apache.org/licenses/LICENSE-2.0
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software
8
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10
+ # License for the specific language governing permissions and limitations
11
+ # under the License.
12
+
13
+ import uuid
14
+
15
+ from openstackclient.tests.functional.image import base
16
+
17
+
18
+ class ImageMetadefResourceTypeTests(base.BaseImageTests):
19
+ """Functional tests for image metadef resource type commands."""
20
+
21
+ def setUp(self):
22
+ super().setUp()
23
+
24
+ # Create unique namespace name using UUID
25
+ self.namespace_name = 'test-mdef-ns-' + uuid.uuid4().hex
26
+ self.resource_type_name = 'test-mdef-rt-' + uuid.uuid4().hex
27
+
28
+ # Create namespace
29
+ self.openstack('image metadef namespace create ' + self.namespace_name)
30
+ self.addCleanup(
31
+ self.openstack,
32
+ 'image metadef namespace delete ' + self.namespace_name,
33
+ )
34
+
35
+ def test_metadef_resource_type(self):
36
+ """Test image metadef resource type commands"""
37
+
38
+ self.openstack(
39
+ 'image metadef resource type association create '
40
+ f'{self.namespace_name} {self.resource_type_name}',
41
+ )
42
+ self.addCleanup(
43
+ self.openstack,
44
+ 'image metadef resource type association delete '
45
+ f'{self.namespace_name} {self.resource_type_name}',
46
+ )
47
+
48
+ output = self.openstack(
49
+ 'image metadef resource type list',
50
+ parse_output=True,
51
+ )
52
+
53
+ self.assertIn(
54
+ self.resource_type_name, [item['Name'] for item in output]
55
+ )
@@ -171,7 +171,7 @@ class VolumeTests(common.BaseVolumeTests):
171
171
  cmd_output["volume_image_metadata"],
172
172
  )
173
173
  self.assertEqual(
174
- 'true',
174
+ True,
175
175
  cmd_output["bootable"],
176
176
  )
177
177
 
@@ -124,7 +124,7 @@ class VolumeTests(common.BaseVolumeTests):
124
124
  cmd_output["properties"],
125
125
  )
126
126
  self.assertEqual(
127
- 'false',
127
+ False,
128
128
  cmd_output["bootable"],
129
129
  )
130
130
  self.wait_for_status("volume", name, "available")
@@ -172,7 +172,7 @@ class VolumeTests(common.BaseVolumeTests):
172
172
  cmd_output["volume_image_metadata"],
173
173
  )
174
174
  self.assertEqual(
175
- 'true',
175
+ True,
176
176
  cmd_output["bootable"],
177
177
  )
178
178
 
@@ -0,0 +1,124 @@
1
+ # Licensed under the Apache License, Version 2.0 (the "License"); you may
2
+ # not use this file except in compliance with the License. You may obtain
3
+ # a copy of the License at
4
+ #
5
+ # http://www.apache.org/licenses/LICENSE-2.0
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software
8
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10
+ # License for the specific language governing permissions and limitations
11
+ # under the License.
12
+ #
13
+
14
+ """Volume v2 API Library Tests"""
15
+
16
+ import http
17
+ from unittest import mock
18
+ import uuid
19
+
20
+ from openstack.block_storage.v2 import _proxy
21
+ from osc_lib import exceptions as osc_lib_exceptions
22
+
23
+ from openstackclient.api import volume_v2 as volume
24
+ from openstackclient.tests.unit import fakes
25
+ from openstackclient.tests.unit import utils
26
+
27
+
28
+ class TestConsistencyGroup(utils.TestCase):
29
+ def setUp(self):
30
+ super().setUp()
31
+
32
+ self.volume_sdk_client = mock.Mock(_proxy.Proxy)
33
+
34
+ def test_find_consistency_group_by_id(self):
35
+ cg_id = uuid.uuid4().hex
36
+ cg_name = 'name-' + uuid.uuid4().hex
37
+ data = {
38
+ 'consistencygroup': {
39
+ 'id': cg_id,
40
+ 'name': cg_name,
41
+ 'status': 'available',
42
+ 'availability_zone': 'az1',
43
+ 'created_at': '2015-09-16T09:28:52.000000',
44
+ 'description': 'description-' + uuid.uuid4().hex,
45
+ 'volume_types': ['123456'],
46
+ }
47
+ }
48
+ self.volume_sdk_client.get.side_effect = [
49
+ fakes.FakeResponse(data=data),
50
+ ]
51
+
52
+ result = volume.find_consistency_group(self.volume_sdk_client, cg_id)
53
+
54
+ self.volume_sdk_client.get.assert_has_calls(
55
+ [
56
+ mock.call(f'/consistencygroups/{cg_id}'),
57
+ ]
58
+ )
59
+ self.assertEqual(data['consistencygroup'], result)
60
+
61
+ def test_find_consistency_group_by_name(self):
62
+ cg_id = uuid.uuid4().hex
63
+ cg_name = 'name-' + uuid.uuid4().hex
64
+ data = {
65
+ 'consistencygroups': [
66
+ {
67
+ 'id': cg_id,
68
+ 'name': cg_name,
69
+ }
70
+ ],
71
+ }
72
+ self.volume_sdk_client.get.side_effect = [
73
+ fakes.FakeResponse(status_code=http.HTTPStatus.NOT_FOUND),
74
+ fakes.FakeResponse(data=data),
75
+ ]
76
+
77
+ result = volume.find_consistency_group(self.volume_sdk_client, cg_name)
78
+
79
+ self.volume_sdk_client.get.assert_has_calls(
80
+ [
81
+ mock.call(f'/consistencygroups/{cg_name}'),
82
+ mock.call('/consistencygroups'),
83
+ ]
84
+ )
85
+ self.assertEqual(data['consistencygroups'][0], result)
86
+
87
+ def test_find_consistency_group_not_found(self):
88
+ data = {'consistencygroups': []}
89
+ self.volume_sdk_client.get.side_effect = [
90
+ fakes.FakeResponse(status_code=http.HTTPStatus.NOT_FOUND),
91
+ fakes.FakeResponse(data=data),
92
+ ]
93
+ self.assertRaises(
94
+ osc_lib_exceptions.NotFound,
95
+ volume.find_consistency_group,
96
+ self.volume_sdk_client,
97
+ 'invalid-cg',
98
+ )
99
+
100
+ def test_find_consistency_group_by_name_duplicate(self):
101
+ cg_name = 'name-' + uuid.uuid4().hex
102
+ data = {
103
+ 'consistencygroups': [
104
+ {
105
+ 'id': uuid.uuid4().hex,
106
+ 'name': cg_name,
107
+ },
108
+ {
109
+ 'id': uuid.uuid4().hex,
110
+ 'name': cg_name,
111
+ },
112
+ ],
113
+ }
114
+ self.volume_sdk_client.get.side_effect = [
115
+ fakes.FakeResponse(status_code=http.HTTPStatus.NOT_FOUND),
116
+ fakes.FakeResponse(data=data),
117
+ ]
118
+
119
+ self.assertRaises(
120
+ osc_lib_exceptions.NotFound,
121
+ volume.find_consistency_group,
122
+ self.volume_sdk_client,
123
+ cg_name,
124
+ )
@@ -0,0 +1,124 @@
1
+ # Licensed under the Apache License, Version 2.0 (the "License"); you may
2
+ # not use this file except in compliance with the License. You may obtain
3
+ # a copy of the License at
4
+ #
5
+ # http://www.apache.org/licenses/LICENSE-2.0
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software
8
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10
+ # License for the specific language governing permissions and limitations
11
+ # under the License.
12
+ #
13
+
14
+ """Volume v3 API Library Tests"""
15
+
16
+ import http
17
+ from unittest import mock
18
+ import uuid
19
+
20
+ from openstack.block_storage.v3 import _proxy
21
+ from osc_lib import exceptions as osc_lib_exceptions
22
+
23
+ from openstackclient.api import volume_v3 as volume
24
+ from openstackclient.tests.unit import fakes
25
+ from openstackclient.tests.unit import utils
26
+
27
+
28
+ class TestConsistencyGroup(utils.TestCase):
29
+ def setUp(self):
30
+ super().setUp()
31
+
32
+ self.volume_sdk_client = mock.Mock(_proxy.Proxy)
33
+
34
+ def test_find_consistency_group_by_id(self):
35
+ cg_id = uuid.uuid4().hex
36
+ cg_name = 'name-' + uuid.uuid4().hex
37
+ data = {
38
+ 'consistencygroup': {
39
+ 'id': cg_id,
40
+ 'name': cg_name,
41
+ 'status': 'available',
42
+ 'availability_zone': 'az1',
43
+ 'created_at': '2015-09-16T09:28:52.000000',
44
+ 'description': 'description-' + uuid.uuid4().hex,
45
+ 'volume_types': ['123456'],
46
+ }
47
+ }
48
+ self.volume_sdk_client.get.side_effect = [
49
+ fakes.FakeResponse(data=data),
50
+ ]
51
+
52
+ result = volume.find_consistency_group(self.volume_sdk_client, cg_id)
53
+
54
+ self.volume_sdk_client.get.assert_has_calls(
55
+ [
56
+ mock.call(f'/consistencygroups/{cg_id}'),
57
+ ]
58
+ )
59
+ self.assertEqual(data['consistencygroup'], result)
60
+
61
+ def test_find_consistency_group_by_name(self):
62
+ cg_id = uuid.uuid4().hex
63
+ cg_name = 'name-' + uuid.uuid4().hex
64
+ data = {
65
+ 'consistencygroups': [
66
+ {
67
+ 'id': cg_id,
68
+ 'name': cg_name,
69
+ }
70
+ ],
71
+ }
72
+ self.volume_sdk_client.get.side_effect = [
73
+ fakes.FakeResponse(status_code=http.HTTPStatus.NOT_FOUND),
74
+ fakes.FakeResponse(data=data),
75
+ ]
76
+
77
+ result = volume.find_consistency_group(self.volume_sdk_client, cg_name)
78
+
79
+ self.volume_sdk_client.get.assert_has_calls(
80
+ [
81
+ mock.call(f'/consistencygroups/{cg_name}'),
82
+ mock.call('/consistencygroups'),
83
+ ]
84
+ )
85
+ self.assertEqual(data['consistencygroups'][0], result)
86
+
87
+ def test_find_consistency_group_not_found(self):
88
+ data = {'consistencygroups': []}
89
+ self.volume_sdk_client.get.side_effect = [
90
+ fakes.FakeResponse(status_code=http.HTTPStatus.NOT_FOUND),
91
+ fakes.FakeResponse(data=data),
92
+ ]
93
+ self.assertRaises(
94
+ osc_lib_exceptions.NotFound,
95
+ volume.find_consistency_group,
96
+ self.volume_sdk_client,
97
+ 'invalid-cg',
98
+ )
99
+
100
+ def test_find_consistency_group_by_name_duplicate(self):
101
+ cg_name = 'name-' + uuid.uuid4().hex
102
+ data = {
103
+ 'consistencygroups': [
104
+ {
105
+ 'id': uuid.uuid4().hex,
106
+ 'name': cg_name,
107
+ },
108
+ {
109
+ 'id': uuid.uuid4().hex,
110
+ 'name': cg_name,
111
+ },
112
+ ],
113
+ }
114
+ self.volume_sdk_client.get.side_effect = [
115
+ fakes.FakeResponse(status_code=http.HTTPStatus.NOT_FOUND),
116
+ fakes.FakeResponse(data=data),
117
+ ]
118
+
119
+ self.assertRaises(
120
+ osc_lib_exceptions.NotFound,
121
+ volume.find_consistency_group,
122
+ self.volume_sdk_client,
123
+ cg_name,
124
+ )
@@ -14,9 +14,9 @@
14
14
 
15
15
  from unittest import mock
16
16
 
17
- from osc_lib.command import command
18
17
  from osc_lib import exceptions
19
18
 
19
+ from openstackclient import command
20
20
  from openstackclient.tests.unit import fakes as test_fakes
21
21
  from openstackclient.tests.unit import utils as test_utils
22
22
 
@@ -10,7 +10,6 @@
10
10
  # License for the specific language governing permissions and limitations
11
11
  # under the License.
12
12
 
13
- from unittest import mock
14
13
 
15
14
  from openstackclient.common import extension
16
15
  from openstackclient.tests.unit.compute.v2 import fakes as compute_fakes
@@ -295,8 +294,8 @@ class TestExtensionShow(TestExtension):
295
294
 
296
295
  self.cmd = extension.ShowExtension(self.app, None)
297
296
 
298
- self.app.client_manager.network.find_extension = mock.Mock(
299
- return_value=self.extension_details
297
+ self.app.client_manager.network.find_extension.return_value = (
298
+ self.extension_details
300
299
  )
301
300
 
302
301
  def test_show_no_options(self):
@@ -11,7 +11,6 @@
11
11
  # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
12
  # License for the specific language governing permissions and limitations
13
13
  # under the License.
14
- #
15
14
 
16
15
  """Test module module"""
17
16
 
@@ -19,10 +18,18 @@ import sys
19
18
  from unittest import mock
20
19
 
21
20
  from openstackclient.common import module as osc_module
22
- from openstackclient.tests.unit import fakes
23
21
  from openstackclient.tests.unit import utils
24
22
 
25
23
 
24
+ class FakeModule:
25
+ def __init__(self, name, version):
26
+ self.name = name
27
+ self.__version__ = version
28
+ # Workaround for openstacksdk case
29
+ self.version = mock.Mock()
30
+ self.version.__version__ = version
31
+
32
+
26
33
  # NOTE(dtroyer): module_1 must match the version list filter (not --all)
27
34
  # currently == '*client*'
28
35
  module_name_1 = 'fakeclient'
@@ -45,11 +52,11 @@ module_version_5 = '0.0.1'
45
52
 
46
53
  MODULES = {
47
54
  'sys': sys,
48
- module_name_1: fakes.FakeModule(module_name_1, module_version_1),
49
- module_name_2: fakes.FakeModule(module_name_2, module_version_2),
50
- module_name_3: fakes.FakeModule(module_name_3, module_version_3),
51
- module_name_4: fakes.FakeModule(module_name_4, module_version_4),
52
- module_name_5: fakes.FakeModule(module_name_5, module_version_5),
55
+ module_name_1: FakeModule(module_name_1, module_version_1),
56
+ module_name_2: FakeModule(module_name_2, module_version_2),
57
+ module_name_3: FakeModule(module_name_3, module_version_3),
58
+ module_name_4: FakeModule(module_name_4, module_version_4),
59
+ module_name_5: FakeModule(module_name_5, module_version_5),
53
60
  }
54
61
 
55
62
 
@@ -1041,6 +1041,26 @@ class TestQuotaShow(TestQuota):
1041
1041
  )
1042
1042
  self.assertNotCalled(self.network_client.get_quota_default)
1043
1043
 
1044
+ def test_quota_show__missing_services(self):
1045
+ self.app.client_manager.compute_endpoint_enabled = False
1046
+ self.app.client_manager.volume_endpoint_enabled = False
1047
+ self.app.client_manager.network_endpoint_enabled = False
1048
+
1049
+ arglist = [
1050
+ self.projects[0].name,
1051
+ ]
1052
+ verifylist = [
1053
+ ('service', 'all'),
1054
+ ('project', self.projects[0].name),
1055
+ ]
1056
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
1057
+
1058
+ self.cmd.take_action(parsed_args)
1059
+
1060
+ self.compute_client.get_quota_set.assert_not_called()
1061
+ self.volume_sdk_client.get_quota_set.assert_not_called()
1062
+ self.network_client.get_quota.assert_not_called()
1063
+
1044
1064
  def test_quota_show__with_compute(self):
1045
1065
  arglist = [
1046
1066
  '--compute',
@@ -165,9 +165,11 @@ class TestAggregateDelete(TestAggregate):
165
165
  sdk_fakes.generate_fake_resources(_aggregate.Aggregate, 2)
166
166
  )
167
167
 
168
- self.compute_client.find_aggregate = mock.Mock(
169
- side_effect=[self.fake_ags[0], self.fake_ags[1]]
170
- )
168
+ self.compute_client.find_aggregate.side_effect = [
169
+ self.fake_ags[0],
170
+ self.fake_ags[1],
171
+ ]
172
+
171
173
  self.cmd = aggregate.DeleteAggregate(self.app, None)
172
174
 
173
175
  def test_aggregate_delete(self):
@@ -13,7 +13,6 @@
13
13
  # under the License.
14
14
  #
15
15
 
16
- from unittest import mock
17
16
 
18
17
  from openstack.compute.v2 import server as _server
19
18
  from openstack.test import fakes as sdk_fakes
@@ -90,9 +89,7 @@ class TestConsoleUrlShow(compute_fakes.TestComputev2):
90
89
  'protocol': 'fake_protocol',
91
90
  'type': 'fake_type',
92
91
  }
93
- self.compute_client.create_console = mock.Mock(
94
- return_value=fake_console_data
95
- )
92
+ self.compute_client.create_console.return_value = fake_console_data
96
93
 
97
94
  self.columns = (
98
95
  'protocol',