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

Commit

Permalink
services.ec2: Support both type of resource ids
Browse files Browse the repository at this point in the history
Signed-off-by: Sayan Chowdhury <sayan.chowdhury2012@gmail.com>
  • Loading branch information
sayanchowdhury committed Jun 5, 2018
1 parent 5698591 commit 10508ba
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions fedimg/services/ec2/ec2imguploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,15 @@ def _retry_and_get_volume_id(self, task_id):

if 'completed' in output:
_log.debug('Task %r complete. Fetching volume id...' % task_id)
match = re.search('\s(vol-\w{17})', output)
volume_id = match.group(1)
volume_id = get_item_from_regex(output,
regex='\s(vol-\w{17})')
if not volume_id:
volume_id = get_item_from_regex(output,
regex='\s(vol-\w{8})')

if not volume_id:
_log.error('Unable to fetch volume_id')
raise Exception('Unable to fetch volume_id.')

_log.debug('The id of the created volume: %r' % volume_id)

Expand Down Expand Up @@ -182,8 +189,18 @@ def _create_volume(self, source):
_log.debug('Initiate task to upload the image via S3. '
'Fetching task id...')

task_id = get_item_from_regex(
output, regex='\s(import-vol-\w{17})')
task_id = get_item_from_regex(output,
regex='\s(import-vol-\w{17})')

# Support the shorter task ids
if not task_id:
task_id = get_item_from_regex(output,
regex='\s(import-vol-\w{8})')

if not task_id:
_log.error('Unable to fetch task_id')
raise Exception('Unable to fetch task_id.')

_log.info('Fetched task_id: %r. Listening to the task.' % task_id)

volume_id = self._retry_and_get_volume_id(task_id)
Expand Down

0 comments on commit 10508ba

Please sign in to comment.