From 999012f5cb475cc2468dd4d4195e8b34b6f917f1 Mon Sep 17 00:00:00 2001 From: Priyanka Agrawal Date: Tue, 27 May 2014 12:31:03 +0530 Subject: [PATCH] Added try catch for request_id null When the request_id is null, there was an exception generated. Currently setting the deployment to None for the reports in case the request_id is null Change-Id: Idde2178d217ac16f1b3e275c730e3fce68ba9f1b --- reports/nova_usage_audit.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/reports/nova_usage_audit.py b/reports/nova_usage_audit.py index dd58049..a8f813d 100644 --- a/reports/nova_usage_audit.py +++ b/reports/nova_usage_audit.py @@ -95,7 +95,10 @@ def _get_exists(beginning, ending): def cell_and_compute(instance, launched_at): usage = InstanceUsage.find(instance, launched_at)[0] - deployment = usage.latest_deployment_for_request_id() + try: + deployment = usage.latest_deployment_for_request_id() + except IndexError: + deployment = None cell = (deployment and deployment.name) or '-' compute = usage.host() or '-' return cell, compute