summaryrefslogtreecommitdiffstats
path: root/app/utils/inventory_mgr.py
diff options
context:
space:
mode:
authorKoren Lev <korenlev@gmail.com>2017-12-18 19:16:16 +0200
committerKoren Lev <korenlev@gmail.com>2017-12-18 19:16:16 +0200
commit98c3ac7c859e34fe60d061b9ca591aba429e4118 (patch)
tree3ff2629def8938b12c0a0147e463e74e475c9032 /app/utils/inventory_mgr.py
parent4709d96cc240c0c4c5308d40361ca3c3da1152fd (diff)
release 1.2 + new tagging
Change-Id: I1e876451ec4a330f458dd57adadb15e39969b225 Signed-off-by: Koren Lev <korenlev@gmail.com>
Diffstat (limited to 'app/utils/inventory_mgr.py')
-rw-r--r--app/utils/inventory_mgr.py26
1 files changed, 16 insertions, 10 deletions
diff --git a/app/utils/inventory_mgr.py b/app/utils/inventory_mgr.py
index 722d0aa..bbc5542 100644
--- a/app/utils/inventory_mgr.py
+++ b/app/utils/inventory_mgr.py
@@ -265,6 +265,7 @@ class InventoryMgr(MongoAccess, metaclass=Singleton):
# source_label, target_label: labels for the ends of the link (optional)
def create_link(self, env, src, source_id, target, target_id,
link_type, link_name, state, link_weight,
+ implicit=False,
source_label="", target_label="",
host=None, switch=None,
extra_attributes=None):
@@ -282,6 +283,7 @@ class InventoryMgr(MongoAccess, metaclass=Singleton):
"link_weight": link_weight,
"source_label": source_label,
"target_label": target_label,
+ "implicit": implicit,
"attributes": extra_attributes if extra_attributes else {}
}
if host:
@@ -347,16 +349,18 @@ class InventoryMgr(MongoAccess, metaclass=Singleton):
if not env_config:
return False
- # Workaround for mechanism_drivers field type
- mechanism_driver = env_config['mechanism_drivers'][0] \
- if isinstance(env_config['mechanism_drivers'], list) \
- else env_config['mechanism_drivers']
+ # Workarounds for mechanism_drivers and distribution_version field types
+ mechanism_driver = env_config.get('mechanism_drivers')
+ if isinstance(mechanism_driver, list):
+ mechanism_driver = mechanism_driver[0]
+ env_distribution_version = env_config.get('distribution_version')
+ if isinstance(env_distribution_version, list):
+ env_distribution_version = env_distribution_version[0]
full_env = {
- 'environment.distribution': env_config['distribution'],
- 'environment.distribution_version':
- {"$in": [env_config['distribution_version']]},
- 'environment.type_drivers': env_config['type_drivers'],
+ 'environment.distribution': env_config.get('distribution'),
+ 'environment.distribution_version': env_distribution_version,
+ 'environment.type_drivers': env_config.get('type_drivers'),
'environment.mechanism_drivers': mechanism_driver
}
return self.is_feature_supported_in_env(full_env, feature)
@@ -394,8 +398,10 @@ class InventoryMgr(MongoAccess, metaclass=Singleton):
self.log.error("failed to find master parent " +
master_parent_id)
return False
- folder_id_path = "/".join((master_parent["id_path"], o["parent_id"]))
- folder_name_path = "/".join((master_parent["name_path"], o["parent_text"]))
+ folder_id_path = "/".join((master_parent["id_path"],
+ o["parent_id"]))
+ folder_name_path = "/".join((master_parent["name_path"],
+ o["parent_text"]))
folder = {
"environment": parent["environment"],
"parent_id": master_parent_id,