Slight change to SpecialTask scheduling code. This is to support my work on a new AFE interface.
Signed-off-by: Steve Howard <[email protected]> --- autotest/frontend/afe/models.py 2010-01-12 13:48:30.000000000 -0800 +++ autotest/frontend/afe/models.py 2010-01-13 19:56:55.000000000 -0800 @@ -1030,17 +1030,20 @@ @classmethod - def schedule_special_task(cls, hosts, task): + def schedule_special_task(cls, host, task): """ - Schedules hosts for a special task, if the task is not already scheduled + Schedules a special task on a host if the task is not already scheduled. """ - for host in hosts: - if not SpecialTask.objects.filter(host__id=host.id, task=task, - is_active=False, - is_complete=False): - special_task = SpecialTask(host=host, task=task, - requested_by=thread_local.get_user()) - special_task.save() + existing_tasks = SpecialTask.objects.filter(host__id=host.id, task=task, + is_active=False, + is_complete=False) + if existing_tasks: + return existing_tasks[0] + + special_task = SpecialTask(host=host, task=task, + requested_by=User.current_user()) + special_task.save() + return special_task def activate(self): --- autotest/frontend/afe/rpc_interface.py 2010-01-12 13:48:30.000000000 -0800 +++ autotest/frontend/afe/rpc_interface.py 2010-01-13 19:56:55.000000000 -0800 @@ -564,8 +564,9 @@ """ hosts = models.Host.query_objects(filter_data) models.AclGroup.check_for_acl_violation_hosts(hosts) - models.SpecialTask.schedule_special_task(hosts, - models.SpecialTask.Task.VERIFY) + for host in hosts: + models.SpecialTask.schedule_special_task(host, + models.SpecialTask.Task.VERIFY) return list(sorted(host.hostname for host in hosts)) _______________________________________________ Autotest mailing list [email protected] http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
