Пример #1
0
def deploy_plugin(request):
    user = user_from_request(request)
    backend_id = request.matchdict['backend']
    machine_id = request.matchdict['machine']
    plugin_id = request.matchdict['plugin']
    params = params_from_request(request)
    plugin_type = params.get('plugin_type')
    host = params.get('host')
    if plugin_type == 'python':
        ret = methods.deploy_python_plugin(
            user, backend_id, machine_id, plugin_id,
            value_type=params.get('value_type', 'gauge'),
            read_function=params.get('read_function'),
            host=host,
        )
        methods.update_metric(
            user,
            metric_id=ret['metric_id'],
            name=params.get('name'),
            unit=params.get('unit'),
            backend_id=backend_id,
            machine_id=machine_id,
        )
        return ret
    else:
        raise BadRequestError("Invalid plugin_type: '%s'" % plugin_type)
Пример #2
0
def deploy_plugin(request):
    user = user_from_request(request)
    backend_id = request.matchdict['backend']
    machine_id = request.matchdict['machine']
    plugin_id = request.matchdict['plugin']
    params = params_from_request(request)
    plugin_type = params.get('plugin_type')
    host = params.get('host')
    if plugin_type == 'python':
        ret = methods.deploy_python_plugin(
            user, backend_id, machine_id, plugin_id,
            value_type=params.get('value_type', 'gauge'),
            read_function=params.get('read_function'),
            host=host,
        )
        methods.update_metric(
            user,
            metric_id=ret['metric_id'],
            name=params.get('name'),
            unit=params.get('unit'),
            backend_id=backend_id,
            machine_id=machine_id,
        )
        return ret
    else:
        raise BadRequestError("Invalid plugin_type: '%s'" % plugin_type)
Пример #3
0
def update_metric(request):
    user = user_from_request(request)
    metric_id = request.matchdict['metric']
    params = params_from_request(request)
    methods.update_metric(
        user,
        metric_id,
        name=params.get('name'),
        unit=params.get('unit'),
        backend_id=params.get('backend_id'),
        machine_id=params.get('machine_id'),
    )
    return {}
Пример #4
0
def update_metric(request):
    user = user_from_request(request)
    metric_id = request.matchdict['metric']
    params = params_from_request(request)
    methods.update_metric(
        user,
        metric_id,
        name=params.get('name'),
        unit=params.get('unit'),
        backend_id=params.get('backend_id'),
        machine_id=params.get('machine_id'),
    )
    return {}