From f700dc909e574b11c686b7f368509a5fb8401da6 Mon Sep 17 00:00:00 2001 From: zhilong-xu Date: Tue, 23 Nov 2021 17:05:07 +0800 Subject: [PATCH 1/6] pure codeview-get_storage Capacity field Modification --- delfin/drivers/pure/flasharray/pure_flasharray.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/delfin/drivers/pure/flasharray/pure_flasharray.py b/delfin/drivers/pure/flasharray/pure_flasharray.py index 2b9ab2869..37c69f0d6 100644 --- a/delfin/drivers/pure/flasharray/pure_flasharray.py +++ b/delfin/drivers/pure/flasharray/pure_flasharray.py @@ -55,12 +55,16 @@ def get_storage(self, context): self.rest_handler.REST_STORAGE_URL) total_capacity = None used_capacity = None + raw_capacity = None if storages: for storage in storages: - total_capacity = int(storage.get('provisioned', - consts.DEFAULT_CAPACITY)) used_capacity = int(storage.get('volumes', consts.DEFAULT_CAPACITY)) + raw_capacity = int(storage.get('capacity', + consts.DEFAULT_CAPACITY)) + shared_space = int(storage.get('shared_space', + consts.DEFAULT_CAPACITY)) + total_capacity = raw_capacity - shared_space break arrays = self.rest_handler.rest_call(self.rest_handler.REST_ARRAY_URL) @@ -88,7 +92,7 @@ def get_storage(self, context): storage_result = { 'model': model, 'total_capacity': total_capacity, - 'raw_capacity': total_capacity, + 'raw_capacity': raw_capacity, 'used_capacity': used_capacity, 'free_capacity': total_capacity - used_capacity, 'vendor': 'PURE', From 6acfaa189cb4104384ee95032c8001ef4794931e Mon Sep 17 00:00:00 2001 From: zhilong-xu Date: Tue, 23 Nov 2021 17:50:11 +0800 Subject: [PATCH 2/6] pure codeview-get_storage total_capacity field Modification --- delfin/drivers/pure/flasharray/pure_flasharray.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/delfin/drivers/pure/flasharray/pure_flasharray.py b/delfin/drivers/pure/flasharray/pure_flasharray.py index 37c69f0d6..8576e89c7 100644 --- a/delfin/drivers/pure/flasharray/pure_flasharray.py +++ b/delfin/drivers/pure/flasharray/pure_flasharray.py @@ -64,7 +64,11 @@ def get_storage(self, context): consts.DEFAULT_CAPACITY)) shared_space = int(storage.get('shared_space', consts.DEFAULT_CAPACITY)) - total_capacity = raw_capacity - shared_space + system = int(storage.get('system', consts.DEFAULT_CAPACITY)) + snapshots = int(storage.get('snapshots', + consts.DEFAULT_CAPACITY)) + total_capacity = raw_capacity - shared_space - system - \ + snapshots break arrays = self.rest_handler.rest_call(self.rest_handler.REST_ARRAY_URL) From 8c7815a3ed8519c5ffc6de0d3b88baef81f91b5f Mon Sep 17 00:00:00 2001 From: zhilong-xu Date: Wed, 24 Nov 2021 10:46:33 +0800 Subject: [PATCH 3/6] pure codeview-alert description --- delfin/drivers/pure/flasharray/consts.py | 9 ++------- delfin/drivers/pure/flasharray/pure_flasharray.py | 15 ++++++++++----- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/delfin/drivers/pure/flasharray/consts.py b/delfin/drivers/pure/flasharray/consts.py index a7497f33c..85608bea4 100644 --- a/delfin/drivers/pure/flasharray/consts.py +++ b/delfin/drivers/pure/flasharray/consts.py @@ -84,10 +84,5 @@ PARSE_ALERT_DESCRIPTION = '1.3.6.1.4.1.40482.3.6' PARSE_ALERT_SEVERITY = '1.3.6.1.4.1.40482.3.7' -PARSE_ALERT_SEVERITY_MAP = {'0': constants.Severity.FATAL, - '1': constants.Severity.CRITICAL, - '2': constants.Severity.MAJOR, - '3': constants.Severity.MINOR, - '4': constants.Severity.WARNING, - '5': constants.Severity.INFORMATIONAL, - '6': constants.Severity.NOT_SPECIFIED} +PARSE_ALERT_SEVERITY_MAP = {'1': constants.Severity.WARNING, + '2': constants.Severity.INFORMATIONAL} diff --git a/delfin/drivers/pure/flasharray/pure_flasharray.py b/delfin/drivers/pure/flasharray/pure_flasharray.py index 8576e89c7..59b11667e 100644 --- a/delfin/drivers/pure/flasharray/pure_flasharray.py +++ b/delfin/drivers/pure/flasharray/pure_flasharray.py @@ -123,14 +123,17 @@ def list_alerts(self, context, query_para=None): time, '%Y-%m-%dT%H:%M:%SZ').timestamp() * consts.DEFAULT_LIST_ALERTS_TIME_CONVERSION) \ if time is not None else None - alerts_model['description'] = alert.get('details') - alerts_model['location'] = alert.get('component_name') + component_name = alert.get('component_name') + alerts_model['location'] = component_name alerts_model['type'] = constants.EventType.EQUIPMENT_ALARM alerts_model['resource_type'] = constants.DEFAULT_RESOURCE_TYPE - alerts_model['alert_name'] = alert.get('event') + event = alert.get('event') + alerts_model['alert_name'] = event alerts_model['sequence_number'] = alert.get('id') alerts_model['match_key'] = hashlib.md5(str(alert.get('id')). encode()).hexdigest() + alerts_model['description'] = ':(<{}>:<{}>): <{}>'.\ + format(alert.get('component_type'), component_name, event) alerts_list.append(alerts_model) return alerts_list @@ -144,8 +147,10 @@ def parse_alert(context, alert): constants.Severity.NOT_SPECIFIED) alert_model['category'] = constants.Category.FAULT alert_model['occur_time'] = utils.utcnow_ms() - alert_model['description'] = alert.get( - consts.PARSE_ALERT_DESCRIPTION) + alert_model['description'] = '(<{}>:<{}>):<{}>'.format(alert.get( + consts.PARSE_ALERT_STORAGE_NAME), + alert.get(consts.PARSE_ALERT_CONTROLLER_NAME), + alert.get(consts.PARSE_ALERT_DESCRIPTION)) alert_model['location'] = alert.get( consts.PARSE_ALERT_CONTROLLER_NAME) alert_model['type'] = constants.EventType.EQUIPMENT_ALARM From 82505f37b4b1d838ca3e4bca0c2216d5d5f53bda Mon Sep 17 00:00:00 2001 From: zhilong-xu Date: Wed, 24 Nov 2021 11:33:04 +0800 Subject: [PATCH 4/6] pure codeview-alert description --- delfin/drivers/pure/flasharray/pure_flasharray.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/delfin/drivers/pure/flasharray/pure_flasharray.py b/delfin/drivers/pure/flasharray/pure_flasharray.py index 59b11667e..c74b3a27f 100644 --- a/delfin/drivers/pure/flasharray/pure_flasharray.py +++ b/delfin/drivers/pure/flasharray/pure_flasharray.py @@ -132,7 +132,7 @@ def list_alerts(self, context, query_para=None): alerts_model['sequence_number'] = alert.get('id') alerts_model['match_key'] = hashlib.md5(str(alert.get('id')). encode()).hexdigest() - alerts_model['description'] = ':(<{}>:<{}>): <{}>'.\ + alerts_model['description'] = '({}:{}): {}'.\ format(alert.get('component_type'), component_name, event) alerts_list.append(alerts_model) return alerts_list @@ -147,7 +147,7 @@ def parse_alert(context, alert): constants.Severity.NOT_SPECIFIED) alert_model['category'] = constants.Category.FAULT alert_model['occur_time'] = utils.utcnow_ms() - alert_model['description'] = '(<{}>:<{}>):<{}>'.format(alert.get( + alert_model['description'] = '({}:{}):{}'.format(alert.get( consts.PARSE_ALERT_STORAGE_NAME), alert.get(consts.PARSE_ALERT_CONTROLLER_NAME), alert.get(consts.PARSE_ALERT_DESCRIPTION)) From 6777fb3fa4427357b402f1e4ee78512be9a24717 Mon Sep 17 00:00:00 2001 From: zhilong-xu Date: Wed, 24 Nov 2021 11:55:32 +0800 Subject: [PATCH 5/6] pure codeview-alert description --- delfin/drivers/pure/flasharray/pure_flasharray.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/delfin/drivers/pure/flasharray/pure_flasharray.py b/delfin/drivers/pure/flasharray/pure_flasharray.py index c74b3a27f..6d49227f4 100644 --- a/delfin/drivers/pure/flasharray/pure_flasharray.py +++ b/delfin/drivers/pure/flasharray/pure_flasharray.py @@ -147,7 +147,7 @@ def parse_alert(context, alert): constants.Severity.NOT_SPECIFIED) alert_model['category'] = constants.Category.FAULT alert_model['occur_time'] = utils.utcnow_ms() - alert_model['description'] = '({}:{}):{}'.format(alert.get( + alert_model['description'] = '({}:{}): {}'.format(alert.get( consts.PARSE_ALERT_STORAGE_NAME), alert.get(consts.PARSE_ALERT_CONTROLLER_NAME), alert.get(consts.PARSE_ALERT_DESCRIPTION)) From d32286b8b3dd41cfb8e617cd5b5605824a79e334 Mon Sep 17 00:00:00 2001 From: zhilong-xu Date: Thu, 25 Nov 2021 15:31:56 +0800 Subject: [PATCH 6/6] pure codeview-Code indentation --- delfin/drivers/pure/flasharray/pure_flasharray.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/delfin/drivers/pure/flasharray/pure_flasharray.py b/delfin/drivers/pure/flasharray/pure_flasharray.py index 6d49227f4..fb7718f90 100644 --- a/delfin/drivers/pure/flasharray/pure_flasharray.py +++ b/delfin/drivers/pure/flasharray/pure_flasharray.py @@ -67,8 +67,8 @@ def get_storage(self, context): system = int(storage.get('system', consts.DEFAULT_CAPACITY)) snapshots = int(storage.get('snapshots', consts.DEFAULT_CAPACITY)) - total_capacity = raw_capacity - shared_space - system - \ - snapshots + total_capacity =\ + raw_capacity - shared_space - system - snapshots break arrays = self.rest_handler.rest_call(self.rest_handler.REST_ARRAY_URL)