コード例 #1
0
ファイル: events.py プロジェクト: fiddyspence/panopuppet
def get_report(key, value, request):
    source_url, source_certs, source_verify = get_server(request)
    # If key is any of the below, all is good!
    allowed_keys = [
        'certname', 'resource_title', 'resource_type', 'containing_class'
    ]
    if key in allowed_keys:
        pass
    # If key does not match above the default will be shown
    else:
        key = 'containing_class'

    events_params = {
        'query': {
            'operator':
            'and',
            1:
            '["=","' + key + '","' + value + '"]',
            2:
            '["=","latest_report?",true]',
            3:
            '["in", "certname",["extract", "certname",["select_nodes",["null?","deactivated",true]]]]'
        },
    }
    results = pdb_api_get(
        api_url=source_url,
        cert=source_certs,
        verify=source_verify,
        path='/events',
        api_version='v4',
        params=mk_puppetdb_query(events_params, request),
    )
    return results
コード例 #2
0
ファイル: events.py プロジェクト: jeroenzeegers/panopuppet
def get_report(key, value, request):
    source_url, source_certs, source_verify = get_server(request)
    # If key is any of the below, all is good!
    allowed_keys = ['certname', 'resource_title', 'resource_type', 'containing_class']
    if key in allowed_keys:
        pass
    # If key does not match above the default will be shown
    else:
        key = 'containing_class'

    events_params = {
        'query':
            {
                'operator': 'and',
                1: '["=","' + key + '","' + value + '"]',
                2: '["=","latest_report?",true]',
                3: '["in", "certname",["extract", "certname",["select_nodes",["null?","deactivated",true]]]]'
            },
    }
    results = pdb_api_get(
        api_url=source_url,
        cert=source_certs,
        verify=source_verify,
        path='/events',
        api_version='v4',
        params=mk_puppetdb_query(events_params, request),
    )
    return results
コード例 #3
0
ファイル: filebucket.py プロジェクト: gmodea/panopuppet
 def get_resource(certname, rtype, rtitle):
     data = pdb_api_get(
         api_url=puppetdb_source,
         path='nodes/' + certname + '/resources/' + rtype + '/' + rtitle,
         verify=puppetdb_verify,
         cert=puppetdb_certs)
     if not data:
         return False
     else:
         return data
コード例 #4
0
ファイル: filebucket.py プロジェクト: fiddyspence/panopuppet
 def get_resource(certname, rtype, rtitle):
     resource_params = {
         'query': {
             'operator': 'and',
             1: '["=", "certname", "' + certname + '"]',
             2: '["=", "type", "' + rtype + '"]',
             3: '["=", "title", "' + rtitle + '"]'
         },
     }
     data = pdb_api_get(api_url=puppetdb_source,
                        path='resources',
                        verify=puppetdb_verify,
                        cert=puppetdb_certs,
                        params=mk_puppetdb_query(resource_params, request))
     if not data:
         return False
     else:
         return data
コード例 #5
0
ファイル: events.py プロジェクト: gmodea/panopuppet
def get_events_summary(request, timespan='latest'):
    if timespan == 'latest':
        events_params = {
            'query':
                {
                    1: '["and",["=","latest-report?",true],["in", "certname",["extract", "certname",["select-nodes",["null?","deactivated",true]]]]]'
                },
        }
    source_url, source_certs, source_verify = get_server(request)
    events = pdb_api_get(
        api_url=source_url,
        cert=source_certs,
        verify=source_verify,
        path='events/',
        api_version='v4',
        params=mk_puppetdb_query(events_params))
    summary = summary_of_events(events)
    return summary
コード例 #6
0
ファイル: events.py プロジェクト: fiddyspence/panopuppet
def get_events_summary(request, timespan='latest'):
    if timespan == 'latest':
        events_params = {
            'query': {
                'operator':
                'and',
                1:
                '["=","latest_report?",true]',
                2:
                '["in","certname",["extract","certname",["select_nodes",["null?","deactivated",true]]]]',
            },
        }
    source_url, source_certs, source_verify = get_server(request)
    events = pdb_api_get(api_url=source_url,
                         cert=source_certs,
                         verify=source_verify,
                         path='/events',
                         api_version='v4',
                         params=mk_puppetdb_query(events_params, request))
    summary = summary_of_events(events)
    return summary
コード例 #7
0
ファイル: filebucket.py プロジェクト: fiddyspence/panopuppet
    def get_resource(certname, rtype, rtitle):
        resource_params = {
            'query':
                {
                    'operator': 'and',
                    1: '["=", "certname", "' + certname + '"]',
                    2: '["=", "type", "' + rtype + '"]',
                    3: '["=", "title", "' + rtitle + '"]'

                },
        }
        data = pdb_api_get(
            api_url=puppetdb_source,
            path='resources',
            verify=puppetdb_verify,
            cert=puppetdb_certs,
            params=mk_puppetdb_query(resource_params, request))
        if not data:
            return False
        else:
            return data
コード例 #8
0
ファイル: events.py プロジェクト: ap-16/panopuppet
def get_events_summary(request, timespan='latest', environment=None):
    events_params = {
        'query':
            {
                'operator': 'and',
                2: '["in","certname",["extract","certname",["select_nodes",["null?","deactivated",true]]]]',
            },
    }
    if timespan == 'latest':
        events_params['query'][1] = '["=","latest_report?",true]'
    elif len(timespan) == 2:
        events_params['query'][1] = '["and",[">","timestamp","' + timespan[0] + '"],["<", "timestamp", "' + timespan[
            1] + '"]]'

    source_url, source_certs, source_verify = get_server(request)
    events = pdb_api_get(
        api_url=source_url,
        cert=source_certs,
        verify=source_verify,
        path='/events',
        api_version='v4',
        params=mk_puppetdb_query(events_params, request))
    summary = summary_of_events(events)
    return summary