aboutsummaryrefslogtreecommitdiffstats
path: root/app/discover/find_links_for_pnics.py
diff options
context:
space:
mode:
authoryayogev <yaronyogev@gmail.com>2017-08-11 00:35:14 +0300
committeryayogev <yaronyogev@gmail.com>2017-08-11 00:35:14 +0300
commit9d51c29acfb81ae16c72a1675d7b021d032dbdfb (patch)
treea815ba52d062fb37c33e6ac99cfb3a6ae11a514a /app/discover/find_links_for_pnics.py
parent2414c92d87a4b807d8480328681ef066ba08e305 (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/find_links_for_pnics.py')
-rw-r--r--app/discover/find_links_for_pnics.py27
1 files changed, 13 insertions, 14 deletions
diff --git a/app/discover/find_links_for_pnics.py b/app/discover/find_links_for_pnics.py
index 268aa55..1372770 100644
--- a/app/discover/find_links_for_pnics.py
+++ b/app/discover/find_links_for_pnics.py
@@ -10,6 +10,7 @@
import re
from discover.find_links import FindLinks
+from utils.util import decode_aci_dn
class FindLinksForPnics(FindLinks):
@@ -19,20 +20,19 @@ class FindLinksForPnics(FindLinks):
def add_links(self):
pnics = self.inv.find_items({
"environment": self.get_env(),
- "type": "pnic",
- "pnic_type": "host"
+ "type": "host_pnic"
})
- self.log.info("adding links of type: pnic-network, host-switch")
+ self.log.info("adding links of type: host_pnic-network, "
+ "host_pnic-switch_pnic")
for pnic in pnics:
self.add_pnic_network_links(pnic)
self.add_host_pnic_to_switch_pnic_link(pnic)
pnics = self.inv.find_items({
"environment": self.get_env(),
- "type": "pnic",
- "pnic_type": "switch",
+ "type": "switch_pnic",
"role": "uplink"
})
- self.log.info("adding links of type: switch-switch")
+ self.log.info("adding links of type: switch_pnic-switch_pnic")
for pnic in pnics:
self.add_switch_to_switch_link(pnic)
@@ -55,13 +55,13 @@ class FindLinksForPnics(FindLinks):
source_id = pnic["id"]
target = network["_id"]
target_id = network["id"]
- link_type = "pnic-network"
+ link_type = "host_pnic-network"
link_name = "Segment-" + str(network["provider:segmentation_id"]) \
if "provider:segmentation_id" in network \
else "Segment-None"
state = "up" if pnic["Link detected"] == "yes" else "down"
link_weight = 0 # TBD
- attributes={"network": target_id}
+ attributes = {"network": target_id}
if "port_id" in pnic:
attributes['source_label'] = "port-" + pnic["port_id"]
self.create_link(self.get_env(),
@@ -73,8 +73,7 @@ class FindLinksForPnics(FindLinks):
def add_host_pnic_to_switch_pnic_link(self, host_pnic):
switch_pnic = self.inv.find_items({
"environment": self.get_env(),
- "type": "pnic",
- "pnic_type": "switch",
+ "type": "switch_pnic",
"mac_address": host_pnic["mac_address"]},
get_single=True)
if not switch_pnic:
@@ -83,7 +82,7 @@ class FindLinksForPnics(FindLinks):
source_id = host_pnic["id"]
target = switch_pnic["_id"]
target_id = switch_pnic["id"]
- link_type = "host-switch"
+ link_type = "host_pnic-switch_pnic"
link_name = "{}-{}".format(host_pnic['host'],
switch_pnic['parent_id'])
state = "up" if host_pnic["Link detected"] == "yes" else "down"
@@ -102,12 +101,12 @@ class FindLinksForPnics(FindLinks):
source_id = leaf_pnic["id"]
target = spine_pnic["_id"]
target_id = spine_pnic["id"]
- link_type = "switch-switch"
+ link_type = "switch_pnic-switch_pnic"
if_id_matches = re.search("(eth.*)$", source_id)
- link_name = if_id_matches.group(1).replace("__", "/")
+ link_name = decode_aci_dn(if_id_matches.group(1))
state = "up" # TBD
link_weight = 0 # TBD
self.create_link(self.get_env(),
source, source_id, target, target_id,
link_type, link_name, state, link_weight,
- switch=leaf_pnic['switch']) \ No newline at end of file
+ switch=leaf_pnic['switch'])