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

Pure Modify alert and storage #319

Merged
merged 6 commits into from
Nov 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 2 additions & 7 deletions delfin/drivers/pure/flasharray/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,5 @@
PARSE_ALERT_DESCRIPTION = '1.3.6.1.4.1.40482.3.6'
PARSE_ALERT_SEVERITY = '1.3.6.1.4.1.40482.3.7'

PARSE_ALERT_SEVERITY_MAP = {'0': constants.Severity.FATAL,
'1': constants.Severity.CRITICAL,
'2': constants.Severity.MAJOR,
'3': constants.Severity.MINOR,
'4': constants.Severity.WARNING,
'5': constants.Severity.INFORMATIONAL,
'6': constants.Severity.NOT_SPECIFIED}
PARSE_ALERT_SEVERITY_MAP = {'1': constants.Severity.WARNING,
'2': constants.Severity.INFORMATIONAL}
29 changes: 21 additions & 8 deletions delfin/drivers/pure/flasharray/pure_flasharray.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,20 @@ def get_storage(self, context):
self.rest_handler.REST_STORAGE_URL)
total_capacity = None
used_capacity = None
raw_capacity = None
if storages:
for storage in storages:
total_capacity = int(storage.get('provisioned',
consts.DEFAULT_CAPACITY))
used_capacity = int(storage.get('volumes',
consts.DEFAULT_CAPACITY))
raw_capacity = int(storage.get('capacity',
consts.DEFAULT_CAPACITY))
shared_space = int(storage.get('shared_space',
consts.DEFAULT_CAPACITY))
system = int(storage.get('system', consts.DEFAULT_CAPACITY))
snapshots = int(storage.get('snapshots',
consts.DEFAULT_CAPACITY))
total_capacity =\
raw_capacity - shared_space - system - snapshots
break

arrays = self.rest_handler.rest_call(self.rest_handler.REST_ARRAY_URL)
Expand Down Expand Up @@ -88,7 +96,7 @@ def get_storage(self, context):
storage_result = {
'model': model,
'total_capacity': total_capacity,
'raw_capacity': total_capacity,
'raw_capacity': raw_capacity,
'used_capacity': used_capacity,
'free_capacity': total_capacity - used_capacity,
'vendor': 'PURE',
Expand All @@ -115,14 +123,17 @@ def list_alerts(self, context, query_para=None):
time, '%Y-%m-%dT%H:%M:%SZ').timestamp()
* consts.DEFAULT_LIST_ALERTS_TIME_CONVERSION) \
if time is not None else None
alerts_model['description'] = alert.get('details')
alerts_model['location'] = alert.get('component_name')
component_name = alert.get('component_name')
alerts_model['location'] = component_name
alerts_model['type'] = constants.EventType.EQUIPMENT_ALARM
alerts_model['resource_type'] = constants.DEFAULT_RESOURCE_TYPE
alerts_model['alert_name'] = alert.get('event')
event = alert.get('event')
alerts_model['alert_name'] = event
alerts_model['sequence_number'] = alert.get('id')
alerts_model['match_key'] = hashlib.md5(str(alert.get('id')).
encode()).hexdigest()
alerts_model['description'] = '({}:{}): {}'.\
format(alert.get('component_type'), component_name, event)
alerts_list.append(alerts_model)
return alerts_list

Expand All @@ -136,8 +147,10 @@ def parse_alert(context, alert):
constants.Severity.NOT_SPECIFIED)
alert_model['category'] = constants.Category.FAULT
alert_model['occur_time'] = utils.utcnow_ms()
alert_model['description'] = alert.get(
consts.PARSE_ALERT_DESCRIPTION)
alert_model['description'] = '({}:{}): {}'.format(alert.get(
consts.PARSE_ALERT_STORAGE_NAME),
alert.get(consts.PARSE_ALERT_CONTROLLER_NAME),
alert.get(consts.PARSE_ALERT_DESCRIPTION))
alert_model['location'] = alert.get(
consts.PARSE_ALERT_CONTROLLER_NAME)
alert_model['type'] = constants.EventType.EQUIPMENT_ALARM
Expand Down