Revision 87f5c298

b/lib/backend.py
2605 2605
    @param idata: the allocator input data
2606 2606

  
2607 2607
    @rtype: tuple
2608
    @return: four element tuple of:
2609
       - run status (one of the IARUN_ constants)
2610
       - stdout
2611
       - stderr
2612
       - fail reason (as from L{utils.RunResult})
2608
    @return: two element tuple of:
2609
       - status
2610
       - either error message or stdout of allocator (for success)
2613 2611

  
2614 2612
    """
2615 2613
    alloc_script = utils.FindFile(name, constants.IALLOCATOR_SEARCH_PATH,
2616 2614
                                  os.path.isfile)
2617 2615
    if alloc_script is None:
2618
      return (constants.IARUN_NOTFOUND, None, None, None)
2616
      _Fail("iallocator module '%s' not found in the search path", name)
2619 2617

  
2620 2618
    fd, fin_name = tempfile.mkstemp(prefix="ganeti-iallocator.")
2621 2619
    try:
......
2623 2621
      os.close(fd)
2624 2622
      result = utils.RunCmd([alloc_script, fin_name])
2625 2623
      if result.failed:
2626
        return (constants.IARUN_FAILURE, result.stdout, result.stderr,
2627
                result.fail_reason)
2624
        _Fail("iallocator module '%s' failed: %s, output '%s'",
2625
              name, result.fail_reason, result.output)
2628 2626
    finally:
2629 2627
      os.unlink(fin_name)
2630 2628

  
2631
    return (constants.IARUN_SUCCESS, result.stdout, result.stderr, None)
2629
    return True, result.stdout
2632 2630

  
2633 2631

  
2634 2632
class DevCacheManager(object):
b/lib/cmdlib.py
7123 7123
    data = self.in_text
7124 7124

  
7125 7125
    result = call_fn(self.lu.cfg.GetMasterNode(), name, self.in_text)
7126
    result.Raise()
7127

  
7128
    if not isinstance(result.data, (list, tuple)) or len(result.data) != 4:
7129
      raise errors.OpExecError("Invalid result from master iallocator runner")
7130

  
7131
    rcode, stdout, stderr, fail = result.data
7126
    msg = result.RemoteFailMsg()
7127
    if msg:
7128
      raise errors.OpExecError("Failure while running the iallocator"
7129
                               " script: %s" % msg)
7132 7130

  
7133
    if rcode == constants.IARUN_NOTFOUND:
7134
      raise errors.OpExecError("Can't find allocator '%s'" % name)
7135
    elif rcode == constants.IARUN_FAILURE:
7136
      raise errors.OpExecError("Instance allocator call failed: %s,"
7137
                               " output: %s" % (fail, stdout+stderr))
7138
    self.out_text = stdout
7131
    self.out_text = result.payload
7139 7132
    if validate:
7140 7133
      self._ValidateResult()
7141 7134

  
b/lib/constants.py
440 440
IALLOCATOR_MODE_ALLOC = "allocate"
441 441
IALLOCATOR_MODE_RELOC = "relocate"
442 442
IALLOCATOR_SEARCH_PATH = _autoconf.IALLOCATOR_SEARCH_PATH
443
IARUN_NOTFOUND = 1
444
IARUN_FAILURE = 2
445
IARUN_SUCCESS = 3
446 443

  
447 444
# Job queue
448 445
JOB_QUEUE_VERSION = 1

Also available in: Unified diff