From: hsiang41 Date: Tue, 6 Nov 2018 08:37:06 +0000 (+0800) Subject: Avoid exception if remote plugin not enabled X-Git-Tag: v14.1.0~955^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=5e72643f05de3237d0eef918d528b2230d324136;p=ceph.git Avoid exception if remote plugin not enabled Avoid code exception when the remote plugin not enabled. Signed-off-by: Rick Chen --- diff --git a/src/pybind/mgr/devicehealth/module.py b/src/pybind/mgr/devicehealth/module.py index c73cf82f3f46..f2dd5368e3a9 100644 --- a/src/pybind/mgr/devicehealth/module.py +++ b/src/pybind/mgr/devicehealth/module.py @@ -583,7 +583,11 @@ class Module(MgrModule): plugin_name = 'diskprediction_local' else: return -1, '', 'unable to enable any disk prediction model[local/cloud]' - return self.remote(plugin_name, 'predict_life_expentancy', devid=devid) + try: + if self.remote(plugin_name, 'can_run'): + return self.remote(plugin_name, 'predict_life_expentancy', devid=devid) + except: + return -1, '', 'unable to invoke diskprediction local or remote plugin' def predict_all_devices(self): plugin_name = '' @@ -594,4 +598,8 @@ class Module(MgrModule): plugin_name = 'diskprediction_local' else: return -1, '', 'unable to enable any disk prediction model[local/cloud]' - return self.remote(plugin_name, 'predict_all_devices') + try: + if self.remote(plugin_name, 'can_run'): + return self.remote(plugin_name, 'predict_all_devices') + except: + return -1, '', 'unable to invoke diskprediction local or remote plugin' diff --git a/src/pybind/mgr/diskprediction_local/module.py b/src/pybind/mgr/diskprediction_local/module.py index 80286f47bf1b..1959739e3975 100644 --- a/src/pybind/mgr/diskprediction_local/module.py +++ b/src/pybind/mgr/diskprediction_local/module.py @@ -85,7 +85,7 @@ class Module(MgrModule): self.log.debug('Last scrape never, next scrape due %s', next_predicted.strftime(TIME_FORMAT)) if now >= next_predicted: - self.predict_all_device() + self.predict_all_devices() last_predicted = now self.set_store('last_predicted', last_predicted.strftime(TIME_FORMAT))