def report_status(client_id): client = Client.load(id=client_id) if client: client.last_report_time = datetime.now() logging.info(client.last_report_time) client.status = 1 client.persist()
def get_command(client_id): client = Client.load(id=client_id) if client and client.command: command = client.command client.command = "" client.last_command = command client.persist() return json.loads(command)
def register(ip, client_name, server_ids): client = Client.load(client_name=client_name, ip=ip) if client: client.server_ids = server_ids client.last_report_time = datetime.now() client.persist() return client.id else: client = Client() client.client_name = client_name client.ip = ip client.last_report_time = datetime.now() client.server_ids = server_ids client.persist() return client.id
def add_command(client_ids, command): client_id_list = client_ids.split(",") command_type = int(command["command_type"]) command["command_type"] = command_type command_json = json.dumps(command) for client_id in client_id_list: logging.debug("client_id[%s], command[%s]" % (client_id, command)) client = Client.load(id=client_id) if client: client.command = command_json client.persist()
def report_result(client_id, data): client = Client.load(id=client_id) logging.debug("report_result, client_id[%s], data[%s]" % (client_id, data)) if client: client.last_command_report = json.dumps(data) client.persist()
def get_client_list(): return Client.query()