From e4dd634990db5d00f3b5f6c60f8123349b42d379 Mon Sep 17 00:00:00 2001 From: Annika Wickert Date: Thu, 13 Jan 2022 10:07:30 +0000 Subject: [PATCH] Allow empty offloader config --- unifi_respondd/unifi_client.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/unifi_respondd/unifi_client.py b/unifi_respondd/unifi_client.py index 455062f..d3a66bc 100644 --- a/unifi_respondd/unifi_client.py +++ b/unifi_respondd/unifi_client.py @@ -162,9 +162,15 @@ def get_infos(): ) except: pass - neighbour_mac = cfg.offloader_mac.get(site["desc"], None) - offloader_id = cfg.offloader_mac.get(site["desc"], "").replace(':', '') - offloader = list(filter(lambda x:x["mac"]==cfg.offloader_mac.get(site["desc"], ""),ffnodes["nodes"]))[0] + try: + neighbour_mac = cfg.offloader_mac.get(site["desc"], None) + offloader_id = cfg.offloader_mac.get(site["desc"], "").replace(':', '') + offloader = list(filter(lambda x:x["mac"]==cfg.offloader_mac.get(site["desc"], ""),ffnodes["nodes"]))[0] + except: + neighbour_mac = None + offloader_id = None + offloader = {} + pass uplink = ap.get("uplink", None) if uplink is not None and uplink.get("ap_mac", None) is not None: neighbour_mac = uplink.get("ap_mac") @@ -190,11 +196,11 @@ def get_infos(): mem_total=ap.get("sys_stats", {}).get("mem_total", 0), tx_bytes=tx, rx_bytes=rx, - gateway=offloader["gateway"], - gateway6=offloader["gateway6"], + gateway=offloader.get("gateway", None), + gateway6=offloader.get("gateway6", None), gateway_nexthop=offloader_id, neighbour_mac=neighbour_mac, - domain_code=offloader["domain"], + domain_code=offloader.get("domain", None), ) ) return aps