python-openstackclient 8.2.0__py3-none-any.whl → 9.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 (233) hide show
  1. openstackclient/api/object_store_v1.py +4 -1
  2. openstackclient/command.py +27 -0
  3. openstackclient/common/availability_zone.py +1 -1
  4. openstackclient/common/clientmanager.py +59 -21
  5. openstackclient/common/configuration.py +1 -1
  6. openstackclient/common/extension.py +1 -1
  7. openstackclient/common/limits.py +1 -1
  8. openstackclient/common/module.py +5 -3
  9. openstackclient/common/project_cleanup.py +10 -8
  10. openstackclient/common/quota.py +54 -23
  11. openstackclient/common/versions.py +1 -2
  12. openstackclient/compute/v2/agent.py +1 -1
  13. openstackclient/compute/v2/aggregate.py +6 -5
  14. openstackclient/compute/v2/console.py +5 -3
  15. openstackclient/compute/v2/console_connection.py +1 -1
  16. openstackclient/compute/v2/flavor.py +1 -1
  17. openstackclient/compute/v2/host.py +1 -1
  18. openstackclient/compute/v2/hypervisor.py +1 -1
  19. openstackclient/compute/v2/hypervisor_stats.py +1 -1
  20. openstackclient/compute/v2/keypair.py +1 -1
  21. openstackclient/compute/v2/server.py +78 -29
  22. openstackclient/compute/v2/server_backup.py +1 -1
  23. openstackclient/compute/v2/server_event.py +1 -1
  24. openstackclient/compute/v2/server_group.py +4 -2
  25. openstackclient/compute/v2/server_image.py +1 -1
  26. openstackclient/compute/v2/server_migration.py +1 -1
  27. openstackclient/compute/v2/server_volume.py +1 -1
  28. openstackclient/compute/v2/service.py +1 -1
  29. openstackclient/compute/v2/usage.py +6 -4
  30. openstackclient/identity/common.py +33 -1
  31. openstackclient/identity/v2_0/catalog.py +3 -2
  32. openstackclient/identity/v2_0/ec2creds.py +1 -1
  33. openstackclient/identity/v2_0/endpoint.py +1 -1
  34. openstackclient/identity/v2_0/project.py +17 -7
  35. openstackclient/identity/v2_0/role.py +1 -1
  36. openstackclient/identity/v2_0/role_assignment.py +3 -3
  37. openstackclient/identity/v2_0/service.py +4 -2
  38. openstackclient/identity/v2_0/token.py +1 -1
  39. openstackclient/identity/v2_0/user.py +2 -2
  40. openstackclient/identity/v3/access_rule.py +16 -4
  41. openstackclient/identity/v3/application_credential.py +30 -10
  42. openstackclient/identity/v3/catalog.py +3 -3
  43. openstackclient/identity/v3/consumer.py +1 -1
  44. openstackclient/identity/v3/credential.py +1 -1
  45. openstackclient/identity/v3/domain.py +10 -4
  46. openstackclient/identity/v3/ec2creds.py +1 -1
  47. openstackclient/identity/v3/endpoint.py +33 -12
  48. openstackclient/identity/v3/endpoint_group.py +1 -1
  49. openstackclient/identity/v3/federation_protocol.py +40 -41
  50. openstackclient/identity/v3/group.py +11 -5
  51. openstackclient/identity/v3/identity_provider.py +12 -10
  52. openstackclient/identity/v3/implied_role.py +1 -1
  53. openstackclient/identity/v3/limit.py +86 -85
  54. openstackclient/identity/v3/mapping.py +1 -1
  55. openstackclient/identity/v3/policy.py +1 -1
  56. openstackclient/identity/v3/project.py +191 -115
  57. openstackclient/identity/v3/region.py +1 -1
  58. openstackclient/identity/v3/registered_limit.py +97 -109
  59. openstackclient/identity/v3/role.py +20 -39
  60. openstackclient/identity/v3/role_assignment.py +12 -23
  61. openstackclient/identity/v3/service.py +1 -1
  62. openstackclient/identity/v3/service_provider.py +1 -1
  63. openstackclient/identity/v3/tag.py +1 -11
  64. openstackclient/identity/v3/token.py +3 -2
  65. openstackclient/identity/v3/trust.py +4 -2
  66. openstackclient/identity/v3/unscoped_saml.py +1 -1
  67. openstackclient/identity/v3/user.py +22 -13
  68. openstackclient/image/v1/image.py +19 -16
  69. openstackclient/image/v2/cache.py +1 -1
  70. openstackclient/image/v2/image.py +16 -12
  71. openstackclient/image/v2/info.py +1 -1
  72. openstackclient/image/v2/metadef_namespaces.py +1 -1
  73. openstackclient/image/v2/metadef_objects.py +1 -1
  74. openstackclient/image/v2/metadef_properties.py +3 -2
  75. openstackclient/image/v2/metadef_resource_type_association.py +1 -1
  76. openstackclient/image/v2/metadef_resource_types.py +1 -1
  77. openstackclient/image/v2/task.py +1 -1
  78. openstackclient/network/common.py +10 -9
  79. openstackclient/network/v2/address_group.py +4 -3
  80. openstackclient/network/v2/address_scope.py +8 -6
  81. openstackclient/network/v2/default_security_group_rule.py +9 -8
  82. openstackclient/network/v2/floating_ip.py +16 -9
  83. openstackclient/network/v2/floating_ip_port_forwarding.py +9 -6
  84. openstackclient/network/v2/ip_availability.py +7 -4
  85. openstackclient/network/v2/l3_conntrack_helper.py +11 -4
  86. openstackclient/network/v2/local_ip.py +13 -7
  87. openstackclient/network/v2/local_ip_association.py +7 -4
  88. openstackclient/network/v2/ndp_proxy.py +13 -6
  89. openstackclient/network/v2/network.py +33 -16
  90. openstackclient/network/v2/network_agent.py +5 -5
  91. openstackclient/network/v2/network_auto_allocated_topology.py +1 -1
  92. openstackclient/network/v2/network_flavor.py +1 -1
  93. openstackclient/network/v2/network_flavor_profile.py +1 -1
  94. openstackclient/network/v2/network_meter.py +1 -1
  95. openstackclient/network/v2/network_meter_rule.py +1 -1
  96. openstackclient/network/v2/network_qos_policy.py +7 -5
  97. openstackclient/network/v2/network_qos_rule.py +1 -1
  98. openstackclient/network/v2/network_qos_rule_type.py +1 -1
  99. openstackclient/network/v2/network_rbac.py +8 -5
  100. openstackclient/network/v2/network_segment.py +2 -2
  101. openstackclient/network/v2/network_segment_range.py +13 -6
  102. openstackclient/network/v2/network_service_provider.py +1 -1
  103. openstackclient/network/v2/network_trunk.py +65 -42
  104. openstackclient/network/v2/port.py +22 -20
  105. openstackclient/network/v2/router.py +19 -8
  106. openstackclient/network/v2/security_group.py +10 -6
  107. openstackclient/network/v2/security_group_rule.py +11 -5
  108. openstackclient/network/v2/subnet.py +17 -18
  109. openstackclient/network/v2/subnet_pool.py +11 -9
  110. openstackclient/network/v2/taas/__init__.py +0 -0
  111. openstackclient/network/v2/taas/tap_flow.py +245 -0
  112. openstackclient/network/v2/taas/tap_mirror.py +237 -0
  113. openstackclient/network/v2/taas/tap_service.py +211 -0
  114. openstackclient/object/v1/account.py +1 -1
  115. openstackclient/object/v1/container.py +1 -1
  116. openstackclient/object/v1/object.py +1 -1
  117. openstackclient/shell.py +18 -8
  118. openstackclient/tests/functional/identity/v3/test_catalog.py +42 -23
  119. openstackclient/tests/functional/identity/v3/test_limit.py +47 -0
  120. openstackclient/tests/functional/identity/v3/test_role_assignment.py +174 -0
  121. openstackclient/tests/functional/image/v2/test_cache.py +54 -0
  122. openstackclient/tests/functional/image/v2/test_metadef_objects.py +69 -0
  123. openstackclient/tests/functional/image/v2/test_metadef_resource_type.py +55 -0
  124. openstackclient/tests/functional/volume/v3/test_volume_snapshot.py +46 -132
  125. openstackclient/tests/unit/common/test_command.py +1 -1
  126. openstackclient/tests/unit/common/test_extension.py +2 -3
  127. openstackclient/tests/unit/common/test_module.py +14 -7
  128. openstackclient/tests/unit/common/test_quota.py +79 -0
  129. openstackclient/tests/unit/compute/v2/test_aggregate.py +5 -3
  130. openstackclient/tests/unit/compute/v2/test_console.py +1 -4
  131. openstackclient/tests/unit/compute/v2/test_flavor.py +1 -3
  132. openstackclient/tests/unit/compute/v2/test_hypervisor_stats.py +1 -9
  133. openstackclient/tests/unit/compute/v2/test_server.py +370 -38
  134. openstackclient/tests/unit/compute/v2/test_server_backup.py +1 -3
  135. openstackclient/tests/unit/compute/v2/test_service.py +1 -3
  136. openstackclient/tests/unit/fakes.py +35 -134
  137. openstackclient/tests/unit/identity/test_common.py +100 -0
  138. openstackclient/tests/unit/identity/v2_0/test_project.py +4 -4
  139. openstackclient/tests/unit/identity/v3/fakes.py +10 -2
  140. openstackclient/tests/unit/identity/v3/test_application_credential.py +3 -3
  141. openstackclient/tests/unit/identity/v3/test_domain.py +1 -1
  142. openstackclient/tests/unit/identity/v3/test_endpoint.py +1 -1
  143. openstackclient/tests/unit/identity/v3/test_group.py +4 -2
  144. openstackclient/tests/unit/identity/v3/test_identity_provider.py +10 -10
  145. openstackclient/tests/unit/identity/v3/test_limit.py +197 -145
  146. openstackclient/tests/unit/identity/v3/test_oauth.py +1 -1
  147. openstackclient/tests/unit/identity/v3/test_project.py +832 -513
  148. openstackclient/tests/unit/identity/v3/test_protocol.py +97 -88
  149. openstackclient/tests/unit/identity/v3/test_registered_limit.py +356 -221
  150. openstackclient/tests/unit/identity/v3/test_role.py +1 -82
  151. openstackclient/tests/unit/identity/v3/test_user.py +7 -51
  152. openstackclient/tests/unit/image/v2/test_image.py +116 -5
  153. openstackclient/tests/unit/network/test_common.py +9 -13
  154. openstackclient/tests/unit/network/v2/taas/__init__.py +0 -0
  155. openstackclient/tests/unit/network/v2/taas/test_osc_tap_flow.py +276 -0
  156. openstackclient/tests/unit/network/v2/taas/test_osc_tap_mirror.py +288 -0
  157. openstackclient/tests/unit/network/v2/taas/test_osc_tap_service.py +271 -0
  158. openstackclient/tests/unit/network/v2/test_address_group.py +19 -22
  159. openstackclient/tests/unit/network/v2/test_address_scope.py +10 -15
  160. openstackclient/tests/unit/network/v2/test_default_security_group_rule.py +38 -49
  161. openstackclient/tests/unit/network/v2/test_floating_ip_network.py +21 -27
  162. openstackclient/tests/unit/network/v2/test_floating_ip_port_forwarding.py +21 -18
  163. openstackclient/tests/unit/network/v2/test_ip_availability.py +6 -8
  164. openstackclient/tests/unit/network/v2/test_l3_conntrack_helper.py +6 -15
  165. openstackclient/tests/unit/network/v2/test_local_ip.py +12 -23
  166. openstackclient/tests/unit/network/v2/test_local_ip_association.py +13 -18
  167. openstackclient/tests/unit/network/v2/test_ndp_proxy.py +11 -21
  168. openstackclient/tests/unit/network/v2/test_network.py +41 -37
  169. openstackclient/tests/unit/network/v2/test_network_agent.py +13 -20
  170. openstackclient/tests/unit/network/v2/test_network_auto_allocated_topology.py +5 -8
  171. openstackclient/tests/unit/network/v2/test_network_flavor.py +14 -26
  172. openstackclient/tests/unit/network/v2/test_network_flavor_profile.py +14 -17
  173. openstackclient/tests/unit/network/v2/test_network_meter.py +7 -17
  174. openstackclient/tests/unit/network/v2/test_network_meter_rule.py +10 -20
  175. openstackclient/tests/unit/network/v2/test_network_qos_policy.py +7 -13
  176. openstackclient/tests/unit/network/v2/test_network_qos_rule.py +44 -54
  177. openstackclient/tests/unit/network/v2/test_network_qos_rule_type.py +2 -7
  178. openstackclient/tests/unit/network/v2/test_network_rbac.py +21 -36
  179. openstackclient/tests/unit/network/v2/test_network_segment.py +13 -29
  180. openstackclient/tests/unit/network/v2/test_network_segment_range.py +20 -19
  181. openstackclient/tests/unit/network/v2/test_network_service_provider.py +1 -4
  182. openstackclient/tests/unit/network/v2/test_network_trunk.py +52 -47
  183. openstackclient/tests/unit/network/v2/test_port.py +75 -86
  184. openstackclient/tests/unit/network/v2/test_router.py +104 -126
  185. openstackclient/tests/unit/network/v2/test_security_group_network.py +19 -26
  186. openstackclient/tests/unit/network/v2/test_security_group_rule_network.py +17 -18
  187. openstackclient/tests/unit/network/v2/test_subnet.py +35 -46
  188. openstackclient/tests/unit/network/v2/test_subnet_pool.py +21 -33
  189. openstackclient/tests/unit/volume/test_find_resource.py +4 -13
  190. openstackclient/tests/unit/volume/v2/test_consistency_group.py +8 -2
  191. openstackclient/tests/unit/volume/v2/test_volume.py +7 -6
  192. openstackclient/tests/unit/volume/v2/test_volume_backup.py +3 -1
  193. openstackclient/tests/unit/volume/v3/test_volume.py +38 -12
  194. openstackclient/tests/unit/volume/v3/test_volume_backup.py +9 -0
  195. openstackclient/volume/client.py +7 -17
  196. openstackclient/volume/v2/backup_record.py +1 -1
  197. openstackclient/volume/v2/consistency_group.py +9 -9
  198. openstackclient/volume/v2/consistency_group_snapshot.py +3 -3
  199. openstackclient/volume/v2/qos_specs.py +3 -3
  200. openstackclient/volume/v2/service.py +1 -1
  201. openstackclient/volume/v2/volume.py +14 -7
  202. openstackclient/volume/v2/volume_backend.py +1 -1
  203. openstackclient/volume/v2/volume_backup.py +7 -5
  204. openstackclient/volume/v2/volume_host.py +1 -2
  205. openstackclient/volume/v2/volume_snapshot.py +4 -4
  206. openstackclient/volume/v2/volume_transfer_request.py +3 -3
  207. openstackclient/volume/v2/volume_type.py +16 -11
  208. openstackclient/volume/v3/block_storage_cleanup.py +1 -1
  209. openstackclient/volume/v3/block_storage_cluster.py +1 -1
  210. openstackclient/volume/v3/block_storage_log_level.py +1 -1
  211. openstackclient/volume/v3/block_storage_manage.py +1 -1
  212. openstackclient/volume/v3/block_storage_resource_filter.py +1 -1
  213. openstackclient/volume/v3/service.py +1 -1
  214. openstackclient/volume/v3/volume.py +16 -9
  215. openstackclient/volume/v3/volume_attachment.py +6 -5
  216. openstackclient/volume/v3/volume_backup.py +20 -5
  217. openstackclient/volume/v3/volume_group.py +1 -1
  218. openstackclient/volume/v3/volume_group_snapshot.py +1 -1
  219. openstackclient/volume/v3/volume_group_type.py +1 -1
  220. openstackclient/volume/v3/volume_message.py +1 -1
  221. openstackclient/volume/v3/volume_snapshot.py +4 -4
  222. openstackclient/volume/v3/volume_transfer_request.py +3 -3
  223. openstackclient/volume/v3/volume_type.py +20 -14
  224. {python_openstackclient-8.2.0.dist-info → python_openstackclient-9.0.0.dist-info}/METADATA +15 -13
  225. {python_openstackclient-8.2.0.dist-info → python_openstackclient-9.0.0.dist-info}/RECORD +231 -219
  226. {python_openstackclient-8.2.0.dist-info → python_openstackclient-9.0.0.dist-info}/WHEEL +1 -1
  227. {python_openstackclient-8.2.0.dist-info → python_openstackclient-9.0.0.dist-info}/entry_points.txt +15 -0
  228. {python_openstackclient-8.2.0.dist-info → python_openstackclient-9.0.0.dist-info/licenses}/AUTHORS +15 -0
  229. python_openstackclient-9.0.0.dist-info/pbr.json +1 -0
  230. openstackclient/tests/unit/common/test_logs.py +0 -221
  231. python_openstackclient-8.2.0.dist-info/pbr.json +0 -1
  232. {python_openstackclient-8.2.0.dist-info → python_openstackclient-9.0.0.dist-info/licenses}/LICENSE +0 -0
  233. {python_openstackclient-8.2.0.dist-info → python_openstackclient-9.0.0.dist-info}/top_level.txt +0 -0
@@ -15,10 +15,10 @@
15
15
 
16
16
  """Identity v3 Token action implementations"""
17
17
 
18
- from osc_lib.command import command
19
18
  from osc_lib import exceptions
20
19
  from osc_lib import utils
21
20
 
21
+ from openstackclient import command
22
22
  from openstackclient.i18n import _
23
23
  from openstackclient.identity import common
24
24
 
@@ -37,6 +37,7 @@ class AuthorizeRequestToken(command.ShowOne):
37
37
  parser.add_argument(
38
38
  '--role',
39
39
  metavar='<role>',
40
+ dest='roles',
40
41
  action='append',
41
42
  default=[],
42
43
  required=True,
@@ -52,7 +53,7 @@ class AuthorizeRequestToken(command.ShowOne):
52
53
 
53
54
  # NOTE(stevemar): We want a list of role ids
54
55
  roles = []
55
- for role in parsed_args.role:
56
+ for role in parsed_args.roles:
56
57
  role_id = utils.find_resource(
57
58
  identity_client.roles,
58
59
  role,
@@ -18,10 +18,10 @@ import itertools
18
18
  import logging
19
19
 
20
20
  from openstack import exceptions as sdk_exceptions
21
- from osc_lib.command import command
22
21
  from osc_lib import exceptions
23
22
  from osc_lib import utils
24
23
 
24
+ from openstackclient import command
25
25
  from openstackclient.i18n import _
26
26
  from openstackclient.identity import common
27
27
 
@@ -179,7 +179,9 @@ class CreateTrust(command.ShowOne):
179
179
  roles = []
180
180
  for role in parsed_args.roles:
181
181
  try:
182
- role_id = identity_client.find_role(role).id
182
+ role_id = identity_client.find_role(
183
+ role, ignore_missing=False
184
+ ).id
183
185
  except sdk_exceptions.ForbiddenException:
184
186
  role_id = role
185
187
  roles.append({"id": role_id})
@@ -17,9 +17,9 @@ The first step of federated auth is to fetch an unscoped token. From there,
17
17
  the user can list domains and projects they are allowed to access, and request
18
18
  a scoped token."""
19
19
 
20
- from osc_lib.command import command
21
20
  from osc_lib import utils
22
21
 
22
+ from openstackclient import command
23
23
  from openstackclient.i18n import _
24
24
 
25
25
 
@@ -20,10 +20,10 @@ import logging
20
20
  import typing as ty
21
21
 
22
22
  from openstack import exceptions as sdk_exc
23
- from osc_lib.command import command
24
23
  from osc_lib import exceptions
25
24
  from osc_lib import utils
26
25
 
26
+ from openstackclient import command
27
27
  from openstackclient.i18n import _
28
28
  from openstackclient.identity import common
29
29
 
@@ -82,9 +82,9 @@ def _get_options_for_user(identity_client, parsed_args):
82
82
  options['multi_factor_auth_enabled'] = True
83
83
  if parsed_args.disable_multi_factor_auth:
84
84
  options['multi_factor_auth_enabled'] = False
85
- if parsed_args.multi_factor_auth_rule:
85
+ if parsed_args.multi_factor_auth_rules:
86
86
  auth_rules = [
87
- rule.split(",") for rule in parsed_args.multi_factor_auth_rule
87
+ rule.split(",") for rule in parsed_args.multi_factor_auth_rules
88
88
  ]
89
89
  if auth_rules:
90
90
  options['multi_factor_auth_rules'] = auth_rules
@@ -175,7 +175,8 @@ def _add_user_options(parser):
175
175
  parser.add_argument(
176
176
  '--multi-factor-auth-rule',
177
177
  metavar='<rule>',
178
- action="append",
178
+ dest='multi_factor_auth_rules',
179
+ action='append',
179
180
  default=[],
180
181
  help=_(
181
182
  'Set multi-factor auth rules. For example, to set a rule '
@@ -298,6 +299,9 @@ class CreateUser(command.ShowOne):
298
299
  "when a user does not have a password."
299
300
  )
300
301
  )
302
+ else:
303
+ kwargs['password'] = password
304
+
301
305
  options = _get_options_for_user(identity_client, parsed_args)
302
306
  if options:
303
307
  kwargs['options'] = options
@@ -306,7 +310,6 @@ class CreateUser(command.ShowOne):
306
310
  user = identity_client.create_user(
307
311
  is_enabled=is_enabled,
308
312
  name=parsed_args.name,
309
- password=password,
310
313
  **kwargs,
311
314
  )
312
315
  except sdk_exc.ConflictException:
@@ -420,7 +423,8 @@ class ListUser(command.Lister):
420
423
  dest='is_enabled',
421
424
  default=None,
422
425
  help=_(
423
- 'List only enabled users, does nothing with --project and --group'
426
+ 'List only enabled users, does nothing with '
427
+ '--project and --group'
424
428
  ),
425
429
  )
426
430
  parser.add_argument(
@@ -429,7 +433,8 @@ class ListUser(command.Lister):
429
433
  dest='is_enabled',
430
434
  default=None,
431
435
  help=_(
432
- 'List only disabled users, does nothing with --project and --group'
436
+ 'List only disabled users, does nothing with '
437
+ '--project and --group'
433
438
  ),
434
439
  )
435
440
  return parser
@@ -441,6 +446,7 @@ class ListUser(command.Lister):
441
446
  if parsed_args.domain:
442
447
  domain = identity_client.find_domain(
443
448
  name_or_id=parsed_args.domain,
449
+ ignore_missing=False,
444
450
  ).id
445
451
 
446
452
  group = None
@@ -467,15 +473,13 @@ class ListUser(command.Lister):
467
473
  ignore_missing=False,
468
474
  ).id
469
475
 
470
- assignments = identity_client.role_assignments_filter(
471
- project=project
472
- )
473
-
474
476
  # NOTE(stevemar): If a user has more than one role on a project
475
477
  # then they will have two entries in the returned data. Since we
476
478
  # are looking for any role, let's just track unique user IDs.
477
479
  user_ids = set()
478
- for assignment in assignments:
480
+ for assignment in identity_client.role_assignments(
481
+ scope_project_id=project
482
+ ):
479
483
  if assignment.user:
480
484
  user_ids.add(assignment.user['id'])
481
485
 
@@ -689,7 +693,12 @@ class SetPasswordUser(command.Command):
689
693
  def take_action(self, parsed_args):
690
694
  identity_client = self.app.client_manager.sdk_connection.identity
691
695
  conn = self.app.client_manager.sdk_connection
692
- user_id = conn.config.get_auth().get_user_id(conn.identity)
696
+ auth = conn.config.get_auth()
697
+ if auth is None:
698
+ # this will never happen
699
+ raise exceptions.CommandError('invalid authentication info')
700
+
701
+ user_id = auth.get_user_id(conn.identity)
693
702
 
694
703
  # FIXME(gyee): there are two scenarios:
695
704
  #
@@ -19,15 +19,16 @@ import argparse
19
19
  import logging
20
20
  import os
21
21
  import sys
22
+ import typing as ty
22
23
 
23
24
  from cliff import columns as cliff_columns
24
25
  from osc_lib.api import utils as api_utils
25
26
  from osc_lib.cli import format_columns
26
27
  from osc_lib.cli import parseractions
27
- from osc_lib.command import command
28
28
  from osc_lib import exceptions
29
29
  from osc_lib import utils
30
30
 
31
+ from openstackclient import command
31
32
  from openstackclient.i18n import _
32
33
 
33
34
  CONTAINER_CHOICES = ["ami", "ari", "aki", "bare", "docker", "ova", "ovf"]
@@ -67,10 +68,7 @@ def _get_columns(item):
67
68
  )
68
69
 
69
70
 
70
- _formatters = {}
71
-
72
-
73
- class HumanReadableSizeColumn(cliff_columns.FormattableColumn):
71
+ class HumanReadableSizeColumn(cliff_columns.FormattableColumn[int]):
74
72
  def human_readable(self):
75
73
  """Return a formatted visibility string
76
74
 
@@ -84,7 +82,7 @@ class HumanReadableSizeColumn(cliff_columns.FormattableColumn):
84
82
  return ''
85
83
 
86
84
 
87
- class VisibilityColumn(cliff_columns.FormattableColumn):
85
+ class VisibilityColumn(cliff_columns.FormattableColumn[bool]):
88
86
  def human_readable(self):
89
87
  """Return a formatted visibility string
90
88
 
@@ -340,9 +338,12 @@ class CreateImage(command.ShowOne):
340
338
 
341
339
  if image:
342
340
  display_columns, columns = _get_columns(image)
343
- _formatters['properties'] = format_columns.DictColumn
344
341
  data = utils.get_item_properties(
345
- image, columns, formatters=_formatters
342
+ image,
343
+ columns,
344
+ formatters={
345
+ 'properties': format_columns.DictColumn,
346
+ },
346
347
  )
347
348
  return (display_columns, data)
348
349
  elif info:
@@ -493,19 +494,19 @@ class ListImage(command.Lister):
493
494
  column_headers = columns
494
495
 
495
496
  # List of image data received
496
- data = list(image_client.images(**kwargs))
497
+ images = list(image_client.images(**kwargs))
497
498
 
498
499
  if parsed_args.property:
499
500
  # NOTE(dtroyer): coerce to a list to subscript it in py3
500
501
  attr, value = list(parsed_args.property.items())[0]
501
502
  api_utils.simple_filter(
502
- data,
503
+ images,
503
504
  attr=attr,
504
505
  value=value,
505
506
  property_field='properties',
506
507
  )
507
508
 
508
- data = utils.sort_items(data, parsed_args.sort)
509
+ data = utils.sort_items(images, parsed_args.sort)
509
510
 
510
511
  return (
511
512
  column_headers,
@@ -839,11 +840,13 @@ class ShowImage(command.ShowOne):
839
840
  parsed_args.image, ignore_missing=False
840
841
  )
841
842
 
843
+ formatters: dict[
844
+ str, type[cliff_columns.FormattableColumn[ty.Any]]
845
+ ] = {
846
+ 'properties': format_columns.DictColumn,
847
+ }
842
848
  if parsed_args.human_readable:
843
- _formatters['size'] = HumanReadableSizeColumn
849
+ formatters['size'] = HumanReadableSizeColumn
844
850
  display_columns, columns = _get_columns(image)
845
- _formatters['properties'] = format_columns.DictColumn
846
- data = utils.get_item_properties(
847
- image, columns, formatters=_formatters
848
- )
851
+ data = utils.get_item_properties(image, columns, formatters=formatters)
849
852
  return (display_columns, data)
@@ -17,10 +17,10 @@ import copy
17
17
  import datetime
18
18
  import logging
19
19
 
20
- from osc_lib.command import command
21
20
  from osc_lib import exceptions
22
21
  from osc_lib import utils
23
22
 
23
+ from openstackclient import command
24
24
  from openstackclient.i18n import _
25
25
 
26
26
 
@@ -30,10 +30,10 @@ from openstack import utils as sdk_utils
30
30
  from osc_lib.api import utils as api_utils
31
31
  from osc_lib.cli import format_columns
32
32
  from osc_lib.cli import parseractions
33
- from osc_lib.command import command
34
33
  from osc_lib import exceptions
35
34
  from osc_lib import utils
36
35
 
36
+ from openstackclient import command
37
37
  from openstackclient.common import pagination
38
38
  from openstackclient.common import progressbar
39
39
  from openstackclient.i18n import _
@@ -551,7 +551,7 @@ class CreateImage(command.ShowOne):
551
551
  sign_cert_id = parsed_args.sign_cert_id
552
552
  signer = image_signer.ImageSigner()
553
553
  try:
554
- pw = utils.get_password(
554
+ pw: str | None = utils.get_password(
555
555
  self.app.stdin,
556
556
  prompt=(
557
557
  "Please enter private key password, leave "
@@ -562,12 +562,11 @@ class CreateImage(command.ShowOne):
562
562
 
563
563
  if not pw or len(pw) < 1:
564
564
  pw = None
565
- else:
566
- # load_private_key() requires the password to be
567
- # passed as bytes
568
- pw = pw.encode()
569
565
 
570
- signer.load_private_key(sign_key_path, password=pw)
566
+ signer.load_private_key(
567
+ sign_key_path,
568
+ password=pw.encode() if pw else None,
569
+ )
571
570
  except Exception:
572
571
  msg = _(
573
572
  "Error during sign operation: private key "
@@ -623,7 +622,7 @@ class CreateImage(command.ShowOne):
623
622
  )
624
623
  # TODO(stephenfin): These should be an error in a future
625
624
  # version
626
- LOG.warning(msg % opt_name)
625
+ LOG.warning(msg, opt_name)
627
626
 
628
627
  source_volume = volume_client.find_volume(
629
628
  parsed_args.volume, ignore_missing=False
@@ -933,18 +932,19 @@ class ListImage(command.Lister):
933
932
  if 'limit' in kwargs:
934
933
  # Disable automatic pagination in SDK
935
934
  kwargs['paginated'] = False
936
- data = list(image_client.images(**kwargs))
935
+
936
+ images = list(image_client.images(**kwargs))
937
937
 
938
938
  if parsed_args.property:
939
939
  for attr, value in parsed_args.property.items():
940
940
  api_utils.simple_filter(
941
- data,
941
+ images,
942
942
  attr=attr,
943
943
  value=value,
944
944
  property_field='properties',
945
945
  )
946
946
 
947
- data = utils.sort_items(data, parsed_args.sort, str)
947
+ data = utils.sort_items(images, parsed_args.sort, str)
948
948
 
949
949
  return (
950
950
  column_headers,
@@ -1393,7 +1393,10 @@ class SetImage(command.Command):
1393
1393
  if parsed_args.visibility is not None:
1394
1394
  kwargs['visibility'] = parsed_args.visibility
1395
1395
 
1396
- if parsed_args.project:
1396
+ # Only set owner_id if --project is used WITHOUT membership flags
1397
+ # When --project is used with --accept/--reject/--pending, it should
1398
+ # only identify which member's status to update, not change ownership
1399
+ if parsed_args.project and not parsed_args.membership:
1397
1400
  # We already did the project lookup above
1398
1401
  kwargs['owner_id'] = project_id
1399
1402
 
@@ -1716,6 +1719,7 @@ class ImportImage(command.ShowOne):
1716
1719
  )
1717
1720
  stores_group.add_argument(
1718
1721
  '--all-stores',
1722
+ action='store_true',
1719
1723
  help=_(
1720
1724
  "Make image available to all stores "
1721
1725
  "(either '--store' or '--all-stores' required with the "
@@ -12,8 +12,8 @@
12
12
 
13
13
 
14
14
  from osc_lib.cli import format_columns
15
- from osc_lib.command import command
16
15
 
16
+ from openstackclient import command
17
17
  from openstackclient.i18n import _
18
18
 
19
19
 
@@ -18,10 +18,10 @@
18
18
  import logging
19
19
 
20
20
  from osc_lib.cli import format_columns
21
- from osc_lib.command import command
22
21
  from osc_lib import exceptions
23
22
  from osc_lib import utils
24
23
 
24
+ from openstackclient import command
25
25
  from openstackclient.i18n import _
26
26
 
27
27
  _formatters = {
@@ -17,10 +17,10 @@
17
17
 
18
18
  import logging
19
19
 
20
- from osc_lib.command import command
21
20
  from osc_lib import exceptions
22
21
  from osc_lib import utils
23
22
 
23
+ from openstackclient import command
24
24
  from openstackclient.i18n import _
25
25
 
26
26
 
@@ -15,10 +15,10 @@
15
15
  import json
16
16
  import logging
17
17
 
18
- from osc_lib.command import command
19
18
  from osc_lib import exceptions
20
19
  from osc_lib import utils
21
20
 
21
+ from openstackclient import command
22
22
  from openstackclient.i18n import _
23
23
 
24
24
 
@@ -127,7 +127,8 @@ class DeleteMetadefProperty(command.Command):
127
127
  nargs="*",
128
128
  help=_(
129
129
  "Metadef properties to delete (name) "
130
- "(omit this argument to delete all properties in the namespace)"
130
+ "(omit this argument to delete all properties "
131
+ "in the namespace)"
131
132
  ),
132
133
  )
133
134
  return parser
@@ -12,10 +12,10 @@
12
12
 
13
13
  import logging
14
14
 
15
- from osc_lib.command import command
16
15
  from osc_lib import exceptions
17
16
  from osc_lib import utils
18
17
 
18
+ from openstackclient import command
19
19
  from openstackclient.i18n import _
20
20
 
21
21
  LOG = logging.getLogger(__name__)
@@ -12,9 +12,9 @@
12
12
 
13
13
  """Image V2 Action Implementations"""
14
14
 
15
- from osc_lib.command import command
16
15
  from osc_lib import utils
17
16
 
17
+ from openstackclient import command
18
18
  from openstackclient.i18n import _
19
19
 
20
20
 
@@ -11,9 +11,9 @@
11
11
  # under the License.
12
12
 
13
13
  from osc_lib.cli import format_columns
14
- from osc_lib.command import command
15
14
  from osc_lib import utils
16
15
 
16
+ from openstackclient import command
17
17
  from openstackclient.i18n import _
18
18
 
19
19
  _formatters = {
@@ -12,17 +12,16 @@
12
12
  #
13
13
 
14
14
  import abc
15
- import argparse
16
15
  import contextlib
17
16
  import logging
18
17
  import typing as ty
19
18
 
20
- import cliff.app
19
+ from cliff import _argparse
21
20
  import openstack.exceptions
22
21
  from osc_lib.cli import parseractions
23
- from osc_lib.command import command
24
22
  from osc_lib import exceptions
25
23
 
24
+ from openstackclient import command
26
25
  from openstackclient.i18n import _
27
26
  from openstackclient.network import utils
28
27
 
@@ -68,8 +67,6 @@ class NetDetectionMixin(metaclass=abc.ABCMeta):
68
67
  present the options for both network types, often qualified accordingly.
69
68
  """
70
69
 
71
- app: cliff.app.App
72
-
73
70
  @property
74
71
  def _network_type(self):
75
72
  """Discover whether the running cloud is using neutron or nova-network.
@@ -84,7 +81,7 @@ class NetDetectionMixin(metaclass=abc.ABCMeta):
84
81
  # Have we set it up yet for this command?
85
82
  if not hasattr(self, '_net_type'):
86
83
  try:
87
- if self.app.client_manager.is_network_endpoint_enabled():
84
+ if self.app.client_manager.is_network_endpoint_enabled(): # type: ignore
88
85
  net_type = _NET_TYPE_NEUTRON
89
86
  else:
90
87
  net_type = _NET_TYPE_COMPUTE
@@ -136,7 +133,7 @@ class NetDetectionMixin(metaclass=abc.ABCMeta):
136
133
  )
137
134
  )
138
135
 
139
- def get_parser(self, prog_name: str) -> argparse.ArgumentParser:
136
+ def get_parser(self, prog_name: str) -> _argparse.ArgumentParser:
140
137
  LOG.debug('get_parser(%s)', prog_name)
141
138
  parser = super().get_parser(prog_name) # type: ignore
142
139
  parser = self.update_parser_common(parser)
@@ -163,11 +160,13 @@ class NetDetectionMixin(metaclass=abc.ABCMeta):
163
160
  def take_action(self, parsed_args):
164
161
  if self.is_neutron:
165
162
  return self.take_action_network(
166
- self.app.client_manager.network, parsed_args
163
+ self.app.client_manager.network, # type: ignore
164
+ parsed_args,
167
165
  )
168
166
  elif self.is_nova_network:
169
167
  return self.take_action_compute(
170
- self.app.client_manager.compute, parsed_args
168
+ self.app.client_manager.compute, # type: ignore
169
+ parsed_args,
171
170
  )
172
171
 
173
172
  def take_action_network(self, client, parsed_args):
@@ -203,6 +202,8 @@ class NetworkAndComputeDelete(NetworkAndComputeCommand, metaclass=abc.ABCMeta):
203
202
  following the rules in doc/source/command-errors.rst.
204
203
  """
205
204
 
205
+ resource: str
206
+
206
207
  def take_action(self, parsed_args):
207
208
  ret = 0
208
209
  resources = getattr(parsed_args, self.resource, [])
@@ -16,10 +16,10 @@
16
16
  import logging
17
17
 
18
18
  import netaddr
19
- from osc_lib.command import command
20
19
  from osc_lib import exceptions
21
20
  from osc_lib import utils
22
21
 
22
+ from openstackclient import command
23
23
  from openstackclient.i18n import _
24
24
  from openstackclient.identity import common as identity_common
25
25
  from openstackclient.network import common
@@ -151,13 +151,14 @@ class ListAddressGroup(command.Lister):
151
151
  parser.add_argument(
152
152
  '--name',
153
153
  metavar='<name>',
154
- help=_("List only address groups of given name in output"),
154
+ help=_("List only address groups with the specified name"),
155
155
  )
156
156
  parser.add_argument(
157
157
  '--project',
158
158
  metavar="<project>",
159
159
  help=_(
160
- "List address groups according to their project (name or ID)"
160
+ "List only address groups with the specified project "
161
+ "(name or ID)"
161
162
  ),
162
163
  )
163
164
  identity_common.add_project_domain_option_to_parser(parser)
@@ -15,10 +15,10 @@
15
15
 
16
16
  import logging
17
17
 
18
- from osc_lib.command import command
19
18
  from osc_lib import exceptions
20
19
  from osc_lib import utils
21
20
 
21
+ from openstackclient import command
22
22
  from openstackclient.i18n import _
23
23
  from openstackclient.identity import common as identity_common
24
24
  from openstackclient.network import common
@@ -160,7 +160,7 @@ class ListAddressScope(command.Lister):
160
160
  parser.add_argument(
161
161
  '--name',
162
162
  metavar='<name>',
163
- help=_("List only address scopes of given name in output"),
163
+ help=_("List only address scopes with the specified name"),
164
164
  )
165
165
  parser.add_argument(
166
166
  '--ip-version',
@@ -169,14 +169,16 @@ class ListAddressScope(command.Lister):
169
169
  metavar='<ip-version>',
170
170
  dest='ip_version',
171
171
  help=_(
172
- "List address scopes of given IP version networks (4 or 6)"
172
+ "List only address scopes with the specified IP version "
173
+ "networks (4 or 6)"
173
174
  ),
174
175
  )
175
176
  parser.add_argument(
176
177
  '--project',
177
178
  metavar="<project>",
178
179
  help=_(
179
- "List address scopes according to their project (name or ID)"
180
+ "List only address scopes with the specified project "
181
+ "(name or ID)"
180
182
  ),
181
183
  )
182
184
  identity_common.add_project_domain_option_to_parser(parser)
@@ -185,12 +187,12 @@ class ListAddressScope(command.Lister):
185
187
  shared_group.add_argument(
186
188
  '--share',
187
189
  action='store_true',
188
- help=_("List address scopes shared between projects"),
190
+ help=_("List only address scopes shared between projects"),
189
191
  )
190
192
  shared_group.add_argument(
191
193
  '--no-share',
192
194
  action='store_true',
193
- help=_("List address scopes not shared between projects"),
195
+ help=_("List only address scopes not shared between projects"),
194
196
  )
195
197
  return parser
196
198