def get_base_path_from_sensor_id(sensor_id): if sensor_id == 'local': rt, system_id = get_system_id_from_local() if not rt: return False, "Can't retrieve the system id" return True, get_base_path_from_system_id(system_id) rt, system_id = get_system_id_from_sensor_id(sensor_id) if not rt: return False, "Can't retrieve the system id" return True, get_base_path_from_system_id(system_id)
def apimethod_ossec_control(sensor_id, operation, option): (success, system_ip) = get_sensor_ip_from_sensor_id(sensor_id) if not success: return False, "Invalid sensor id %s" % sensor_id (result, ans_result) = ans_ossec_control(system_ip=system_ip, operation=operation, option=option) if result and operation == "restart": # Update status of all HIDS Agents from celerymethods.tasks.hids import update_system_hids_agents try: (success, system_id) = get_system_id_from_sensor_id(sensor_id) if success: update_system_hids_agents.delay(system_id) except Exception as e: api_log.error("[update_system_hids_agents]: {0}".format(e)) return (result, ans_result)