From 72b7b6c157c643549006fea1eb4f7348581cb9a4 Mon Sep 17 00:00:00 2001 From: Yaron Yogev Date: Thu, 10 Aug 2017 15:42:41 +0300 Subject: US2853 add switch-switch links Change-Id: I5e27d33f32dc1dfe930cb692cd98604cf437855b Signed-off-by: Yaron Yogev --- app/utils/inventory_mgr.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'app/utils/inventory_mgr.py') diff --git a/app/utils/inventory_mgr.py b/app/utils/inventory_mgr.py index 2fe2894..257b0e3 100644 --- a/app/utils/inventory_mgr.py +++ b/app/utils/inventory_mgr.py @@ -259,15 +259,15 @@ class InventoryMgr(MongoAccess, metaclass=Singleton): # state: up/down # link_weight: integer, position/priority for graph placement # source_label, target_label: labels for the ends of the link (optional) - def create_link(self, env, host, src, source_id, target, target_id, + def create_link(self, env, src, source_id, target, target_id, link_type, link_name, state, link_weight, source_label="", target_label="", + host=None, switch=None, extra_attributes=None): s = bson.ObjectId(src) t = bson.ObjectId(target) link = { "environment": env, - "host": host, "source": s, "source_id": source_id, "target": t, @@ -280,6 +280,10 @@ class InventoryMgr(MongoAccess, metaclass=Singleton): "target_label": target_label, "attributes": extra_attributes if extra_attributes else {} } + if host: + link['host'] = host + if switch: + link['switch'] = switch return self.write_link(link) def write_link(self, link): @@ -359,7 +363,8 @@ class InventoryMgr(MongoAccess, metaclass=Singleton): return features_in_env.get(feature.value) is True def save_inventory_object(self, o: dict, parent: dict, - environment: str, type_to_fetch: dict = None) -> bool: + environment: str, type_to_fetch: dict = None) \ + -> bool: if not type_to_fetch: type_to_fetch = {} -- cgit 1.2.3-korg