Skip to content
This repository has been archived by the owner on Aug 9, 2024. It is now read-only.

Commit

Permalink
services.ec2: Delete the source for every image urls
Browse files Browse the repository at this point in the history
Signed-off-by: Sayan Chowdhury <[email protected]>
  • Loading branch information
sayanchowdhury committed Apr 25, 2018
1 parent f92be3f commit bebd8bd
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions fedimg/services/ec2/ec2initiate.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def main(image_urls, access_id, secret_key, regions, volume_types=None,

uploader.set_image_virt_type(virt_type)
_log.debug('(uploader) Virtualization type '
'is set to: %r' % virt_type)
'is set to: %r' % virt_type)

image_name = get_image_name_from_image(
image_url=image_url,
Expand Down Expand Up @@ -158,10 +158,16 @@ def main(image_urls, access_id, secret_key, regions, volume_types=None,
published_images.extend(publisher.publish_images(
region_image_mapping=[(region, image.id)]
))
except ValueError:
_log.debug('Source not found.')
return []
except Exception as e:
_log.debug(e.message)
return []
#TODO: Implement the clean up of the images if failed.
# uploader.clean_up(image_id=image.id, delete_snapshot=True)

shutil.rmtree(os.path.dirname(source))
shutil.rmtree(os.path.dirname(source))
_log.debug("Cleaned up %r" % source)

return published_images

0 comments on commit bebd8bd

Please sign in to comment.