From b08035aeaa950a593c44a47d8378e827543c1e1b Mon Sep 17 00:00:00 2001 From: tanjy Date: Thu, 30 Dec 2021 17:32:13 +0800 Subject: [PATCH 1/3] vsp add alerts get --- delfin/drivers/hitachi/vsp/rest_handler.py | 7 +++++++ delfin/drivers/hitachi/vsp/vsp_stor.py | 17 ++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/delfin/drivers/hitachi/vsp/rest_handler.py b/delfin/drivers/hitachi/vsp/rest_handler.py index c3c864e1c..55e34fc0b 100644 --- a/delfin/drivers/hitachi/vsp/rest_handler.py +++ b/delfin/drivers/hitachi/vsp/rest_handler.py @@ -254,3 +254,10 @@ def get_detail_ports(self, port_id): (RestHandler.COMM_URL, self.storage_device_id, port_id) result_json = self.get_rest_info(url) return result_json + + def get_alerts(self, param, start, end): + url = '%s/%s/alerts?%s&start=%s&count=%s' % (RestHandler.COMM_URL, + self.storage_device_id, + param, start, end) + result_json = self.get_rest_info(url) + return result_json diff --git a/delfin/drivers/hitachi/vsp/vsp_stor.py b/delfin/drivers/hitachi/vsp/vsp_stor.py index 8da2dd336..07612de1d 100644 --- a/delfin/drivers/hitachi/vsp/vsp_stor.py +++ b/delfin/drivers/hitachi/vsp/vsp_stor.py @@ -75,6 +75,9 @@ class HitachiVspDriver(driver.StorageDriver): TRAP_NICKNAME_OID = '1.3.6.1.4.1.116.5.11.4.2.2' OID_SEVERITY = '1.3.6.1.6.3.1.1.4.1.0' SECONDS_TO_MS = 1000 + ALERT_START = 1 + CTL_ALERT_COUNT = 255 + DKC_ALERT_COUNT = 10239 def __init__(self, **kwargs): super().__init__(**kwargs) @@ -389,6 +392,8 @@ def list_disks(self, context): @staticmethod def parse_queried_alerts(alerts, alert_list, query_para=None): + if not alerts: + return for alert in alerts: occur_time = int(time.mktime(time.strptime( alert.get('occurenceTime'), @@ -417,9 +422,15 @@ def parse_queried_alerts(alerts, alert_list, query_para=None): def list_alerts(self, context, query_para=None): alert_list = [] if self.rest_handler.device_model in consts.SUPPORTED_VSP_SERIES: - alerts_info_ctl1 = self.resthanlder.get_alerts('type=CTL1') - alerts_info_ctl2 = self.resthanlder.get_alerts('type=CTL2') - alerts_info_dkc = self.resthanlder.get_alerts('type=DKC') + alerts_info_ctl1 = self.resthanlder.get_alerts( + 'type=CTL1', HitachiVspDriver.ALERT_START, + HitachiVspDriver.CTL_ALERT_COUNT) + alerts_info_ctl2 = self.resthanlder.get_alerts( + 'type=CTL2', HitachiVspDriver.ALERT_START, + HitachiVspDriver.CTL_ALERT_COUNT) + alerts_info_dkc = self.resthanlder.get_alerts( + 'type=DKC', HitachiVspDriver.ALERT_START, + HitachiVspDriver.DKC_ALERT_COUNT) HitachiVspDriver.parse_queried_alerts(alerts_info_ctl1, alert_list, query_para) HitachiVspDriver.parse_queried_alerts(alerts_info_ctl2, From dce29b570041d9d8909a0f0fba5fda862510da93 Mon Sep 17 00:00:00 2001 From: tanjy Date: Thu, 30 Dec 2021 17:39:12 +0800 Subject: [PATCH 2/3] vsp add alerts get --- delfin/drivers/hitachi/vsp/vsp_stor.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/delfin/drivers/hitachi/vsp/vsp_stor.py b/delfin/drivers/hitachi/vsp/vsp_stor.py index 07612de1d..c1aa53091 100644 --- a/delfin/drivers/hitachi/vsp/vsp_stor.py +++ b/delfin/drivers/hitachi/vsp/vsp_stor.py @@ -374,8 +374,9 @@ def list_disks(self, context): 'storage_id': self.storage_id, 'native_disk_id': disk.get('driveLocationId'), 'serial_number': disk.get('serialNumber'), - 'speed': int(disk.get('driveSpeed')), - 'capacity': int(disk.get('totalCapacity') * units.Gi), + 'speed': int(disk.get('driveSpeed', 0)), + 'capacity': + int(disk.get('totalCapacity', 0)) * units.Gi, 'status': status, 'physical_type': physical_type, 'logical_type': logical_type, From e4edb8a1b7cef25aef9995e0fd58b34769c03862 Mon Sep 17 00:00:00 2001 From: tanjy Date: Thu, 30 Dec 2021 18:01:16 +0800 Subject: [PATCH 3/3] vsp add alerts get --- delfin/drivers/hitachi/vsp/vsp_stor.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/delfin/drivers/hitachi/vsp/vsp_stor.py b/delfin/drivers/hitachi/vsp/vsp_stor.py index c1aa53091..f9f554813 100644 --- a/delfin/drivers/hitachi/vsp/vsp_stor.py +++ b/delfin/drivers/hitachi/vsp/vsp_stor.py @@ -423,13 +423,13 @@ def parse_queried_alerts(alerts, alert_list, query_para=None): def list_alerts(self, context, query_para=None): alert_list = [] if self.rest_handler.device_model in consts.SUPPORTED_VSP_SERIES: - alerts_info_ctl1 = self.resthanlder.get_alerts( + alerts_info_ctl1 = self.rest_handler.get_alerts( 'type=CTL1', HitachiVspDriver.ALERT_START, HitachiVspDriver.CTL_ALERT_COUNT) - alerts_info_ctl2 = self.resthanlder.get_alerts( + alerts_info_ctl2 = self.rest_handler.get_alerts( 'type=CTL2', HitachiVspDriver.ALERT_START, HitachiVspDriver.CTL_ALERT_COUNT) - alerts_info_dkc = self.resthanlder.get_alerts( + alerts_info_dkc = self.rest_handler.get_alerts( 'type=DKC', HitachiVspDriver.ALERT_START, HitachiVspDriver.DKC_ALERT_COUNT) HitachiVspDriver.parse_queried_alerts(alerts_info_ctl1,