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

change pool status and some optimize for vsp #395

Merged
merged 11 commits into from
Nov 28, 2020
2 changes: 1 addition & 1 deletion delfin/drivers/hitachi/vsp/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
ERROR_SESSION_INVALID_CODE = 403
ERROR_SESSION_IS_BEING_USED_CODE = 409
BLOCK_SIZE = 512

MAX_LDEV_NUMBER_OF_RESTAPI = 16383
SUPPORTED_VSP_SERIES = ('VSP G350', 'VSP G370', 'VSP G700', 'VSP G900',
'VSP F350', 'VSP F370', 'VSP F700', 'VSP F900')
9 changes: 5 additions & 4 deletions delfin/drivers/hitachi/vsp/rest_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def call(self, url, data=None, method=None):
except Exception as e:
err_msg = "Get RestHandler.call failed: %s" % (six.text_type(e))
LOG.error(err_msg)
raise exception.InvalidResults(err_msg)
raise e

def get_rest_info(self, url, data=None):
result_json = None
Expand Down Expand Up @@ -109,7 +109,7 @@ def login(self):
LOG.error("Login error. URL: %(url)s\n"
"Reason: %(reason)s.",
{"url": url, "reason": res.text})
if 'invalid username or password' in res.text:
if 'authentication failed' in res.text:
raise exception.InvalidUsernameOrPassword()
else:
raise exception.BadResponse(res.text)
Expand Down Expand Up @@ -192,8 +192,9 @@ def get_all_pools(self):
return result_json

def get_all_volumes(self):
url = '%s/%s/ldevs' % \
(RestHandler.COMM_URL, self.storage_device_id)
url = '%s/%s/ldevs?ldevOption=defined&count=%s' % \
(RestHandler.COMM_URL, self.storage_device_id,
consts.MAX_LDEV_NUMBER_OF_RESTAPI)
result_json = self.get_rest_info(url)
return result_json

Expand Down
26 changes: 18 additions & 8 deletions delfin/drivers/hitachi/vsp/vsp_stor.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

class HitachiVspDriver(driver.StorageDriver):
POOL_STATUS_MAP = {"POLN": constants.StoragePoolStatus.NORMAL,
"POLF": constants.StoragePoolStatus.ABNORMAL,
"POLF": constants.StoragePoolStatus.NORMAL,
"POLS": constants.StoragePoolStatus.ABNORMAL,
"POLE": constants.StoragePoolStatus.OFFLINE
}
Expand All @@ -38,6 +38,12 @@ class HitachiVspDriver(driver.StorageDriver):
"Moderate": constants.Severity.WARNING,
"Service": constants.Severity.INFORMATIONAL
}
TRAP_ALERT_LEVEL_MAP = {
"1.3.6.1.4.1.116.3.11.4.1.1.0.1": constants.Severity.CRITICAL,
"1.3.6.1.4.1.116.3.11.4.1.1.0.2": constants.Severity.MAJOR,
"1.3.6.1.4.1.116.3.11.4.1.1.0.3": constants.Severity.WARNING,
"1.3.6.1.4.1.116.3.11.4.1.1.0.4": constants.Severity.INFORMATIONAL
}

TIME_PATTERN = '%Y-%m-%dT%H:%M:%S'

Expand All @@ -47,6 +53,7 @@ class HitachiVspDriver(driver.StorageDriver):
TRAP_DATE_OID = '1.3.6.1.4.1.116.5.11.4.2.5'
TRAP_NICKNAME_OID = '1.3.6.1.4.1.116.5.11.4.2.2'
LOCATION_OID = '1.3.6.1.4.1.116.5.11.4.2.4'
OID_SEVERITY = '1.3.6.1.6.3.1.1.4.1.0'
SECONDS_TO_MS = 1000

def __init__(self, **kwargs):
Expand Down Expand Up @@ -131,7 +138,6 @@ def list_storage_pools(self, context):
'description': 'Hitachi VSP Pool',
'status': status,
'storage_type': storage_type,
'subscribed_capacity': int(total_cap),
'total_capacity': int(total_cap),
'used_capacity': int(used_cap),
'free_capacity': int(free_cap),
Expand Down Expand Up @@ -237,7 +243,7 @@ def parse_queried_alerts(alerts, alert_list, query_para=None):
'alert_name': alert.get('errorSection'),
'resource_type': constants.DEFAULT_RESOURCE_TYPE,
'occur_time': occur_time,
'category': 'Fault',
'category': constants.Category.FAULT,
'type': constants.EventType.EQUIPMENT_ALARM,
'severity': HitachiVspDriver.ALERT_LEVEL_MAP.get(
alert.get('errorLevel'),
Expand Down Expand Up @@ -273,12 +279,16 @@ def parse_alert(context, alert):
alert_model = dict()
alert_model['alert_id'] = alert.get(HitachiVspDriver.REFCODE_OID)
alert_model['alert_name'] = alert.get(HitachiVspDriver.DESC_OID)
alert_model['severity'] = constants.Severity.INFORMATIONAL
alert_model['category'] = constants.Category.NOT_SPECIFIED
severity = HitachiVspDriver.TRAP_ALERT_LEVEL_MAP.get(
alert.get(HitachiVspDriver.OID_SEVERITY),
constants.Severity.INFORMATIONAL
)
alert_model['severity'] = severity
alert_model['category'] = constants.Category.FAULT
alert_model['type'] = constants.EventType.EQUIPMENT_ALARM
aler_time = '%s %s' % (alert.get(HitachiVspDriver.TRAP_DATE_OID),
alert.get(HitachiVspDriver.TRAP_TIME_OID))
pattern = '%Y-%m-%d %H:%M:%S'
aler_time = '%s%s' % (alert.get(HitachiVspDriver.TRAP_DATE_OID),
alert.get(HitachiVspDriver.TRAP_TIME_OID))
pattern = '%Y/%m/%d%H:%M:%S'
occur_time = time.strptime(aler_time, pattern)
alert_model['occur_time'] = int(time.mktime(occur_time) *
HitachiVspDriver.SECONDS_TO_MS)
Expand Down
4 changes: 2 additions & 2 deletions delfin/drivers/utils/ssh_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def do_exec(self, command_str):
raise exception.SSHConnectTimeout()
elif 'No authentication methods available' in str(e) \
or 'Authentication failed' in str(e):
raise exception.SSHInvalidUsernameOrPassword()
raise exception.InvalidUsernameOrPassword()
elif 'not a valid RSA private key file' in str(e):
raise exception.InvalidPrivateKey()
elif 'not found in known_hosts' in str(e):
Expand Down Expand Up @@ -196,7 +196,7 @@ def create(self):
raise exception.SSHConnectTimeout()
elif 'No authentication methods available' in err \
or 'Authentication failed' in err:
raise exception.SSHInvalidUsernameOrPassword()
raise exception.InvalidUsernameOrPassword()
elif 'not a valid RSA private key file' in err:
raise exception.InvalidPrivateKey()
elif 'not found in known_hosts' in err:
Expand Down
5 changes: 0 additions & 5 deletions delfin/exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,6 @@ class SSHConnectTimeout(DelfinException):
code = 500


class SSHInvalidUsernameOrPassword(DelfinException):
msg_fmt = _("SSH invalid username or password.")
code = 400


class SSHNotFoundKnownHosts(NotFound):
msg_fmt = _("{0} not found in known_hosts.")
code = 400
Expand Down
4 changes: 2 additions & 2 deletions delfin/tests/unit/drivers/hitachi/vsp/test_hitachi_vspstor.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,11 @@ def __init__(self):
}
TRAP_INFO = {
"1.3.6.1.2.1.1.3.0": "0",
'1.3.6.1.6.3.1.1.4.1.0': '1.3.6.1.4.1.2.6.190.3',
'1.3.6.1.6.3.1.1.4.1.0': '1.3.6.1.4.1.116.3.11.4.1.1.0.1',
'1.3.6.1.4.1.116.5.11.4.2.3': 'eeeeeeeee',
'1.3.6.1.4.1.116.5.11.4.2.7': 'ddddddd',
'1.3.6.1.4.1.116.5.11.4.2.6': '14:10:10',
'1.3.6.1.4.1.116.5.11.4.2.5': '2020-11-20',
'1.3.6.1.4.1.116.5.11.4.2.5': '2020/11/20',
'1.3.6.1.4.1.116.5.11.4.2.2': ' System Version = 7.4.0.11 ',
'1.3.6.1.4.1.116.5.11.4.2.4': '# FRU = None '
}
Expand Down