Merge "Improve error message for AggregateAlreadyHasHost exception"

This commit is contained in:
Zuul 2018-11-06 08:28:46 +00:00 committed by Gerrit Code Review
commit 7ee3c800ea
2 changed files with 5 additions and 4 deletions

View File

@ -48,7 +48,8 @@ class AggregateHaveHost(exceptions.BlazarException):
class AggregateAlreadyHasHost(exceptions.BlazarException):
code = 409
msg_fmt = _("Aggregate %(pool)s already has host(s) %(host)s ")
msg_fmt = _("Conflict while adding host %(host)s to aggregate %(pool)s: "
"%(nova_exception)s")
class AggregateNotFound(exceptions.NotFound):

View File

@ -365,9 +365,9 @@ class ReservationPool(NovaClientWrapper):
return self.nova.aggregates.add_host(agg.id, host)
except nova_exception.NotFound:
raise manager_exceptions.HostNotFound(host=host)
except nova_exception.Conflict:
raise manager_exceptions.AggregateAlreadyHasHost(pool=pool,
host=host)
except nova_exception.Conflict as e:
raise manager_exceptions.AggregateAlreadyHasHost(
pool=pool, host=host, nova_exception=str(e))
def remove_all_computehosts(self, pool):
"""Remove all compute hosts attached to an aggregate."""