diff options
author | Stevan Radakovic <stevan.radakovic@linaro.org> | 2018-02-08 14:52:29 +0100 |
---|---|---|
committer | Stevan Radakovic <stevan.radakovic@linaro.org> | 2018-02-08 14:55:21 +0100 |
commit | e4de3220859df10124d0c0a89a3db99ce98fc614 (patch) | |
tree | e2a350ecde69191c93cbf3dc9e5958f1032dae10 | |
parent | 77c90b9078e5ad408e212e5ef80d7305f4ddbf45 (diff) |
LAVA-1223 - lava-tool: check remote api for wait-job-events
wait-job-events needs to cope with the older API automatically
by restoring the previous behaviour depending on the system.api
reported.
Change-Id: I87e4a0030bdbf50bad03745772ec9b778b338151
-rw-r--r-- | lava_scheduler_tool/commands.py | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/lava_scheduler_tool/commands.py b/lava_scheduler_tool/commands.py index 915021e..1a927cb 100644 --- a/lava_scheduler_tool/commands.py +++ b/lava_scheduler_tool/commands.py @@ -163,7 +163,7 @@ class submit_job(Command): # pylint: disable=invalid-name if self.args.block: print('') - print('This kind of polling is deprecated and will be removed in the next release. Please use "wait-for-job" command.') + print('This kind of polling is deprecated and will be removed in the next release. Please use "wait-job-events" command.') print('') print('Waiting for the job to run ') print('. = job waiting in the queue') @@ -696,8 +696,10 @@ class wait_job_events(Command): # pylint: disable=invalid-name Wait for job to finish and return job details. """ - FINISHED_JOB_STATE = "Finished" + FINISHED_JOB_STATE = ["Finished"] + FINISHED_JOB_STATUS = ["Complete", "Incomplete", "Canceled"] EVENT_SOCKET_PATTERN_SYMBOL = "*" + API_UPDATE_VERSION = "2018.1" def reparse_arguments(self, parser, raw_args): pass @@ -742,12 +744,20 @@ class wait_job_events(Command): # pylint: disable=invalid-name host = get_server_url(auth_backend, self.args.SERVER) hostname = urlparse.urlparse(host).hostname + # Support both old and new API versions. + if server.system.version().split("+")[0] >= self.API_UPDATE_VERSION: + state_key = "state" + relevant_finished_states = self.FINISHED_JOB_STATE + else: + state_key = "status" + relevant_finished_states = self.FINISHED_JOB_STATUS + if self.args.job_id: job_ids = [self.args.job_id] try: job = server.scheduler.job_details(self.args.job_id) - if job["state"] == self.FINISHED_JOB_STATE: + if job[state_key] in relevant_finished_states: print("Job %s already finished with state %s." % ( self.args.job_id, job["health"])) return @@ -817,7 +827,7 @@ class wait_job_events(Command): # pylint: disable=invalid-name if data["job"] in job_ids: data["job"] = urlparse.urljoin( job_url_template, str(data["job"])) - if data["state"] == self.FINISHED_JOB_STATE: + if data[state_key] in relevant_finished_states: print(data) break elif not self.args.quiet: |