def update_status(args): query_first = """ UPDATE NODE Set status = 'disabled' """ Sql.exec(query=query_first, args={}) for ip in args: query = """ UPDATE NODE SET status = 'running' where ip = '{ip}' """ Sql.exec(query, args={'ip': ip}) return "OK"
def create_task_result(args): query = """ INSERT INTO TaskResult(taskId, data) VALUES({task_id}, '{data}') returning id """ return Sql.exec(query=query, args=args)
def add_cert(args): query = """ INSERT INTO cert (ip, status) VALUES('{ip}', '{status}') returning id """ return Sql.exec(query=query, args=args)
def create_task(args): query = """ INSERT INTO tasks (nodeId, status) VALUES({nodeId}, '{status}') returning id """ return Sql.exec(query=query, args=args)
def insert_node(args): query = """ INSERT INTO Node (ip,status) VALUES('{ip}', 'running') returning id """ return Sql.exec(query=query, args=args)
def get_cert_id(args): query = """ SELECT id FROM cert where data = '{data}' """ return Sql.exec(query=query, args=args)
def get_tasks(args): query = """ SELECT * FROM TaskResult join Tasks t on t.id = TaskResult.taskid """ return Sql.exec(query=query, args=args)
def get_nodes(args): query = """ SELECT id, status FROM Node """ return Sql.exec(query=query, args=args)