示例#1
0
  def _CheckProcess():
    if not IsProcessAlive(pid):
      return

    try:
      (result_pid, _) = os.waitpid(pid, os.WNOHANG)
    except OSError:
      raise utils_retry.RetryAgain()

    if result_pid > 0:
      return

    raise utils_retry.RetryAgain()
示例#2
0
 def fn():
     out = stdout_of([
         "gnt-job", "list", "--output=status", "--no-headers", "--filter",
         '"%s(%s)" in summary' % (move_type, inst.name)
     ])
     if 'success' not in out:
         raise retry.RetryAgain()
示例#3
0
 def fn():
     out = stdout_of([
         "gnt-node", "list", "--output=name", "--no-headers", "--filter",
         "drained"
     ])
     if node.primary not in out:
         raise retry.RetryAgain()
示例#4
0
 def fn():
     out = stdout_of([
         "gnt-job", "list", "--output=status", "--no-headers", "--filter",
         '"REPAIR_COMMAND" in summary'
     ])
     if 'success' not in out:
         raise retry.RetryAgain()
示例#5
0
def _CheckIfAlive(child):
  """Raises L{utils_retry.RetryAgain} if child is still alive.

  @raises utils_retry.RetryAgain: If child is still alive

  """
  if child.poll() is None:
    raise utils_retry.RetryAgain()
示例#6
0
 def fn():
     out = stdout_of([
         "gnt-instance", "list", "--output=status", "--no-headers",
         "--filter",
         "name == \"%s\"" % inst.name
     ])
     if "running" not in out:
         raise retry.RetryAgain()
示例#7
0
 def fn():
     tags = _GetMaintTags(node)
     if len(tags) == 0:
         raise retry.RetryAgain()
     if len(tags) > 1:
         raise qa_error.Error("Only one tag should be added")
     else:
         return tags[0]
示例#8
0
    def _Lock(fd, flag, timeout):
        try:
            fcntl.flock(fd, flag)
        except IOError as err:
            if timeout is not None and err.errno == errno.EAGAIN:
                raise retry.RetryAgain()

            logging.exception("fcntl.flock failed")
            raise
示例#9
0
 def _TryStat(name):
   try:
     os.stat(name)
     return True
   except EnvironmentError, err:
     if err.errno in (errno.ENOENT, errno.ENOTDIR):
       return False
     elif err.errno == errno.EINVAL:
       raise utils_retry.RetryAgain(err)
     raise
示例#10
0
def RetryingUntilJobStatus(retry_status, job_id):
    """ Used with C{retry.Retry}, waits for a given status.

  @type retry_status: string
  @param retry_status: The job status to wait for.
  @type job_id: string
  @param job_id: The job id, represented as a string.

  """
    status = GetJobStatus(job_id)
    if status != retry_status:
        raise retry.RetryAgain()
示例#11
0
文件: qa_job.py 项目: badp/ganeti
def _RetryingFetchJobStatus(retry_status, job_id):
    """ Used with C{retry.Retry}, waits for a status other than the one given.

  @type retry_status: string
  @param retry_status: The old job status, expected to change.
  @type job_id: string
  @param job_id: The job id, represented as a string.

  @rtype: string or None
  @return: The new job status, or None if none could be retrieved.

  """
    status = _GetJobStatus(job_id)
    if status == retry_status:
        raise retry.RetryAgain()
    return status
示例#12
0
 def _CheckSsconfInstanceList():
     if instance_name not in _ReadSsconfInstanceList():
         raise retry.RetryAgain()