예제 #1
0
파일: Job.py 프로젝트: omaciel/lnst
def get_job_class(what):
    if what["type"] == "shell":
        return ShellExecJob(what)
    elif what["type"] == "module":
        return ModuleJob(what)
    else:
        logging.error("Unknown job type \"%s\"" % what["type"])
        raise JobError("Unknown command type \"%s\"" % what["type"])
예제 #2
0
 def _to_dict(self):
     d = {"job_id": self._id, "type": self.type, "json": self._json}
     if self.type == "shell":
         d["command"] = self._what
     elif self.type == "module":
         d["module"] = self._what
     else:
         raise JobError("Unknown Job type %s" % self.type)
     return d
예제 #3
0
    def __init__(self, namespace, what,
                 expect=True, json=False, desc=None,
                 level=ResultLevel.DEBUG):
        self._what = what
        self._expect = expect
        self._json = json
        self._netns = namespace
        self._desc = desc
        self._level = level

        self._res = None

        if self.type == "unknown":
            raise JobError("Unable to run '%s'" % str(what))

        self._id = None
예제 #4
0
파일: Job.py 프로젝트: jbenc/lnst
    def wait(self, timeout=0):
        """waits for the Job to finish for the specified amount of time

        Args:
            timeout -- integer value indicating how long to wait for.
                Default is 0, means wait forever. Don't use for infinitelly
                running Jobs.
                If non-zero LNST uses a timed SIGALARM signal to return from
                this method.
        Returns:
            True if the Job finished, False if the Job is still running and
            the wait method just timed out.
        """
        if self.finished:
            return True
        if timeout < 0:
            raise JobError("Negative timeout value not allowed.")
        return self._host.wait_for_job(self, timeout)
예제 #5
0
파일: Job.py 프로젝트: jbenc/lnst
    def __init__(self,
                 host,
                 what,
                 expect=True,
                 json=False,
                 netns=None,
                 desc=None):
        self._host = host
        self._what = what
        self._expect = expect
        self._json = json
        self._netns = netns
        self._desc = desc

        self._res = None

        if isinstance(what, BaseTestModule):
            self._type = "module"
        elif type(what) == str:
            self._type = "shell"
        else:
            raise JobError("Unable to run '%s'" % str(what))

        self._id = None
예제 #6
0
파일: Job.py 프로젝트: omaciel/lnst
 def run(self):
     raise JobError("Method run must be defined.")