Merge lp:~stylesen/lava-scheduler/multinode into lp:lava-scheduler/multinode

Proposed by Senthil Kumaran S
Status: Merged
Approved by: Neil Williams
Approved revision: no longer in the source branch.
Merged at revision: 255
Proposed branch: lp:~stylesen/lava-scheduler/multinode
Merge into: lp:lava-scheduler/multinode
Diff against target: 74 lines (+42/-0)
2 files modified
lava_scheduler_app/api.py (+15/-0)
lava_scheduler_app/utils.py (+27/-0)
To merge this branch: bzr merge lp:~stylesen/lava-scheduler/multinode
Reviewer Review Type Date Requested Status
Linaro Automation & Validation Pending
Review via email: mp+171829@code.launchpad.net

Description of the change

Catch device availability during multinode job submission.

To post a comment you must log in.
255. By Neil Williams

Senthil Kumaran 2013-06-27 Detect device availability during job submission for multinode jobs.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lava_scheduler_app/api.py'
--- lava_scheduler_app/api.py 2013-06-20 11:41:39 +0000
+++ lava_scheduler_app/api.py 2013-06-27 14:57:48 +0000
@@ -2,6 +2,7 @@
2from simplejson import JSONDecodeError2from simplejson import JSONDecodeError
3from django.db.models import Count3from django.db.models import Count
4from linaro_django_xmlrpc.models import ExposedAPI4from linaro_django_xmlrpc.models import ExposedAPI
5from lava_scheduler_app import utils
5from lava_scheduler_app.models import (6from lava_scheduler_app.models import (
6 Device,7 Device,
7 DeviceType,8 DeviceType,
@@ -27,6 +28,20 @@
27 "'lava_scheduler_app.add_testjob' permission. Contact "28 "'lava_scheduler_app.add_testjob' permission. Contact "
28 "the administrators." % self.user.username)29 "the administrators." % self.user.username)
29 try:30 try:
31 requested_devices = utils.requested_device_count(job_data)
32 if requested_devices:
33 all_devices = {}
34 for d in self.all_device_types():
35 all_devices[d['name']] = d['idle'] + d['busy']
36
37 for board, count in requested_devices.iteritems():
38 if all_devices.get(board, None) and \
39 count <= all_devices[board]:
40 continue
41 else:
42 raise xmlrpclib.Fault(
43 400, "Required number of device(s) unavailable.")
44
30 job = TestJob.from_json_and_user(job_data, self.user)45 job = TestJob.from_json_and_user(job_data, self.user)
31 except JSONDecodeError as e:46 except JSONDecodeError as e:
32 raise xmlrpclib.Fault(400, "Decoding JSON failed: %s." % e)47 raise xmlrpclib.Fault(400, "Decoding JSON failed: %s." % e)
3348
=== modified file 'lava_scheduler_app/utils.py'
--- lava_scheduler_app/utils.py 2013-06-27 12:17:42 +0000
+++ lava_scheduler_app/utils.py 2013-06-27 14:57:48 +0000
@@ -18,6 +18,7 @@
18# along with LAVA Scheduler. If not, see <http://www.gnu.org/licenses/>.18# along with LAVA Scheduler. If not, see <http://www.gnu.org/licenses/>.
1919
20import copy20import copy
21import simplejson
2122
2223
23def split_multi_job(json_jobdata, target_group):24def split_multi_job(json_jobdata, target_group):
@@ -70,3 +71,29 @@
70 return node_json71 return node_json
7172
72 return 073 return 0
74
75
76def requested_device_count(json_data):
77 """Utility function check the requested number of devices for each
78 device_type in a multinode job.
79
80 JSON_DATA is the job definition string.
81
82 Returns requested_device which is a dictionary of the following format:
83
84 {'kvm': 1, 'qemu': 3, 'panda': 1}
85
86 If the job is not a multinode job, then return None.
87 """
88 job_data = simplejson.loads(json_data)
89 if 'device_group' in job_data:
90 requested_devices = {}
91 for device_group in job_data['device_group']:
92 device_type = device_group['device_type']
93 count = device_group['count']
94 requested_devices[device_type] = count
95 return requested_devices
96 else:
97 # TODO: Put logic to check whether we have requested devices attached
98 # to this lava-server, even if it is a single node job?
99 return None

Subscribers

People subscribed via source and target branches

to status/vote changes: