'Waits for a consistency group snapshot to reach a given status.'

def wait_for_cgsnapshot_status(self, cgsnapshot_id, status):

    body = self.show_cgsnapshot(cgsnapshot_id)['cgsnapshot']
    cgsnapshot_status = body['status']
    start = int(time.time())
    while (cgsnapshot_status != status):
        time.sleep(self.build_interval)
        body = self.show_cgsnapshot(cgsnapshot_id)['cgsnapshot']
        cgsnapshot_status = body['status']
        if (cgsnapshot_status == 'error'):
            raise exceptions.ConsistencyGroupSnapshotException(cgsnapshot_id=cgsnapshot_id)
        if ((int(time.time()) - start) >= self.build_timeout):
            message = ('Consistency    group    snapshot    %s    failed    to    reach    %s    status    (current    %s)    within    the    required    time    (%s    s).' % (cgsnapshot_id, status, cgsnapshot_status, self.build_timeout))
            raise exceptions.TimeoutException(message)
