Skip to content
This repository has been archived by the owner on Dec 15, 2021. It is now read-only.

Commit

Permalink
Fix bug where unreported is always 2 hours
Browse files Browse the repository at this point in the history
A bug was found where the code did not properly
declare the puppet run time interval specified
for the selected puppetdb instance.
Fixes issue #136
  • Loading branch information
propyless committed May 2, 2016
1 parent 0094e94 commit ca1d67d
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 34 deletions.
2 changes: 1 addition & 1 deletion panopuppet/pano/methods/dictfuncs.py
Expand Up @@ -140,7 +140,7 @@ def append_list(n_data, s_data, m_list, r_status):
node_is_unreported = False
node_has_mismatching_timestamps = False
# Check if its unreported.
if is_unreported(node['report_timestamp']):
if is_unreported(node_report_timestamp=node['report_timestamp'], unreported=puppet_run_time):
node_is_unreported = True
if check_failed_compile(report_timestamp=node.get('report_timestamp', None),
fact_timestamp=node.get('facts_timestamp', None),
Expand Down
62 changes: 37 additions & 25 deletions panopuppet/pano/views/api/dashboard_data.py
Expand Up @@ -105,13 +105,14 @@ def dashboard_status_json(request):
reports_list = puppetdb_results['reports']
reports_dict = {item['certname']: item for item in reports_list}

failed_list, changed_list, unreported_list, mismatch_list, pending_list = dictstatus(all_nodes_list,
reports_dict,
event_dict,
sort=True,
sortby='latestReport',
get_status='notall',
puppet_run_time=puppet_run_time)
failed_list, changed_list, unreported_list, mismatch_list, pending_list = dictstatus(
all_nodes_list,
reports_dict,
event_dict,
sort=True,
sortby='latestReport',
get_status='notall',
puppet_run_time=puppet_run_time)

pending_list = [x for x in pending_list if x not in unreported_list]
changed_list = [x for x in changed_list if
Expand Down Expand Up @@ -239,13 +240,15 @@ def dashboard_nodes_json(request):
# 25 Nodes
node_list = puppetdb_results['nodes']

failed_list, changed_list, unreported_list, mismatch_list, pending_list = dictstatus(all_nodes_list,
reports_dict,
event_dict,
sort=True,
sortby='latestReport',
get_status='notall',
puppet_run_time=puppet_run_time)
failed_list, changed_list, unreported_list, mismatch_list, pending_list = dictstatus(
all_nodes_list,
reports_dict,
event_dict,
sort=True,
sortby='latestReport',
get_status='notall',
puppet_run_time=puppet_run_time)

pending_list = [x for x in pending_list if x not in unreported_list]
changed_list = [x for x in changed_list if
x not in unreported_list and x not in failed_list and x not in pending_list]
Expand Down Expand Up @@ -390,13 +393,14 @@ def dashboard_json(request):
# 25 Nodes
node_list = puppetdb_results['nodes']

failed_list, changed_list, unreported_list, mismatch_list, pending_list = dictstatus(all_nodes_list,
reports_dict,
event_dict,
sort=True,
sortby='latestReport',
get_status='notall',
puppet_run_time=puppet_run_time)
failed_list, changed_list, unreported_list, mismatch_list, pending_list = dictstatus(
all_nodes_list,
reports_dict,
event_dict,
sort=True,
sortby='latestReport',
get_status='notall',
puppet_run_time=puppet_run_time)

pending_list = [x for x in pending_list if x not in unreported_list]
changed_list = [x for x in changed_list if
Expand All @@ -411,8 +415,12 @@ def dashboard_json(request):
node_pending_count = len(pending_list)

if dashboard_show == 'recent':
merged_nodes_list = dictstatus(
node_list, reports_dict, event_dict, sort=False, get_status="all", puppet_run_time=puppet_run_time)
merged_nodes_list = dictstatus(node_list,
reports_dict,
event_dict,
sort=False,
get_status="all",
puppet_run_time=puppet_run_time)
elif dashboard_show == 'failed':
merged_nodes_list = failed_list
elif dashboard_show == 'unreported':
Expand All @@ -424,8 +432,12 @@ def dashboard_json(request):
elif dashboard_show == 'pending':
merged_nodes_list = pending_list
else:
merged_nodes_list = dictstatus(
node_list, reports_dict, event_dict, sort=False, get_status="all", puppet_run_time=puppet_run_time)
merged_nodes_list = dictstatus(node_list,
reports_dict,
event_dict,
sort=False,
get_status="all",
puppet_run_time=puppet_run_time)

context['node_list'] = merged_nodes_list
context['selected_view'] = dashboard_show
Expand Down
24 changes: 16 additions & 8 deletions panopuppet/pano/views/api/node_data.py
Expand Up @@ -28,6 +28,7 @@ def nodes_json(request):
return redirect(request.POST['return_url'])

source_url, source_certs, source_verify = get_server(request)
puppet_run_time = get_server(request, type='run_time')
valid_sort_fields = (
'certname',
'catalog_timestamp',
Expand Down Expand Up @@ -259,12 +260,22 @@ def nodes_json(request):
status_dict = {item['certname']: item for item in report_status_list}
report_dict = {item['subject']['title']: item for item in report_list}
if sort_field_order == 'desc':
rows = dictstatus(
node_list, status_dict, report_dict, sortby=sort_field, asc=True, sort=False)
rows = dictstatus(node_list,
status_dict,
report_dict,
sortby=sort_field,
asc=True,
sort=False,
puppet_run_time=puppet_run_time)
sort_field_order_opposite = 'asc'
elif sort_field_order == 'asc':
rows = dictstatus(
node_list, status_dict, report_dict, sortby=sort_field, asc=False, sort=False)
rows = dictstatus(node_list,
status_dict,
report_dict,
sortby=sort_field,
asc=False,
sort=False,
puppet_run_time=puppet_run_time)
sort_field_order_opposite = 'desc'

if dl_csv is True:
Expand Down Expand Up @@ -383,7 +394,7 @@ def search_nodes_json(request):
'order': 'desc',
},
},
#'limit': 25,
# 'limit': 25,
}
nodes_list = puppetdb.api_get(
api_url=source_url,
Expand All @@ -395,6 +406,3 @@ def search_nodes_json(request):
nodes_params, request),
)
return HttpResponse(json.dumps(nodes_list, indent=2), content_type="application/json")



0 comments on commit ca1d67d

Please sign in to comment.