diff options
author | Dan Rue <dan.rue@linaro.org> | 2019-06-18 15:06:34 -0500 |
---|---|---|
committer | Guillaume Tucker <guillaume.tucker@collabora.com> | 2019-06-28 09:43:22 +0100 |
commit | b530d9184b144d417b95966fb70b930ee291a0c6 (patch) | |
tree | 3d7841f132ccc6761de9c886ad914961b67045ab /lava-v2-submit-jobs.py | |
parent | c2df3b67eed0a1a020f49276bd427b70080a1407 (diff) |
Find LAVA devices by aliases, when available
In addition to looking up available device_types in each lava instance,
also look for aliases.
Create a new lookup function, get_device_type_by_name(), to simplify the
lookup. Provide 6 unit tests for the new function.
Example run:
./lava-v2-submit-jobs.py --username dan.rue --token='XXX' --lab lab-linaro-lkft --jobs foo
Loading jobs from foo
LAVA API: https://lkft.validation.linaro.org/RPC2/
Connecting to Server...
Connection Successful!
connect-to-server : pass
Fetching all devices from LAVA
Fetching all device-types from LAVA
Fetching all device-type aliases from LAVA
Submitting Jobs to Server...
Submitting job kernelci-staging.kernelci.org-v5.2-rc5-178-gdac6ebf0e111-arm-multi_v7_defconfig-gcc-8-no-dtb-qemu-boot to device-type qemu
Submitting job arm-soc-for-next-v5.2-rc5-110-ge57f4f2c4506-arm-multi_v7_defconfig-gcc-8-am57xx-beagle-x15.dtb-am57xx-beagle-x15-simple to device-type am57xx-beagle-x15
Submitting job lkft-ltp-quickhit-master-1894 to device-type x15
Signed-off-by: Dan Rue <dan.rue@linaro.org>
Diffstat (limited to 'lava-v2-submit-jobs.py')
-rwxr-xr-x | lava-v2-submit-jobs.py | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/lava-v2-submit-jobs.py b/lava-v2-submit-jobs.py index e013e8e..6269579 100755 --- a/lava-v2-submit-jobs.py +++ b/lava-v2-submit-jobs.py @@ -36,6 +36,7 @@ import configparser from lib import utils from lib import configuration +from kernelci import lava DEVICE_ONLINE_STATUS = ['idle', 'running', 'reserved'] JOBS = {} @@ -46,6 +47,14 @@ def submit_jobs(connection): all_devices = connection.scheduler.all_devices() print "Fetching all device-types from LAVA" all_device_types = connection.scheduler.all_device_types() + print "Fetching all device-type aliases from LAVA" + all_aliases = [] + try: + for alias in connection.scheduler.aliases.list(): + all_aliases.append(connection.scheduler.aliases.show(alias)) + except (xmlrpclib.ProtocolError, xmlrpclib.Fault, IOError, ValueError) as e: + print("Unable to retrieve device_type aliases from LAVA; continuing") + print(e) result = True @@ -57,14 +66,14 @@ def submit_jobs(connection): job_info = yaml.safe_load(job_data) # Check if request device(s) are available if 'device_type' in job_info: - for device_type in all_device_types: - if device_type['name'] == job_info['device_type']: - if device_type_has_available(device_type, all_devices): - print "Submitting job %s to device-type %s" % (job_info.get('job_name', 'unknown'), job_info['device_type']) - job_id = connection.scheduler.submit_job(job_data) - SUBMITTED[job] = job_id - else: - print "Found device-type %s on server, but it had no available pipeline devices" % device_type['name'] + device_type = lava.get_device_type_by_name(job_info['device_type'], all_device_types, all_aliases) + if device_type: + if device_type_has_available(device_type, all_devices): + print "Submitting job %s to device-type %s" % (job_info.get('job_name', 'unknown'), job_info['device_type']) + job_id = connection.scheduler.submit_job(job_data) + SUBMITTED[job] = job_id + else: + print "Found device-type %s on server, but it had no available pipeline devices" % device_type['name'] elif 'device_group' in job_info: print "Multinode Job Detected! Not supported yet :(" elif 'vm_group' in job_info: |