diff --git a/lib/backend.py b/lib/backend.py index eaf559b8fc70880081ccb853bf4fdbe1963fd52e..3635d49fd832f9fda2c590e2ea79ccdaa74d94d2 100644 --- a/lib/backend.py +++ b/lib/backend.py @@ -2605,17 +2605,15 @@ class IAllocatorRunner(object): @param idata: the allocator input data @rtype: tuple - @return: four element tuple of: - - run status (one of the IARUN_ constants) - - stdout - - stderr - - fail reason (as from L{utils.RunResult}) + @return: two element tuple of: + - status + - either error message or stdout of allocator (for success) """ alloc_script = utils.FindFile(name, constants.IALLOCATOR_SEARCH_PATH, os.path.isfile) if alloc_script is None: - return (constants.IARUN_NOTFOUND, None, None, None) + _Fail("iallocator module '%s' not found in the search path", name) fd, fin_name = tempfile.mkstemp(prefix="ganeti-iallocator.") try: @@ -2623,12 +2621,12 @@ class IAllocatorRunner(object): os.close(fd) result = utils.RunCmd([alloc_script, fin_name]) if result.failed: - return (constants.IARUN_FAILURE, result.stdout, result.stderr, - result.fail_reason) + _Fail("iallocator module '%s' failed: %s, output '%s'", + name, result.fail_reason, result.output) finally: os.unlink(fin_name) - return (constants.IARUN_SUCCESS, result.stdout, result.stderr, None) + return True, result.stdout class DevCacheManager(object): diff --git a/lib/cmdlib.py b/lib/cmdlib.py index d2eb0fdde976d69468820ff40ea71137beb813c3..a96087ec89c13b77038999629e804bdec63e6ca4 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -7123,19 +7123,12 @@ class IAllocator(object): data = self.in_text result = call_fn(self.lu.cfg.GetMasterNode(), name, self.in_text) - result.Raise() - - if not isinstance(result.data, (list, tuple)) or len(result.data) != 4: - raise errors.OpExecError("Invalid result from master iallocator runner") - - rcode, stdout, stderr, fail = result.data + msg = result.RemoteFailMsg() + if msg: + raise errors.OpExecError("Failure while running the iallocator" + " script: %s" % msg) - if rcode == constants.IARUN_NOTFOUND: - raise errors.OpExecError("Can't find allocator '%s'" % name) - elif rcode == constants.IARUN_FAILURE: - raise errors.OpExecError("Instance allocator call failed: %s," - " output: %s" % (fail, stdout+stderr)) - self.out_text = stdout + self.out_text = result.payload if validate: self._ValidateResult() diff --git a/lib/constants.py b/lib/constants.py index 260b509ef5ba0adec7c58ba87cf476b3caea8bf7..9fb44ea5ec40363b68602dbfe7c24f70ca0bde6b 100644 --- a/lib/constants.py +++ b/lib/constants.py @@ -440,9 +440,6 @@ IALLOCATOR_DIR_OUT = "out" IALLOCATOR_MODE_ALLOC = "allocate" IALLOCATOR_MODE_RELOC = "relocate" IALLOCATOR_SEARCH_PATH = _autoconf.IALLOCATOR_SEARCH_PATH -IARUN_NOTFOUND = 1 -IARUN_FAILURE = 2 -IARUN_SUCCESS = 3 # Job queue JOB_QUEUE_VERSION = 1