Pass kwargs to exception to get better format of error message

If we do not pass kwargs to exception, the parameter will be deemed
as message and will be displayed directly. This is to pass kwargs to
MultipleHostsFound and UnsupportedResourceType, to get better format
of error message.

Change-Id: Ib40ee68249b34f3e83100c5da8d30e13ff820dfa
This commit is contained in:
zhufl
2019-04-18 10:22:42 +08:00
parent c36dc9b652
commit 985876e9a8
3 changed files with 8 additions and 5 deletions

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