image.py (ec2-api-12.0.0) | : | image.py (ec2-api-13.0.0) | ||
---|---|---|---|---|
skipping to change at line 155 | skipping to change at line 155 | |||
err = (_("Couldn't stop instance within %d sec") % timeout) | err = (_("Couldn't stop instance within %d sec") % timeout) | |||
raise exception.EC2Exception(message=err) | raise exception.EC2Exception(message=err) | |||
# NOTE(ft): create an image with ec2_id metadata to let other code | # NOTE(ft): create an image with ec2_id metadata to let other code | |||
# link os and db objects in race conditions | # link os and db objects in race conditions | |||
os_image_id = os_instance.create_image( | os_image_id = os_instance.create_image( | |||
name, metadata={'ec2_id': image['id']}) | name, metadata={'ec2_id': image['id']}) | |||
image['os_id'] = os_image_id | image['os_id'] = os_image_id | |||
db_api.update_item(context, image) | db_api.update_item(context, image) | |||
except Exception: | except Exception: | |||
LOG.exception('Failed to complete image %s creation', image.id) | LOG.exception('Failed to complete image %s creation', image['id']) | |||
try: | try: | |||
image['state'] = 'failed' | image['state'] = 'failed' | |||
db_api.update_item(context, image) | db_api.update_item(context, image) | |||
except Exception: | except Exception: | |||
LOG.warning("Couldn't set 'failed' state for db image %s", | LOG.warning("Couldn't set 'failed' state for db image %s", | |||
image.id, exc_info=True) | image['id'], exc_info=True) | |||
try: | try: | |||
os_instance.start() | os_instance.start() | |||
except Exception: | except Exception: | |||
LOG.warning('Failed to start instance %(i_id)s after ' | LOG.warning('Failed to start instance %(i_id)s after ' | |||
'completed creation of image %(image_id)s', | 'completed creation of image %(image_id)s', | |||
{'i_id': instance['id'], | {'i_id': instance['id'], | |||
'image_id': image['id']}, | 'image_id': image['id']}, | |||
exc_info=True) | exc_info=True) | |||
End of changes. 2 change blocks. | ||||
2 lines changed or deleted | 2 lines changed or added |