Example #1
0
    def wait_for_backup_status(self, backup_id, status):
        """Waits for a Backup to reach a given status."""
        resp, body = self.get_backup(backup_id)
        backup_status = body['status']
        start = int(time.time())

        while backup_status != status:
            time.sleep(self.build_interval)
            resp, body = self.get_backup(backup_id)
            backup_status = body['status']
            if backup_status == 'error':
                raise exceptions.VolumeBackupException(backup_id=backup_id)

            if int(time.time()) - start >= self.build_timeout:
                message = ('Volume backup %s failed to reach %s status within '
                           'the required time (%s s).' %
                           (backup_id, status, self.build_timeout))
                raise exceptions.TimeoutException(message)
Example #2
0
def wait_for_backup_status(client, backup_id, status):
    """Waits for a Backup to reach a given status."""
    body = client.show_backup(backup_id)['backup']
    backup_status = body['status']
    start = int(time.time())

    while backup_status != status:
        time.sleep(client.build_interval)
        body = client.show_backup(backup_id)['backup']
        backup_status = body['status']
        if backup_status == 'error' and backup_status != status:
            raise exceptions.VolumeBackupException(backup_id=backup_id)

        if int(time.time()) - start >= client.build_timeout:
            message = ('Volume backup %s failed to reach %s status '
                       '(current %s) within the required time (%s s).' %
                       (backup_id, status, backup_status,
                        client.build_timeout))
            raise exceptions.TimeoutException(message)