From 7bcb582f79893b12ae2ef44345553a2f76460018 Mon Sep 17 00:00:00 2001 From: "jiagen.luo" Date: Thu, 30 Mar 2023 09:56:23 +0800 Subject: [PATCH 1/5] Modify Used Capacity Unit Conversion Error --- delfin/drivers/dell_emc/vplex/vplex_stor.py | 23 ++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/delfin/drivers/dell_emc/vplex/vplex_stor.py b/delfin/drivers/dell_emc/vplex/vplex_stor.py index 10b808c47..cd152ef0a 100644 --- a/delfin/drivers/dell_emc/vplex/vplex_stor.py +++ b/delfin/drivers/dell_emc/vplex/vplex_stor.py @@ -325,17 +325,34 @@ def get_cluster_used_capacity(self, cluster_name): try: custom_data = resposne_summary.get("custom-data") find_capacity = re.findall( - r"capacity\s+is\s+(([0-9]*(\.[0-9]{1,3}))|([0-9]+))", + r"capacity\s+is\s+(([0-9]*(\.[0-9]{1,3}))|([0-9]+)[a-zA-Z])", custom_data) find_capacity_str = find_capacity[-1][0] - find_capacity_float = float(find_capacity_str) - capacity = int(find_capacity_float * units.Ti) + capacity = self.get_capacity_by_unit(find_capacity_str) except Exception as e: LOG.error("Storage used capacity, cluster %s analyse error %s" % cluster_name, six.text_type(e)) raise e return capacity + def get_capacity_by_unit(self, find_capacity_str): + if find_capacity_str.find('G'): + find_capacity_float = float( + find_capacity_str[:find_capacity_str.index('G')]) + capacity = int(find_capacity_float * units.Gi) + elif find_capacity_str.find('T'): + find_capacity_float = float( + find_capacity_str[:find_capacity_str.index('G')]) + capacity = int(find_capacity_float * units.Ti) + elif find_capacity_str.find('M'): + find_capacity_float = float( + find_capacity_str[:find_capacity_str.index('M')]) + capacity = int(find_capacity_float * units.Mi) + else: + find_capacity_float = float(find_capacity_str) + capacity = int(find_capacity_float * units.Mi) + return capacity + def list_controllers(self, context): """List all storage controllers from storage system.""" ct_list = [] From 145cc69f8f4d4bbb651c68a8c0dbad376a941327 Mon Sep 17 00:00:00 2001 From: "jiagen.luo" Date: Thu, 30 Mar 2023 10:15:19 +0800 Subject: [PATCH 2/5] Modify Used Capacity Unit Conversion Error --- delfin/drivers/dell_emc/vplex/vplex_stor.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/delfin/drivers/dell_emc/vplex/vplex_stor.py b/delfin/drivers/dell_emc/vplex/vplex_stor.py index cd152ef0a..3c55c184a 100644 --- a/delfin/drivers/dell_emc/vplex/vplex_stor.py +++ b/delfin/drivers/dell_emc/vplex/vplex_stor.py @@ -324,8 +324,9 @@ def get_cluster_used_capacity(self, cluster_name): get_virtual_volume_summary_resp(cluster_name) try: custom_data = resposne_summary.get("custom-data") - find_capacity = re.findall( - r"capacity\s+is\s+(([0-9]*(\.[0-9]{1,3}))|([0-9]+)[a-zA-Z])", + find_capacity = re.findall(r"capacity\s+is\s+((" + r"[0-9]*(\.[0-9]{1,3})" + r"[a-zA-Z])|([0-9]+)[a-zA-Z])", custom_data) find_capacity_str = find_capacity[-1][0] capacity = self.get_capacity_by_unit(find_capacity_str) @@ -336,15 +337,15 @@ def get_cluster_used_capacity(self, cluster_name): return capacity def get_capacity_by_unit(self, find_capacity_str): - if find_capacity_str.find('G'): + if 'G' in find_capacity_str: find_capacity_float = float( find_capacity_str[:find_capacity_str.index('G')]) capacity = int(find_capacity_float * units.Gi) - elif find_capacity_str.find('T'): + elif 'T' in find_capacity_str: find_capacity_float = float( - find_capacity_str[:find_capacity_str.index('G')]) + find_capacity_str[:find_capacity_str.index('T')]) capacity = int(find_capacity_float * units.Ti) - elif find_capacity_str.find('M'): + elif 'M' in find_capacity_str: find_capacity_float = float( find_capacity_str[:find_capacity_str.index('M')]) capacity = int(find_capacity_float * units.Mi) From 34844adfd9511586b8fbd128bcea18173f5c0cc0 Mon Sep 17 00:00:00 2001 From: "jiagen.luo" Date: Thu, 30 Mar 2023 10:19:33 +0800 Subject: [PATCH 3/5] Modify Used Capacity Unit Conversion Error --- delfin/drivers/dell_emc/vplex/vplex_stor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/delfin/drivers/dell_emc/vplex/vplex_stor.py b/delfin/drivers/dell_emc/vplex/vplex_stor.py index 3c55c184a..37efb6037 100644 --- a/delfin/drivers/dell_emc/vplex/vplex_stor.py +++ b/delfin/drivers/dell_emc/vplex/vplex_stor.py @@ -327,7 +327,7 @@ def get_cluster_used_capacity(self, cluster_name): find_capacity = re.findall(r"capacity\s+is\s+((" r"[0-9]*(\.[0-9]{1,3})" r"[a-zA-Z])|([0-9]+)[a-zA-Z])", - custom_data) + custom_data) find_capacity_str = find_capacity[-1][0] capacity = self.get_capacity_by_unit(find_capacity_str) except Exception as e: From c3f075610ae91f7108331d28eb3b24bd15250ac0 Mon Sep 17 00:00:00 2001 From: "jiagen.luo" Date: Thu, 30 Mar 2023 11:01:05 +0800 Subject: [PATCH 4/5] Modify Used Capacity Unit Conversion Error --- delfin/drivers/dell_emc/vplex/vplex_stor.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/delfin/drivers/dell_emc/vplex/vplex_stor.py b/delfin/drivers/dell_emc/vplex/vplex_stor.py index 37efb6037..b3bf45636 100644 --- a/delfin/drivers/dell_emc/vplex/vplex_stor.py +++ b/delfin/drivers/dell_emc/vplex/vplex_stor.py @@ -349,9 +349,12 @@ def get_capacity_by_unit(self, find_capacity_str): find_capacity_float = float( find_capacity_str[:find_capacity_str.index('M')]) capacity = int(find_capacity_float * units.Mi) + elif 'K' in find_capacity_str: + find_capacity_float = float( + find_capacity_str[:find_capacity_str.index('K')]) + capacity = int(find_capacity_float * units.Ki) else: - find_capacity_float = float(find_capacity_str) - capacity = int(find_capacity_float * units.Mi) + capacity = int(find_capacity_str) return capacity def list_controllers(self, context): From a0500349a0588e635b5ae7bd27a7b208efffc21a Mon Sep 17 00:00:00 2001 From: "jiagen.luo" Date: Fri, 31 Mar 2023 08:58:46 +0800 Subject: [PATCH 5/5] delete unused method --- delfin/drivers/dell_emc/vplex/vplex_stor.py | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/delfin/drivers/dell_emc/vplex/vplex_stor.py b/delfin/drivers/dell_emc/vplex/vplex_stor.py index b3bf45636..adad83769 100644 --- a/delfin/drivers/dell_emc/vplex/vplex_stor.py +++ b/delfin/drivers/dell_emc/vplex/vplex_stor.py @@ -732,16 +732,3 @@ def get_attributes_from_response(response): child_map[name] = value attributes_list.append(child_map) return attributes_list - - -@staticmethod -def handle_detail_list(detail_info, detail_map, split): - detail_arr = detail_info.split('\n') - for detail in detail_arr: - if detail is not None and detail != '': - strinfo = detail.split(split, 1) - key = strinfo[0] - value = '' - if len(strinfo) > 1: - value = strinfo[1] - detail_map[key] = value