handling the exception in case no instanceusage with specific instance and launched_at is present

Change-Id: I7eb6d0b76aa41b0f26ab4b81fe033ddd527fc331
This commit is contained in:
Manali Latkar 2014-08-11 16:38:49 +05:30
parent f0f8d2e9ca
commit 7d77f59478

View File

@ -94,10 +94,14 @@ def _get_exists(beginning, ending):
def cell_and_compute(instance, launched_at): def cell_and_compute(instance, launched_at):
usage = InstanceUsage.find(instance, launched_at)[0] 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() deployment = usage.latest_deployment_for_request_id()
cell = (deployment and deployment.name) or '-' cell = (deployment and deployment.name) or '-'
compute = usage.host() or '-' compute = (usage and usage.host()) or '-'
return cell, compute return cell, compute