Skip to content

Commit

Permalink
delfin 0.8.0 to master (#439)
Browse files Browse the repository at this point in the history
* Code improvement (#363)

* ibm storwize_svc add sshpool and fixed some issue (#381)

Add storage driver for IBM Storwize and svc series

* add hitachi vsp storage driver to community (#388)

Add hitachi vsp driver

* Fix vsp driver issue

* change pool status and some optimize for vsp (#395)

* rest api change timeout and fix trap parse (#401)

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

* Update the value of 'update_at' of storage when going to sync the storage (#425)

* Code improvement (#363)

* ibm storwize_svc add sshpool and fixed some issue (#381)

Add storage driver for IBM Storwize and svc series

* add hitachi vsp storage driver to community (#388)

Add hitachi vsp driver

* Fix vsp driver issue

* change pool status and some optimize for vsp (#395)

* rest api change timeout and fix trap parse (#401)

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

* Update the value of 'update_at' of storage when going to sync the storage (#425)

* Fix rebase issue

* Fixing CI failure issues

Co-authored-by: ThisIsClark <liuyuchibubao@gmail.com>
Co-authored-by: jiangyutan <69443713+jiangyutan@users.noreply.github.com>
Co-authored-by: Joseph Vazhappilly <josephvp@gmail.com>
Co-authored-by: root <pravin ranjan>
  • Loading branch information
4 people authored Jan 2, 2021
1 parent e1f1934 commit 1073b05
Show file tree
Hide file tree
Showing 46 changed files with 2,107 additions and 259 deletions.
1 change: 0 additions & 1 deletion delfin/alert_manager/snmp_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def __init__(self):
self.snmp_error_flag = {}

def validate(self, ctxt, alert_source):
alert_source = dict(alert_source)
engine_id = alert_source.get('engine_id')
try:
alert_source = self.validate_connectivity(alert_source)
Expand Down
1 change: 1 addition & 0 deletions delfin/api/v1/storages.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,4 +217,5 @@ def _set_synced_if_ok(context, storage_id, resource_count):
storage['sync_status'] > 0:
raise exception.StorageIsSyncing(storage['id'])
storage['sync_status'] = resource_count * constants.ResourceSync.START
storage['updated_at'] = current_time
db.storage_update(context, storage['id'], storage)
7 changes: 4 additions & 3 deletions delfin/drivers/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ def discover_storage(self, context, access_info):
access_info = db.access_info_create(context, access_info)
storage['id'] = access_info['storage_id']
storage = db.storage_create(context, storage)
self.driver_manager.update_driver(storage['id'], driver)

LOG.info("Storage found successfully.")
return storage
Expand All @@ -63,7 +62,6 @@ def update_access_info(self, context, access_info):
helper.check_storage_consistency(context, storage_id, storage_new)
access_info = db.access_info_update(context, storage_id, access_info)
db.storage_update(context, storage_id, storage_new)
self.driver_manager.update_driver(storage_id, driver)

LOG.info("Access information updated successfully.")
return access_info
Expand Down Expand Up @@ -114,7 +112,10 @@ def remove_trap_config(self, context, storage_id, trap_config):

def parse_alert(self, context, storage_id, alert):
"""Parse alert data got from snmp trap server."""
driver = self.driver_manager.get_driver(context, storage_id=storage_id)
access_info = db.access_info_get(context, storage_id)
driver = self.driver_manager.get_driver(context,
invoke_on_load=False,
**access_info)
return driver.parse_alert(context, alert)

def clear_alert(self, context, storage_id, sequence_number):
Expand Down
5 changes: 3 additions & 2 deletions delfin/drivers/dell_emc/vmax/alert_handler/oid_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,15 @@ class OidMapper(object):
def __init__(self):
pass

def map_oids(self, alert):
@staticmethod
def map_oids(alert):
"""Translate oids using static map."""
alert_model = dict()

for attr in alert:
# Remove the instance number at the end of oid before mapping
oid_str = attr.rsplit('.', 1)[0]
key = self.OID_MAP.get(oid_str, None)
key = OidMapper.OID_MAP.get(oid_str, None)
alert_model[key] = alert[attr]

return alert_model
12 changes: 5 additions & 7 deletions delfin/drivers/dell_emc/vmax/alert_handler/snmp_alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
class AlertHandler(object):
"""Alert handling functions for vmax snmp traps"""

def __init__(self):
self.oid_mapper = oid_mapper.OidMapper()

# Translation of trap severity to alert model severity
# Values are:
# unknown 1, emergency 2, alert 3, critical 4, error 5,
Expand All @@ -53,12 +50,13 @@ def __init__(self):
'emcAsyncEventComponentName',
'emcAsyncEventSource')

def parse_alert(self, context, alert):
@staticmethod
def parse_alert(context, alert):
"""Parse alert data got from alert manager and fill the alert model."""

alert = self.oid_mapper.map_oids(alert)
alert = oid_mapper.OidMapper.map_oids(alert)
# Check for mandatory alert attributes
for attr in self._mandatory_alert_attributes:
for attr in AlertHandler._mandatory_alert_attributes:
if not alert.get(attr):
msg = "Mandatory information %s missing in alert message. " \
% attr
Expand All @@ -71,7 +69,7 @@ def parse_alert(self, context, alert):
alert_model['alert_name'] = alert_mapper.alarm_id_name_mapping.get(
alert_model['alert_id'], alert_model['alert_id'])

alert_model['severity'] = self.SEVERITY_MAP.get(
alert_model['severity'] = AlertHandler.SEVERITY_MAP.get(
alert['connUnitEventSeverity'],
constants.Severity.INFORMATIONAL)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def parse_queried_alerts(self, alert_list):
alert['severity'], constants.Severity.NOT_SPECIFIED)

# category and type are not part of queried alerts
alert_model['category'] = constants.Category.EVENT
alert_model['category'] = constants.Category.FAULT
alert_model['type'] = constants.EventType.EQUIPMENT_ALARM

alert_model['sequence_number'] = alert['alertId']
Expand Down
3 changes: 1 addition & 2 deletions delfin/drivers/dell_emc/vmax/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ def init_connection(self, access_info):
LOG.error(msg)
raise e
except (exception.SSLCertificateFailed,
exception.WrongTlsVersion,
exception.CipherNotMatch) as e:
exception.SSLHandshakeFailed) as e:
msg = ("Failed to connect to VMAX: {}".format(e))
LOG.error(msg)
raise
Expand Down
36 changes: 5 additions & 31 deletions delfin/drivers/dell_emc/vmax/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,21 @@
# under the License.

import json
import ssl
import sys

from oslo_log import log as logging
import requests
import requests.auth
import requests.exceptions as r_exc
import six
import urllib3
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.poolmanager import PoolManager
from oslo_log import log as logging

from delfin import cryptor
from delfin import exception
from delfin import ssl_utils
from delfin.common import alert_util
from delfin.drivers.dell_emc.vmax import perf_utils, constants
from delfin.i18n import _
from delfin import ssl_utils

LOG = logging.getLogger(__name__)
SLOPROVISIONING = 'sloprovisioning'
Expand All @@ -53,24 +50,6 @@
VERSION_GET_TIME_OUT = 10


class HostNameIgnoringAdapter(HTTPAdapter):

def cert_verify(self, conn, url, verify, cert):
conn.assert_hostname = False
return super(HostNameIgnoringAdapter, self).cert_verify(
conn, url, verify, cert)

def init_poolmanager(self, connections, maxsize, block=False,
**pool_kwargs):
self._pool_connections = connections
self._pool_maxsize = maxsize
self._pool_block = block
self.poolmanager = PoolManager(num_pools=connections, maxsize=maxsize,
block=block, strict=True,
ssl_version=ssl.PROTOCOL_TLSv1,
**pool_kwargs)


class VMaxRest(object):
"""Rest class based on Unisphere for VMax Rest API."""

Expand Down Expand Up @@ -115,7 +94,7 @@ def establish_rest_session(self):
LOG.debug("Enable certificate verification, ca_path: {0}".format(
self.verify))
session.verify = self.verify
session.mount("https://", ssl_utils.HostNameIgnoreAdapter())
session.mount("https://", ssl_utils.get_host_name_ignore_adapter())

self.session = session
return session
Expand Down Expand Up @@ -176,15 +155,10 @@ def request(self, target_uri, method, params=None, request_object=None,
"message: %(e)s") % {'base_uri': self.base_uri, 'e': e}
LOG.error(msg)
err_str = six.text_type(e)
if 'wrong ssl version' in err_str or \
'sslv3 alert handshake failure' in err_str:
raise exception.WrongTlsVersion()
elif 'no cipher match' in err_str:
raise exception.CipherNotMatch()
elif 'certificate verify failed' in err_str:
if 'certificate verify failed' in err_str:
raise exception.SSLCertificateFailed()
else:
raise e
raise exception.SSLHandshakeFailed()

except (r_exc.Timeout, r_exc.ConnectionError,
r_exc.HTTPError) as e:
Expand Down
3 changes: 2 additions & 1 deletion delfin/drivers/dell_emc/vmax/vmax.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ def add_trap_config(self, context, trap_config):
def remove_trap_config(self, context, trap_config):
pass

def parse_alert(self, context, alert):
@staticmethod
def parse_alert(context, alert):
return snmp_alerts.AlertHandler().parse_alert(context, alert)

def clear_alert(self, context, sequence_number):
Expand Down
4 changes: 2 additions & 2 deletions delfin/drivers/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ def remove_trap_config(self, context, trap_config):
"""Remove trap receiver configuration from storage system."""
pass

@abc.abstractmethod
def parse_alert(self, context, alert):
@staticmethod
def parse_alert(context, alert):
"""Parse alert data got from snmp trap server."""

"""
Expand Down
3 changes: 2 additions & 1 deletion delfin/drivers/fake_storage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,8 @@ def add_trap_config(self, context, trap_config):
def remove_trap_config(self, context, trap_config):
pass

def parse_alert(self, context, alert):
@staticmethod
def parse_alert(context, alert):
pass

def clear_alert(self, context, alert):
Expand Down
Empty file.
Empty file.
20 changes: 20 additions & 0 deletions delfin/drivers/hitachi/vsp/consts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2020 The SODA Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
SOCKET_TIMEOUT = 30
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')
Loading

0 comments on commit 1073b05

Please sign in to comment.