Merge "Pass kwargs to exception to get better format of error message"

This commit is contained in:
Zuul 2019-05-14 10:30:51 +00:00 committed by Gerrit Code Review
commit d9fdb7ed20
3 changed files with 8 additions and 5 deletions

View File

@ -118,7 +118,8 @@ def get_plugin_reservation(resource_type, resource_id):
elif resource_type == instance_plugin.RESOURCE_TYPE:
return api.instance_reservation_get(resource_id)
else:
raise mgr_exceptions.UnsupportedResourceType(resource_type)
raise mgr_exceptions.UnsupportedResourceType(
resource_type=resource_type)
def get_free_periods(resource_id, start_date, end_date, duration,

View File

@ -597,7 +597,8 @@ class ManagerService(service_utils.RPCServer):
def _create_reservation(self, values):
resource_type = values['resource_type']
if resource_type not in self.plugins:
raise exceptions.UnsupportedResourceType(resource_type)
raise exceptions.UnsupportedResourceType(
resource_type=resource_type)
reservation_values = {
'lease_id': values['lease_id'],
'resource_type': resource_type,
@ -677,7 +678,8 @@ class ManagerService(service_utils.RPCServer):
except KeyError:
LOG.error("Plugin with resource type %s not found",
resource_type)
raise exceptions.UnsupportedResourceType(resource_type)
raise exceptions.UnsupportedResourceType(
resource_type=resource_type)
except AttributeError:
LOG.error("Plugin %s doesn't include method %s",
self.plugins[resource_type], method)

View File

@ -480,7 +480,7 @@ class NovaInventory(NovaClientWrapper):
except nova_exception.NotFound:
raise manager_exceptions.HostNotFound(host=host)
if len(hypervisors_list) > 1:
raise manager_exceptions.MultipleHostsFound(host)
raise manager_exceptions.MultipleHostsFound(host=host)
else:
hypervisor_id = hypervisors_list[0].id
# NOTE(sbauza): No need to catch the exception as we're sure
@ -523,7 +523,7 @@ class NovaInventory(NovaClientWrapper):
except nova_exception.NotFound:
raise manager_exceptions.HostNotFound(host=host)
if len(hypervisors_list) > 1:
raise manager_exceptions.MultipleHostsFound(host)
raise manager_exceptions.MultipleHostsFound(host=host)
else:
try:
return hypervisors_list[0].servers