def wait_snapshot(ec2_conn, snap_id, logger=None, timeout=SNAPSHOT_TIMEOUT): ''' Waits until snapshot becomes 'completed' or 'error' ''' logger = logger or logging.getLogger(__name__) if isinstance(snap_id, basestring): snap = Snapshot(ec2_conn) snap.id = snap_id else: snap = snap_id logger.debug('Checking that snapshot %s is completed', snap.id) wait_until( lambda: snap.update() and snap.status != 'pending', logger=logger, timeout=timeout, error_text="EBS snapshot %s wasn't completed in a reasonable time" % snap.id ) if snap.status == 'error': raise PlatformError('Snapshot %s creation failed' % snap.id) elif snap.status == 'completed': logger.debug('Snapshot %s completed', snap.id)