diff --git a/delfin/drivers/ibm/storwize_svc/ssh_handler.py b/delfin/drivers/ibm/storwize_svc/ssh_handler.py index a7f0aab2c..1be7f71f6 100644 --- a/delfin/drivers/ibm/storwize_svc/ssh_handler.py +++ b/delfin/drivers/ibm/storwize_svc/ssh_handler.py @@ -20,7 +20,7 @@ from oslo_utils import units from delfin import exception, utils -from delfin.common import constants +from delfin.common import constants, alert_util from delfin.drivers.utils.ssh_client import SSHPool LOG = logging.getLogger(__name__) @@ -193,13 +193,16 @@ def get_storage(self): 'total_drive_raw_capacity')) subscribed_capacity = self.parse_string(storage_map.get( 'virtual_capacity')) + firmware_version = '' + if storage_map.get('code_level') is not None: + firmware_version = storage_map.get('code_level').split(' ')[0] s = { 'name': storage_map.get('name'), 'vendor': 'IBM', 'model': storage_map.get('product_name'), 'status': status, 'serial_number': serial_number, - 'firmware_version': storage_map.get('code_level'), + 'firmware_version': firmware_version, 'location': location, 'total_capacity': int(free_capacity + used_capacity), 'raw_capacity': int(raw_capacity), @@ -248,6 +251,8 @@ def list_storage_pools(self, storage_id): total_cap = self.parse_string(pool_map.get('capacity')) free_cap = self.parse_string(pool_map.get('free_capacity')) used_cap = self.parse_string(pool_map.get('used_capacity')) + subscribed_capacity = self.parse_string(pool_map.get( + 'virtual_capacity')) p = { 'name': pool_map.get('name'), 'storage_id': storage_id, @@ -255,6 +260,7 @@ def list_storage_pools(self, storage_id): 'description': '', 'status': status, 'storage_type': constants.StorageType.BLOCK, + 'subscribed_capacity': int(subscribed_capacity), 'total_capacity': int(total_cap), 'used_capacity': int(used_cap), 'free_capacity': int(free_cap) @@ -329,25 +335,6 @@ def list_volumes(self, storage_id): LOG.error(err_msg) raise exception.InvalidResults(err_msg) - def judge_alert_time(self, alert_map, query_para): - if len(alert_map) <= 1: - return False - if query_para is None and len(alert_map) > 1: - return True - occur_time = int(alert_map.get('last_timestamp_epoch')) * \ - self.SECONDS_TO_MS - if query_para.get('begin_time') and query_para.get('end_time'): - if occur_time >= int(query_para.get('begin_time')) and \ - occur_time <= int(query_para.get('end_time')): - return True - if query_para.get('begin_time'): - if occur_time >= int(query_para.get('begin_time')): - return True - if query_para.get('end_time'): - if occur_time <= int(query_para.get('end_time')): - return True - return False - def list_alerts(self, query_para): try: alert_list = [] @@ -357,15 +344,16 @@ def list_alerts(self, query_para): if alert_res[i] is None or alert_res[i] == '': continue alert_str = ' '.join(alert_res[i].split()) - strinfo = alert_str.split(' ', 9) + strinfo = alert_str.split(' ', 1) detail_command = 'lseventlog %s' % strinfo[0] deltail_info = self.exec_ssh_command(detail_command) alert_map = {} self.handle_detail(deltail_info, alert_map, split=' ') - if self.judge_alert_time(alert_map, query_para) is False: - continue - time_stamp = int(alert_map.get('last_timestamp_epoch')) * \ + occur_time = int(alert_map.get('last_timestamp_epoch')) * \ self.SECONDS_TO_MS + if not alert_util.is_alert_in_time_range(query_para, + occur_time): + continue alert_name = alert_map.get('event_id_text', '') event_id = alert_map.get('event_id') location = alert_map.get('object_name', '') @@ -380,7 +368,7 @@ def list_alerts(self, query_para): 'category': constants.Category.FAULT, 'type': 'EquipmentAlarm', 'sequence_number': alert_map.get('sequence_number'), - 'occur_time': time_stamp, + 'occur_time': occur_time, 'description': alert_name, 'resource_type': resource_type, 'location': location diff --git a/delfin/drivers/utils/ssh_client.py b/delfin/drivers/utils/ssh_client.py index 4629b583e..bed423938 100644 --- a/delfin/drivers/utils/ssh_client.py +++ b/delfin/drivers/utils/ssh_client.py @@ -193,7 +193,7 @@ def create(self): err = six.text_type(e) LOG.error('doexec InvalidUsernameOrPassword error') if 'timed out' in err: - raise exception.SSHConnectTimeout() + raise exception.InvalidIpOrPort() elif 'No authentication methods available' in err \ or 'Authentication failed' in err: raise exception.InvalidUsernameOrPassword()