Skip to content

Commit

Permalink
Merge pull request sodafoundation#787 from gh-ca/vsp_1230
Browse files Browse the repository at this point in the history
vsp add alerts get
  • Loading branch information
joseph-v authored Jan 5, 2022
2 parents 92919b8 + 42041db commit 8332cd7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
7 changes: 7 additions & 0 deletions delfin/drivers/hitachi/vsp/rest_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,3 +254,10 @@ def get_detail_ports(self, port_id):
(RestHandler.COMM_URL, self.storage_device_id, port_id)
result_json = self.get_rest_info(url)
return result_json

def get_alerts(self, param, start, end):
url = '%s/%s/alerts?%s&start=%s&count=%s' % (RestHandler.COMM_URL,
self.storage_device_id,
param, start, end)
result_json = self.get_rest_info(url)
return result_json
22 changes: 17 additions & 5 deletions delfin/drivers/hitachi/vsp/vsp_stor.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ class HitachiVspDriver(driver.StorageDriver):
TRAP_NICKNAME_OID = '1.3.6.1.4.1.116.5.11.4.2.2'
OID_SEVERITY = '1.3.6.1.6.3.1.1.4.1.0'
SECONDS_TO_MS = 1000
ALERT_START = 1
CTL_ALERT_COUNT = 255
DKC_ALERT_COUNT = 10239

def __init__(self, **kwargs):
super().__init__(**kwargs)
Expand Down Expand Up @@ -371,8 +374,9 @@ def list_disks(self, context):
'storage_id': self.storage_id,
'native_disk_id': disk.get('driveLocationId'),
'serial_number': disk.get('serialNumber'),
'speed': int(disk.get('driveSpeed')),
'capacity': int(disk.get('totalCapacity') * units.Gi),
'speed': int(disk.get('driveSpeed', 0)),
'capacity':
int(disk.get('totalCapacity', 0)) * units.Gi,
'status': status,
'physical_type': physical_type,
'logical_type': logical_type,
Expand All @@ -389,6 +393,8 @@ def list_disks(self, context):

@staticmethod
def parse_queried_alerts(alerts, alert_list, query_para=None):
if not alerts:
return
for alert in alerts:
occur_time = int(time.mktime(time.strptime(
alert.get('occurenceTime'),
Expand Down Expand Up @@ -417,9 +423,15 @@ def parse_queried_alerts(alerts, alert_list, query_para=None):
def list_alerts(self, context, query_para=None):
alert_list = []
if self.rest_handler.device_model in consts.SUPPORTED_VSP_SERIES:
alerts_info_ctl1 = self.resthanlder.get_alerts('type=CTL1')
alerts_info_ctl2 = self.resthanlder.get_alerts('type=CTL2')
alerts_info_dkc = self.resthanlder.get_alerts('type=DKC')
alerts_info_ctl1 = self.rest_handler.get_alerts(
'type=CTL1', HitachiVspDriver.ALERT_START,
HitachiVspDriver.CTL_ALERT_COUNT)
alerts_info_ctl2 = self.rest_handler.get_alerts(
'type=CTL2', HitachiVspDriver.ALERT_START,
HitachiVspDriver.CTL_ALERT_COUNT)
alerts_info_dkc = self.rest_handler.get_alerts(
'type=DKC', HitachiVspDriver.ALERT_START,
HitachiVspDriver.DKC_ALERT_COUNT)
HitachiVspDriver.parse_queried_alerts(alerts_info_ctl1,
alert_list, query_para)
HitachiVspDriver.parse_queried_alerts(alerts_info_ctl2,
Expand Down

0 comments on commit 8332cd7

Please sign in to comment.