Skip to content

Commit

Permalink
svc do some optimize (#932)
Browse files Browse the repository at this point in the history
  • Loading branch information
tanjiangyu-ghca authored Oct 28, 2022
1 parent f5b25eb commit 996ff13
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
31 changes: 21 additions & 10 deletions delfin/drivers/ibm/storwize_svc/ssh_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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]
Expand All @@ -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),
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 996ff13

Please sign in to comment.