Commit 6dddb7c2 authored by Luis Araujo's avatar Luis Araujo

Add --live option to submit command

This option allows to submit a job and shows its live output
once it starts running.

This option can't be used together with the --wait option or
if more than one job is submitted.

Reviewed By: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
Differential Revision: https://phabricator.collabora.com/D1252Signed-off-by: Luis Araujo's avatarLuis Araujo <luis.araujo@collabora.co.uk>
parent fe286a57
......@@ -75,6 +75,8 @@ class Cli(object):
submit_parser.add_argument('--priority',
choices=['high', 'medium', 'low'],
help="Set the job priority"),
submit_parser.add_argument('--live', action='store_true',
help="show job output live")
submit_parser.add_argument('--check-image-url', action='store_true',
help="Check that the image url exists before "
"submitting job")
......
......@@ -32,6 +32,7 @@ from jinja2 import Environment, FileSystemLoader, \
from lqa_api.exit_codes import APPLICATION_ERROR
from lqa_api.job import Job
from lqa_api.waitqueue import WaitQueue
from lqa_api.outputlog import OutputLog, OutputLogError
from lqa_tool.settings import lqa_logger
from lqa_tool.utils import merge_profiles
from lqa_tool.commands import Command
......@@ -215,6 +216,23 @@ class SubmitCmd(Command):
lqa_logger.info("Submitted job {} with id {}" \
.format(job_file, job_id))
# Show live output if '--live' option passed
if self.args.live:
if len(job_files) > 1:
lqa_logger.info("lqa submit: --live option is not valid "
"with more than 1 file (skipping)")
elif self.args.wait_timeout:
lqa_logger.info("lqa submit: --live option can't be used "
"together with --wait option (skipping)")
else:
# Everything is valid to use live option, then go for it!
try:
OutputLog(job_id, self.server, is_live=True,
logger=lqa_logger).run()
except OutputLogError as e:
lqa_logger.error("lqa submit: error: {}".format(e))
exit(APPLICATION_ERROR)
def _check_image_url(self, json_job_obj):
"""This method checks for the existence of the image field url path
for all the 'deploy_image' actions (if available)"""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment