#NEWLINE# @ app . route ( '/node/<node_name>' , defaults = { #NEWLINE# #INDENT# 'env' : app . config [ 'DEFAULT_ENVIRONMENT' ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# @ app . route ( '/<env>/node/<node_name>' ) #NEWLINE# def node( env , node_name ) : #NEWLINE# #INDENT# 'Display a dashboard for a node showing as much data as we have on that\n    node. This includes facts and reports but not Resources as that is too\n    heavy to do within a single request.\n\n    :param env: Ensure that the node, facts and reports are in this environment\n    :type env: :obj:`string`\n    ' #NEWLINE# envs = environments ( ) #NEWLINE# check_env ( env , envs ) #NEWLINE# if ( env == '*' ) : #NEWLINE# #INDENT# query = '["=", "certname", "{0}"]]' . format ( node_name ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# query = ( '["and", ["=", "environment", "{0}"],["=", "certname", "{1}"]]' . format ( env , node_name ) , ) #NEWLINE# #UNINDENT# node = get_or_abort ( puppetdb . node , node_name ) #NEWLINE# facts = node . facts ( ) #NEWLINE# reports = get_or_abort ( puppetdb . reports , query = query , limit = app . config [ 'REPORTS_COUNT' ] , order_by = '[{"field": "start_time", "order": "desc"}]' ) #NEWLINE# ( reports , reports_events ) = tee ( reports ) #NEWLINE# report_event_counts = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for report in reports_events : #NEWLINE# #INDENT# counts = get_or_abort ( puppetdb . event_counts , query = '["and", ["=", "environment", "{0}"],["=", "certname", "{1}"], ["=", "report", "{2}"]]' . format ( env , node_name , report . hash_ ) , summarize_by = 'certname' ) #NEWLINE# try : #NEWLINE# #INDENT# report_event_counts [ report . hash_ ] = counts [ 0 ] #NEWLINE# #UNINDENT# except IndexError : #NEWLINE# #INDENT# report_event_counts [ report . hash_ ] = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# #UNINDENT# return render_template ( 'node.html' , node = node , facts = yield_or_stop ( facts ) , reports = yield_or_stop ( reports ) , reports_count = app . config [ 'REPORTS_COUNT' ] , report_event_counts = report_event_counts , envs = envs , current_env = env )