def wait_for_volume_status(client, volume_id, status):
 body = client.show_volume(volume_id)['volume']
 volume_status = body['status']
 start = int(time.time())
 while (volume_status != status):
  time.sleep(client.build_interval)
  body = client.show_volume(volume_id)['volume']
  volume_status = body['status']
  if ((volume_status == 'error') and (status != 'error')):
   raise exceptions.VolumeBuildErrorException(volume_id=volume_id)
  if (volume_status == 'error_restoring'):
   raise exceptions.VolumeRestoreErrorException(volume_id=volume_id)
  if ((int(time.time()) - start) >= client.build_timeout):
   message = ('Volume %s failed to reach %s status (current %s) within the required time (%s s).' % (volume_id, status, volume_status, client.build_timeout))
   raise lib_exc.TimeoutException(message)

def wait_for_volume_status ( client , volume_id , status ) : body = client . show_volume ( volume_id ) [ 'volume' ] volume_status = body [ 'status' ] start = int ( time . time ( ) ) while ( volume_status != status ) : time . sleep ( client . build_interval ) body = client . show_volume ( volume_id ) [ 'volume' ] volume_status = body [ 'status' ] if ( ( volume_status == 'error' ) and ( status != 'error' ) ) : raise exceptions . VolumeBuildErrorException ( volume_id = volume_id ) if ( volume_status == 'error_restoring' ) : raise exceptions . VolumeRestoreErrorException ( volume_id = volume_id ) if ( ( int ( time . time ( ) ) - start ) >= client . build_timeout ) : message = ( 'Volume %s failed to reach %s status (current %s) within the required time (%s s).' % ( volume_id , status , volume_status , client . build_timeout ) ) raise lib_exc . TimeoutException ( message )
waits for a volume to reach a given status .