From 83c7b069ea910e9b025a29a797b02a90dd8b834d Mon Sep 17 00:00:00 2001 From: Shubhendu Date: Thu, 2 Feb 2017 14:33:49 +0530 Subject: [PATCH] Corrected sds detection plugin logic Signed-off-by: Shubhendu --- .../sds/plugins/discover_ceph_sds_details.py | 4 ++++ tendrl/node_agent/manager/__init__.py | 14 +++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/tendrl/node_agent/discovery/sds/plugins/discover_ceph_sds_details.py b/tendrl/node_agent/discovery/sds/plugins/discover_ceph_sds_details.py index 9150e3ad..33b6f8f8 100644 --- a/tendrl/node_agent/discovery/sds/plugins/discover_ceph_sds_details.py +++ b/tendrl/node_agent/discovery/sds/plugins/discover_ceph_sds_details.py @@ -1,5 +1,6 @@ import json import logging +import os.path import subprocess from tendrl.node_agent.discovery.sds.discover_sds_plugin \ @@ -39,6 +40,9 @@ def discover_storage_system(self): #TODO(shtripat) handle the case of ubuntu if cfg_file != "": + if not os.path.exists(cfg_file): + LOG.info("config file: %s not found" % cfg_file) + return ret_val with open(cfg_file) as f: for line in f: if line.startswith("CLUSTER="): diff --git a/tendrl/node_agent/manager/__init__.py b/tendrl/node_agent/manager/__init__.py index 3c537782..9bb449f2 100644 --- a/tendrl/node_agent/manager/__init__.py +++ b/tendrl/node_agent/manager/__init__.py @@ -66,11 +66,15 @@ def load_and_execute_sds_discovery_plugins(self): for plugin in sds_discovery_manager.get_available_plugins(): sds_details = plugin.discover_storage_system() if sds_details: - tendrl_ns.node_agent.objects.DetectedCluster( - detected_cluster_id=sds_details['detected_cluster_id'], - sds_pkg_name=sds_details['pkg_name'], - sds_pkg_version=sds_details['pkg_version'], - ).save() + try: + tendrl_ns.node_agent.objects.DetectedCluster( + detected_cluster_id=sds_details['detected_cluster_id'], + sds_pkg_name=sds_details['pkg_name'], + sds_pkg_version=sds_details['pkg_version'], + ).save() + except etcd.EtcdException as ex: + LOG.error('Failed to update etcd . \Error %s' % str(ex)) + break def main():