aboutsummaryrefslogtreecommitdiffstats
path: root/src/dashboard
diff options
context:
space:
mode:
authorParker Berberian <pberberian@iol.unh.edu>2018-04-13 18:24:29 +0000
committerGerrit Code Review <gerrit@opnfv.org>2018-04-13 18:24:29 +0000
commitab4a06206f40b2b08c353a662805b38ee2a4a2c1 (patch)
treed2b8f10539b1a02360035fa03a10a56d7b09c4d1 /src/dashboard
parent71f34ee19c36ab44ddb8bafcc2044393ecd5667c (diff)
parentc5214f6accee741d64efd29498d813aae9f4068e (diff)
Merge "Gracefully Handle Missing Jenkins Utilization for Dev Pod"
Diffstat (limited to 'src/dashboard')
-rw-r--r--src/dashboard/views.py43
1 files changed, 24 insertions, 19 deletions
diff --git a/src/dashboard/views.py b/src/dashboard/views.py
index 62a9f83..4bab036 100644
--- a/src/dashboard/views.py
+++ b/src/dashboard/views.py
@@ -120,22 +120,27 @@ class JenkinsUtilizationJSON(View):
def get(self, request, *args, **kwargs):
resource = get_object_or_404(Resource, id=kwargs['resource_id'])
weeks = int(kwargs['weeks'])
- utilization = resource.slave.get_utilization(timedelta(weeks=weeks))
- utilization = [
- {
- 'label': 'Offline',
- 'data': utilization['offline'],
- 'color': '#d9534f'
- },
- {
- 'label': 'Online',
- 'data': utilization['online'],
- 'color': '#5cb85c'
- },
- {
- 'label': 'Idle',
- 'data': utilization['idle'],
- 'color': '#5bc0de'
- },
- ]
- return JsonResponse({'data': utilization})
+ try:
+ utilization = resource.slave.get_utilization(timedelta(weeks=weeks))
+ utilization = [
+ {
+ 'label': 'Offline',
+ 'data': utilization['offline'],
+ 'color': '#d9534f'
+ },
+ {
+ 'label': 'Online',
+ 'data': utilization['online'],
+ 'color': '#5cb85c'
+ },
+ {
+ 'label': 'Idle',
+ 'data': utilization['idle'],
+ 'color': '#5bc0de'
+ },
+ ]
+ jutilization = JsonResponse({'data': utilization})
+ except AttributeError:
+ return JsonResponse({'data': ''})
+ if jutilization:
+ return jutilization