From 121caad6031d9df99730e64d0f771a2254ef16de Mon Sep 17 00:00:00 2001 From: tanjy Date: Tue, 25 Jan 2022 11:42:39 +0800 Subject: [PATCH 1/5] vsp change disk status --- delfin/drivers/hitachi/vsp/vsp_stor.py | 15 ++++++++++++--- .../drivers/hitachi/vsp/test_hitachi_vspstor.py | 8 ++++---- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/delfin/drivers/hitachi/vsp/vsp_stor.py b/delfin/drivers/hitachi/vsp/vsp_stor.py index f9f554813..8619f5f6d 100644 --- a/delfin/drivers/hitachi/vsp/vsp_stor.py +++ b/delfin/drivers/hitachi/vsp/vsp_stor.py @@ -64,6 +64,16 @@ class HitachiVspDriver(driver.StorageDriver): "HNASS": constants.PortType.OTHER, "HNASU": constants.PortType.OTHER } + DISK_STATUS_TYPE = {"NML": constants.DiskStatus.NORMAL, + "CPY": constants.DiskStatus.NORMAL, + "CPI": constants.DiskStatus.NORMAL, + "RSV": constants.DiskStatus.NORMAL, + "FAI": constants.DiskStatus.ABNORMAL, + "BLK": constants.DiskStatus.ABNORMAL, + "WAR": constants.DiskStatus.ABNORMAL, + "UNK": constants.DiskStatus.ABNORMAL, + "Unknown": constants.DiskStatus.ABNORMAL + } TIME_PATTERN = '%Y-%m-%dT%H:%M:%S' AUTO_PORT_SPEED = 8 * units.Gi @@ -359,9 +369,8 @@ def list_disks(self, context): if disks is not None: disk_entries = disks.get('data') for disk in disk_entries: - status = constants.DiskStatus.ABNORMAL - if disk.get('status' == 'NML'): - status = constants.DiskStatus.NORMAL + status = HitachiVspDriver.DISK_STATUS_TYPE.get( + disk.get('status'), constants.DiskStatus.NORMAL) physical_type = \ HitachiVspDriver.DISK_PHYSICAL_TYPE_MAP.get( disk.get('driveTypeName'), diff --git a/delfin/tests/unit/drivers/hitachi/vsp/test_hitachi_vspstor.py b/delfin/tests/unit/drivers/hitachi/vsp/test_hitachi_vspstor.py index 52df5aaef..dc1f58ce5 100644 --- a/delfin/tests/unit/drivers/hitachi/vsp/test_hitachi_vspstor.py +++ b/delfin/tests/unit/drivers/hitachi/vsp/test_hitachi_vspstor.py @@ -327,7 +327,7 @@ def __init__(self): 'serial_number': '123456789012345678901', 'speed': 10000, 'capacity': 644245094400, - 'status': 'abnormal', + 'status': 'normal', 'physical_type': 'sas', 'logical_type': 'member', 'native_disk_group_id': '1-6', @@ -339,7 +339,7 @@ def __init__(self): 'serial_number': '123456789012345678902', 'speed': 10000, 'capacity': 644245094400, - 'status': 'abnormal', + 'status': 'normal', 'physical_type': 'sas', 'logical_type': 'member', 'native_disk_group_id': '1-6', @@ -351,7 +351,7 @@ def __init__(self): 'serial_number': '123456789012345678903', 'speed': 10000, 'capacity': 644245094400, - 'status': 'abnormal', + 'status': 'normal', 'physical_type': 'sas', 'logical_type': 'member', 'native_disk_group_id': '1-6', @@ -363,7 +363,7 @@ def __init__(self): 'serial_number': '123456789012345678904', 'speed': 10000, 'capacity': 644245094400, - 'status': 'abnormal', + 'status': 'normal', 'physical_type': 'sas', 'logical_type': 'member', 'native_disk_group_id': '1-6', From c7512ccaa2182b653c499b7fc36346e2c92df0d3 Mon Sep 17 00:00:00 2001 From: tanjy Date: Tue, 25 Jan 2022 12:12:01 +0800 Subject: [PATCH 2/5] vsp change disk status --- delfin/drivers/hitachi/vsp/vsp_stor.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/delfin/drivers/hitachi/vsp/vsp_stor.py b/delfin/drivers/hitachi/vsp/vsp_stor.py index 8619f5f6d..631ed9d44 100644 --- a/delfin/drivers/hitachi/vsp/vsp_stor.py +++ b/delfin/drivers/hitachi/vsp/vsp_stor.py @@ -71,8 +71,8 @@ class HitachiVspDriver(driver.StorageDriver): "FAI": constants.DiskStatus.ABNORMAL, "BLK": constants.DiskStatus.ABNORMAL, "WAR": constants.DiskStatus.ABNORMAL, - "UNK": constants.DiskStatus.ABNORMAL, - "Unknown": constants.DiskStatus.ABNORMAL + "UNK": constants.DiskStatus.NORMAL, + "Unknown": constants.DiskStatus.NORMAL } TIME_PATTERN = '%Y-%m-%dT%H:%M:%S' From 991dc641e09b7176e684c4b8204137d09f8390e9 Mon Sep 17 00:00:00 2001 From: tanjy Date: Tue, 25 Jan 2022 12:23:31 +0800 Subject: [PATCH 3/5] vsp change disk status --- delfin/drivers/hitachi/vsp/vsp_stor.py | 1 - 1 file changed, 1 deletion(-) diff --git a/delfin/drivers/hitachi/vsp/vsp_stor.py b/delfin/drivers/hitachi/vsp/vsp_stor.py index 631ed9d44..d4d47d5f0 100644 --- a/delfin/drivers/hitachi/vsp/vsp_stor.py +++ b/delfin/drivers/hitachi/vsp/vsp_stor.py @@ -74,7 +74,6 @@ class HitachiVspDriver(driver.StorageDriver): "UNK": constants.DiskStatus.NORMAL, "Unknown": constants.DiskStatus.NORMAL } - TIME_PATTERN = '%Y-%m-%dT%H:%M:%S' AUTO_PORT_SPEED = 8 * units.Gi From 7208a005479465d042d2f509923aa456457aa440 Mon Sep 17 00:00:00 2001 From: tanjy Date: Tue, 25 Jan 2022 16:43:09 +0800 Subject: [PATCH 4/5] vsp change disk status --- delfin/drivers/hitachi/vsp/rest_handler.py | 34 +++++++++++++++++++ delfin/drivers/hitachi/vsp/vsp_stor.py | 14 +++++--- .../hitachi/vsp/test_hitachi_vspstor.py | 4 +-- 3 files changed, 46 insertions(+), 6 deletions(-) diff --git a/delfin/drivers/hitachi/vsp/rest_handler.py b/delfin/drivers/hitachi/vsp/rest_handler.py index 55e34fc0b..ff5a465ea 100644 --- a/delfin/drivers/hitachi/vsp/rest_handler.py +++ b/delfin/drivers/hitachi/vsp/rest_handler.py @@ -261,3 +261,37 @@ def get_alerts(self, param, start, end): param, start, end) result_json = self.get_rest_info(url) return result_json + + def get_all_host_groups(self): + url = '%s/%s/host-groups' % \ + (RestHandler.COMM_URL, self.storage_device_id) + result_json = self.get_rest_info(url) + return result_json + + def get_specific_host_group(self, group_id): + url = '%s/%s/host-groups/%s' % \ + (RestHandler.COMM_URL, self.storage_device_id, group_id) + result_json = self.get_rest_info(url) + return result_json + + def get_host_wwn(self, port_id, group_number): + url = '%s/%s/host-wwns?portId=%s&hostGroupNumber=%s' % \ + (RestHandler.COMM_URL, self.storage_device_id, port_id, + group_number) + result_json = self.get_rest_info(url) + return result_json + + def get_iscsi_name(self, port_id, group_number): + url = '%s/%s/host-iscsis?portId=%s&hostGroupNumber=%s' % \ + (RestHandler.COMM_URL, self.storage_device_id, port_id, + group_number) + result_json = self.get_rest_info(url) + return result_json + + def get_lun_path(self, port_id, group_number): + url = '%s/%s/luns?portId=%s&hostGroupNumber=%s&' \ + 'isBasicLunInformation=true' % \ + (RestHandler.COMM_URL, self.storage_device_id, port_id, + group_number) + 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 d4d47d5f0..82bcdfb92 100644 --- a/delfin/drivers/hitachi/vsp/vsp_stor.py +++ b/delfin/drivers/hitachi/vsp/vsp_stor.py @@ -370,10 +370,16 @@ def list_disks(self, context): for disk in disk_entries: status = HitachiVspDriver.DISK_STATUS_TYPE.get( disk.get('status'), constants.DiskStatus.NORMAL) - physical_type = \ - HitachiVspDriver.DISK_PHYSICAL_TYPE_MAP.get( - disk.get('driveTypeName'), - constants.DiskPhysicalType.UNKNOWN) + if disk.get('driveTypeName'): + type_name = 'SSD' if 'SSD' in \ + disk.get('driveTypeName').upper()\ + else disk.get('driveTypeName') + physical_type = \ + HitachiVspDriver.DISK_PHYSICAL_TYPE_MAP.get( + type_name, + constants.DiskPhysicalType.UNKNOWN) + else: + physical_type = constants.DiskPhysicalType.UNKNOWN logical_type = HitachiVspDriver.DISK_LOGIC_TYPE_MAP.get( disk.get('usageType'), constants.DiskLogicalType.UNKNOWN) diff --git a/delfin/tests/unit/drivers/hitachi/vsp/test_hitachi_vspstor.py b/delfin/tests/unit/drivers/hitachi/vsp/test_hitachi_vspstor.py index dc1f58ce5..e235501ac 100644 --- a/delfin/tests/unit/drivers/hitachi/vsp/test_hitachi_vspstor.py +++ b/delfin/tests/unit/drivers/hitachi/vsp/test_hitachi_vspstor.py @@ -146,7 +146,7 @@ def __init__(self): "data": [ { "driveLocationId": "0-0", - "driveTypeName": "SAS", + "driveTypeName": "SSD(FMC)", "driveSpeed": 10000, "totalCapacity": 600, "driveType": "DKR5D-J600SS", @@ -328,7 +328,7 @@ def __init__(self): 'speed': 10000, 'capacity': 644245094400, 'status': 'normal', - 'physical_type': 'sas', + 'physical_type': 'ssd', 'logical_type': 'member', 'native_disk_group_id': '1-6', 'location': '0-0' From 183d0be9bb44546ea1b856b14880b53031b86411 Mon Sep 17 00:00:00 2001 From: tanjy Date: Thu, 10 Feb 2022 16:24:48 +0800 Subject: [PATCH 5/5] vsp change disk status --- delfin/drivers/hitachi/vsp/rest_handler.py | 34 ---------------------- 1 file changed, 34 deletions(-) diff --git a/delfin/drivers/hitachi/vsp/rest_handler.py b/delfin/drivers/hitachi/vsp/rest_handler.py index ff5a465ea..55e34fc0b 100644 --- a/delfin/drivers/hitachi/vsp/rest_handler.py +++ b/delfin/drivers/hitachi/vsp/rest_handler.py @@ -261,37 +261,3 @@ def get_alerts(self, param, start, end): param, start, end) result_json = self.get_rest_info(url) return result_json - - def get_all_host_groups(self): - url = '%s/%s/host-groups' % \ - (RestHandler.COMM_URL, self.storage_device_id) - result_json = self.get_rest_info(url) - return result_json - - def get_specific_host_group(self, group_id): - url = '%s/%s/host-groups/%s' % \ - (RestHandler.COMM_URL, self.storage_device_id, group_id) - result_json = self.get_rest_info(url) - return result_json - - def get_host_wwn(self, port_id, group_number): - url = '%s/%s/host-wwns?portId=%s&hostGroupNumber=%s' % \ - (RestHandler.COMM_URL, self.storage_device_id, port_id, - group_number) - result_json = self.get_rest_info(url) - return result_json - - def get_iscsi_name(self, port_id, group_number): - url = '%s/%s/host-iscsis?portId=%s&hostGroupNumber=%s' % \ - (RestHandler.COMM_URL, self.storage_device_id, port_id, - group_number) - result_json = self.get_rest_info(url) - return result_json - - def get_lun_path(self, port_id, group_number): - url = '%s/%s/luns?portId=%s&hostGroupNumber=%s&' \ - 'isBasicLunInformation=true' % \ - (RestHandler.COMM_URL, self.storage_device_id, port_id, - group_number) - result_json = self.get_rest_info(url) - return result_json