python-openstackclient 8.3.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 (46) hide show
  1. openstackclient/common/module.py +1 -1
  2. openstackclient/common/quota.py +31 -17
  3. openstackclient/compute/v2/server.py +2 -2
  4. openstackclient/identity/common.py +31 -0
  5. openstackclient/identity/v2_0/service.py +3 -1
  6. openstackclient/identity/v3/federation_protocol.py +39 -40
  7. openstackclient/identity/v3/limit.py +85 -84
  8. openstackclient/identity/v3/project.py +181 -112
  9. openstackclient/identity/v3/registered_limit.py +82 -99
  10. openstackclient/identity/v3/tag.py +0 -11
  11. openstackclient/image/v2/image.py +2 -1
  12. openstackclient/tests/functional/identity/v3/test_limit.py +47 -0
  13. openstackclient/tests/functional/image/v2/test_metadef_objects.py +69 -0
  14. openstackclient/tests/functional/volume/v3/test_volume_snapshot.py +46 -132
  15. openstackclient/tests/unit/common/test_quota.py +59 -0
  16. openstackclient/tests/unit/compute/v2/test_server.py +6 -8
  17. openstackclient/tests/unit/identity/v3/test_limit.py +197 -145
  18. openstackclient/tests/unit/identity/v3/test_project.py +831 -512
  19. openstackclient/tests/unit/identity/v3/test_protocol.py +97 -88
  20. openstackclient/tests/unit/identity/v3/test_registered_limit.py +355 -220
  21. openstackclient/tests/unit/image/v2/test_image.py +5 -5
  22. openstackclient/tests/unit/volume/v2/test_consistency_group.py +8 -2
  23. openstackclient/tests/unit/volume/v2/test_volume.py +7 -6
  24. openstackclient/tests/unit/volume/v3/test_volume.py +34 -12
  25. openstackclient/volume/v2/consistency_group.py +8 -8
  26. openstackclient/volume/v2/consistency_group_snapshot.py +2 -2
  27. openstackclient/volume/v2/qos_specs.py +2 -2
  28. openstackclient/volume/v2/volume.py +12 -5
  29. openstackclient/volume/v2/volume_backup.py +2 -2
  30. openstackclient/volume/v2/volume_snapshot.py +2 -2
  31. openstackclient/volume/v2/volume_transfer_request.py +2 -2
  32. openstackclient/volume/v2/volume_type.py +5 -5
  33. openstackclient/volume/v3/volume.py +14 -7
  34. openstackclient/volume/v3/volume_backup.py +2 -2
  35. openstackclient/volume/v3/volume_snapshot.py +2 -2
  36. openstackclient/volume/v3/volume_transfer_request.py +2 -2
  37. openstackclient/volume/v3/volume_type.py +5 -5
  38. {python_openstackclient-8.3.0.dist-info → python_openstackclient-9.0.0.dist-info}/METADATA +1 -1
  39. {python_openstackclient-8.3.0.dist-info → python_openstackclient-9.0.0.dist-info}/RECORD +45 -44
  40. {python_openstackclient-8.3.0.dist-info → python_openstackclient-9.0.0.dist-info}/WHEEL +1 -1
  41. {python_openstackclient-8.3.0.dist-info → python_openstackclient-9.0.0.dist-info}/licenses/AUTHORS +5 -0
  42. python_openstackclient-9.0.0.dist-info/pbr.json +1 -0
  43. python_openstackclient-8.3.0.dist-info/pbr.json +0 -1
  44. {python_openstackclient-8.3.0.dist-info → python_openstackclient-9.0.0.dist-info}/entry_points.txt +0 -0
  45. {python_openstackclient-8.3.0.dist-info → python_openstackclient-9.0.0.dist-info}/licenses/LICENSE +0 -0
  46. {python_openstackclient-8.3.0.dist-info → python_openstackclient-9.0.0.dist-info}/top_level.txt +0 -0
@@ -17,7 +17,7 @@
17
17
 
18
18
  import logging
19
19
 
20
- from keystoneauth1 import exceptions as ks_exc
20
+ from openstack import exceptions as sdk_exc
21
21
  from osc_lib.cli import parseractions
22
22
  from osc_lib import exceptions
23
23
  from osc_lib import utils
@@ -30,6 +30,21 @@ from openstackclient.identity.v3 import tag
30
30
  LOG = logging.getLogger(__name__)
31
31
 
32
32
 
33
+ def _format_project(project):
34
+ # NOTE(0weng): Projects allow unknown attributes in the body, so extract
35
+ # the column names separately.
36
+ (column_headers, columns) = utils.get_osc_show_columns_for_sdk_resource(
37
+ project,
38
+ {'is_enabled': 'enabled'},
39
+ ['links', 'location', 'parents_as_ids', 'subtree_as_ids'],
40
+ )
41
+
42
+ return (
43
+ column_headers,
44
+ utils.get_item_properties(project, columns),
45
+ )
46
+
47
+
33
48
  class CreateProject(command.ShowOne):
34
49
  _description = _("Create new project")
35
50
 
@@ -90,22 +105,13 @@ class CreateProject(command.ShowOne):
90
105
  return parser
91
106
 
92
107
  def take_action(self, parsed_args):
93
- identity_client = self.app.client_manager.identity
94
-
95
- domain = None
96
- if parsed_args.domain:
97
- domain = common.find_domain(identity_client, parsed_args.domain).id
98
-
99
- parent = None
100
- if parsed_args.parent:
101
- parent = utils.find_resource(
102
- identity_client.projects,
103
- parsed_args.parent,
104
- ).id
108
+ identity_client = self.app.client_manager.sdk_connection.identity
105
109
 
106
110
  kwargs = {}
111
+
107
112
  if parsed_args.properties:
108
113
  kwargs = parsed_args.properties.copy()
114
+
109
115
  if 'is_domain' in kwargs.keys():
110
116
  if kwargs['is_domain'].lower() == "true":
111
117
  kwargs['is_domain'] = True
@@ -114,35 +120,55 @@ class CreateProject(command.ShowOne):
114
120
  elif kwargs['is_domain'].lower() == "none":
115
121
  kwargs['is_domain'] = None
116
122
 
117
- kwargs['tags'] = list(set(parsed_args.tags))
123
+ if parsed_args.description:
124
+ kwargs['description'] = parsed_args.description
125
+
126
+ if parsed_args.name:
127
+ kwargs['name'] = parsed_args.name
128
+
129
+ domain = None
130
+ if parsed_args.domain:
131
+ domain = common.find_domain_id_sdk(
132
+ identity_client, parsed_args.domain
133
+ )
134
+ kwargs['domain_id'] = domain
135
+
136
+ if parsed_args.parent:
137
+ kwargs['parent_id'] = common.find_project_id_sdk(
138
+ identity_client,
139
+ parsed_args.parent,
140
+ domain_name_or_id=domain,
141
+ )
142
+
143
+ kwargs['is_enabled'] = parsed_args.enabled
144
+
145
+ if parsed_args.tags:
146
+ kwargs['tags'] = list(set(parsed_args.tags))
118
147
 
119
- options = {}
120
148
  if parsed_args.immutable is not None:
121
- options['immutable'] = parsed_args.immutable
149
+ kwargs['options'] = {'immutable': parsed_args.immutable}
122
150
 
123
151
  try:
124
- project = identity_client.projects.create(
125
- name=parsed_args.name,
126
- domain=domain,
127
- parent=parent,
128
- description=parsed_args.description,
129
- enabled=parsed_args.enabled,
130
- options=options,
152
+ project = identity_client.create_project(
131
153
  **kwargs,
132
154
  )
133
- except ks_exc.Conflict:
155
+ except sdk_exc.ConflictException:
134
156
  if parsed_args.or_show:
135
- project = utils.find_resource(
136
- identity_client.projects,
137
- parsed_args.name,
138
- domain_id=domain,
139
- )
157
+ if parsed_args.domain:
158
+ project = identity_client.find_project(
159
+ parsed_args.name,
160
+ domain_id=domain,
161
+ ignore_missing=False,
162
+ )
163
+ else:
164
+ project = identity_client.find_project(
165
+ parsed_args.name, ignore_missing=False
166
+ )
140
167
  LOG.info(_('Returning existing project %s'), project.name)
141
168
  else:
142
169
  raise
143
170
 
144
- project._info.pop('links')
145
- return zip(*sorted(project._info.items()))
171
+ return _format_project(project)
146
172
 
147
173
 
148
174
  class DeleteProject(command.Command):
@@ -171,23 +197,19 @@ class DeleteProject(command.Command):
171
197
  return parser
172
198
 
173
199
  def take_action(self, parsed_args):
174
- identity_client = self.app.client_manager.identity
200
+ identity_client = self.app.client_manager.sdk_connection.identity
175
201
 
176
- domain = None
177
- if parsed_args.domain:
178
- domain = common.find_domain(identity_client, parsed_args.domain)
179
202
  errors = 0
180
203
  for project in parsed_args.projects:
181
204
  try:
182
- if domain is not None:
183
- project_obj = utils.find_resource(
184
- identity_client.projects, project, domain_id=domain.id
185
- )
186
- else:
187
- project_obj = utils.find_resource(
188
- identity_client.projects, project
189
- )
190
- identity_client.projects.delete(project_obj.id)
205
+ project = common.find_project_id_sdk(
206
+ identity_client,
207
+ project,
208
+ domain_name_or_id=parsed_args.domain,
209
+ validate_actor_existence=True,
210
+ validate_domain_actor_existence=False,
211
+ )
212
+ identity_client.delete_project(project)
191
213
  except Exception as e:
192
214
  errors += 1
193
215
  LOG.error(
@@ -268,38 +290,46 @@ class ListProject(command.Lister):
268
290
  return parser
269
291
 
270
292
  def take_action(self, parsed_args):
271
- identity_client = self.app.client_manager.identity
272
- columns: tuple[str, ...] = ('ID', 'Name')
293
+ identity_client = self.app.client_manager.sdk_connection.identity
294
+
295
+ column_headers: tuple[str, ...] = ('ID', 'Name')
296
+ if parsed_args.long:
297
+ column_headers += ('Domain ID', 'Description', 'Enabled')
298
+
299
+ columns: tuple[str, ...] = ('id', 'name')
273
300
  if parsed_args.long:
274
- columns += ('Domain ID', 'Description', 'Enabled')
301
+ columns += ('domain_id', 'description', 'is_enabled')
302
+
275
303
  kwargs = {}
276
304
 
277
305
  domain_id = None
278
306
  if parsed_args.domain:
279
- domain_id = common.find_domain(
307
+ domain_id = common.find_domain_id_sdk(
280
308
  identity_client, parsed_args.domain
281
- ).id
282
- kwargs['domain'] = domain_id
309
+ )
310
+ kwargs['domain_id'] = domain_id
283
311
 
284
312
  if parsed_args.parent:
285
- parent_id = common.find_project(
286
- identity_client, parsed_args.parent
287
- ).id
288
- kwargs['parent'] = parent_id
313
+ parent_id = common.find_project_id_sdk(
314
+ identity_client,
315
+ parsed_args.parent,
316
+ domain_name_or_id=domain_id,
317
+ )
318
+ kwargs['parent_id'] = parent_id
289
319
 
320
+ user = None
290
321
  if parsed_args.user:
291
322
  if parsed_args.domain:
292
- user_id = utils.find_resource(
293
- identity_client.users,
323
+ user = common.find_user_id_sdk(
324
+ identity_client,
294
325
  parsed_args.user,
295
- domain_id=domain_id,
296
- ).id
326
+ domain_name_or_id=domain_id,
327
+ )
297
328
  else:
298
- user_id = utils.find_resource(
299
- identity_client.users, parsed_args.user
300
- ).id
301
-
302
- kwargs['user'] = user_id
329
+ user = common.find_user_id_sdk(
330
+ identity_client,
331
+ parsed_args.user,
332
+ )
303
333
 
304
334
  if parsed_args.is_enabled is not None:
305
335
  kwargs['is_enabled'] = parsed_args.is_enabled
@@ -308,32 +338,29 @@ class ListProject(command.Lister):
308
338
 
309
339
  if parsed_args.my_projects:
310
340
  # NOTE(adriant): my-projects supersedes all the other filters.
311
- kwargs = {'user': self.app.client_manager.auth_ref.user_id}
341
+ kwargs = {}
342
+ user = self.app.client_manager.auth_ref.user_id
312
343
 
313
- try:
314
- data = identity_client.projects.list(**kwargs)
315
- except ks_exc.Forbidden:
316
- # NOTE(adriant): if no filters, assume a forbidden is non-admin
317
- # wanting their own project list.
318
- if not kwargs:
319
- user = self.app.client_manager.auth_ref.user_id
320
- data = identity_client.projects.list(user=user)
321
- else:
322
- raise
344
+ if user:
345
+ data = identity_client.user_projects(user, **kwargs)
346
+ else:
347
+ try:
348
+ data = identity_client.projects(**kwargs)
349
+ except sdk_exc.ForbiddenException:
350
+ # NOTE(adriant): if no filters, assume a forbidden is non-admin
351
+ # wanting their own project list.
352
+ if not kwargs:
353
+ user = self.app.client_manager.auth_ref.user_id
354
+ data = identity_client.user_projects(user)
355
+ else:
356
+ raise
323
357
 
324
358
  if parsed_args.sort:
325
359
  data = utils.sort_items(data, parsed_args.sort)
326
360
 
327
361
  return (
328
- columns,
329
- (
330
- utils.get_item_properties(
331
- s,
332
- columns,
333
- formatters={},
334
- )
335
- for s in data
336
- ),
362
+ column_headers,
363
+ (utils.get_item_properties(s, columns) for s in data),
337
364
  )
338
365
 
339
366
 
@@ -392,11 +419,7 @@ class SetProject(command.Command):
392
419
  return parser
393
420
 
394
421
  def take_action(self, parsed_args):
395
- identity_client = self.app.client_manager.identity
396
-
397
- project = common.find_project(
398
- identity_client, parsed_args.project, parsed_args.domain
399
- )
422
+ identity_client = self.app.client_manager.sdk_connection.identity
400
423
 
401
424
  kwargs = {}
402
425
  if parsed_args.name:
@@ -409,9 +432,50 @@ class SetProject(command.Command):
409
432
  kwargs['options'] = {'immutable': parsed_args.immutable}
410
433
  if parsed_args.properties:
411
434
  kwargs.update(parsed_args.properties)
412
- tag.update_tags_in_args(parsed_args, project, kwargs)
413
435
 
414
- identity_client.projects.update(project.id, **kwargs)
436
+ if parsed_args.domain:
437
+ domain = common.find_domain_id_sdk(
438
+ identity_client,
439
+ parsed_args.domain,
440
+ validate_actor_existence=False,
441
+ )
442
+ project = identity_client.find_project(
443
+ parsed_args.project,
444
+ domain_id=domain,
445
+ ignore_missing=True,
446
+ )
447
+ else:
448
+ project = identity_client.find_project(
449
+ parsed_args.project,
450
+ ignore_missing=True,
451
+ )
452
+
453
+ if (
454
+ parsed_args.tags
455
+ or parsed_args.remove_tags
456
+ or parsed_args.clear_tags
457
+ ):
458
+ existing_tags = []
459
+ if project:
460
+ existing_tags = project.tags
461
+
462
+ if parsed_args.clear_tags:
463
+ kwargs['tags'] = []
464
+ else:
465
+ existing_tags_set = set(existing_tags)
466
+ if parsed_args.remove_tags:
467
+ tags = sorted(
468
+ existing_tags_set - set(parsed_args.remove_tags)
469
+ )
470
+ if parsed_args.tags:
471
+ tags = sorted(
472
+ existing_tags_set.union(set(parsed_args.tags))
473
+ )
474
+ kwargs['tags'] = tags
475
+
476
+ project_id = project.id if project else parsed_args.project
477
+
478
+ identity_client.update_project(project_id, **kwargs)
415
479
 
416
480
 
417
481
  class ShowProject(command.ShowOne):
@@ -444,31 +508,36 @@ class ShowProject(command.ShowOne):
444
508
  return parser
445
509
 
446
510
  def take_action(self, parsed_args):
447
- identity_client = self.app.client_manager.identity
511
+ identity_client = self.app.client_manager.sdk_connection.identity
448
512
 
449
- project_str = common._get_token_resource(
450
- identity_client, 'project', parsed_args.project, parsed_args.domain
451
- )
513
+ kwargs = {}
452
514
 
515
+ domain = None
453
516
  if parsed_args.domain:
454
- domain = common.find_domain(identity_client, parsed_args.domain)
455
- project = utils.find_resource(
456
- identity_client.projects, project_str, domain_id=domain.id
457
- )
458
- else:
459
- project = utils.find_resource(
460
- identity_client.projects, project_str
517
+ domain = common.find_domain_id_sdk(
518
+ identity_client, parsed_args.domain
461
519
  )
462
520
 
463
- if parsed_args.parents or parsed_args.children:
464
- # NOTE(RuiChen): utils.find_resource() can't pass kwargs,
465
- # if id query hit the result at first, so call
466
- # identity manager.get() with kwargs directly.
467
- project = identity_client.projects.get(
468
- project.id,
469
- parents_as_ids=parsed_args.parents,
470
- subtree_as_ids=parsed_args.children,
471
- )
521
+ kwargs['domain_id'] = domain
522
+
523
+ # Get project id first; otherwise, find_project() can't find
524
+ # parents/children if only project name was given
525
+ project = common.find_project_id_sdk(
526
+ identity_client,
527
+ parsed_args.project,
528
+ domain_name_or_id=domain,
529
+ validate_actor_existence=False,
530
+ validate_domain_actor_existence=False,
531
+ )
532
+
533
+ # Include these options as query parameters if they are provided
534
+ if parsed_args.parents:
535
+ kwargs['parents_as_ids'] = True
536
+ if parsed_args.children:
537
+ kwargs['subtree_as_ids'] = True
538
+
539
+ project = identity_client.find_project(
540
+ project, **kwargs, ignore_missing=False
541
+ )
472
542
 
473
- project._info.pop('links')
474
- return zip(*sorted(project._info.items()))
543
+ return _format_project(project)
@@ -25,6 +25,29 @@ from openstackclient.identity import common as common_utils
25
25
  LOG = logging.getLogger(__name__)
26
26
 
27
27
 
28
+ def _format_registered_limit(registered_limit):
29
+ columns = (
30
+ 'default_limit',
31
+ 'description',
32
+ 'id',
33
+ 'region_id',
34
+ 'resource_name',
35
+ 'service_id',
36
+ )
37
+ column_headers = (
38
+ 'default_limit',
39
+ 'description',
40
+ 'id',
41
+ 'region_id',
42
+ 'resource_name',
43
+ 'service_id',
44
+ )
45
+ return (
46
+ column_headers,
47
+ utils.get_item_properties(registered_limit, columns),
48
+ )
49
+
50
+
28
51
  class CreateRegisteredLimit(command.ShowOne):
29
52
  _description = _("Create a registered limit")
30
53
 
@@ -64,43 +87,28 @@ class CreateRegisteredLimit(command.ShowOne):
64
87
  return parser
65
88
 
66
89
  def take_action(self, parsed_args):
67
- identity_client = self.app.client_manager.identity
90
+ identity_client = self.app.client_manager.sdk_connection.identity
91
+
92
+ kwargs = {}
93
+
94
+ if parsed_args.description:
95
+ kwargs["description"] = parsed_args.description
96
+
97
+ kwargs["service_id"] = common_utils.find_service_sdk(
98
+ identity_client, parsed_args.service
99
+ ).id
68
100
 
69
- service = utils.find_resource(
70
- identity_client.services, parsed_args.service
71
- )
72
- region = None
73
101
  if parsed_args.region:
74
- if 'None' not in parsed_args.region:
75
- # NOTE (vishakha): Due to bug #1799153 and for any another
76
- # related case where GET resource API does not support the
77
- # filter by name, osc_lib.utils.find_resource() method cannot
78
- # be used because that method try to fall back to list all the
79
- # resource if requested resource cannot be get via name. Which
80
- # ends up with NoUniqueMatch error.
81
- # So osc_lib.utils.find_resource() function cannot be used for
82
- # 'regions', using common_utils.get_resource() instead.
83
- region = common_utils.get_resource(
84
- identity_client.regions, parsed_args.region
85
- )
86
- else:
87
- self.log.warning(
88
- _(
89
- "Passing 'None' to indicate no region is deprecated. "
90
- "Instead, don't pass --region."
91
- )
92
- )
102
+ kwargs["region_id"] = identity_client.get_region(
103
+ parsed_args.region
104
+ ).id
93
105
 
94
- registered_limit = identity_client.registered_limits.create(
95
- service,
96
- parsed_args.resource_name,
97
- parsed_args.default_limit,
98
- description=parsed_args.description,
99
- region=region,
100
- )
106
+ kwargs["resource_name"] = parsed_args.resource_name
107
+ kwargs["default_limit"] = parsed_args.default_limit
108
+
109
+ registered_limit = identity_client.create_registered_limit(**kwargs)
101
110
 
102
- registered_limit._info.pop('links', None)
103
- return zip(*sorted(registered_limit._info.items()))
111
+ return _format_registered_limit(registered_limit)
104
112
 
105
113
 
106
114
  class DeleteRegisteredLimit(command.Command):
@@ -112,17 +120,22 @@ class DeleteRegisteredLimit(command.Command):
112
120
  'registered_limits',
113
121
  metavar='<registered-limits>',
114
122
  nargs="+",
115
- help=_('Registered limit(s) to delete (ID)'),
123
+ help=_(
124
+ 'Registered limit(s) to delete (ID) '
125
+ '(repeat option to remove multiple registered limits)'
126
+ ),
116
127
  )
117
128
  return parser
118
129
 
119
130
  def take_action(self, parsed_args):
120
- identity_client = self.app.client_manager.identity
131
+ identity_client = self.app.client_manager.sdk_connection.identity
121
132
 
122
133
  errors = 0
123
134
  for registered_limit_id in parsed_args.registered_limits:
124
135
  try:
125
- identity_client.registered_limits.delete(registered_limit_id)
136
+ identity_client.delete_registered_limit(
137
+ registered_limit_id, ignore_missing=False
138
+ )
126
139
  except Exception as e:
127
140
  errors += 1
128
141
  from pprint import pprint
@@ -170,40 +183,22 @@ class ListRegisteredLimit(command.Lister):
170
183
  return parser
171
184
 
172
185
  def take_action(self, parsed_args):
173
- identity_client = self.app.client_manager.identity
186
+ identity_client = self.app.client_manager.sdk_connection.identity
174
187
 
175
- service = None
188
+ kwargs = {}
176
189
  if parsed_args.service:
177
- service = common_utils.find_service(
190
+ kwargs["service_id"] = common_utils.find_service_sdk(
178
191
  identity_client, parsed_args.service
179
- )
180
- region = None
192
+ ).id
181
193
  if parsed_args.region:
182
- if 'None' not in parsed_args.region:
183
- # NOTE (vishakha): Due to bug #1799153 and for any another
184
- # related case where GET resource API does not support the
185
- # filter by name, osc_lib.utils.find_resource() method cannot
186
- # be used because that method try to fall back to list all the
187
- # resource if requested resource cannot be get via name. Which
188
- # ends up with NoUniqueMatch error.
189
- # So osc_lib.utils.find_resource() function cannot be used for
190
- # 'regions', using common_utils.get_resource() instead.
191
- region = common_utils.get_resource(
192
- identity_client.regions, parsed_args.region
193
- )
194
- else:
195
- self.log.warning(
196
- _(
197
- "Passing 'None' to indicate no region is deprecated. "
198
- "Instead, don't pass --region."
199
- )
200
- )
194
+ kwargs["region_id"] = identity_client.get_region(
195
+ parsed_args.region
196
+ ).id
201
197
 
202
- registered_limits = identity_client.registered_limits.list(
203
- service=service,
204
- resource_name=parsed_args.resource_name,
205
- region=region,
206
- )
198
+ if parsed_args.resource_name:
199
+ kwargs["resource_name"] = parsed_args.resource_name
200
+
201
+ registered_limits = identity_client.registered_limits(**kwargs)
207
202
 
208
203
  columns = (
209
204
  'ID',
@@ -273,44 +268,33 @@ class SetRegisteredLimit(command.ShowOne):
273
268
  return parser
274
269
 
275
270
  def take_action(self, parsed_args):
276
- identity_client = self.app.client_manager.identity
271
+ identity_client = self.app.client_manager.sdk_connection.identity
277
272
 
278
- service = None
273
+ kwargs = {}
279
274
  if parsed_args.service:
280
- service = common_utils.find_service(
275
+ kwargs["service_id"] = common_utils.find_service_sdk(
281
276
  identity_client, parsed_args.service
282
- )
277
+ ).id
278
+
279
+ if parsed_args.resource_name:
280
+ kwargs["resource_name"] = parsed_args.resource_name
281
+
282
+ if parsed_args.default_limit:
283
+ kwargs["default_limit"] = parsed_args.default_limit
284
+
285
+ if parsed_args.description:
286
+ kwargs["description"] = parsed_args.description
283
287
 
284
- region = None
285
288
  if parsed_args.region:
286
- if 'None' not in parsed_args.region:
287
- # NOTE (vishakha): Due to bug #1799153 and for any another
288
- # related case where GET resource API does not support the
289
- # filter by name, osc_lib.utils.find_resource() method cannot
290
- # be used because that method try to fall back to list all the
291
- # resource if requested resource cannot be get via name. Which
292
- # ends up with NoUniqueMatch error.
293
- # So osc_lib.utils.find_resource() function cannot be used for
294
- # 'regions', using common_utils.get_resource() instead.
295
- region = common_utils.get_resource(
296
- identity_client.regions, parsed_args.region
297
- )
298
- else:
299
- self.log.warning(
300
- _("Passing 'None' to indicate no region is deprecated.")
301
- )
289
+ kwargs["region_id"] = identity_client.get_region(
290
+ parsed_args.region
291
+ ).id
302
292
 
303
- registered_limit = identity_client.registered_limits.update(
304
- parsed_args.registered_limit_id,
305
- service=service,
306
- resource_name=parsed_args.resource_name,
307
- default_limit=parsed_args.default_limit,
308
- description=parsed_args.description,
309
- region=region,
293
+ registered_limit = identity_client.update_registered_limit(
294
+ parsed_args.registered_limit_id, **kwargs
310
295
  )
311
296
 
312
- registered_limit._info.pop('links', None)
313
- return zip(*sorted(registered_limit._info.items()))
297
+ return _format_registered_limit(registered_limit)
314
298
 
315
299
 
316
300
  class ShowRegisteredLimit(command.ShowOne):
@@ -326,9 +310,8 @@ class ShowRegisteredLimit(command.ShowOne):
326
310
  return parser
327
311
 
328
312
  def take_action(self, parsed_args):
329
- identity_client = self.app.client_manager.identity
330
- registered_limit = identity_client.registered_limits.get(
313
+ identity_client = self.app.client_manager.sdk_connection.identity
314
+ registered_limit = identity_client.get_registered_limit(
331
315
  parsed_args.registered_limit_id
332
316
  )
333
- registered_limit._info.pop('links', None)
334
- return zip(*sorted(registered_limit._info.items()))
317
+ return _format_registered_limit(registered_limit)
@@ -123,14 +123,3 @@ def add_tag_option_to_parser_for_set(parser, resource_name):
123
123
  )
124
124
  % resource_name,
125
125
  )
126
-
127
-
128
- def update_tags_in_args(parsed_args, obj, args):
129
- if parsed_args.clear_tags:
130
- args['tags'] = []
131
- obj.tags = []
132
- if parsed_args.remove_tags:
133
- args['tags'] = sorted(set(obj.tags) - set(parsed_args.remove_tags))
134
- return
135
- if parsed_args.tags:
136
- args['tags'] = sorted(set(obj.tags).union(set(parsed_args.tags)))
@@ -622,7 +622,7 @@ class CreateImage(command.ShowOne):
622
622
  )
623
623
  # TODO(stephenfin): These should be an error in a future
624
624
  # version
625
- LOG.warning(msg % opt_name)
625
+ LOG.warning(msg, opt_name)
626
626
 
627
627
  source_volume = volume_client.find_volume(
628
628
  parsed_args.volume, ignore_missing=False
@@ -1719,6 +1719,7 @@ class ImportImage(command.ShowOne):
1719
1719
  )
1720
1720
  stores_group.add_argument(
1721
1721
  '--all-stores',
1722
+ action='store_true',
1722
1723
  help=_(
1723
1724
  "Make image available to all stores "
1724
1725
  "(either '--store' or '--all-stores' required with the "