python-openstackclient 7.3.1__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 (235) 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 +8 -9
  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 +42 -31
  91. openstackclient/network/v2/router.py +55 -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_credential.py +4 -4
  159. openstackclient/tests/unit/identity/v3/test_endpoint.py +167 -172
  160. openstackclient/tests/unit/identity/v3/test_mappings.py +2 -2
  161. openstackclient/tests/unit/identity/v3/test_trust.py +5 -2
  162. openstackclient/tests/unit/identity/v3/test_user.py +16 -0
  163. openstackclient/tests/unit/image/v1/fakes.py +2 -2
  164. openstackclient/tests/unit/image/v2/test_image.py +39 -1
  165. openstackclient/tests/unit/integ/cli/test_shell.py +1 -2
  166. openstackclient/tests/unit/network/test_common.py +2 -2
  167. openstackclient/tests/unit/network/v2/test_floating_ip_compute.py +8 -14
  168. openstackclient/tests/unit/network/v2/test_floating_ip_network.py +49 -35
  169. openstackclient/tests/unit/network/v2/test_floating_ip_pool_compute.py +1 -1
  170. openstackclient/tests/unit/network/v2/test_network_compute.py +11 -11
  171. openstackclient/tests/unit/network/v2/test_network_trunk.py +2 -2
  172. openstackclient/tests/unit/network/v2/test_port.py +33 -5
  173. openstackclient/tests/unit/network/v2/test_router.py +120 -7
  174. openstackclient/tests/unit/network/v2/test_security_group_compute.py +11 -19
  175. openstackclient/tests/unit/network/v2/test_security_group_rule_compute.py +14 -14
  176. openstackclient/tests/unit/object/v1/test_object_all.py +4 -3
  177. openstackclient/tests/unit/test_shell.py +16 -13
  178. openstackclient/tests/unit/volume/v2/test_volume.py +1 -1
  179. openstackclient/tests/unit/volume/v2/test_volume_transfer_request.py +1 -1
  180. openstackclient/tests/unit/volume/v3/fakes.py +2 -8
  181. openstackclient/tests/unit/volume/v3/test_volume.py +1 -1
  182. openstackclient/tests/unit/volume/v3/test_volume_attachment.py +3 -3
  183. openstackclient/tests/unit/volume/v3/test_volume_snapshot.py +1 -2
  184. openstackclient/tests/unit/volume/v3/test_volume_transfer_request.py +1 -1
  185. openstackclient/volume/client.py +1 -3
  186. openstackclient/volume/v2/consistency_group.py +4 -8
  187. openstackclient/volume/v2/consistency_group_snapshot.py +1 -2
  188. openstackclient/volume/v2/qos_specs.py +1 -2
  189. openstackclient/volume/v2/volume.py +8 -16
  190. openstackclient/volume/v2/volume_backup.py +6 -7
  191. openstackclient/volume/v2/volume_snapshot.py +8 -9
  192. openstackclient/volume/v2/volume_transfer_request.py +0 -3
  193. openstackclient/volume/v2/volume_type.py +10 -21
  194. openstackclient/volume/v3/block_storage_cluster.py +3 -3
  195. openstackclient/volume/v3/block_storage_manage.py +1 -3
  196. openstackclient/volume/v3/volume.py +18 -19
  197. openstackclient/volume/v3/volume_attachment.py +3 -2
  198. openstackclient/volume/v3/volume_backup.py +7 -8
  199. openstackclient/volume/v3/volume_group.py +2 -1
  200. openstackclient/volume/v3/volume_group_snapshot.py +2 -1
  201. openstackclient/volume/v3/volume_snapshot.py +4 -3
  202. openstackclient/volume/v3/volume_type.py +10 -21
  203. {python_openstackclient-7.3.1.dist-info → python_openstackclient-8.0.0.dist-info}/AUTHORS +4 -0
  204. {python_openstackclient-7.3.1.dist-info → python_openstackclient-8.0.0.dist-info}/METADATA +7 -13
  205. {python_openstackclient-7.3.1.dist-info → python_openstackclient-8.0.0.dist-info}/RECORD +210 -233
  206. {python_openstackclient-7.3.1.dist-info → python_openstackclient-8.0.0.dist-info}/WHEEL +1 -1
  207. {python_openstackclient-7.3.1.dist-info → python_openstackclient-8.0.0.dist-info}/entry_points.txt +0 -41
  208. python_openstackclient-8.0.0.dist-info/pbr.json +1 -0
  209. openstackclient/tests/functional/volume/v1/__init__.py +0 -0
  210. openstackclient/tests/functional/volume/v1/common.py +0 -35
  211. openstackclient/tests/functional/volume/v1/test_qos.py +0 -100
  212. openstackclient/tests/functional/volume/v1/test_service.py +0 -76
  213. openstackclient/tests/functional/volume/v1/test_snapshot.py +0 -232
  214. openstackclient/tests/functional/volume/v1/test_transfer_request.py +0 -111
  215. openstackclient/tests/functional/volume/v1/test_volume.py +0 -228
  216. openstackclient/tests/functional/volume/v1/test_volume_type.py +0 -213
  217. openstackclient/tests/unit/volume/v1/__init__.py +0 -0
  218. openstackclient/tests/unit/volume/v1/fakes.py +0 -615
  219. openstackclient/tests/unit/volume/v1/test_qos_specs.py +0 -471
  220. openstackclient/tests/unit/volume/v1/test_service.py +0 -295
  221. openstackclient/tests/unit/volume/v1/test_transfer_request.py +0 -380
  222. openstackclient/tests/unit/volume/v1/test_type.py +0 -633
  223. openstackclient/tests/unit/volume/v1/test_volume.py +0 -1447
  224. openstackclient/tests/unit/volume/v1/test_volume_backup.py +0 -435
  225. openstackclient/volume/v1/__init__.py +0 -0
  226. openstackclient/volume/v1/qos_specs.py +0 -377
  227. openstackclient/volume/v1/service.py +0 -136
  228. openstackclient/volume/v1/volume.py +0 -734
  229. openstackclient/volume/v1/volume_backup.py +0 -302
  230. openstackclient/volume/v1/volume_snapshot.py +0 -433
  231. openstackclient/volume/v1/volume_transfer_request.py +0 -200
  232. openstackclient/volume/v1/volume_type.py +0 -520
  233. python_openstackclient-7.3.1.dist-info/pbr.json +0 -1
  234. {python_openstackclient-7.3.1.dist-info → python_openstackclient-8.0.0.dist-info}/LICENSE +0 -0
  235. {python_openstackclient-7.3.1.dist-info → python_openstackclient-8.0.0.dist-info}/top_level.txt +0 -0
@@ -256,7 +256,7 @@ class DeleteSubnetPool(command.Command):
256
256
  if result > 0:
257
257
  total = len(parsed_args.subnet_pool)
258
258
  msg = _(
259
- "%(result)s of %(total)s subnet pools failed " "to delete."
259
+ "%(result)s of %(total)s subnet pools failed to delete."
260
260
  ) % {'result': result, 'total': total}
261
261
  raise exceptions.CommandError(msg)
262
262
 
@@ -290,7 +290,7 @@ class ListSubnetPool(command.Lister):
290
290
  '--default',
291
291
  action='store_true',
292
292
  help=_(
293
- "List subnet pools used as the default external " "subnet pool"
293
+ "List subnet pools used as the default external subnet pool"
294
294
  ),
295
295
  )
296
296
  default_group.add_argument(
@@ -356,8 +356,8 @@ class ListSubnetPool(command.Lister):
356
356
  _tag.get_tag_filtering_args(parsed_args, filters)
357
357
  data = network_client.subnet_pools(**filters)
358
358
 
359
- headers = ('ID', 'Name', 'Prefixes')
360
- columns = ('id', 'name', 'prefixes')
359
+ headers: tuple[str, ...] = ('ID', 'Name', 'Prefixes')
360
+ columns: tuple[str, ...] = ('id', 'name', 'prefixes')
361
361
  if parsed_args.long:
362
362
  headers += (
363
363
  'Default Prefix Length',
@@ -19,12 +19,11 @@ from osc_lib import utils
19
19
 
20
20
  from openstackclient.api import object_store_v1
21
21
 
22
+ # global variables used when building the shell
22
23
  DEFAULT_API_VERSION = '1'
23
24
  API_VERSION_OPTION = 'os_object_api_version'
24
25
  API_NAME = 'object_store'
25
- API_VERSIONS = {
26
- '1': 'openstackclient.object.client.ObjectClientv1',
27
- }
26
+ API_VERSIONS = ('1',)
28
27
 
29
28
 
30
29
  def make_client(instance):
@@ -148,10 +148,9 @@ class ListContainer(command.Lister):
148
148
  return parser
149
149
 
150
150
  def take_action(self, parsed_args):
151
+ columns: tuple[str, ...] = ('Name',)
151
152
  if parsed_args.long:
152
- columns = ('Name', 'Bytes', 'Count')
153
- else:
154
- columns = ('Name',)
153
+ columns += ('Bytes', 'Count')
155
154
 
156
155
  kwargs = {}
157
156
  if parsed_args.prefix:
@@ -162,16 +162,9 @@ class ListObject(command.Lister):
162
162
  return parser
163
163
 
164
164
  def take_action(self, parsed_args):
165
+ columns: tuple[str, ...] = ('Name',)
165
166
  if parsed_args.long:
166
- columns = (
167
- 'Name',
168
- 'Bytes',
169
- 'Hash',
170
- 'Content Type',
171
- 'Last Modified',
172
- )
173
- else:
174
- columns = ('Name',)
167
+ columns += ('Bytes', 'Hash', 'Content Type', 'Last Modified')
175
168
 
176
169
  kwargs = {}
177
170
  if parsed_args.prefix:
openstackclient/shell.py CHANGED
@@ -88,17 +88,34 @@ class OpenStackShell(shell.OpenStackShell):
88
88
  # this throws an exception if invalid
89
89
  skip_old_check = mod_check_api_version(version_opt)
90
90
 
91
+ # NOTE(stephenfin): API_VERSIONS has traditionally been a
92
+ # dictionary but the values are only used internally and are
93
+ # ignored for the modules using SDK. So we now support tuples
94
+ # instead.
91
95
  mod_versions = getattr(mod, 'API_VERSIONS', None)
92
- if not skip_old_check and mod_versions:
96
+ if mod_versions is not None and not isinstance(
97
+ mod_versions, (dict, tuple)
98
+ ):
99
+ raise TypeError(
100
+ f'Plugin {mod} has incompatible API_VERSIONS. '
101
+ f'Expected: tuple, dict. Got: {type(mod_versions)}. '
102
+ f'Please report this to your package maintainer.'
103
+ )
104
+
105
+ if mod_versions and not skip_old_check:
93
106
  if version_opt not in mod_versions:
94
107
  sorted_versions = sorted(
95
- mod.API_VERSIONS.keys(),
108
+ list(mod.API_VERSIONS),
96
109
  key=lambda s: list(map(int, s.split('.'))),
97
110
  )
98
111
  self.log.warning(
99
- "{} version {} is not in supported versions: {}".format(
100
- api, version_opt, ', '.join(sorted_versions)
101
- )
112
+ "%(name)s API version %(version)s is not in "
113
+ "supported versions: %(supported)s",
114
+ {
115
+ 'name': api,
116
+ 'version': version_opt,
117
+ 'supported': ', '.join(sorted_versions),
118
+ },
102
119
  )
103
120
 
104
121
  # Command groups deal only with major versions
@@ -36,8 +36,8 @@ def execute(cmd, *, fail_ok=False):
36
36
 
37
37
  proc = subprocess.Popen(cmdlist, stdout=stdout, stderr=stderr, env=env)
38
38
 
39
- result_out, result_err = proc.communicate()
40
- result_out = result_out.decode('utf-8')
39
+ result_out_b, result_err = proc.communicate()
40
+ result_out = result_out_b.decode('utf-8')
41
41
  LOG.debug('stdout: %s', result_out)
42
42
  LOG.debug('stderr: %s', result_err)
43
43
 
@@ -25,7 +25,7 @@ class QuotaTests(base.TestCase):
25
25
  test runs as these may run in parallel and otherwise step on each other.
26
26
  """
27
27
 
28
- PROJECT_NAME = None
28
+ PROJECT_NAME: str
29
29
 
30
30
  @classmethod
31
31
  def setUpClass(cls):
@@ -250,6 +250,8 @@ class QuotaTests(base.TestCase):
250
250
  row_headers = [str(r) for r in row.keys()]
251
251
  self.assertEqual(sorted(expected_headers), sorted(row_headers))
252
252
  resources.append(row['Resource'])
253
+ for header in expected_headers[1:]:
254
+ self.assertIsInstance(row[header], int)
253
255
  # Ensure that returned quota has network quota...
254
256
  self.assertIn("networks", resources)
255
257
  # ...and compute quota
@@ -22,9 +22,9 @@ from openstackclient.tests.functional import base
22
22
  class ComputeTestCase(base.TestCase):
23
23
  """Common functional test bits for Compute commands"""
24
24
 
25
- flavor_name = None
26
- image_name = None
27
- network_arg = None
25
+ flavor_name: str
26
+ image_name: str
27
+ network_arg: str
28
28
 
29
29
  def setUp(self):
30
30
  """Select common resources"""
@@ -34,7 +34,7 @@ class ComputeTestCase(base.TestCase):
34
34
  self.network_arg = self.get_network()
35
35
 
36
36
  @classmethod
37
- def get_flavor(cls):
37
+ def get_flavor(cls) -> str:
38
38
  # NOTE(rtheis): Get cirros256 or m1.tiny flavors since functional
39
39
  # tests may create other flavors.
40
40
  flavors = cls.openstack("flavor list", parse_output=True)
@@ -43,10 +43,13 @@ class ComputeTestCase(base.TestCase):
43
43
  if flavor['Name'] in ['m1.tiny', 'cirros256']:
44
44
  server_flavor = flavor['Name']
45
45
  break
46
+
47
+ assert server_flavor is not None
48
+
46
49
  return server_flavor
47
50
 
48
51
  @classmethod
49
- def get_image(cls):
52
+ def get_image(cls) -> str:
50
53
  # NOTE(rtheis): Get first Cirros image since functional tests may
51
54
  # create other images. Image may be named '-uec' or
52
55
  # '-disk'.
@@ -59,10 +62,13 @@ class ComputeTestCase(base.TestCase):
59
62
  ):
60
63
  server_image = image['Name']
61
64
  break
65
+
66
+ assert server_image is not None
67
+
62
68
  return server_image
63
69
 
64
70
  @classmethod
65
- def get_network(cls):
71
+ def get_network(cls) -> str:
66
72
  try:
67
73
  # NOTE(rtheis): Get private network since functional tests may
68
74
  # create other networks.
@@ -156,7 +156,7 @@ class ServerTests(common.ComputeTestCase):
156
156
  server_name3 = cmd_output['name']
157
157
 
158
158
  cmd_output = self.openstack(
159
- 'server list ' '--changes-since ' + updated_at2,
159
+ 'server list --changes-since ' + updated_at2,
160
160
  parse_output=True,
161
161
  )
162
162
 
@@ -852,8 +852,7 @@ class ServerTests(common.ComputeTestCase):
852
852
  # it to the server at /dev/vdb and delete the volume when the
853
853
  # server is deleted.
854
854
  bdm_arg = (
855
- f'--block-device-mapping '
856
- f'vdb={self.image_name}:image:1:true '
855
+ f'--block-device-mapping vdb={self.image_name}:image:1:true '
857
856
  )
858
857
  else:
859
858
  # get image ID
@@ -93,7 +93,7 @@ class ServerEventTests(common.ComputeTestCase):
93
93
  # And verify we can get the event list after it's deleted
94
94
  # Test 'server event list' for deleting
95
95
  cmd_output = self.openstack(
96
- '--os-compute-api-version 2.21 ' 'server event list ' + server_id,
96
+ '--os-compute-api-version 2.21 server event list ' + server_id,
97
97
  parse_output=True,
98
98
  )
99
99
  request_id = None
@@ -37,7 +37,7 @@ class UserTests(common.IdentityTests):
37
37
  new_username = data_utils.rand_name('NewTestUser')
38
38
  new_email = data_utils.rand_name() + '@example.com'
39
39
  raw_output = self.openstack(
40
- 'user set ' '--email {email} ' '--name {new_name} ' '{id}'.format(
40
+ 'user set --email {email} --name {new_name} {id}'.format(
41
41
  email=new_email, new_name=new_username, id=user['id']
42
42
  )
43
43
  )
@@ -187,8 +187,7 @@ class IdentityTests(base.TestCase):
187
187
  f'domain set --disable {cls.domain_name}'
188
188
  )
189
189
  cls.openstack(
190
- '--os-identity-api-version 3 '
191
- f'domain delete {cls.domain_name}'
190
+ f'--os-identity-api-version 3 domain delete {cls.domain_name}'
192
191
  )
193
192
  finally:
194
193
  super().tearDownClass()
@@ -270,9 +269,7 @@ class IdentityTests(base.TestCase):
270
269
  if add_clean_up:
271
270
  self.addCleanup(
272
271
  self.openstack,
273
- 'group delete '
274
- f'--domain {self.domain_name} '
275
- f'{group_name}',
272
+ f'group delete --domain {self.domain_name} {group_name}',
276
273
  )
277
274
  items = self.parse_show(raw_output)
278
275
  self.assert_show_fields(items, self.GROUP_FIELDS)
@@ -305,9 +302,7 @@ class IdentityTests(base.TestCase):
305
302
  if add_clean_up:
306
303
  self.addCleanup(
307
304
  self.openstack,
308
- 'project delete '
309
- f'--domain {self.domain_name} '
310
- f'{project_name}',
305
+ f'project delete --domain {self.domain_name} {project_name}',
311
306
  )
312
307
  return project_name
313
308
 
@@ -50,35 +50,35 @@ class ApplicationCredentialTests(common.IdentityTests):
50
50
  def _create_role_assignments(self):
51
51
  try:
52
52
  user = self.openstack(
53
- 'configuration show -f value' ' -c auth.username'
53
+ 'configuration show -f value -c auth.username'
54
54
  )
55
55
  except Exception:
56
56
  user = self.openstack(
57
- 'configuration show -f value' ' -c auth.user_id'
57
+ 'configuration show -f value -c auth.user_id'
58
58
  )
59
59
  try:
60
60
  user_domain = self.openstack(
61
- 'configuration show -f value' ' -c auth.user_domain_name'
61
+ 'configuration show -f value -c auth.user_domain_name'
62
62
  )
63
63
  except Exception:
64
64
  user_domain = self.openstack(
65
- 'configuration show -f value' ' -c auth.user_domain_id'
65
+ 'configuration show -f value -c auth.user_domain_id'
66
66
  )
67
67
  try:
68
68
  project = self.openstack(
69
- 'configuration show -f value' ' -c auth.project_name'
69
+ 'configuration show -f value -c auth.project_name'
70
70
  )
71
71
  except Exception:
72
72
  project = self.openstack(
73
- 'configuration show -f value' ' -c auth.project_id'
73
+ 'configuration show -f value -c auth.project_id'
74
74
  )
75
75
  try:
76
76
  project_domain = self.openstack(
77
- 'configuration show -f value' ' -c auth.project_domain_name'
77
+ 'configuration show -f value -c auth.project_domain_name'
78
78
  )
79
79
  except Exception:
80
80
  project_domain = self.openstack(
81
- 'configuration show -f value' ' -c auth.project_domain_id'
81
+ 'configuration show -f value -c auth.project_domain_id'
82
82
  )
83
83
  role1 = self._create_dummy_role()
84
84
  role2 = self._create_dummy_role()
@@ -130,7 +130,7 @@ class ApplicationCredentialTests(common.IdentityTests):
130
130
  def test_application_credential_delete(self):
131
131
  name = data_utils.rand_name('name')
132
132
  self.openstack(f'application credential create {name}')
133
- raw_output = self.openstack('application credential delete ' f'{name}')
133
+ raw_output = self.openstack(f'application credential delete {name}')
134
134
  self.assertEqual(0, len(raw_output))
135
135
 
136
136
  def test_application_credential_list(self):
@@ -147,6 +147,6 @@ class ApplicationCredentialTests(common.IdentityTests):
147
147
  self.openstack,
148
148
  f'application credential delete {name}',
149
149
  )
150
- raw_output = self.openstack('application credential show ' f'{name}')
150
+ raw_output = self.openstack(f'application credential show {name}')
151
151
  items = self.parse_show(raw_output)
152
152
  self.assert_show_fields(items, self.APPLICATION_CREDENTIAL_FIELDS)
@@ -45,7 +45,7 @@ class EndpointTests(common.IdentityTests):
45
45
  endpoint_id = self._create_dummy_endpoint(add_clean_up=False)
46
46
  project_id = self._create_dummy_project(add_clean_up=False)
47
47
  raw_output = self.openstack(
48
- 'endpoint add project ' f'{endpoint_id} ' f'{project_id}'
48
+ f'endpoint add project {endpoint_id} {project_id}'
49
49
  )
50
50
  self.assertEqual(0, len(raw_output))
51
51
  raw_output = self.openstack(f'endpoint list --endpoint {endpoint_id}')
@@ -89,11 +89,11 @@ class EndpointTests(common.IdentityTests):
89
89
  endpoint_id = self._create_dummy_endpoint(add_clean_up=False)
90
90
  project_id = self._create_dummy_project(add_clean_up=False)
91
91
  raw_output = self.openstack(
92
- 'endpoint add project ' f'{endpoint_id} ' f'{project_id}'
92
+ f'endpoint add project {endpoint_id} {project_id}'
93
93
  )
94
94
  self.assertEqual(0, len(raw_output))
95
95
 
96
96
  raw_output = self.openstack(
97
- 'endpoint remove project ' f'{endpoint_id} ' f'{project_id}'
97
+ f'endpoint remove project {endpoint_id} {project_id}'
98
98
  )
99
99
  self.assertEqual(0, len(raw_output))
@@ -36,14 +36,14 @@ class GroupTests(common.IdentityTests):
36
36
  def test_group_delete(self):
37
37
  group_name = self._create_dummy_group(add_clean_up=False)
38
38
  raw_output = self.openstack(
39
- 'group delete ' f'--domain {self.domain_name} ' f'{group_name}'
39
+ f'group delete --domain {self.domain_name} {group_name}'
40
40
  )
41
41
  self.assertEqual(0, len(raw_output))
42
42
 
43
43
  def test_group_show(self):
44
44
  group_name = self._create_dummy_group()
45
45
  raw_output = self.openstack(
46
- 'group show ' f'--domain {self.domain_name} ' f'{group_name}'
46
+ f'group show --domain {self.domain_name} {group_name}'
47
47
  )
48
48
  items = self.parse_show(raw_output)
49
49
  self.assert_show_fields(items, self.GROUP_FIELDS)
@@ -59,7 +59,7 @@ class GroupTests(common.IdentityTests):
59
59
  )
60
60
  self.assertEqual(0, len(raw_output))
61
61
  raw_output = self.openstack(
62
- 'group show ' f'--domain {self.domain_name} ' f'{new_group_name}'
62
+ f'group show --domain {self.domain_name} {new_group_name}'
63
63
  )
64
64
  group = self.parse_show_as_object(raw_output)
65
65
  self.assertEqual(new_group_name, group['name'])
@@ -54,13 +54,9 @@ class IdentityProviderTests(common.IdentityTests):
54
54
  identity_provider = self._create_dummy_idp(add_clean_up=True)
55
55
  new_remoteid = data_utils.rand_name('newRemoteId')
56
56
  raw_output = self.openstack(
57
- 'identity provider set '
58
- '%(identity-provider)s '
59
- '--remote-id %(remote-id)s '
60
- % {
61
- 'identity-provider': identity_provider,
62
- 'remote-id': new_remoteid,
63
- }
57
+ f'identity provider set '
58
+ f'{identity_provider} '
59
+ f'--remote-id {new_remoteid}'
64
60
  )
65
61
  self.assertEqual(0, len(raw_output))
66
62
  raw_output = self.openstack(
@@ -174,7 +174,7 @@ class LimitTestCase(common.IdentityTests):
174
174
  }
175
175
 
176
176
  raw_output = self.openstack(
177
- 'limit set' ' --description {description}' ' {limit_id}'.format(
177
+ 'limit set --description {description} {limit_id}'.format(
178
178
  **params
179
179
  ),
180
180
  cloud=SYSTEM_CLOUD,
@@ -188,9 +188,9 @@ class LimitTestCase(common.IdentityTests):
188
188
  params = {'resource_limit': 5, 'limit_id': limit_id}
189
189
 
190
190
  raw_output = self.openstack(
191
- 'limit set'
192
- ' --resource-limit {resource_limit}'
193
- ' {limit_id}'.format(**params),
191
+ 'limit set --resource-limit {resource_limit} {limit_id}'.format(
192
+ **params
193
+ ),
194
194
  cloud=SYSTEM_CLOUD,
195
195
  )
196
196
  items = self.parse_show(raw_output)
@@ -30,9 +30,7 @@ class ProjectTests(common.IdentityTests):
30
30
  )
31
31
  self.addCleanup(
32
32
  self.openstack,
33
- 'project delete '
34
- f'--domain {self.domain_name} '
35
- f'{project_name}',
33
+ f'project delete --domain {self.domain_name} {project_name}',
36
34
  )
37
35
  items = self.parse_show(raw_output)
38
36
  show_fields = list(self.PROJECT_FIELDS)
@@ -45,7 +43,7 @@ class ProjectTests(common.IdentityTests):
45
43
  def test_project_delete(self):
46
44
  project_name = self._create_dummy_project(add_clean_up=False)
47
45
  raw_output = self.openstack(
48
- 'project delete ' f'--domain {self.domain_name} ' f'{project_name}'
46
+ f'project delete --domain {self.domain_name} {project_name}'
49
47
  )
50
48
  self.assertEqual(0, len(raw_output))
51
49
 
@@ -77,9 +75,7 @@ class ProjectTests(common.IdentityTests):
77
75
  self.assertEqual(0, len(raw_output))
78
76
  # check project details
79
77
  raw_output = self.openstack(
80
- 'project show '
81
- f'--domain {self.domain_name} '
82
- f'{new_project_name}'
78
+ f'project show --domain {self.domain_name} {new_project_name}'
83
79
  )
84
80
  items = self.parse_show(raw_output)
85
81
  fields = list(self.PROJECT_FIELDS)
@@ -91,17 +87,12 @@ class ProjectTests(common.IdentityTests):
91
87
  self.assertEqual('v0', project['k0'])
92
88
  # reset project to make sure it will be cleaned up
93
89
  self.openstack(
94
- 'project set '
95
- f'--name {project_name} '
96
- '--enable '
97
- f'{new_project_name}'
90
+ f'project set --name {project_name} --enable {new_project_name}'
98
91
  )
99
92
 
100
93
  def test_project_show(self):
101
94
  raw_output = self.openstack(
102
- 'project show '
103
- f'--domain {self.domain_name} '
104
- f'{self.project_name}'
95
+ f'project show --domain {self.domain_name} {self.project_name}'
105
96
  )
106
97
  items = self.parse_show(raw_output)
107
98
  self.assert_show_fields(items, self.PROJECT_FIELDS)
@@ -49,9 +49,7 @@ class RegionTests(common.IdentityTests):
49
49
  self.assertEqual(region_id, region['region'])
50
50
  # update parent-region
51
51
  raw_output = self.openstack(
52
- 'region set '
53
- f'--parent-region {new_parent_region_id} '
54
- f'{region_id}'
52
+ f'region set --parent-region {new_parent_region_id} {region_id}'
55
53
  )
56
54
  self.assertEqual(0, len(raw_output))
57
55
  # check updated region details
@@ -25,7 +25,7 @@ class RegisteredLimitTestCase(common.IdentityTests):
25
25
 
26
26
  def test_registered_limit_create_with_service_id(self):
27
27
  service_name = self._create_dummy_service()
28
- raw_output = self.openstack('service show' f' {service_name}')
28
+ raw_output = self.openstack(f'service show {service_name}')
29
29
  service_items = self.parse_show(raw_output)
30
30
  service_id = self._extract_value_from_items('id', service_items)
31
31
 
@@ -44,7 +44,7 @@ class RegisteredLimitTestCase(common.IdentityTests):
44
44
  registered_limit_id = self._extract_value_from_items('id', items)
45
45
  self.addCleanup(
46
46
  self.openstack,
47
- 'registered limit delete' f' {registered_limit_id}',
47
+ f'registered limit delete {registered_limit_id}',
48
48
  cloud=SYSTEM_CLOUD,
49
49
  )
50
50
 
@@ -178,7 +178,7 @@ class RegisteredLimitTestCase(common.IdentityTests):
178
178
  add_clean_up=False
179
179
  )
180
180
  raw_output = self.openstack(
181
- 'registered limit delete' f' {registered_limit_id}',
181
+ f'registered limit delete {registered_limit_id}',
182
182
  cloud=SYSTEM_CLOUD,
183
183
  )
184
184
  self.assertEqual(0, len(raw_output))
@@ -23,7 +23,7 @@ class RoleTests(common.IdentityTests):
23
23
  role_name = data_utils.rand_name('TestRole')
24
24
  description = data_utils.rand_name('description')
25
25
  raw_output = self.openstack(
26
- 'role create ' f'--description {description} ' f'{role_name}'
26
+ f'role create --description {description} {role_name}'
27
27
  )
28
28
  role = self.parse_show_as_object(raw_output)
29
29
  self.addCleanup(self.openstack, 'role delete {}'.format(role['id']))
@@ -24,35 +24,25 @@ class RoleAssignmentTests(common.IdentityTests):
24
24
  username = self._create_dummy_user()
25
25
  system = 'all'
26
26
  raw_output = self.openstack(
27
- 'role add '
28
- f'--user {username} '
29
- f'--system {system} '
30
- f'{role_name}'
27
+ f'role add --user {username} --system {system} {role_name}'
31
28
  )
32
29
  self.addCleanup(
33
30
  self.openstack,
34
- 'role remove '
35
- f'--user {username} '
36
- f'--system {system} '
37
- f'{role_name}',
31
+ f'role remove --user {username} --system {system} {role_name}',
38
32
  )
39
33
  self.assertEqual(0, len(raw_output))
40
34
 
41
- raw_output = self.openstack(
42
- 'role assignment list ' f'--user {username} '
43
- )
35
+ raw_output = self.openstack(f'role assignment list --user {username} ')
44
36
  items = self.parse_listing(raw_output)
45
37
  self.assert_table_structure(items, self.ROLE_ASSIGNMENT_LIST_HEADERS)
46
38
 
47
39
  raw_output = self.openstack(
48
- 'role assignment list ' f'--role {role_name} '
40
+ f'role assignment list --role {role_name} '
49
41
  )
50
42
  items = self.parse_listing(raw_output)
51
43
  self.assert_table_structure(items, self.ROLE_ASSIGNMENT_LIST_HEADERS)
52
44
 
53
- raw_output = self.openstack(
54
- 'role assignment list ' f'--system {system} '
55
- )
45
+ raw_output = self.openstack(f'role assignment list --system {system} ')
56
46
  items = self.parse_listing(raw_output)
57
47
  self.assert_table_structure(items, self.ROLE_ASSIGNMENT_LIST_HEADERS)
58
48
 
@@ -61,22 +51,14 @@ class RoleAssignmentTests(common.IdentityTests):
61
51
  group = self._create_dummy_group()
62
52
  system = 'all'
63
53
  raw_output = self.openstack(
64
- 'role add '
65
- f'--group {group} '
66
- f'--system {system} '
67
- f'{role_name}'
54
+ f'role add --group {group} --system {system} {role_name}'
68
55
  )
69
56
  self.addCleanup(
70
57
  self.openstack,
71
- 'role remove '
72
- f'--group {group} '
73
- f'--system {system} '
74
- f'{role_name}',
58
+ f'role remove --group {group} --system {system} {role_name}',
75
59
  )
76
60
  self.assertEqual(0, len(raw_output))
77
- raw_output = self.openstack(
78
- 'role assignment list ' f'--group {group} '
79
- )
61
+ raw_output = self.openstack(f'role assignment list --group {group} ')
80
62
  items = self.parse_listing(raw_output)
81
63
  self.assert_table_structure(items, self.ROLE_ASSIGNMENT_LIST_HEADERS)
82
64
 
@@ -98,7 +80,7 @@ class RoleAssignmentTests(common.IdentityTests):
98
80
  )
99
81
  self.assertEqual(0, len(raw_output))
100
82
  raw_output = self.openstack(
101
- 'role assignment list ' f'--domain {self.domain_name} '
83
+ f'role assignment list --domain {self.domain_name} '
102
84
  )
103
85
  items = self.parse_listing(raw_output)
104
86
  self.assert_table_structure(items, self.ROLE_ASSIGNMENT_LIST_HEADERS)
@@ -121,23 +103,23 @@ class RoleAssignmentTests(common.IdentityTests):
121
103
  )
122
104
  self.assertEqual(0, len(raw_output))
123
105
  raw_output = self.openstack(
124
- 'role assignment list ' f'--project {self.project_name} '
106
+ f'role assignment list --project {self.project_name} '
125
107
  )
126
108
  items = self.parse_listing(raw_output)
127
109
  self.assert_table_structure(items, self.ROLE_ASSIGNMENT_LIST_HEADERS)
128
110
 
129
111
  def test_role_assignment_list_effective(self):
130
- raw_output = self.openstack('role assignment list ' '--effective')
112
+ raw_output = self.openstack('role assignment list --effective')
131
113
  items = self.parse_listing(raw_output)
132
114
  self.assert_table_structure(items, self.ROLE_ASSIGNMENT_LIST_HEADERS)
133
115
 
134
116
  def test_role_assignment_list_auth_user(self):
135
- raw_output = self.openstack('role assignment list ' '--auth-user')
117
+ raw_output = self.openstack('role assignment list --auth-user')
136
118
  items = self.parse_listing(raw_output)
137
119
  self.assert_table_structure(items, self.ROLE_ASSIGNMENT_LIST_HEADERS)
138
120
 
139
121
  def test_role_assignment_list_auth_project(self):
140
- raw_output = self.openstack('role assignment list ' '--auth-project')
122
+ raw_output = self.openstack('role assignment list --auth-project')
141
123
  items = self.parse_listing(raw_output)
142
124
  self.assert_table_structure(items, self.ROLE_ASSIGNMENT_LIST_HEADERS)
143
125
 
@@ -52,13 +52,9 @@ class ServiceProviderTests(common.IdentityTests):
52
52
  service_provider = self._create_dummy_sp(add_clean_up=True)
53
53
  new_description = data_utils.rand_name('newDescription')
54
54
  raw_output = self.openstack(
55
- 'service provider set '
56
- '%(service-provider)s '
57
- '--description %(description)s '
58
- % {
59
- 'service-provider': service_provider,
60
- 'description': new_description,
61
- }
55
+ f'service provider set '
56
+ f'{service_provider} '
57
+ f'--description {new_description}'
62
58
  )
63
59
  updated_value = self.parse_show_as_object(raw_output)
64
60
  self.assertEqual(new_description, updated_value.get('description'))