Exemplo n.º 1
0
def task_kill(lassod, *ids):
    """Kill task by id number."""
    db = Session()
    output = list()
    tasks = db.query(Task).filter(Task.id.in_(ids)).all()
    for task in tasks:
        if task.running:
            cattle = db.query(Cattle).filter(Cattle.id==task.running).first()
            client = CattleClient(cattle.hostname)
            client.kill_task(task.id)
            output.append(True)
        else:
            output.append(False)
    db.close()
    return output
Exemplo n.º 2
0
 def kill_hook(task):
     self.info("Stopped task %d." % task.id)
     self.queue.remove(task.id)
     if task.status == task.RUNNING:
         cattle_id = task.running
         cattle = db.query(Cattle).filter(Cattle.id==cattle_id).first()
         client = CattleClient(cattle.hostname)
         if client.kill_task(task.id):
             output.append(task.id)
             print task.id, 'has been killed.'