Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix ssh excption error when the port is wrong and do some optimize #402

Merged
merged 20 commits into from
Dec 1, 2020
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
bf50dc4
edit
jiangyutan Nov 2, 2020
770cc02
过滤rest警告
jiangyutan Nov 2, 2020
bc9b126
add vnx block driver
yuanyu-ghca Nov 6, 2020
0e7b702
Add storage driver for IBM Storwize and svc series
jiangyutan Nov 6, 2020
32b4000
Merge pull request #1 from sodafoundation/v0.8.0-maint
jiangyutan Nov 23, 2020
a9a9637
Merge pull request #3 from sodafoundation/v0.8.0-maint
jiangyutan Nov 25, 2020
f124585
synchronization soda
yuanyu-ghca Nov 27, 2020
974050a
Merge branch 'ibm' into v0.8.0-maint
jiangyutan Nov 27, 2020
aacc227
Merge pull request #8 from jiangyutan/v0.8.0-maint
jiangyutan Nov 27, 2020
353b03a
change SSHInvalidUsernameOrPassword with InvalidUsernameOrPassword an…
jiangyutan Nov 27, 2020
4eb0570
fix parse trap alert
jiangyutan Nov 27, 2020
5d6492b
fix parse trap alert
jiangyutan Nov 27, 2020
958870c
change alert default Category
jiangyutan Nov 27, 2020
eb8c0fa
Merge pull request #10 from sodafoundation/v0.8.0-maint
jiangyutan Nov 28, 2020
0eb3dff
Merge pull request #12 from sodafoundation/v0.8.0-maint
jiangyutan Dec 1, 2020
1e1d29a
fix ssh excption error when the port is wrong and do some optimize
jiangyutan Dec 1, 2020
2569d22
fix ssh excption error when the port is wrong and do some optimize
jiangyutan Dec 1, 2020
cfcd828
fix ssh excption error when the port is wrong and do some optimize
jiangyutan Dec 1, 2020
86013a7
fix ssh excption error when the port is wrong and do some optimize
jiangyutan Dec 1, 2020
b912a2c
Merge branch 'v0.8.0-maint' into ibm
ThisIsClark Dec 1, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 14 additions & 26 deletions delfin/drivers/ibm/storwize_svc/ssh_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -248,13 +251,16 @@ 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,
'native_storage_pool_id': pool_map.get('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)
Expand Down Expand Up @@ -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 = []
Expand All @@ -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', '')
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion delfin/drivers/utils/ssh_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down