diff options
author | Yaron Yogev <yaronyogev@gmail.com> | 2017-08-10 15:42:41 +0300 |
---|---|---|
committer | Yaron Yogev <yaronyogev@gmail.com> | 2017-08-10 15:42:41 +0300 |
commit | 72b7b6c157c643549006fea1eb4f7348581cb9a4 (patch) | |
tree | dfca00f51dbbc7b04aad9d29ead1f214da19777e /app/utils | |
parent | aad40dd5763265a4efcbfce248f6e8d2788ae7b5 (diff) |
US2853 add switch-switch links
Change-Id: I5e27d33f32dc1dfe930cb692cd98604cf437855b
Signed-off-by: Yaron Yogev <yaronyogev@gmail.com>
Diffstat (limited to 'app/utils')
-rw-r--r-- | app/utils/inventory_mgr.py | 11 |
1 files changed, 8 insertions, 3 deletions
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 = {} |