diff options
author | yayogev <yaronyogev@gmail.com> | 2017-08-11 00:35:14 +0300 |
---|---|---|
committer | yayogev <yaronyogev@gmail.com> | 2017-08-11 00:35:14 +0300 |
commit | 9d51c29acfb81ae16c72a1675d7b021d032dbdfb (patch) | |
tree | a815ba52d062fb37c33e6ac99cfb3a6ae11a514a /app/discover/clique_finder.py | |
parent | 2414c92d87a4b807d8480328681ef066ba08e305 (diff) |
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 <yaronyogev@gmail.com>
Diffstat (limited to 'app/discover/clique_finder.py')
-rw-r--r-- | app/discover/clique_finder.py | 22 |
1 files changed, 14 insertions, 8 deletions
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"]: |