summaryrefslogtreecommitdiffstats
path: root/app/discover/link_finders
diff options
context:
space:
mode:
Diffstat (limited to 'app/discover/link_finders')
-rw-r--r--app/discover/link_finders/__init__.py10
-rw-r--r--app/discover/link_finders/find_links_for_pnics.py12
-rw-r--r--app/discover/link_finders/find_links_for_vconnectors.py3
-rw-r--r--app/discover/link_finders/find_links_for_vservice_vnics.py16
4 files changed, 33 insertions, 8 deletions
diff --git a/app/discover/link_finders/__init__.py b/app/discover/link_finders/__init__.py
index e69de29..1e85a2a 100644
--- a/app/discover/link_finders/__init__.py
+++ b/app/discover/link_finders/__init__.py
@@ -0,0 +1,10 @@
+###############################################################################
+# Copyright (c) 2017 Koren Lev (Cisco Systems), Yaron Yogev (Cisco Systems) #
+# and others #
+# #
+# All rights reserved. This program and the accompanying materials #
+# are made available under the terms of the Apache License, Version 2.0 #
+# which accompanies this distribution, and is available at #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+###############################################################################
+
diff --git a/app/discover/link_finders/find_links_for_pnics.py b/app/discover/link_finders/find_links_for_pnics.py
index 1f02426..94eba7b 100644
--- a/app/discover/link_finders/find_links_for_pnics.py
+++ b/app/discover/link_finders/find_links_for_pnics.py
@@ -41,6 +41,18 @@ class FindLinksForPnics(FindLinks):
def add_pnic_network_links(self, pnic):
host = pnic["host"]
+ if self.configuration.get_env_config()['type_drivers'] == "vlan":
+ # take this pnic only if we can find matching vedge-pnic links
+ matches = self.inv.find({
+ "environment": self.get_env(),
+ "link_type": "vedge-host_pnic",
+ "host": host,
+ "target_id": pnic["id"]},
+ projection={"_id": 1},
+ collection="links",
+ get_single=True)
+ if not matches:
+ return
# find ports for that host, and fetch just the network ID
ports = self.inv.find_items({
"environment": self.get_env(),
diff --git a/app/discover/link_finders/find_links_for_vconnectors.py b/app/discover/link_finders/find_links_for_vconnectors.py
index edb351a..0703cd8 100644
--- a/app/discover/link_finders/find_links_for_vconnectors.py
+++ b/app/discover/link_finders/find_links_for_vconnectors.py
@@ -31,7 +31,8 @@ class FindLinksForVconnectors(FindLinks):
is_ovs = mechanism_drivers and mechanism_drivers[0] == 'OVS'
if is_ovs:
# interface ID for OVS
- vnic = self.inv.get_by_id(self.get_env(), interface_name)
+ vnic_id = "{}-{}".format(vconnector["host"], interface_name)
+ vnic = self.inv.get_by_id(self.get_env(), vnic_id)
else:
# interface ID for VPP - match interface MAC address to vNIC MAC
interface = vconnector['interfaces'][interface_name]
diff --git a/app/discover/link_finders/find_links_for_vservice_vnics.py b/app/discover/link_finders/find_links_for_vservice_vnics.py
index ca9bc4a..f975c92 100644
--- a/app/discover/link_finders/find_links_for_vservice_vnics.py
+++ b/app/discover/link_finders/find_links_for_vservice_vnics.py
@@ -33,11 +33,6 @@ class FindLinksForVserviceVnics(FindLinks):
host = self.inv.get_by_id(self.get_env(), v["host"])
if "Network" not in host["host_type"]:
return
- if "network" not in v:
- return
- network = self.inv.get_by_id(self.get_env(), v["network"])
- if network == []:
- return
vservice_id = v["parent_id"]
vservice_id = vservice_id[:vservice_id.rindex('-')]
vservice = self.inv.get_by_id(self.get_env(), vservice_id)
@@ -46,7 +41,14 @@ class FindLinksForVserviceVnics(FindLinks):
target = v["_id"]
target_id = v["id"]
link_type = "vservice-vnic"
- link_name = network["name"]
+ extra_attributes = None
+ if "network" in v:
+ network = self.inv.get_by_id(self.get_env(), v["network"])
+ link_name = network["name"]
+ extra_attributes = {'network': v['network']}
+ else:
+ link_name = "{}-{}".format(vservice["object_name"],
+ v["object_name"])
state = "up" # TBD
link_weight = 0 # TBD
self.create_link(self.get_env(),
@@ -54,4 +56,4 @@ class FindLinksForVserviceVnics(FindLinks):
target, target_id,
link_type, link_name, state, link_weight,
host=v["host"],
- extra_attributes={'network': v['network']})
+ extra_attributes=extra_attributes)