only claim vmExec tasks if the requested VM is available on the current host

This commit is contained in:
Mike Bonnet 2010-07-30 13:31:06 -04:00
parent 123f007e51
commit 63f0d357a3

View file

@ -781,6 +781,22 @@ class VMTaskManager(TaskManager):
"""See if we have enough space to accept another job"""
return self.checkDisk() and self.checkMem()
def takeTask(self, task):
"""
Verify that this builder can handle the task before claiming it.
"""
if task['method'] == 'vmExec':
task_info = self.session.getTaskInfo(task['id'], request=True)
vm_name = task_info['request'][0]
try:
vm = self.libvirt_conn.lookupByName(vm_name)
except libvirt.libvirtError:
# if this builder does not have the requested VM,
# we can't handle the task
self.logger.debug('VM %s not available, ignoring task %i', vm_name, task['id'])
return False
return super(VMTaskManager, self).takeTask(task)
def cleanupVM(self, vm_name):
"""
Cleanup a single VM with the given name.