From ae15c9c6702ec5e8af44d72c5a37eaefee27a0d8 Mon Sep 17 00:00:00 2001 From: Parker Berberian 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 --- src/resource_inventory/pdf_templater.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/resource_inventory') diff --git a/src/resource_inventory/pdf_templater.py b/src/resource_inventory/pdf_templater.py index 9f7e7f1..a50f04c 100644 --- a/src/resource_inventory/pdf_templater.py +++ b/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 1.2.3-korg