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
@@ -83,7 +83,7 @@ def add_tag_option_to_parser_for_create(parser, resource_name):
83
83
  metavar='<tag>',
84
84
  default=[],
85
85
  help=_(
86
- 'Tag to be added to the %s ' '(repeat option to set multiple tags)'
86
+ 'Tag to be added to the %s (repeat option to set multiple tags)'
87
87
  )
88
88
  % resource_name,
89
89
  )
@@ -97,7 +97,7 @@ def add_tag_option_to_parser_for_set(parser, resource_name):
97
97
  metavar='<tag>',
98
98
  default=[],
99
99
  help=_(
100
- 'Tag to be added to the %s ' '(repeat option to set multiple tags)'
100
+ 'Tag to be added to the %s (repeat option to set multiple tags)'
101
101
  )
102
102
  % resource_name,
103
103
  )
@@ -136,8 +136,7 @@ class CreateRequestToken(command.ShowOne):
136
136
  '--project',
137
137
  metavar='<project>',
138
138
  help=_(
139
- 'Project that consumer wants to access (name or ID)'
140
- ' (required)'
139
+ 'Project that consumer wants to access (name or ID) (required)'
141
140
  ),
142
141
  required=True,
143
142
  )
@@ -123,37 +123,67 @@ class CreateTrust(command.ShowOne):
123
123
  # pointless, and trusts are immutable, so let's enforce it at the
124
124
  # client level.
125
125
  try:
126
- trustor_id = identity_client.find_user(
127
- parsed_args.trustor, parsed_args.trustor_domain
128
- ).id
129
- kwargs['trustor_id'] = trustor_id
126
+ if parsed_args.trustor_domain:
127
+ trustor_domain_id = identity_client.find_domain(
128
+ parsed_args.trustor_domain, ignore_missing=False
129
+ ).id
130
+ trustor_id = identity_client.find_user(
131
+ parsed_args.trustor,
132
+ ignore_missing=False,
133
+ domain_id=trustor_domain_id,
134
+ ).id
135
+ else:
136
+ trustor_id = identity_client.find_user(
137
+ parsed_args.trustor, ignore_missing=False
138
+ ).id
139
+ kwargs['trustor_user_id'] = trustor_id
130
140
  except sdk_exceptions.ForbiddenException:
131
- kwargs['trustor_id'] = parsed_args.trustor
141
+ kwargs['trustor_user_id'] = parsed_args.trustor
132
142
 
133
143
  try:
134
- trustee_id = identity_client.find_user(
135
- parsed_args.trustee, parsed_args.trustee_domain
136
- ).id
137
- kwargs['trustee_id'] = trustee_id
144
+ if parsed_args.trustee_domain:
145
+ trustee_domain_id = identity_client.find_domain(
146
+ parsed_args.trustee_domain, ignore_missing=False
147
+ ).id
148
+ trustee_id = identity_client.find_user(
149
+ parsed_args.trustee,
150
+ ignore_missing=False,
151
+ domain_id=trustee_domain_id,
152
+ ).id
153
+ else:
154
+ trustee_id = identity_client.find_user(
155
+ parsed_args.trustee, ignore_missing=False
156
+ ).id
157
+ kwargs['trustee_user_id'] = trustee_id
138
158
  except sdk_exceptions.ForbiddenException:
139
- kwargs['trustee_id'] = parsed_args.trustee
159
+ kwargs['trustee_user_id'] = parsed_args.trustee
140
160
 
141
161
  try:
142
- project_id = identity_client.find_project(
143
- parsed_args.project, parsed_args.project_domain
144
- ).id
162
+ if parsed_args.project_domain:
163
+ project_domain_id = identity_client.find_domain(
164
+ parsed_args.project_domain, ignore_missing=False
165
+ ).id
166
+ project_id = identity_client.find_project(
167
+ parsed_args.project,
168
+ ignore_missing=False,
169
+ domain_id=project_domain_id,
170
+ ).id
171
+ else:
172
+ project_id = identity_client.find_project(
173
+ parsed_args.project, ignore_missing=False
174
+ ).id
145
175
  kwargs['project_id'] = project_id
146
176
  except sdk_exceptions.ForbiddenException:
147
177
  kwargs['project_id'] = parsed_args.project
148
178
 
149
- role_ids = []
179
+ roles = []
150
180
  for role in parsed_args.roles:
151
181
  try:
152
182
  role_id = identity_client.find_role(role).id
153
183
  except sdk_exceptions.ForbiddenException:
154
184
  role_id = role
155
- role_ids.append(role_id)
156
- kwargs['roles'] = role_ids
185
+ roles.append({"id": role_id})
186
+ kwargs['roles'] = roles
157
187
 
158
188
  if parsed_args.expiration:
159
189
  expires_at = datetime.datetime.strptime(
@@ -161,8 +191,7 @@ class CreateTrust(command.ShowOne):
161
191
  )
162
192
  kwargs['expires_at'] = expires_at
163
193
 
164
- if parsed_args.is_impersonation:
165
- kwargs['is_impersonation'] = parsed_args.is_impersonation
194
+ kwargs['impersonation'] = bool(parsed_args.is_impersonation)
166
195
 
167
196
  trust = identity_client.create_trust(**kwargs)
168
197
 
@@ -204,7 +233,7 @@ class DeleteTrust(command.Command):
204
233
 
205
234
  if errors > 0:
206
235
  total = len(parsed_args.trust)
207
- msg = _("%(errors)s of %(total)s trusts failed " "to delete.") % {
236
+ msg = _("%(errors)s of %(total)s trusts failed to delete.") % {
208
237
  'errors': errors,
209
238
  'total': total,
210
239
  }
@@ -289,9 +318,19 @@ class ListTrust(command.Lister):
289
318
  trustor = None
290
319
  if parsed_args.trustor:
291
320
  try:
292
- trustor_id = identity_client.find_user(
293
- parsed_args.trustor, parsed_args.trustor_domain
294
- ).id
321
+ if parsed_args.trustor_domain:
322
+ trustor_domain_id = identity_client.find_domain(
323
+ parsed_args.trustor_domain, ignore_missing=False
324
+ ).id
325
+ trustor_id = identity_client.find_user(
326
+ parsed_args.trustor,
327
+ ignore_missing=False,
328
+ domain_id=trustor_domain_id,
329
+ ).id
330
+ else:
331
+ trustor_id = identity_client.find_user(
332
+ parsed_args.trustor, ignore_missing=False
333
+ ).id
295
334
  trustor = trustor_id
296
335
  except sdk_exceptions.ForbiddenException:
297
336
  trustor = parsed_args.trustor
@@ -299,9 +338,19 @@ class ListTrust(command.Lister):
299
338
  trustee = None
300
339
  if parsed_args.trustee:
301
340
  try:
302
- trustee_id = identity_client.find_user(
303
- parsed_args.trustee, parsed_args.trustee_domain
304
- ).id
341
+ if parsed_args.trustee_domain:
342
+ trustee_domain_id = identity_client.find_domain(
343
+ parsed_args.trustee_domain, ignore_missing=False
344
+ ).id
345
+ trustee_id = identity_client.find_user(
346
+ parsed_args.trustee,
347
+ ignore_missing=False,
348
+ domain_id=trustee_domain_id,
349
+ ).id
350
+ else:
351
+ trustee_id = identity_client.find_user(
352
+ parsed_args.trustee, ignore_missing=False
353
+ ).id
305
354
  trustee = trustee_id
306
355
  except sdk_exceptions.ForbiddenException:
307
356
  trustee = parsed_args.trustee
@@ -17,6 +17,7 @@
17
17
 
18
18
  import copy
19
19
  import logging
20
+ import typing as ty
20
21
 
21
22
  from openstack import exceptions as sdk_exc
22
23
  from osc_lib.command import command
@@ -58,7 +59,7 @@ def _format_user(user):
58
59
 
59
60
 
60
61
  def _get_options_for_user(identity_client, parsed_args):
61
- options = {}
62
+ options: dict[str, ty.Any] = {}
62
63
  if parsed_args.ignore_lockout_failure_attempts:
63
64
  options['ignore_lockout_failure_attempts'] = True
64
65
  if parsed_args.no_ignore_lockout_failure_attempts:
@@ -377,7 +378,7 @@ class DeleteUser(command.Command):
377
378
 
378
379
  if errors > 0:
379
380
  total = len(parsed_args.users)
380
- msg = _("%(errors)s of %(total)s users failed " "to delete.") % {
381
+ msg = _("%(errors)s of %(total)s users failed to delete.") % {
381
382
  'errors': errors,
382
383
  'total': total,
383
384
  }
@@ -612,10 +613,12 @@ class SetUser(command.Command):
612
613
  if parsed_args.description:
613
614
  kwargs['description'] = parsed_args.description
614
615
  if parsed_args.project:
615
- project_domain_id = identity_client.find_domain(
616
- name_or_id=parsed_args.project_domain,
617
- ignore_missing=False,
618
- ).id
616
+ project_domain_id = None
617
+ if parsed_args.project_domain:
618
+ project_domain_id = identity_client.find_domain(
619
+ name_or_id=parsed_args.project_domain,
620
+ ignore_missing=False,
621
+ ).id
619
622
  project_id = identity_client.find_project(
620
623
  name_or_id=parsed_args.project,
621
624
  ignore_missing=False,
@@ -11,7 +11,6 @@
11
11
  # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
12
  # License for the specific language governing permissions and limitations
13
13
  # under the License.
14
- #
15
14
 
16
15
  import logging
17
16
 
@@ -21,13 +20,11 @@ from openstackclient.i18n import _
21
20
 
22
21
  LOG = logging.getLogger(__name__)
23
22
 
23
+ # global variables used when building the shell
24
24
  DEFAULT_API_VERSION = '2'
25
25
  API_VERSION_OPTION = 'os_image_api_version'
26
26
  API_NAME = 'image'
27
- API_VERSIONS = {
28
- '1': 'openstack.connection.Connection',
29
- '2': 'openstack.connection.Connection',
30
- }
27
+ API_VERSIONS = ('1', '2')
31
28
 
32
29
 
33
30
  def make_client(instance):
@@ -30,12 +30,6 @@ from osc_lib import utils
30
30
 
31
31
  from openstackclient.i18n import _
32
32
 
33
- if os.name == "nt":
34
- import msvcrt
35
- else:
36
- msvcrt = None
37
-
38
-
39
33
  CONTAINER_CHOICES = ["ami", "ari", "aki", "bare", "docker", "ova", "ovf"]
40
34
  DEFAULT_CONTAINER_FORMAT = 'bare'
41
35
  DEFAULT_DISK_FORMAT = 'raw'
@@ -53,7 +47,6 @@ DISK_CHOICES = [
53
47
  "ploop",
54
48
  ]
55
49
 
56
-
57
50
  LOG = logging.getLogger(__name__)
58
51
 
59
52
 
@@ -323,8 +316,10 @@ class CreateImage(command.ShowOne):
323
316
  else:
324
317
  # Read file from stdin
325
318
  if not sys.stdin.isatty():
326
- if msvcrt:
327
- msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY)
319
+ if os.name == "nt":
320
+ import msvcrt
321
+
322
+ msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY) # type: ignore
328
323
  if hasattr(sys.stdin, 'buffer'):
329
324
  kwargs['data'] = sys.stdin.buffer
330
325
  else:
@@ -384,8 +379,7 @@ class DeleteImage(command.Command):
384
379
  except Exception as e:
385
380
  result += 1
386
381
  msg = _(
387
- "Failed to delete image with name or "
388
- "ID '%(image)s': %(e)s"
382
+ "Failed to delete image with name or ID '%(image)s': %(e)s"
389
383
  )
390
384
  LOG.error(msg, {'image': image, 'e': e})
391
385
 
@@ -468,7 +462,7 @@ class ListImage(command.Lister):
468
462
  kwargs['is_private'] = True
469
463
 
470
464
  if parsed_args.long:
471
- columns = (
465
+ columns: tuple[str, ...] = (
472
466
  'ID',
473
467
  'Name',
474
468
  'Disk Format',
@@ -481,7 +475,7 @@ class ListImage(command.Lister):
481
475
  'owner_id',
482
476
  'properties',
483
477
  )
484
- column_headers = (
478
+ column_headers: tuple[str, ...] = (
485
479
  'ID',
486
480
  'Name',
487
481
  'Disk Format',
@@ -775,8 +769,10 @@ class SetImage(command.Command):
775
769
  # Read file from stdin
776
770
  if sys.stdin.isatty() is not True:
777
771
  if parsed_args.stdin:
778
- if msvcrt:
779
- msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY)
772
+ if os.name == "nt":
773
+ import msvcrt
774
+
775
+ msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY) # type: ignore
780
776
  if hasattr(sys.stdin, 'buffer'):
781
777
  kwargs['data'] = sys.stdin.buffer
782
778
  else:
@@ -131,8 +131,7 @@ class QueueCachedImage(command.Command):
131
131
  except Exception as e:
132
132
  failures += 1
133
133
  msg = _(
134
- "Failed to queue image with name or "
135
- "ID '%(image)s': %(e)s"
134
+ "Failed to queue image with name or ID '%(image)s': %(e)s"
136
135
  )
137
136
  LOG.error(msg, {'image': image, 'e': e})
138
137
 
@@ -171,8 +170,7 @@ class DeleteCachedImage(command.Command):
171
170
  except Exception as e:
172
171
  failures += 1
173
172
  msg = _(
174
- "Failed to delete image with name or "
175
- "ID '%(image)s': %(e)s"
173
+ "Failed to delete image with name or ID '%(image)s': %(e)s"
176
174
  )
177
175
  LOG.error(msg, {'image': image, 'e': e})
178
176
 
@@ -20,6 +20,7 @@ from base64 import b64encode
20
20
  import logging
21
21
  import os
22
22
  import sys
23
+ import typing as ty
23
24
 
24
25
  from cinderclient import api_versions
25
26
  from openstack import exceptions as sdk_exceptions
@@ -36,12 +37,6 @@ from openstackclient.common import progressbar
36
37
  from openstackclient.i18n import _
37
38
  from openstackclient.identity import common as identity_common
38
39
 
39
- if os.name == "nt":
40
- import msvcrt
41
- else:
42
- msvcrt = None
43
-
44
-
45
40
  CONTAINER_CHOICES = ["ami", "ari", "aki", "bare", "docker", "ova", "ovf"]
46
41
  DEFAULT_CONTAINER_FORMAT = 'bare'
47
42
  DEFAULT_DISK_FORMAT = 'raw'
@@ -60,7 +55,6 @@ DISK_CHOICES = [
60
55
  ]
61
56
  MEMBER_STATUS_CHOICES = ["accepted", "pending", "rejected", "all"]
62
57
 
63
-
64
58
  LOG = logging.getLogger(__name__)
65
59
 
66
60
 
@@ -154,8 +148,10 @@ def get_data_from_stdin():
154
148
  image = sys.stdin
155
149
  if hasattr(sys.stdin, 'buffer'):
156
150
  image = sys.stdin.buffer
157
- if msvcrt:
158
- msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY)
151
+ if os.name == "nt":
152
+ import msvcrt
153
+
154
+ msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY) # type: ignore
159
155
 
160
156
  return image
161
157
  else:
@@ -359,8 +355,7 @@ class CreateImage(command.ShowOne):
359
355
  action="store_true",
360
356
  default=False,
361
357
  help=_(
362
- "Show upload progress bar "
363
- "(ignored if passing data via stdin)"
358
+ "Show upload progress bar (ignored if passing data via stdin)"
364
359
  ),
365
360
  )
366
361
  parser.add_argument(
@@ -401,8 +396,7 @@ class CreateImage(command.ShowOne):
401
396
  metavar="<tag>",
402
397
  action='append',
403
398
  help=_(
404
- "Set a tag on this image "
405
- "(repeat option to set multiple tags)"
399
+ "Set a tag on this image (repeat option to set multiple tags)"
406
400
  ),
407
401
  )
408
402
  parser.add_argument(
@@ -434,7 +428,7 @@ class CreateImage(command.ShowOne):
434
428
 
435
429
  # Build an attribute dict from the parsed args, only include
436
430
  # attributes that were actually set on the command line
437
- kwargs = {'allow_duplicates': True}
431
+ kwargs: dict[str, ty.Any] = {'allow_duplicates': True}
438
432
  copy_attrs = (
439
433
  'name',
440
434
  'id',
@@ -617,7 +611,10 @@ class CreateImage(command.ShowOne):
617
611
  volume_client.volumes,
618
612
  parsed_args.volume,
619
613
  )
620
- kwargs = {}
614
+ kwargs: dict[str, ty.Any] = {
615
+ 'visibility': None,
616
+ 'protected': None,
617
+ }
621
618
  if volume_client.api_version < api_versions.APIVersion('3.1'):
622
619
  if parsed_args.visibility or parsed_args.is_protected is not None:
623
620
  msg = _(
@@ -627,10 +624,8 @@ class CreateImage(command.ShowOne):
627
624
  )
628
625
  raise exceptions.CommandError(msg)
629
626
  else:
630
- kwargs.update(
631
- visibility=parsed_args.visibility or 'private',
632
- protected=parsed_args.is_protected or False,
633
- )
627
+ kwargs['visibility'] = parsed_args.visibility or 'private'
628
+ kwargs['protected'] = parsed_args.is_protected or False
634
629
 
635
630
  response, body = volume_client.volumes.upload_to_image(
636
631
  source_volume.id,
@@ -705,8 +700,7 @@ class DeleteImage(command.Command):
705
700
  except Exception as e:
706
701
  result += 1
707
702
  msg = _(
708
- "Failed to delete image with name or "
709
- "ID '%(image)s': %(e)s"
703
+ "Failed to delete image with name or ID '%(image)s': %(e)s"
710
704
  )
711
705
  LOG.error(msg, {'image': image, 'e': e})
712
706
 
@@ -884,7 +878,7 @@ class ListImage(command.Lister):
884
878
  if parsed_args.is_hidden:
885
879
  kwargs['is_hidden'] = parsed_args.is_hidden
886
880
  if parsed_args.long:
887
- columns = (
881
+ columns: tuple[str, ...] = (
888
882
  'ID',
889
883
  'Name',
890
884
  'Disk Format',
@@ -897,7 +891,7 @@ class ListImage(command.Lister):
897
891
  'owner_id',
898
892
  'tags',
899
893
  )
900
- column_headers = (
894
+ column_headers: tuple[str, ...] = (
901
895
  'ID',
902
896
  'Name',
903
897
  'Disk Format',
@@ -959,7 +953,7 @@ class ListImageProjects(command.Lister):
959
953
 
960
954
  def take_action(self, parsed_args):
961
955
  image_client = self.app.client_manager.image
962
- columns = ("Image ID", "Member ID", "Status")
956
+ columns: tuple[str, ...] = ("Image ID", "Member ID", "Status")
963
957
 
964
958
  image_id = image_client.find_image(
965
959
  parsed_args.image,
@@ -1153,8 +1147,7 @@ class SetImage(command.Command):
1153
1147
  default=None,
1154
1148
  action='append',
1155
1149
  help=_(
1156
- "Set a tag on this image "
1157
- "(repeat option to set multiple tags)"
1150
+ "Set a tag on this image (repeat option to set multiple tags)"
1158
1151
  ),
1159
1152
  )
1160
1153
  parser.add_argument(
@@ -1457,7 +1450,6 @@ class UnsetImage(command.Command):
1457
1450
  ignore_missing=False,
1458
1451
  )
1459
1452
 
1460
- kwargs = {}
1461
1453
  tagret = 0
1462
1454
  propret = 0
1463
1455
  if parsed_args.tags:
@@ -1466,10 +1458,11 @@ class UnsetImage(command.Command):
1466
1458
  image_client.remove_tag(image.id, k)
1467
1459
  except Exception:
1468
1460
  LOG.error(
1469
- _("tag unset failed, '%s' is a " "nonexistent tag "), k
1461
+ _("tag unset failed, '%s' is a nonexistent tag "), k
1470
1462
  )
1471
1463
  tagret += 1
1472
1464
 
1465
+ kwargs: dict[str, ty.Any] = {}
1473
1466
  if parsed_args.properties:
1474
1467
  for k in parsed_args.properties:
1475
1468
  if k in image:
@@ -1519,7 +1512,7 @@ class UnsetImage(command.Command):
1519
1512
  raise exceptions.CommandError(msg)
1520
1513
  elif propret > 0:
1521
1514
  msg = _(
1522
- "Failed to unset %(propret)s of %(proptotal)s" " properties."
1515
+ "Failed to unset %(propret)s of %(proptotal)s properties."
1523
1516
  ) % {'propret': propret, 'proptotal': proptotal}
1524
1517
  raise exceptions.CommandError(msg)
1525
1518
 
@@ -1551,8 +1544,7 @@ class StageImage(command.Command):
1551
1544
  action='store_true',
1552
1545
  default=False,
1553
1546
  help=_(
1554
- 'Show upload progress bar '
1555
- '(ignored if passing data via stdin)'
1547
+ 'Show upload progress bar (ignored if passing data via stdin)'
1556
1548
  ),
1557
1549
  )
1558
1550
  parser.add_argument(
@@ -1583,7 +1575,7 @@ class StageImage(command.Command):
1583
1575
  else:
1584
1576
  fp = get_data_from_stdin()
1585
1577
 
1586
- kwargs = {}
1578
+ kwargs: dict[str, ty.Any] = {}
1587
1579
 
1588
1580
  if parsed_args.progress and parsed_args.filename:
1589
1581
  # NOTE(stephenfin): we only show a progress bar if the user
@@ -1689,7 +1681,8 @@ class ImportImage(command.ShowOne):
1689
1681
  "'copy-image' import method)"
1690
1682
  ),
1691
1683
  )
1692
- parser.add_argument(
1684
+ allow_failure_group = parser.add_mutually_exclusive_group()
1685
+ allow_failure_group.add_argument(
1693
1686
  '--allow-failure',
1694
1687
  action='store_true',
1695
1688
  dest='allow_failure',
@@ -1700,9 +1693,9 @@ class ImportImage(command.ShowOne):
1700
1693
  'Only usable with --stores or --all-stores'
1701
1694
  ),
1702
1695
  )
1703
- parser.add_argument(
1696
+ allow_failure_group.add_argument(
1704
1697
  '--disallow-failure',
1705
- action='store_true',
1698
+ action='store_false',
1706
1699
  dest='allow_failure',
1707
1700
  default=True,
1708
1701
  help=_(
@@ -1866,8 +1859,8 @@ class StoresInfo(command.Lister):
1866
1859
  def take_action(self, parsed_args):
1867
1860
  image_client = self.app.client_manager.image
1868
1861
  try:
1869
- columns = ("id", "description", "is_default")
1870
- column_headers = ("ID", "Description", "Default")
1862
+ columns: tuple[str, ...] = ("id", "description", "is_default")
1863
+ column_headers: tuple[str, ...] = ("ID", "Description", "Default")
1871
1864
  if parsed_args.detail:
1872
1865
  columns += ("properties",)
1873
1866
  column_headers += ("Properties",)
@@ -169,9 +169,10 @@ class DeleteMetadefNamespace(command.Command):
169
169
 
170
170
  if result > 0:
171
171
  total = len(parsed_args.namespace)
172
- msg = _(
173
- "%(result)s of %(total)s namespace failed " "to delete."
174
- ) % {'result': result, 'total': total}
172
+ msg = _("%(result)s of %(total)s namespace failed to delete.") % {
173
+ 'result': result,
174
+ 'total': total,
175
+ }
175
176
  raise exceptions.CommandError(msg)
176
177
 
177
178
 
@@ -22,10 +22,9 @@ LOG = logging.getLogger(__name__)
22
22
 
23
23
 
24
24
  def _get_columns(item):
25
- column_map = {}
26
25
  hidden_columns = ['location']
27
26
  return utils.get_osc_show_columns_for_sdk_resource(
28
- item, column_map, hidden_columns
27
+ item, {}, hidden_columns
29
28
  )
30
29
 
31
30
 
@@ -23,8 +23,7 @@ class ListMetadefResourceTypes(command.Lister):
23
23
 
24
24
  def take_action(self, parsed_args):
25
25
  image_client = self.app.client_manager.image
26
- kwargs = {}
27
- data = image_client.metadef_resource_types(**kwargs)
26
+ data = image_client.metadef_resource_types()
28
27
  columns = ['Name']
29
28
  column_headers = columns
30
29
  return (