Example #1
0
def get_sensor_detector_by_device(sensor_id):
    """
    Return the [sensor]/plugin list for a given sensor
    :param sensor_id: The sensor which we want to get the data
    :param device_id: Filter by device (canonical uuid)
    """
    (success, sensor_ip) = get_sensor_ip_from_sensor_id(sensor_id)
    if not success:
        current_app.logger.error(
            "detector: get_sensor_detector: Bad 'sensor_id'")
        return make_bad_request("Bad sensor_id")

    device_id = request.args.get('device_id', None)

    # Now call the ansible module to obtain the [sensor]/iface
    (success, data) = get_sensor_detectors_from_yaml(sensor_ip)
    if not success:
        current_app.logger.error(
            "detector: get_sensor_detector_by_device: %s" % str(data))
        return make_error("Error getting sensor plugins", 500)
    try:
        yaml_data = get_plugin_get_request_from_yml(
            data['contacted'][sensor_ip]['plugins'], device_id)
    except:
        return make_error(
            "Something wrong while parsing the yml file. %s" % data, 500)
    # Now format the list by a dict which key is the sensor_id and the value if the list of ifaces
    return make_ok(plugins=yaml_data)
Example #2
0
def get_sensor_detector_by_device(sensor_id):
    """
    Return the [sensor]/plugin list for a given sensor
    :param sensor_id: The sensor which we want to get the data
    :param device_id: Filter by device (canonical uuid)
    """
    (success, sensor_ip) = get_sensor_ip_from_sensor_id(sensor_id)
    if not success:
        current_app.logger.error("detector: get_sensor_detector: Bad 'sensor_id'")
        return make_bad_request("Bad sensor_id")

    device_id = request.args.get('device_id', None)

    # Now call the ansible module to obtain the [sensor]/iface
    (success, data) = get_sensor_detectors_from_yaml(sensor_ip)
    if not success:
        current_app.logger.error("detector: get_sensor_detector_by_device: %s" % str(data))
        return make_error("Error getting sensor plugins", 500)
    try:
        yaml_data = get_plugin_get_request_from_yml(data['contacted'][sensor_ip]['plugins'], device_id)
    except:
        return make_error("Something wrong while parsing the yml file. %s" % data, 500)
    # Now format the list by a dict which key is the sensor_id and the value if the list of ifaces
    return make_ok(plugins=yaml_data)
Example #3
0
def get_plugins_from_yaml(sensor_id, no_cache=False):
    (rt, admin_ip) = get_sensor_ip_from_sensor_id(sensor_id)
    if not rt:
        return False, "Can't retrieve the system id"
    return get_sensor_detectors_from_yaml(admin_ip)
Example #4
0
def get_plugins_from_yaml(sensor_id, no_cache=False):
    (rt, admin_ip) = get_sensor_ip_from_sensor_id(sensor_id)
    if not rt:
        return False, "Can't retrieve the system id"
    return get_sensor_detectors_from_yaml(admin_ip)