From cf964f230250489c9a38029c3012e4c796617998 Mon Sep 17 00:00:00 2001
From: Giuseppe Attardi <giuseppe.attardi@garr.it>
Date: Sun, 7 Jul 2019 19:03:41 +0200
Subject: [PATCH] Update views.py

---
 charms/garr-dashboard/files/plugins/admin-costs/views.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/charms/garr-dashboard/files/plugins/admin-costs/views.py b/charms/garr-dashboard/files/plugins/admin-costs/views.py
index f9079eb..0e01622 100644
--- a/charms/garr-dashboard/files/plugins/admin-costs/views.py
+++ b/charms/garr-dashboard/files/plugins/admin-costs/views.py
@@ -157,8 +157,10 @@ class IndexView(tables.DataTableView):
 
     def get_price(self, resource, request, db_session):
         if resource['type'] == 'instance':
-            flavor_name = resource.get('flavor_name', None)
-            if not flavor_name: flavor_name = api.nova.flavor_get(request, resource['flavor_id']).name
+            flavor_name = resource.get('flavor_name',
+                api.nova.flavor_get(request, resource['flavor_id']).name)
+            if not flavor_name:
+                LOG.error('No such flavor %s' % flavor_name)
             flavor = db_session.query(Flavor).filter(Flavor.name == flavor_name).first()
             row_list = db_session.query(Price).filter(Price.resource == flavor.id, Price.type == 'flavor').all()
         elif resource['type'] == 'volume':
-- 
GitLab