yocto-autobuilder-helper/lava/lava_scheduler.py
Aaron Chan bbf23b22b4 trigger-lava-jobs: Add LAVA RPC trigger pipeline script
trigger-lava-jobs accepts the YAML pipeline lava-job config file
generated by run-jinja-parser scripts. This triggers a new job at
LAVA end thru RPC and parses the authentication token and user
credentials to launch/start the hardware automation on LAVA
Dispatcher.Script will exit on error when lava-job return a state
either incomplete or canceling stage.

trigger-lava-jobs uses lava_scheduler.py python module where the
LAVA classes and library constructed from XML-RPC API which are
define and supported by Linaro, LAVA.

Signed-off-by: Aaron Chan <aaron.chun.yew.chan@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-08-30 16:21:51 +01:00

71 lines
2.1 KiB
Python

#!/usr/bin/env python3
'''
author__ = "Aaron Chan"
__copyright__ = "Copyright 2018, Intel Corp"
__credits__" = ["Aaron Chan"]
__license__" = "GPL"
__version__" = "1.0"
__maintainer__ = "Aaron Chan"
__email__ = "aaron.chun.yew.chan@intel.com"
'''
import xmlrpc
class scheduler():
def __init__(self, server, user, token, url):
self.server = server
self.user = user
self.token = token
self.url = url
@classmethod
# Description: Submit the given job data which is in LAVA
# job JSON or YAML format as a new job to
# LAVA scheduler.
# Return: dict <type>
def lava_jobs_submit(self, server, data):
return server.scheduler.jobs.submit(data)
@classmethod
# Description: Cancel the given job referred by its id
# Return: Boolean <type>
def lava_jobs_cancel(self, server, jobid):
state = server.scheduler.jobs.cancel(jobid)
if type(state) is bool: return state
@classmethod
def lava_jobs_resubmit(self, server, jobid):
return server.scheduler.jobs.resubmit(jobid)
@classmethod
# Description: Return the logs for the given job
# Args: jobid <str>, line <int> - Show only after the given line
# Return: tuple <type>
def lava_jobs_logs(self, server, jobid, line):
return server.scheduler.jobs.logs(jobid, line)
@classmethod
# Description: Show job details
# Return: Dict <type>
def lava_jobs_show(self, server, jobid):
return server.scheduler.jobs.show(jobid)
@classmethod
# Description: Return the job definition
# Return: Instance <type>
def lava_jobs_define(self, server, jobid):
return server.scheduler.jobs.definition(jobid)
@classmethod
def lava_jobs_status(self, server, jobid):
return server.scheduler.job_status(jobid)
@classmethod
def lava_jobs_output(self, server, jobid, offset):
return server.scheduler.job_output(jobid, offset)
@classmethod
def lava_jobs_details(self, server, jobid):
return server.scheduler.job_details(jobid)