Merge "Updated the take_actions for unified limits"
This commit is contained in:
commit
9100e56d08
@ -68,6 +68,25 @@ def find_service(identity_client, name_type_or_id):
|
|||||||
raise exceptions.CommandError(msg % name_type_or_id)
|
raise exceptions.CommandError(msg % name_type_or_id)
|
||||||
|
|
||||||
|
|
||||||
|
def get_resource(manager, name_type_or_id):
|
||||||
|
# NOTE (vishakha): Due to bug #1799153 and for any another related case
|
||||||
|
# where GET resource API does not support the filter by name,
|
||||||
|
# osc_lib.utils.find_resource() method cannot be used because that method
|
||||||
|
# try to fall back to list all the resource if requested resource cannot
|
||||||
|
# be get via name. Which ends up with NoUniqueMatch error.
|
||||||
|
# This new function is the replacement for osc_lib.utils.find_resource()
|
||||||
|
# for resources does not support GET by name.
|
||||||
|
# For example: identity GET /regions.
|
||||||
|
"""Find a resource by id or name."""
|
||||||
|
|
||||||
|
try:
|
||||||
|
return manager.get(name_type_or_id)
|
||||||
|
except identity_exc.NotFound:
|
||||||
|
# raise NotFound exception
|
||||||
|
msg = _("No resource with name or id of '%s' exists")
|
||||||
|
raise exceptions.CommandError(msg % name_type_or_id)
|
||||||
|
|
||||||
|
|
||||||
def _get_token_resource(client, resource, parsed_name, parsed_domain=None):
|
def _get_token_resource(client, resource, parsed_name, parsed_domain=None):
|
||||||
"""Peek into the user's auth token to get resource IDs
|
"""Peek into the user's auth token to get resource IDs
|
||||||
|
|
||||||
|
@ -78,9 +78,19 @@ class CreateLimit(command.ShowOne):
|
|||||||
)
|
)
|
||||||
region = None
|
region = None
|
||||||
if parsed_args.region:
|
if parsed_args.region:
|
||||||
region = utils.find_resource(
|
val = getattr(parsed_args, 'region', None)
|
||||||
identity_client.regions, parsed_args.region
|
if 'None' not in val:
|
||||||
)
|
# NOTE (vishakha): Due to bug #1799153 and for any another
|
||||||
|
# related case where GET resource API does not support the
|
||||||
|
# filter by name, osc_lib.utils.find_resource() method cannot
|
||||||
|
# be used because that method try to fall back to list all the
|
||||||
|
# resource if requested resource cannot be get via name. Which
|
||||||
|
# ends up with NoUniqueMatch error.
|
||||||
|
# So osc_lib.utils.find_resource() function cannot be used for
|
||||||
|
# 'regions', using common_utils.get_resource() instead.
|
||||||
|
region = common_utils.get_resource(
|
||||||
|
identity_client.regions, parsed_args.region
|
||||||
|
)
|
||||||
|
|
||||||
limit = identity_client.limits.create(
|
limit = identity_client.limits.create(
|
||||||
project,
|
project,
|
||||||
@ -136,6 +146,19 @@ class ListLimit(command.Lister):
|
|||||||
region = utils.find_resource(
|
region = utils.find_resource(
|
||||||
identity_client.regions, parsed_args.region
|
identity_client.regions, parsed_args.region
|
||||||
)
|
)
|
||||||
|
val = getattr(parsed_args, 'region', None)
|
||||||
|
if 'None' not in val:
|
||||||
|
# NOTE (vishakha): Due to bug #1799153 and for any another
|
||||||
|
# related case where GET resource API does not support the
|
||||||
|
# filter by name, osc_lib.utils.find_resource() method cannot
|
||||||
|
# be used because that method try to fall back to list all the
|
||||||
|
# resource if requested resource cannot be get via name. Which
|
||||||
|
# ends up with NoUniqueMatch error.
|
||||||
|
# So osc_lib.utils.find_resource() function cannot be used for
|
||||||
|
# 'regions', using common_utils.get_resource() instead.
|
||||||
|
region = common_utils.get_resource(
|
||||||
|
identity_client.regions, parsed_args.region
|
||||||
|
)
|
||||||
project = None
|
project = None
|
||||||
if parsed_args.project:
|
if parsed_args.project:
|
||||||
project = utils.find_resource(
|
project = utils.find_resource(
|
||||||
|
@ -69,9 +69,19 @@ class CreateRegisteredLimit(command.ShowOne):
|
|||||||
)
|
)
|
||||||
region = None
|
region = None
|
||||||
if parsed_args.region:
|
if parsed_args.region:
|
||||||
region = utils.find_resource(
|
val = getattr(parsed_args, 'region', None)
|
||||||
identity_client.regions, parsed_args.region
|
if 'None' not in val:
|
||||||
)
|
# NOTE (vishakha): Due to bug #1799153 and for any another
|
||||||
|
# related case where GET resource API does not support the
|
||||||
|
# filter by name, osc_lib.utils.find_resource() method cannot
|
||||||
|
# be used because that method try to fall back to list all the
|
||||||
|
# resource if requested resource cannot be get via name. Which
|
||||||
|
# ends up with NoUniqueMatch error.
|
||||||
|
# So osc_lib.utils.find_resource() function cannot be used for
|
||||||
|
# 'regions', using common_utils.get_resource() instead.
|
||||||
|
region = common_utils.get_resource(
|
||||||
|
identity_client.regions, parsed_args.region
|
||||||
|
)
|
||||||
|
|
||||||
registered_limit = identity_client.registered_limits.create(
|
registered_limit = identity_client.registered_limits.create(
|
||||||
service,
|
service,
|
||||||
@ -153,9 +163,19 @@ class ListRegisteredLimit(command.Lister):
|
|||||||
)
|
)
|
||||||
region = None
|
region = None
|
||||||
if parsed_args.region:
|
if parsed_args.region:
|
||||||
region = utils.find_resource(
|
val = getattr(parsed_args, 'region', None)
|
||||||
identity_client.regions, parsed_args.region
|
if 'None' not in val:
|
||||||
)
|
# NOTE (vishakha): Due to bug #1799153 and for any another
|
||||||
|
# related case where GET resource API does not support the
|
||||||
|
# filter by name, osc_lib.utils.find_resource() method cannot
|
||||||
|
# be used because that method try to fall back to list all the
|
||||||
|
# resource if requested resource cannot be get via name. Which
|
||||||
|
# ends up with NoUniqueMatch error.
|
||||||
|
# So osc_lib.utils.find_resource() function cannot be used for
|
||||||
|
# 'regions', using common_utils.get_resource() instead.
|
||||||
|
region = common_utils.get_resource(
|
||||||
|
identity_client.regions, parsed_args.region
|
||||||
|
)
|
||||||
|
|
||||||
registered_limits = identity_client.registered_limits.list(
|
registered_limits = identity_client.registered_limits.list(
|
||||||
service=service,
|
service=service,
|
||||||
@ -222,9 +242,19 @@ class SetRegisteredLimit(command.ShowOne):
|
|||||||
|
|
||||||
region = None
|
region = None
|
||||||
if parsed_args.region:
|
if parsed_args.region:
|
||||||
region = utils.find_resource(
|
val = getattr(parsed_args, 'region', None)
|
||||||
identity_client.regions, parsed_args.region
|
if 'None' not in val:
|
||||||
)
|
# NOTE (vishakha): Due to bug #1799153 and for any another
|
||||||
|
# related case where GET resource API does not support the
|
||||||
|
# filter by name, osc_lib.utils.find_resource() method cannot
|
||||||
|
# be used because that method try to fall back to list all the
|
||||||
|
# resource if requested resource cannot be get via name. Which
|
||||||
|
# ends up with NoUniqueMatch error.
|
||||||
|
# So osc_lib.utils.find_resource() function cannot be used for
|
||||||
|
# 'regions', using common_utils.get_resource() instead.
|
||||||
|
region = common_utils.get_resource(
|
||||||
|
identity_client.regions, parsed_args.region
|
||||||
|
)
|
||||||
|
|
||||||
registered_limit = identity_client.registered_limits.update(
|
registered_limit = identity_client.registered_limits.update(
|
||||||
parsed_args.registered_limit_id,
|
parsed_args.registered_limit_id,
|
||||||
|
Loading…
Reference in New Issue
Block a user