add exception handling for trying to update bad instances

This commit is contained in:
Paul Marshall 2012-08-08 16:09:10 -05:00 committed by Tim Simpson
parent 5f978fff3d
commit 0827b8bfa7
3 changed files with 16 additions and 2 deletions

View File

@ -172,3 +172,7 @@ class InvalidModelError(ReddwarfError):
class ModelNotFoundError(NotFound):
message = _("Not Found")
class UpdateGuestError(ReddwarfError):
message = _("Failed to update instances")

View File

@ -289,7 +289,8 @@ class Controller(object):
exception.VolumeQuotaExceeded,
],
webob.exc.HTTPServerError: [
exception.VolumeCreationFailure
exception.VolumeCreationFailure,
exception.UpdateGuestError,
],
}

View File

@ -81,9 +81,18 @@ class DetailedHost(object):
def update_all(self, context):
num_i = len(self.instances)
LOG.debug("Host %s has %s instances to update" % (self.name, num_i))
failed_instances = []
for instance in self.instances:
client = create_guest_client(context, instance['id'])
client.update_guest()
try:
client.update_guest()
except exception.ReddwarfError as re:
LOG.error(re)
LOG.error("Unable to update instance: %s" % instance['id'])
failed_instances.append(instance['id'])
if len(failed_instances) > 0:
msg = "Failed to update instances: %s" % failed_instances
raise exception.UpdateGuestError(msg)
@staticmethod
def load(context, name):