From a296d84e3879465048a78b27ff4a1a253c405c65 Mon Sep 17 00:00:00 2001
From: Parker Berberian <pberberian@iol.unh.edu>
Date: Mon, 25 Mar 2019 14:07:15 -0400
Subject: Allow query to fail

Query for interface speed when templating the pdf may fail.
If it does fail, we provide a default value instead of aborting.

Change-Id: Ib3d6ddca7dd055e4066fb4915d33f6f9ad73ca80
Signed-off-by: Parker Berberian <pberberian@iol.unh.edu>
---
 dashboard/src/resource_inventory/pdf_templater.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/dashboard/src/resource_inventory/pdf_templater.py b/dashboard/src/resource_inventory/pdf_templater.py
index 9f7e7f1..a50f04c 100644
--- a/dashboard/src/resource_inventory/pdf_templater.py
+++ b/dashboard/src/resource_inventory/pdf_templater.py
@@ -154,8 +154,13 @@ class PDFTemplater:
         iface_info['features'] = "none"
         iface_info['mac_address'] = interface.mac_address
         iface_info['name'] = interface.name
-        profile = InterfaceProfile.objects.get(host=interface.host.profile, name=interface.name)
-        iface_info['speed'] = str(int(profile.speed / 1000)) + "gb"
+        speed = "unknown"
+        try:
+            profile = InterfaceProfile.objects.get(host=interface.host.profile, name=interface.name)
+            speed = str(int(profile.speed / 1000)) + "gb"
+        except Exception:
+            pass
+        iface_info['speed'] = speed
         return iface_info
 
     @classmethod
-- 
cgit