From 1a606b5a04ef5f90bc8772b2fa19591ac63145aa Mon Sep 17 00:00:00 2001 From: Wirut Getbamrung Date: Wed, 30 Jan 2019 13:40:52 +0700 Subject: [PATCH] [device/alibaba] - Update fanutil plugin to avoid null fru data --- .../alibaba/x86_64-alibaba_as13-32h-cl-r0/plugins/fanutil.py | 5 ++++- .../x86_64-alibaba_as13-48f8h-cl-r0/plugins/fanutil.py | 5 ++++- .../x86_64-alibaba_as23-128h-cl-r0/plugins/fanutil.py | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/device/alibaba/x86_64-alibaba_as13-32h-cl-r0/plugins/fanutil.py b/device/alibaba/x86_64-alibaba_as13-32h-cl-r0/plugins/fanutil.py index 5586e1299e83..dab2f64dd5e0 100644 --- a/device/alibaba/x86_64-alibaba_as13-32h-cl-r0/plugins/fanutil.py +++ b/device/alibaba/x86_64-alibaba_as13-32h-cl-r0/plugins/fanutil.py @@ -256,6 +256,8 @@ def get_all(self): if len(fan_fru) == 0: fan_idx = fan_raw_idx + fan_pn = "N/A" + fan_sn = "N/A" else: fan_key = fan_fru[0].split() if str(fan_key[-1]).lower() == "absent": @@ -290,7 +292,8 @@ def get_all(self): fan_data = sensor_data.get(fan_key) fan_sp_list = map(int, re.findall(r'\d+', fan_data)) fan_dict["Present"] = fan_fru_dict[f_index]["Present"] - if fan_dict["Present"]: + if fan_dict["Present"] or fan_sp_list[0] > 0: + fan_dict["Present"] = True fan_dict["Speed"] = fan_sp_list[0] fan_dict["Running"] = True if fan_dict["Speed"] > 0 else False fan_dict["LowThd"] = fan_sp_list[1] diff --git a/device/alibaba/x86_64-alibaba_as13-48f8h-cl-r0/plugins/fanutil.py b/device/alibaba/x86_64-alibaba_as13-48f8h-cl-r0/plugins/fanutil.py index 5586e1299e83..dab2f64dd5e0 100644 --- a/device/alibaba/x86_64-alibaba_as13-48f8h-cl-r0/plugins/fanutil.py +++ b/device/alibaba/x86_64-alibaba_as13-48f8h-cl-r0/plugins/fanutil.py @@ -256,6 +256,8 @@ def get_all(self): if len(fan_fru) == 0: fan_idx = fan_raw_idx + fan_pn = "N/A" + fan_sn = "N/A" else: fan_key = fan_fru[0].split() if str(fan_key[-1]).lower() == "absent": @@ -290,7 +292,8 @@ def get_all(self): fan_data = sensor_data.get(fan_key) fan_sp_list = map(int, re.findall(r'\d+', fan_data)) fan_dict["Present"] = fan_fru_dict[f_index]["Present"] - if fan_dict["Present"]: + if fan_dict["Present"] or fan_sp_list[0] > 0: + fan_dict["Present"] = True fan_dict["Speed"] = fan_sp_list[0] fan_dict["Running"] = True if fan_dict["Speed"] > 0 else False fan_dict["LowThd"] = fan_sp_list[1] diff --git a/device/alibaba/x86_64-alibaba_as23-128h-cl-r0/plugins/fanutil.py b/device/alibaba/x86_64-alibaba_as23-128h-cl-r0/plugins/fanutil.py index 554914bcfbba..7c37088b927e 100644 --- a/device/alibaba/x86_64-alibaba_as23-128h-cl-r0/plugins/fanutil.py +++ b/device/alibaba/x86_64-alibaba_as23-128h-cl-r0/plugins/fanutil.py @@ -256,6 +256,8 @@ def get_all(self): if len(fan_fru) == 0: fan_idx = fan_raw_idx + fan_pn = "N/A" + fan_sn = "N/A" else: fan_key = fan_fru[0].split() if str(fan_key[-1]).lower() == "absent": @@ -290,7 +292,8 @@ def get_all(self): fan_data = sensor_data.get(fan_key) fan_sp_list = map(int, re.findall(r'\d+', fan_data)) fan_dict["Present"] = fan_fru_dict[f_index]["Present"] - if fan_dict["Present"]: + if fan_dict["Present"] or fan_sp_list[0] > 0: + fan_dict["Present"] = True fan_dict["Speed"] = fan_sp_list[0] fan_dict["Running"] = True if fan_dict["Speed"] > 0 else False fan_dict["LowThd"] = fan_sp_list[1]