From 7d77f59478d45e12d81971d5877afa022d14f682 Mon Sep 17 00:00:00 2001 From: Manali Latkar Date: Mon, 11 Aug 2014 16:38:49 +0530 Subject: [PATCH] handling the exception in case no instanceusage with specific instance and launched_at is present Change-Id: I7eb6d0b76aa41b0f26ab4b81fe033ddd527fc331 --- reports/nova_usage_audit.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/reports/nova_usage_audit.py b/reports/nova_usage_audit.py index dd58049..37328b6 100644 --- a/reports/nova_usage_audit.py +++ b/reports/nova_usage_audit.py @@ -94,10 +94,14 @@ 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() + usage_list = InstanceUsage.find(instance, launched_at) + deployment = None + usage = None + if usage_list: + usage = usage_list[0] + deployment = usage.latest_deployment_for_request_id() cell = (deployment and deployment.name) or '-' - compute = usage.host() or '-' + compute = (usage and usage.host()) or '-' return cell, compute