From 9d51c29acfb81ae16c72a1675d7b021d032dbdfb Mon Sep 17 00:00:00 2001 From: yayogev Date: Fri, 11 Aug 2017 00:35:14 +0300 Subject: US2853 rename pnic to host_pnic & switch_pnic fixed clique finder to work with switch-switch link type Change-Id: I4f815f77e6b4ea36669dfb58bb5f5e914fe3e1ac Signed-off-by: yayogev --- app/discover/clique_finder.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'app/discover/clique_finder.py') diff --git a/app/discover/clique_finder.py b/app/discover/clique_finder.py index 9b5aad2..4c4e636 100644 --- a/app/discover/clique_finder.py +++ b/app/discover/clique_finder.py @@ -100,11 +100,15 @@ class CliqueFinder(Fetcher): link_type_parts = link_type.split('-') link_type_parts.reverse() link_type_reversed = '-'.join(link_type_parts) - matches = self.links.find_one({ - "environment": self.env, - "link_type": link_type_reversed - }) - reversed = True if matches else False + self_linked = link_type == link_type_reversed + if self_linked: + reversed = False + else: + matches = self.links.find_one({ + "environment": self.env, + "link_type": link_type_reversed + }) + reversed = True if matches else False if reversed: link_type = link_type_reversed from_type = link_type[:link_type.index("-")] @@ -115,6 +119,7 @@ class CliqueFinder(Fetcher): if match_type not in nodes_of_type.keys(): continue other_side_type = to_type if not reversed else from_type + nodes_to_add = {} for match_point in nodes_of_type[match_type].keys(): matches = self.links.find({ "environment": self.env, @@ -130,9 +135,10 @@ class CliqueFinder(Fetcher): clique["links"].append(id) clique["links_detailed"].append(link) other_side_point = str(link[other_side]) - if other_side_type not in nodes_of_type: - nodes_of_type[other_side_type] = {} - nodes_of_type[other_side_type][other_side_point] = 1 + nodes_to_add[other_side_point] = 1 + if other_side_type not in nodes_of_type: + nodes_of_type[other_side_type] = {} + nodes_of_type[other_side_type].update(nodes_to_add) # after adding the links to the clique, create/update the clique if not clique["links"]: -- cgit 1.2.3-korg