diff --git a/delfin/drivers/hitachi/vsp/rest_handler.py b/delfin/drivers/hitachi/vsp/rest_handler.py index 7d85fc397..5d597f332 100644 --- a/delfin/drivers/hitachi/vsp/rest_handler.py +++ b/delfin/drivers/hitachi/vsp/rest_handler.py @@ -138,9 +138,7 @@ def get_token(self): def login(self): try: - succeed = False - succeed = self.get_device_id() - return succeed + self.get_device_id() except Exception as e: LOG.error("Login error: %s", six.text_type(e)) raise e @@ -170,13 +168,14 @@ def logout(self): def get_device_id(self): try: - succeed = False if self.session is None: self.init_http_head() storage_systems = self.get_system_info() system_info = storage_systems.get('data') for system in system_info: - succeed = True + self.storage_device_id = system.get('storageDeviceId') + self.device_model = system.get('model') + self.serial_number = system.get('serialNumber') if system.get('svpIp'): if system.get('svpIp') == self.rest_host: self.storage_device_id = system.get('storageDeviceId') @@ -190,8 +189,10 @@ def get_device_id(self): self.serial_number = system.get('serialNumber') break if self.storage_device_id is None: - LOG.error("Get device id fail,model or something is wrong") - return succeed + error_msg = f'Get device id fail,' \ + f'system info:{storage_systems}' + LOG.error(error_msg) + raise exception.StorageBackendException(error_msg) except Exception as e: LOG.error("Get device id error: %s", six.text_type(e)) raise e diff --git a/delfin/drivers/ibm/storwize_svc/ssh_handler.py b/delfin/drivers/ibm/storwize_svc/ssh_handler.py index eda47b434..7f00bed35 100644 --- a/delfin/drivers/ibm/storwize_svc/ssh_handler.py +++ b/delfin/drivers/ibm/storwize_svc/ssh_handler.py @@ -62,6 +62,14 @@ class SSHHandler(object): 'fc': constants.DiskPhysicalType.FC, 'sas_direct': constants.DiskPhysicalType.SAS } + DISK_STATUS_MAP = { + 'online': constants.DiskStatus.NORMAL, + 'offline': constants.DiskStatus.OFFLINE, + 'excluded': constants.DiskStatus.ABNORMAL, + 'degraded_paths': constants.DiskStatus.DEGRADED, + 'degraded_ports': constants.DiskStatus.DEGRADED, + 'degraded': constants.DiskStatus.DEGRADED + } VOLUME_PERF_METRICS = { 'readIops': 'ro', 'writeIops': 'wo', @@ -280,6 +288,9 @@ def get_storage(self): 'total_mdisk_capacity')) subscribed_capacity = self.parse_string(storage_map.get( 'virtual_capacity')) + total_capacity = int(free_capacity + used_capacity) + if total_capacity > raw_capacity: + raw_capacity = total_capacity firmware_version = '' if storage_map.get('code_level') is not None: firmware_version = storage_map.get('code_level').split(' ')[0] @@ -291,7 +302,7 @@ def get_storage(self): 'serial_number': serial_number, 'firmware_version': firmware_version, 'location': location, - 'total_capacity': int(free_capacity + used_capacity), + 'total_capacity': total_capacity, 'raw_capacity': int(raw_capacity), 'subscribed_capacity': int(subscribed_capacity), 'used_capacity': int(used_capacity), @@ -544,9 +555,8 @@ def list_disks(self, storage_id): deltail_info = self.exec_ssh_command(detail_command) disk_map = {} self.handle_detail(deltail_info, disk_map, split=' ') - status = constants.DiskStatus.NORMAL - if disk_map.get('status') == 'offline': - status = constants.DiskStatus.OFFLINE + status = SSHHandler.DISK_STATUS_MAP.get( + disk_map.get('status'), constants.DiskStatus.ABNORMAL) physical_type = SSHHandler.DISK_PHYSICAL_TYPE.get( disk_map.get('fabric_type'), constants.DiskPhysicalType.UNKNOWN) @@ -806,8 +816,9 @@ def count_metric_data(last_data, now_data, interval, target, metric_type, value = value / interval / units.Mi elif 'IOSIZE' in metric_type.upper(): value = value / units.Ki - elif 'IOPS' in metric_type.upper() or 'RESPONSETIME' \ - in metric_type.upper(): + elif 'IOPS' in metric_type.upper(): + value = int(value / interval) + elif 'RESPONSETIME' in metric_type.upper(): value = value / interval value = round(value, 3) if metric_map.get(res_id): @@ -929,12 +940,12 @@ def package_xml_data(file_data, file_time, resource_type): rht = 0 wht = 0 if resource_type == constants.ResourceType.PORT: - rb = int(file_data.get('cbr')) + int(file_data.get('hbr')) + int( + rb = (int(file_data.get('cbr')) + int(file_data.get('hbr')) + int( file_data.get('lnbr')) + int( - file_data.get('rmbr')) * SSHHandler.BYTES_TO_BIT - wb = int(file_data.get('cbt')) + int(file_data.get('hbt')) + int( + file_data.get('rmbr'))) * SSHHandler.BYTES_TO_BIT + wb = (int(file_data.get('cbt')) + int(file_data.get('hbt')) + int( file_data.get('lnbt')) + int( - file_data.get('rmbt')) * SSHHandler.BYTES_TO_BIT + file_data.get('rmbt'))) * SSHHandler.BYTES_TO_BIT ro = int(file_data.get('cer')) + int(file_data.get('her')) + int( file_data.get('lner')) + int(file_data.get('rmer')) wo = int(file_data.get('cet')) + int(file_data.get('het')) + int( diff --git a/delfin/tests/unit/drivers/ibm/storwize_svc/test_ibm_storwize_svc.py b/delfin/tests/unit/drivers/ibm/storwize_svc/test_ibm_storwize_svc.py index 0aecc2fb1..67f1be9c1 100644 --- a/delfin/tests/unit/drivers/ibm/storwize_svc/test_ibm_storwize_svc.py +++ b/delfin/tests/unit/drivers/ibm/storwize_svc/test_ibm_storwize_svc.py @@ -364,7 +364,7 @@ def __init__(self): 'firmware_version': '7.4.0.11', 'location': 'local', 'total_capacity': 8961019766374, - 'raw_capacity': 8906044184985, + 'raw_capacity': 8961019766374, 'subscribed_capacity': 0, 'used_capacity': 5552533720268, 'free_capacity': 3408486046105