From 885ec8db68fe58a6687d236f6e48325c6c36f32c Mon Sep 17 00:00:00 2001
From: Erik Reid <erik.reid@geant.org>
Date: Wed, 15 Jan 2020 21:51:29 +0100
Subject: [PATCH] only return one-sided location from link if no services

---
 inventory_provider/routes/classifier.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/inventory_provider/routes/classifier.py b/inventory_provider/routes/classifier.py
index 685b2764..76bae856 100644
--- a/inventory_provider/routes/classifier.py
+++ b/inventory_provider/routes/classifier.py
@@ -144,9 +144,6 @@ def get_juniper_link_info(source_equipment, interface):
             'locations': []
         }
 
-        router_location = _location_from_router(source_equipment)
-        result['locations'] += [router_location]
-
         top_level_services = []
 
         services = r.get(
@@ -194,6 +191,9 @@ def get_juniper_link_info(source_equipment, interface):
         if top_level_services:
             result['related-services'] = top_level_services
 
+        if not result['locations']:
+            result['locations'] = [_location_from_router(source_equipment)]
+
         result['locations'] = _unique_dicts_from_list(result['locations'])
         result = json.dumps(result)
         # cache this data for the next call
-- 
GitLab