def wait_for_volume_status(self, volume_id, status): """Waits for a Volume to reach a given status.""" resp, body = self.get_volume(volume_id) volume_name = body['displayName'] volume_status = body['status'] start = int(time.time()) while volume_status != status: time.sleep(self.build_interval) resp, body = self.get_volume(volume_id) volume_status = body['status'] if volume_status == 'error': raise exceptions.VolumeBuildErrorException(volume_id=volume_id) if int(time.time()) - start >= self.build_timeout: message = ('Volume %s failed to reach %s status within ' 'the required time (%s s).' % (volume_name, status, self.build_timeout)) raise exceptions.TimeoutException(message)
def wait_for_volume_status(self, volume_id, status): """Waits for a Volume to reach a given status.""" body = self.show_volume(volume_id) volume_status = body['status'] start = int(time.time()) while volume_status != status: time.sleep(self.build_interval) body = self.show_volume(volume_id) volume_status = body['status'] if volume_status == 'error': raise exceptions.VolumeBuildErrorException(volume_id=volume_id) if int(time.time()) - start >= self.build_timeout: message = ('Volume %s failed to reach %s status (current %s) ' 'within the required time (%s s).' % (volume_id, status, volume_status, self.build_timeout)) raise exceptions.TimeoutException(message)