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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (234) hide show
  1. openstackclient/common/availability_zone.py +3 -6
  2. openstackclient/common/clientmanager.py +2 -1
  3. openstackclient/common/envvars.py +57 -0
  4. openstackclient/common/extension.py +3 -11
  5. openstackclient/common/limits.py +1 -1
  6. openstackclient/common/project_cleanup.py +3 -2
  7. openstackclient/common/quota.py +54 -28
  8. openstackclient/compute/client.py +2 -5
  9. openstackclient/compute/v2/agent.py +5 -5
  10. openstackclient/compute/v2/aggregate.py +17 -15
  11. openstackclient/compute/v2/console.py +3 -4
  12. openstackclient/compute/v2/flavor.py +14 -18
  13. openstackclient/compute/v2/host.py +3 -3
  14. openstackclient/compute/v2/hypervisor.py +10 -4
  15. openstackclient/compute/v2/hypervisor_stats.py +1 -1
  16. openstackclient/compute/v2/keypair.py +8 -10
  17. openstackclient/compute/v2/server.py +70 -112
  18. openstackclient/compute/v2/server_backup.py +1 -1
  19. openstackclient/compute/v2/server_event.py +7 -16
  20. openstackclient/compute/v2/server_group.py +6 -6
  21. openstackclient/compute/v2/server_image.py +1 -1
  22. openstackclient/compute/v2/server_migration.py +6 -6
  23. openstackclient/compute/v2/server_volume.py +4 -4
  24. openstackclient/compute/v2/service.py +9 -13
  25. openstackclient/compute/v2/usage.py +4 -6
  26. openstackclient/identity/client.py +2 -4
  27. openstackclient/identity/common.py +16 -17
  28. openstackclient/identity/v2_0/ec2creds.py +4 -3
  29. openstackclient/identity/v2_0/endpoint.py +12 -10
  30. openstackclient/identity/v2_0/project.py +6 -6
  31. openstackclient/identity/v2_0/role.py +1 -1
  32. openstackclient/identity/v2_0/service.py +7 -7
  33. openstackclient/identity/v2_0/user.py +6 -21
  34. openstackclient/identity/v3/access_rule.py +2 -5
  35. openstackclient/identity/v3/consumer.py +4 -3
  36. openstackclient/identity/v3/credential.py +6 -7
  37. openstackclient/identity/v3/domain.py +1 -1
  38. openstackclient/identity/v3/ec2creds.py +4 -3
  39. openstackclient/identity/v3/endpoint.py +104 -88
  40. openstackclient/identity/v3/endpoint_group.py +1 -1
  41. openstackclient/identity/v3/group.py +3 -4
  42. openstackclient/identity/v3/identity_provider.py +1 -2
  43. openstackclient/identity/v3/limit.py +4 -9
  44. openstackclient/identity/v3/mapping.py +4 -3
  45. openstackclient/identity/v3/policy.py +5 -8
  46. openstackclient/identity/v3/project.py +6 -6
  47. openstackclient/identity/v3/region.py +2 -5
  48. openstackclient/identity/v3/registered_limit.py +4 -8
  49. openstackclient/identity/v3/role.py +15 -16
  50. openstackclient/identity/v3/service.py +8 -8
  51. openstackclient/identity/v3/service_provider.py +3 -6
  52. openstackclient/identity/v3/tag.py +2 -2
  53. openstackclient/identity/v3/token.py +1 -2
  54. openstackclient/identity/v3/trust.py +74 -25
  55. openstackclient/identity/v3/user.py +9 -6
  56. openstackclient/image/client.py +2 -5
  57. openstackclient/image/v1/image.py +11 -15
  58. openstackclient/image/v2/cache.py +2 -4
  59. openstackclient/image/v2/image.py +30 -37
  60. openstackclient/image/v2/metadef_namespaces.py +4 -3
  61. openstackclient/image/v2/metadef_resource_type_association.py +1 -2
  62. openstackclient/image/v2/metadef_resource_types.py +1 -2
  63. openstackclient/locale/tr_TR/LC_MESSAGES/openstackclient.po +9 -1370
  64. openstackclient/network/client.py +4 -10
  65. openstackclient/network/common.py +16 -12
  66. openstackclient/network/utils.py +3 -3
  67. openstackclient/network/v2/address_group.py +5 -9
  68. openstackclient/network/v2/address_scope.py +2 -3
  69. openstackclient/network/v2/default_security_group_rule.py +1 -2
  70. openstackclient/network/v2/floating_ip.py +14 -21
  71. openstackclient/network/v2/floating_ip_port_forwarding.py +7 -7
  72. openstackclient/network/v2/ip_availability.py +1 -2
  73. openstackclient/network/v2/l3_conntrack_helper.py +8 -12
  74. openstackclient/network/v2/local_ip.py +24 -26
  75. openstackclient/network/v2/local_ip_association.py +4 -5
  76. openstackclient/network/v2/ndp_proxy.py +9 -10
  77. openstackclient/network/v2/network.py +12 -16
  78. openstackclient/network/v2/network_agent.py +29 -37
  79. openstackclient/network/v2/network_auto_allocated_topology.py +4 -5
  80. openstackclient/network/v2/network_flavor.py +1 -1
  81. openstackclient/network/v2/network_flavor_profile.py +5 -5
  82. openstackclient/network/v2/network_meter.py +3 -3
  83. openstackclient/network/v2/network_meter_rule.py +5 -8
  84. openstackclient/network/v2/network_qos_policy.py +4 -4
  85. openstackclient/network/v2/network_qos_rule.py +4 -5
  86. openstackclient/network/v2/network_rbac.py +4 -4
  87. openstackclient/network/v2/network_segment.py +6 -7
  88. openstackclient/network/v2/network_segment_range.py +16 -20
  89. openstackclient/network/v2/network_trunk.py +24 -16
  90. openstackclient/network/v2/port.py +28 -29
  91. openstackclient/network/v2/router.py +52 -41
  92. openstackclient/network/v2/security_group.py +8 -15
  93. openstackclient/network/v2/security_group_rule.py +9 -10
  94. openstackclient/network/v2/subnet.py +31 -30
  95. openstackclient/network/v2/subnet_pool.py +4 -4
  96. openstackclient/object/client.py +2 -3
  97. openstackclient/object/v1/container.py +2 -3
  98. openstackclient/object/v1/object.py +2 -9
  99. openstackclient/shell.py +22 -5
  100. openstackclient/tests/functional/base.py +2 -2
  101. openstackclient/tests/functional/common/test_quota.py +3 -1
  102. openstackclient/tests/functional/compute/v2/common.py +12 -6
  103. openstackclient/tests/functional/compute/v2/test_server.py +2 -3
  104. openstackclient/tests/functional/compute/v2/test_server_event.py +1 -1
  105. openstackclient/tests/functional/identity/v2/test_user.py +1 -1
  106. openstackclient/tests/functional/identity/v3/common.py +3 -8
  107. openstackclient/tests/functional/identity/v3/test_application_credential.py +10 -10
  108. openstackclient/tests/functional/identity/v3/test_endpoint.py +3 -3
  109. openstackclient/tests/functional/identity/v3/test_group.py +3 -3
  110. openstackclient/tests/functional/identity/v3/test_idp.py +3 -7
  111. openstackclient/tests/functional/identity/v3/test_limit.py +4 -4
  112. openstackclient/tests/functional/identity/v3/test_project.py +5 -14
  113. openstackclient/tests/functional/identity/v3/test_region.py +1 -3
  114. openstackclient/tests/functional/identity/v3/test_registered_limit.py +3 -3
  115. openstackclient/tests/functional/identity/v3/test_role.py +1 -1
  116. openstackclient/tests/functional/identity/v3/test_role_assignment.py +13 -31
  117. openstackclient/tests/functional/identity/v3/test_service_provider.py +3 -7
  118. openstackclient/tests/functional/identity/v3/test_user.py +8 -8
  119. openstackclient/tests/functional/network/v2/common.py +7 -3
  120. openstackclient/tests/functional/network/v2/test_address_group.py +4 -0
  121. openstackclient/tests/functional/network/v2/test_l3_conntrack_helper.py +15 -11
  122. openstackclient/tests/functional/network/v2/test_local_ip.py +4 -0
  123. openstackclient/tests/functional/network/v2/test_network_meter_rule.py +2 -2
  124. openstackclient/tests/functional/network/v2/test_network_ndp_proxy.py +2 -3
  125. openstackclient/tests/functional/network/v2/test_network_rbac.py +2 -2
  126. openstackclient/tests/functional/network/v2/test_network_trunk.py +1 -1
  127. openstackclient/tests/functional/network/v2/test_port.py +17 -7
  128. openstackclient/tests/functional/network/v2/test_router.py +42 -0
  129. openstackclient/tests/functional/network/v2/test_subnet_pool.py +4 -0
  130. openstackclient/tests/unit/api/test_compute_v2.py +67 -87
  131. openstackclient/tests/unit/common/test_availability_zone.py +6 -14
  132. openstackclient/tests/unit/common/test_command.py +1 -1
  133. openstackclient/tests/unit/common/test_extension.py +5 -7
  134. openstackclient/tests/unit/common/test_limits.py +1 -1
  135. openstackclient/tests/unit/common/test_project_cleanup.py +5 -6
  136. openstackclient/tests/unit/common/test_quota.py +51 -28
  137. openstackclient/tests/unit/compute/v2/fakes.py +4 -10
  138. openstackclient/tests/unit/compute/v2/test_agent.py +16 -16
  139. openstackclient/tests/unit/compute/v2/test_aggregate.py +56 -60
  140. openstackclient/tests/unit/compute/v2/test_console.py +16 -16
  141. openstackclient/tests/unit/compute/v2/test_flavor.py +71 -71
  142. openstackclient/tests/unit/compute/v2/test_host.py +8 -8
  143. openstackclient/tests/unit/compute/v2/test_hypervisor.py +22 -30
  144. openstackclient/tests/unit/compute/v2/test_hypervisor_stats.py +2 -2
  145. openstackclient/tests/unit/compute/v2/test_keypair.py +24 -24
  146. openstackclient/tests/unit/compute/v2/test_server.py +524 -560
  147. openstackclient/tests/unit/compute/v2/test_server_backup.py +5 -7
  148. openstackclient/tests/unit/compute/v2/test_server_event.py +16 -18
  149. openstackclient/tests/unit/compute/v2/test_server_group.py +25 -31
  150. openstackclient/tests/unit/compute/v2/test_server_image.py +6 -8
  151. openstackclient/tests/unit/compute/v2/test_server_migration.py +37 -37
  152. openstackclient/tests/unit/compute/v2/test_server_volume.py +12 -12
  153. openstackclient/tests/unit/compute/v2/test_service.py +39 -45
  154. openstackclient/tests/unit/compute/v2/test_usage.py +5 -5
  155. openstackclient/tests/unit/identity/v2_0/fakes.py +1 -1
  156. openstackclient/tests/unit/identity/v3/test_access_rule.py +1 -3
  157. openstackclient/tests/unit/identity/v3/test_application_credential.py +1 -1
  158. openstackclient/tests/unit/identity/v3/test_endpoint.py +167 -172
  159. openstackclient/tests/unit/identity/v3/test_mappings.py +2 -2
  160. openstackclient/tests/unit/identity/v3/test_trust.py +5 -2
  161. openstackclient/tests/unit/identity/v3/test_user.py +16 -0
  162. openstackclient/tests/unit/image/v1/fakes.py +2 -2
  163. openstackclient/tests/unit/image/v2/test_image.py +39 -1
  164. openstackclient/tests/unit/integ/cli/test_shell.py +1 -2
  165. openstackclient/tests/unit/network/test_common.py +2 -2
  166. openstackclient/tests/unit/network/v2/test_floating_ip_compute.py +8 -14
  167. openstackclient/tests/unit/network/v2/test_floating_ip_network.py +49 -35
  168. openstackclient/tests/unit/network/v2/test_floating_ip_pool_compute.py +1 -1
  169. openstackclient/tests/unit/network/v2/test_network_compute.py +11 -11
  170. openstackclient/tests/unit/network/v2/test_network_trunk.py +2 -2
  171. openstackclient/tests/unit/network/v2/test_port.py +4 -5
  172. openstackclient/tests/unit/network/v2/test_router.py +63 -0
  173. openstackclient/tests/unit/network/v2/test_security_group_compute.py +11 -19
  174. openstackclient/tests/unit/network/v2/test_security_group_rule_compute.py +14 -14
  175. openstackclient/tests/unit/object/v1/test_object_all.py +4 -3
  176. openstackclient/tests/unit/test_shell.py +16 -13
  177. openstackclient/tests/unit/volume/v2/test_volume.py +1 -1
  178. openstackclient/tests/unit/volume/v2/test_volume_transfer_request.py +1 -1
  179. openstackclient/tests/unit/volume/v3/fakes.py +2 -8
  180. openstackclient/tests/unit/volume/v3/test_volume.py +1 -1
  181. openstackclient/tests/unit/volume/v3/test_volume_attachment.py +3 -3
  182. openstackclient/tests/unit/volume/v3/test_volume_snapshot.py +1 -2
  183. openstackclient/tests/unit/volume/v3/test_volume_transfer_request.py +1 -1
  184. openstackclient/volume/client.py +1 -3
  185. openstackclient/volume/v2/consistency_group.py +4 -8
  186. openstackclient/volume/v2/consistency_group_snapshot.py +1 -2
  187. openstackclient/volume/v2/qos_specs.py +1 -2
  188. openstackclient/volume/v2/volume.py +8 -16
  189. openstackclient/volume/v2/volume_backup.py +6 -7
  190. openstackclient/volume/v2/volume_snapshot.py +8 -9
  191. openstackclient/volume/v2/volume_transfer_request.py +0 -3
  192. openstackclient/volume/v2/volume_type.py +10 -21
  193. openstackclient/volume/v3/block_storage_cluster.py +3 -3
  194. openstackclient/volume/v3/block_storage_manage.py +1 -3
  195. openstackclient/volume/v3/volume.py +18 -19
  196. openstackclient/volume/v3/volume_attachment.py +3 -2
  197. openstackclient/volume/v3/volume_backup.py +7 -8
  198. openstackclient/volume/v3/volume_group.py +2 -1
  199. openstackclient/volume/v3/volume_group_snapshot.py +2 -1
  200. openstackclient/volume/v3/volume_snapshot.py +4 -3
  201. openstackclient/volume/v3/volume_type.py +10 -21
  202. {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.0.0.dist-info}/AUTHORS +3 -0
  203. {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.0.0.dist-info}/METADATA +7 -13
  204. {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.0.0.dist-info}/RECORD +209 -232
  205. {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.0.0.dist-info}/WHEEL +1 -1
  206. {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.0.0.dist-info}/entry_points.txt +0 -41
  207. python_openstackclient-8.0.0.dist-info/pbr.json +1 -0
  208. openstackclient/tests/functional/volume/v1/__init__.py +0 -0
  209. openstackclient/tests/functional/volume/v1/common.py +0 -35
  210. openstackclient/tests/functional/volume/v1/test_qos.py +0 -100
  211. openstackclient/tests/functional/volume/v1/test_service.py +0 -76
  212. openstackclient/tests/functional/volume/v1/test_snapshot.py +0 -232
  213. openstackclient/tests/functional/volume/v1/test_transfer_request.py +0 -111
  214. openstackclient/tests/functional/volume/v1/test_volume.py +0 -228
  215. openstackclient/tests/functional/volume/v1/test_volume_type.py +0 -213
  216. openstackclient/tests/unit/volume/v1/__init__.py +0 -0
  217. openstackclient/tests/unit/volume/v1/fakes.py +0 -615
  218. openstackclient/tests/unit/volume/v1/test_qos_specs.py +0 -471
  219. openstackclient/tests/unit/volume/v1/test_service.py +0 -295
  220. openstackclient/tests/unit/volume/v1/test_transfer_request.py +0 -380
  221. openstackclient/tests/unit/volume/v1/test_type.py +0 -633
  222. openstackclient/tests/unit/volume/v1/test_volume.py +0 -1447
  223. openstackclient/tests/unit/volume/v1/test_volume_backup.py +0 -435
  224. openstackclient/volume/v1/__init__.py +0 -0
  225. openstackclient/volume/v1/qos_specs.py +0 -377
  226. openstackclient/volume/v1/service.py +0 -136
  227. openstackclient/volume/v1/volume.py +0 -734
  228. openstackclient/volume/v1/volume_backup.py +0 -302
  229. openstackclient/volume/v1/volume_snapshot.py +0 -433
  230. openstackclient/volume/v1/volume_transfer_request.py +0 -200
  231. openstackclient/volume/v1/volume_type.py +0 -520
  232. python_openstackclient-7.4.0.dist-info/pbr.json +0 -1
  233. {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.0.0.dist-info}/LICENSE +0 -0
  234. {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.0.0.dist-info}/top_level.txt +0 -0
@@ -55,7 +55,7 @@ class TestMappingCreate(TestMapping):
55
55
  mocker = mock.Mock()
56
56
  mocker.return_value = identity_fakes.MAPPING_RULES
57
57
  with mock.patch(
58
- "openstackclient.identity.v3.mapping." "CreateMapping._read_rules",
58
+ "openstackclient.identity.v3.mapping.CreateMapping._read_rules",
59
59
  mocker,
60
60
  ):
61
61
  columns, data = self.cmd.take_action(parsed_args)
@@ -170,7 +170,7 @@ class TestMappingSet(TestMapping):
170
170
  mocker = mock.Mock()
171
171
  mocker.return_value = identity_fakes.MAPPING_RULES_2
172
172
  with mock.patch(
173
- "openstackclient.identity.v3.mapping." "SetMapping._read_rules",
173
+ "openstackclient.identity.v3.mapping.SetMapping._read_rules",
174
174
  mocker,
175
175
  ):
176
176
  result = self.cmd.take_action(parsed_args)
@@ -70,12 +70,15 @@ class TestTrustCreate(identity_fakes.TestIdentityv3):
70
70
  # Set expected values
71
71
  kwargs = {
72
72
  'project_id': self.project.id,
73
- 'roles': [self.role.id],
73
+ 'roles': [{'id': self.role.id}],
74
+ 'impersonation': False,
74
75
  }
75
76
  # TrustManager.create(trustee_id, trustor_id, impersonation=,
76
77
  # project=, role_names=, expires_at=)
77
78
  self.identity_sdk_client.create_trust.assert_called_with(
78
- trustor_id=self.user.id, trustee_id=self.user.id, **kwargs
79
+ trustor_user_id=self.user.id,
80
+ trustee_user_id=self.user.id,
81
+ **kwargs,
79
82
  )
80
83
 
81
84
  collist = (
@@ -1206,6 +1206,17 @@ class TestUserSet(identity_fakes.TestIdentityv3):
1206
1206
  self.identity_sdk_client.update_user.assert_called_with(
1207
1207
  user=self.user, **kwargs
1208
1208
  )
1209
+ self.identity_sdk_client.find_domain.assert_not_called()
1210
+
1211
+ # Set expected values
1212
+ kwargs = {
1213
+ 'ignore_missing': False,
1214
+ 'domain_id': None,
1215
+ }
1216
+ self.identity_sdk_client.find_project.assert_called_once_with(
1217
+ name_or_id=self.project.id, **kwargs
1218
+ )
1219
+
1209
1220
  self.assertIsNone(result)
1210
1221
 
1211
1222
  def test_user_set_project_domain(self):
@@ -1238,6 +1249,11 @@ class TestUserSet(identity_fakes.TestIdentityv3):
1238
1249
  self.identity_sdk_client.update_user.assert_called_with(
1239
1250
  user=self.user, **kwargs
1240
1251
  )
1252
+
1253
+ self.identity_sdk_client.find_domain.assert_called_once_with(
1254
+ name_or_id=self.project.domain_id, ignore_missing=False
1255
+ )
1256
+
1241
1257
  self.assertIsNone(result)
1242
1258
 
1243
1259
  def test_user_set_enable(self):
@@ -20,7 +20,7 @@ from openstack.image.v1 import image
20
20
 
21
21
  from openstackclient.tests.unit import fakes
22
22
  from openstackclient.tests.unit import utils
23
- from openstackclient.tests.unit.volume.v1 import fakes as volume_fakes
23
+ from openstackclient.tests.unit.volume.v2 import fakes as volume_fakes
24
24
 
25
25
 
26
26
  class FakeClientMixin:
@@ -35,7 +35,7 @@ class TestImagev1(FakeClientMixin, utils.TestCommand):
35
35
  def setUp(self):
36
36
  super().setUp()
37
37
 
38
- self.app.client_manager.volume = volume_fakes.FakeVolumev1Client(
38
+ self.app.client_manager.volume = volume_fakes.FakeVolumeClient(
39
39
  endpoint=fakes.AUTH_URL,
40
40
  token=fakes.AUTH_TOKEN,
41
41
  )
@@ -346,7 +346,13 @@ class TestImageCreate(TestImage):
346
346
  columns, data = self.cmd.take_action(parsed_args)
347
347
 
348
348
  self.volumes_mock.upload_to_image.assert_called_with(
349
- fake_vol_id, False, self.new_image.name, 'bare', 'raw'
349
+ fake_vol_id,
350
+ False,
351
+ self.new_image.name,
352
+ 'bare',
353
+ 'raw',
354
+ visibility=None,
355
+ protected=None,
350
356
  )
351
357
 
352
358
  @mock.patch('osc_lib.utils.find_resource')
@@ -2092,6 +2098,38 @@ class TestImageImport(TestImage):
2092
2098
  all_stores_must_succeed=False,
2093
2099
  )
2094
2100
 
2101
+ def test_import_image__copy_image_disallow_failure(self):
2102
+ self.image.status = 'active'
2103
+ arglist = [
2104
+ self.image.name,
2105
+ '--method',
2106
+ 'copy-image',
2107
+ '--store',
2108
+ 'fast',
2109
+ '--disallow-failure',
2110
+ ]
2111
+ verifylist = [
2112
+ ('image', self.image.name),
2113
+ ('import_method', 'copy-image'),
2114
+ ('stores', ['fast']),
2115
+ ('allow_failure', False),
2116
+ ]
2117
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
2118
+
2119
+ self.cmd.take_action(parsed_args)
2120
+
2121
+ self.image_client.import_image.assert_called_once_with(
2122
+ self.image,
2123
+ method='copy-image',
2124
+ uri=None,
2125
+ remote_region=None,
2126
+ remote_image_id=None,
2127
+ remote_service_interface=None,
2128
+ stores=['fast'],
2129
+ all_stores=None,
2130
+ all_stores_must_succeed=True,
2131
+ )
2132
+
2095
2133
  def test_import_image__glance_download(self):
2096
2134
  arglist = [
2097
2135
  self.image.name,
@@ -361,8 +361,7 @@ class TestIntegShellCliPrecedence(test_base.TestInteg):
361
361
 
362
362
  _shell = shell.OpenStackShell()
363
363
  _shell.run(
364
- "--os-username zarquon --os-password qaz "
365
- "extension list".split(),
364
+ "--os-username zarquon --os-password qaz extension list".split(),
366
365
  )
367
366
 
368
367
  # Check general calls
@@ -132,8 +132,8 @@ class TestNetworkAndCompute(utils.TestCommand):
132
132
  return_value='take_action_network'
133
133
  )
134
134
 
135
- self.app.client_manager.sdk_connection.compute = mock.Mock()
136
- self.compute_client = self.app.client_manager.sdk_connection.compute
135
+ self.app.client_manager.compute = mock.Mock()
136
+ self.compute_client = self.app.client_manager.compute
137
137
  self.compute_client.compute_action = mock.Mock(
138
138
  return_value='take_action_compute'
139
139
  )
@@ -73,7 +73,7 @@ class TestCreateFloatingIPCompute(compute_fakes.TestComputev2):
73
73
  columns, data = self.cmd.take_action(parsed_args)
74
74
 
75
75
  fip_mock.assert_called_once_with(
76
- self.compute_sdk_client, self._floating_ip['pool']
76
+ self.compute_client, self._floating_ip['pool']
77
77
  )
78
78
  self.assertEqual(self.columns, columns)
79
79
  self.assertEqual(self.data, data)
@@ -103,7 +103,7 @@ class TestDeleteFloatingIPCompute(compute_fakes.TestComputev2):
103
103
  result = self.cmd.take_action(parsed_args)
104
104
 
105
105
  fip_mock.assert_called_once_with(
106
- self.compute_sdk_client, self._floating_ips[0]['id']
106
+ self.compute_client, self._floating_ips[0]['id']
107
107
  )
108
108
  self.assertIsNone(result)
109
109
 
@@ -122,12 +122,8 @@ class TestDeleteFloatingIPCompute(compute_fakes.TestComputev2):
122
122
 
123
123
  fip_mock.assert_has_calls(
124
124
  [
125
- mock.call(
126
- self.compute_sdk_client, self._floating_ips[0]['id']
127
- ),
128
- mock.call(
129
- self.compute_sdk_client, self._floating_ips[1]['id']
130
- ),
125
+ mock.call(self.compute_client, self._floating_ips[0]['id']),
126
+ mock.call(self.compute_client, self._floating_ips[1]['id']),
131
127
  ]
132
128
  )
133
129
  self.assertIsNone(result)
@@ -157,11 +153,9 @@ class TestDeleteFloatingIPCompute(compute_fakes.TestComputev2):
157
153
  self.assertEqual('1 of 2 floating_ips failed to delete.', str(e))
158
154
 
159
155
  fip_mock.assert_any_call(
160
- self.compute_sdk_client, self._floating_ips[0]['id']
161
- )
162
- fip_mock.assert_any_call(
163
- self.compute_sdk_client, 'unexist_floating_ip'
156
+ self.compute_client, self._floating_ips[0]['id']
164
157
  )
158
+ fip_mock.assert_any_call(self.compute_client, 'unexist_floating_ip')
165
159
 
166
160
 
167
161
  @mock.patch.object(compute_v2, 'list_floating_ips')
@@ -203,7 +197,7 @@ class TestListFloatingIPCompute(compute_fakes.TestComputev2):
203
197
 
204
198
  columns, data = self.cmd.take_action(parsed_args)
205
199
 
206
- fip_mock.assert_called_once_with(self.compute_sdk_client)
200
+ fip_mock.assert_called_once_with(self.compute_client)
207
201
  self.assertEqual(self.columns, columns)
208
202
  self.assertEqual(self.data, list(data))
209
203
 
@@ -248,7 +242,7 @@ class TestShowFloatingIPCompute(compute_fakes.TestComputev2):
248
242
  columns, data = self.cmd.take_action(parsed_args)
249
243
 
250
244
  fip_mock.assert_called_once_with(
251
- self.compute_sdk_client, self._floating_ip['id']
245
+ self.compute_client, self._floating_ip['id']
252
246
  )
253
247
  self.assertEqual(self.columns, columns)
254
248
  self.assertEqual(self.data, data)
@@ -14,6 +14,9 @@
14
14
  from unittest import mock
15
15
  from unittest.mock import call
16
16
 
17
+ from openstack.network.v2 import floating_ip as _floating_ip
18
+ from openstack.test import fakes as sdk_fakes
19
+ from osc_lib.cli import format_columns
17
20
  from osc_lib import exceptions
18
21
 
19
22
  from openstackclient.network.v2 import floating_ip as fip
@@ -706,46 +709,57 @@ class TestListFloatingIPNetwork(TestFloatingIPNetwork):
706
709
 
707
710
 
708
711
  class TestShowFloatingIPNetwork(TestFloatingIPNetwork):
709
- # The floating ip to display.
710
- floating_ip = network_fakes.FakeFloatingIP.create_one_floating_ip()
711
-
712
- columns = (
713
- 'description',
714
- 'dns_domain',
715
- 'dns_name',
716
- 'fixed_ip_address',
717
- 'floating_ip_address',
718
- 'floating_network_id',
719
- 'id',
720
- 'port_id',
721
- 'project_id',
722
- 'qos_policy_id',
723
- 'router_id',
724
- 'status',
725
- 'tags',
726
- )
727
-
728
- data = (
729
- floating_ip.description,
730
- floating_ip.dns_domain,
731
- floating_ip.dns_name,
732
- floating_ip.fixed_ip_address,
733
- floating_ip.floating_ip_address,
734
- floating_ip.floating_network_id,
735
- floating_ip.id,
736
- floating_ip.port_id,
737
- floating_ip.project_id,
738
- floating_ip.qos_policy_id,
739
- floating_ip.router_id,
740
- floating_ip.status,
741
- floating_ip.tags,
742
- )
743
-
744
712
  def setUp(self):
745
713
  super().setUp()
746
714
 
715
+ self.floating_ip = sdk_fakes.generate_fake_resource(
716
+ _floating_ip.FloatingIP
717
+ )
747
718
  self.network_client.find_ip = mock.Mock(return_value=self.floating_ip)
748
719
 
720
+ self.columns = (
721
+ 'created_at',
722
+ 'description',
723
+ 'dns_domain',
724
+ 'dns_name',
725
+ 'fixed_ip_address',
726
+ 'floating_ip_address',
727
+ 'floating_network_id',
728
+ 'id',
729
+ 'name',
730
+ 'port_details',
731
+ 'port_id',
732
+ 'project_id',
733
+ 'qos_policy_id',
734
+ 'revision_number',
735
+ 'router_id',
736
+ 'status',
737
+ 'subnet_id',
738
+ 'tags',
739
+ 'updated_at',
740
+ )
741
+ self.data = (
742
+ self.floating_ip.created_at,
743
+ self.floating_ip.description,
744
+ self.floating_ip.dns_domain,
745
+ self.floating_ip.dns_name,
746
+ self.floating_ip.fixed_ip_address,
747
+ self.floating_ip.floating_ip_address,
748
+ self.floating_ip.floating_network_id,
749
+ self.floating_ip.id,
750
+ self.floating_ip.name,
751
+ format_columns.DictColumn(self.floating_ip.port_details),
752
+ self.floating_ip.port_id,
753
+ self.floating_ip.project_id,
754
+ self.floating_ip.qos_policy_id,
755
+ self.floating_ip.revision_number,
756
+ self.floating_ip.router_id,
757
+ self.floating_ip.status,
758
+ self.floating_ip.subnet_id,
759
+ self.floating_ip.tags,
760
+ self.floating_ip.updated_at,
761
+ )
762
+
749
763
  # Get the command object to test
750
764
  self.cmd = fip.ShowFloatingIP(self.app, None)
751
765
 
@@ -44,6 +44,6 @@ class TestListFloatingIPPoolCompute(compute_fakes.TestComputev2):
44
44
 
45
45
  columns, data = self.cmd.take_action(parsed_args)
46
46
 
47
- fipp_mock.assert_called_once_with(self.compute_sdk_client)
47
+ fipp_mock.assert_called_once_with(self.compute_client)
48
48
  self.assertEqual(self.columns, columns)
49
49
  self.assertEqual(self.data, list(data))
@@ -148,7 +148,7 @@ class TestCreateNetworkCompute(compute_fakes.TestComputev2):
148
148
  columns, data = self.cmd.take_action(parsed_args)
149
149
 
150
150
  net_mock.assert_called_once_with(
151
- self.compute_sdk_client,
151
+ self.compute_client,
152
152
  subnet=self._network['cidr'],
153
153
  name=self._network['label'],
154
154
  )
@@ -182,7 +182,7 @@ class TestDeleteNetworkCompute(compute_fakes.TestComputev2):
182
182
  result = self.cmd.take_action(parsed_args)
183
183
 
184
184
  delete_net_mock.assert_called_once_with(
185
- self.compute_sdk_client,
185
+ self.compute_client,
186
186
  self._networks[0]['id'],
187
187
  )
188
188
  self.assertIsNone(result)
@@ -203,8 +203,8 @@ class TestDeleteNetworkCompute(compute_fakes.TestComputev2):
203
203
 
204
204
  delete_net_mock.assert_has_calls(
205
205
  [
206
- mock.call(self.compute_sdk_client, self._networks[0]['id']),
207
- mock.call(self.compute_sdk_client, self._networks[1]['id']),
206
+ mock.call(self.compute_client, self._networks[0]['id']),
207
+ mock.call(self.compute_client, self._networks[1]['id']),
208
208
  ]
209
209
  )
210
210
  self.assertIsNone(result)
@@ -238,15 +238,15 @@ class TestDeleteNetworkCompute(compute_fakes.TestComputev2):
238
238
 
239
239
  find_net_mock.assert_has_calls(
240
240
  [
241
- mock.call(self.compute_sdk_client, self._networks[0]['id']),
242
- mock.call(self.compute_sdk_client, 'xxxx-yyyy-zzzz'),
243
- mock.call(self.compute_sdk_client, self._networks[1]['id']),
241
+ mock.call(self.compute_client, self._networks[0]['id']),
242
+ mock.call(self.compute_client, 'xxxx-yyyy-zzzz'),
243
+ mock.call(self.compute_client, self._networks[1]['id']),
244
244
  ]
245
245
  )
246
246
  delete_net_mock.assert_has_calls(
247
247
  [
248
- mock.call(self.compute_sdk_client, self._networks[0]['id']),
249
- mock.call(self.compute_sdk_client, self._networks[1]['id']),
248
+ mock.call(self.compute_client, self._networks[0]['id']),
249
+ mock.call(self.compute_client, self._networks[1]['id']),
250
250
  ]
251
251
  )
252
252
 
@@ -286,7 +286,7 @@ class TestListNetworkCompute(compute_fakes.TestComputev2):
286
286
 
287
287
  columns, data = self.cmd.take_action(parsed_args)
288
288
 
289
- net_mock.assert_called_once_with(self.compute_sdk_client)
289
+ net_mock.assert_called_once_with(self.compute_client)
290
290
  self.assertEqual(self.columns, columns)
291
291
  self.assertEqual(self.data, list(data))
292
292
 
@@ -398,7 +398,7 @@ class TestShowNetworkCompute(compute_fakes.TestComputev2):
398
398
  columns, data = self.cmd.take_action(parsed_args)
399
399
 
400
400
  net_mock.assert_called_once_with(
401
- self.compute_sdk_client, self._network['label']
401
+ self.compute_client, self._network['label']
402
402
  )
403
403
  self.assertEqual(self.columns, columns)
404
404
  self.assertEqual(self.data, data)
@@ -263,7 +263,7 @@ class TestCreateNetworkTrunk(TestNetworkTrunk):
263
263
  '--parent-port',
264
264
  self.new_trunk.port_id,
265
265
  '--subport',
266
- 'segmentation-type={seg_type},' 'segmentation-id={seg_id}'.format(
266
+ 'segmentation-type={seg_type},segmentation-id={seg_id}'.format(
267
267
  seg_id=subport['segmentation_id'],
268
268
  seg_type=subport['segmentation_type'],
269
269
  ),
@@ -727,7 +727,7 @@ class TestSetNetworkTrunk(TestNetworkTrunk):
727
727
  subport = self._trunk['sub_ports'][0]
728
728
  arglist = [
729
729
  '--subport',
730
- 'segmentation-type={seg_type},' 'segmentation-id={seg_id}'.format(
730
+ 'segmentation-type={seg_type},segmentation-id={seg_id}'.format(
731
731
  seg_id=subport['segmentation_id'],
732
732
  seg_type=subport['segmentation_type'],
733
733
  ),
@@ -807,8 +807,7 @@ class TestCreatePort(TestPort):
807
807
  extra_dhcp_options = [
808
808
  {
809
809
  'opt_name': 'classless-static-route',
810
- 'opt_value': '169.254.169.254/32,22.2.0.2,'
811
- '0.0.0.0/0,22.2.0.1',
810
+ 'opt_value': '169.254.169.254/32,22.2.0.2,0.0.0.0/0,22.2.0.1',
812
811
  'ip_version': '4',
813
812
  },
814
813
  {
@@ -826,7 +825,7 @@ class TestCreatePort(TestPort):
826
825
  '0.0.0.0/0,22.2.0.1,'
827
826
  'ip-version=4',
828
827
  '--extra-dhcp-option',
829
- 'name=dns-server,value=240C::6666,' 'ip-version=6',
828
+ 'name=dns-server,value=240C::6666,ip-version=6',
830
829
  'test-port',
831
830
  ]
832
831
 
@@ -1379,7 +1378,7 @@ class TestListPort(compute_fakes.FakeClientMixin, TestPort):
1379
1378
 
1380
1379
  def test_port_list_with_server_option(self):
1381
1380
  fake_server = compute_fakes.create_one_sdk_server()
1382
- self.compute_sdk_client.find_server.return_value = fake_server
1381
+ self.compute_client.find_server.return_value = fake_server
1383
1382
 
1384
1383
  arglist = [
1385
1384
  '--server',
@@ -1394,7 +1393,7 @@ class TestListPort(compute_fakes.FakeClientMixin, TestPort):
1394
1393
  self.network_client.ports.assert_called_once_with(
1395
1394
  device_id=fake_server.id, fields=LIST_FIELDS_TO_RETRIEVE
1396
1395
  )
1397
- self.compute_sdk_client.find_server.aassert_called_once_with(
1396
+ self.compute_client.find_server.aassert_called_once_with(
1398
1397
  mock.ANY, 'fake-server-name'
1399
1398
  )
1400
1399
  self.assertEqual(self.columns, columns)
@@ -552,6 +552,69 @@ class TestCreateRouter(TestRouter):
552
552
  parsed_args,
553
553
  )
554
554
 
555
+ def test_create_with_qos_policy(self):
556
+ _network = network_fakes.create_one_network()
557
+ self.network_client.find_network = mock.Mock(return_value=_network)
558
+ _qos_policy = (
559
+ network_fakes.FakeNetworkQosPolicy.create_one_qos_policy()
560
+ )
561
+ self.network_client.find_qos_policy = mock.Mock(
562
+ return_value=_qos_policy
563
+ )
564
+ arglist = [
565
+ self.new_router.name,
566
+ '--external-gateway',
567
+ _network.id,
568
+ '--qos-policy',
569
+ _qos_policy.id,
570
+ ]
571
+ verifylist = [
572
+ ('name', self.new_router.name),
573
+ ('enable', True),
574
+ ('distributed', False),
575
+ ('ha', False),
576
+ ('qos_policy', _qos_policy.id),
577
+ ('external_gateways', [_network.id]),
578
+ ]
579
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
580
+ columns, data = self.cmd.take_action(parsed_args)
581
+ gw_info = {'network_id': _network.id, 'qos_policy_id': _qos_policy.id}
582
+ self.network_client.create_router.assert_called_once_with(
583
+ **{
584
+ 'admin_state_up': True,
585
+ 'name': self.new_router.name,
586
+ **{'external_gateway_info': gw_info},
587
+ }
588
+ )
589
+ self.assertEqual(self.columns, columns)
590
+ self.assertCountEqual(self.data, data)
591
+
592
+ def test_create_with_qos_policy_no_external_gateway(self):
593
+ _qos_policy = (
594
+ network_fakes.FakeNetworkQosPolicy.create_one_qos_policy()
595
+ )
596
+ self.network_client.find_qos_policy = mock.Mock(
597
+ return_value=_qos_policy
598
+ )
599
+ arglist = [
600
+ self.new_router.name,
601
+ '--qos-policy',
602
+ _qos_policy.id,
603
+ ]
604
+ verifylist = [
605
+ ('name', self.new_router.name),
606
+ ('enable', True),
607
+ ('distributed', False),
608
+ ('ha', False),
609
+ ('qos_policy', _qos_policy.id),
610
+ ]
611
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
612
+ self.assertRaises(
613
+ exceptions.CommandError,
614
+ self.cmd.take_action,
615
+ parsed_args,
616
+ )
617
+
555
618
 
556
619
  class TestDeleteRouter(TestRouter):
557
620
  # The routers to delete.
@@ -72,7 +72,7 @@ class TestCreateSecurityGroupCompute(compute_fakes.TestComputev2):
72
72
  columns, data = self.cmd.take_action(parsed_args)
73
73
 
74
74
  sg_mock.assert_called_once_with(
75
- self.compute_sdk_client,
75
+ self.compute_client,
76
76
  self._security_group['name'],
77
77
  self._security_group['name'],
78
78
  )
@@ -95,7 +95,7 @@ class TestCreateSecurityGroupCompute(compute_fakes.TestComputev2):
95
95
  columns, data = self.cmd.take_action(parsed_args)
96
96
 
97
97
  sg_mock.assert_called_once_with(
98
- self.compute_sdk_client,
98
+ self.compute_client,
99
99
  self._security_group['name'],
100
100
  self._security_group['description'],
101
101
  )
@@ -133,7 +133,7 @@ class TestDeleteSecurityGroupCompute(compute_fakes.TestComputev2):
133
133
  result = self.cmd.take_action(parsed_args)
134
134
 
135
135
  sg_mock.assert_called_once_with(
136
- self.compute_sdk_client,
136
+ self.compute_client,
137
137
  self._security_groups[0]['id'],
138
138
  )
139
139
  self.assertIsNone(result)
@@ -153,12 +153,8 @@ class TestDeleteSecurityGroupCompute(compute_fakes.TestComputev2):
153
153
 
154
154
  sg_mock.assert_has_calls(
155
155
  [
156
- mock.call(
157
- self.compute_sdk_client, self._security_groups[0]['id']
158
- ),
159
- mock.call(
160
- self.compute_sdk_client, self._security_groups[1]['id']
161
- ),
156
+ mock.call(self.compute_client, self._security_groups[0]['id']),
157
+ mock.call(self.compute_client, self._security_groups[1]['id']),
162
158
  ]
163
159
  )
164
160
  self.assertIsNone(result)
@@ -187,9 +183,7 @@ class TestDeleteSecurityGroupCompute(compute_fakes.TestComputev2):
187
183
 
188
184
  sg_mock.assert_has_calls(
189
185
  [
190
- mock.call(
191
- self.compute_sdk_client, self._security_groups[0]['id']
192
- ),
186
+ mock.call(self.compute_client, self._security_groups[0]['id']),
193
187
  ]
194
188
  )
195
189
 
@@ -250,7 +244,7 @@ class TestListSecurityGroupCompute(compute_fakes.TestComputev2):
250
244
  columns, data = self.cmd.take_action(parsed_args)
251
245
 
252
246
  sg_mock.assert_called_once_with(
253
- self.compute_sdk_client, all_projects=False
247
+ self.compute_client, all_projects=False
254
248
  )
255
249
  self.assertEqual(self.columns, columns)
256
250
  self.assertCountEqual(self.data, list(data))
@@ -267,9 +261,7 @@ class TestListSecurityGroupCompute(compute_fakes.TestComputev2):
267
261
 
268
262
  columns, data = self.cmd.take_action(parsed_args)
269
263
 
270
- sg_mock.assert_called_once_with(
271
- self.compute_sdk_client, all_projects=True
272
- )
264
+ sg_mock.assert_called_once_with(self.compute_client, all_projects=True)
273
265
  self.assertEqual(self.columns_all_projects, columns)
274
266
  self.assertCountEqual(self.data_all_projects, list(data))
275
267
 
@@ -309,7 +301,7 @@ class TestSetSecurityGroupCompute(compute_fakes.TestComputev2):
309
301
  result = self.cmd.take_action(parsed_args)
310
302
 
311
303
  sg_mock.assert_called_once_with(
312
- self.compute_sdk_client, self._security_group['id']
304
+ self.compute_client, self._security_group['id']
313
305
  )
314
306
  self.assertIsNone(result)
315
307
 
@@ -334,7 +326,7 @@ class TestSetSecurityGroupCompute(compute_fakes.TestComputev2):
334
326
  result = self.cmd.take_action(parsed_args)
335
327
 
336
328
  sg_mock.assert_called_once_with(
337
- self.compute_sdk_client,
329
+ self.compute_client,
338
330
  self._security_group['id'],
339
331
  name=new_name,
340
332
  description=new_description,
@@ -394,7 +386,7 @@ class TestShowSecurityGroupCompute(compute_fakes.TestComputev2):
394
386
  columns, data = self.cmd.take_action(parsed_args)
395
387
 
396
388
  sg_mock.assert_called_once_with(
397
- self.compute_sdk_client, self._security_group['id']
389
+ self.compute_client, self._security_group['id']
398
390
  )
399
391
  self.assertEqual(self.columns, columns)
400
392
  self.assertCountEqual(self.data, data)