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

Update setup.cfg #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[run]
branch = true
source = dolphin
omit = dolphin/tests/*
16 changes: 16 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
language: python
sudo: required

python:
- "3.6"
- "3.7"
- "3.8"

install:
- pip install tox codecov

script:
- tox

after_success:
- codecov
6 changes: 6 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
comment:
layout: "header, diff, tree"

coverage:
status:
project: false
5 changes: 2 additions & 3 deletions dolphin/alert_manager/alert_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ def process_alert_info(self, alert):
access_info = db.access_info_get_all(ctxt, filters=filters)
except Exception:
msg = "Access information could not be found with host %s." \
% alert['transport_address']
% alert['transport_address']
raise exception.AccessInfoNotFound(message=msg)

# For given source ip, there should be unique access_info
if len(access_info) != 1:
msg = "Failed to get unique access information with host %s." \
% alert['transport_address']
% alert['transport_address']
raise exception.InvalidResults(message=msg)

try:
Expand All @@ -80,4 +80,3 @@ def process_alert_info(self, alert):
def _export_alert_model(self, alert_model):
"""Exports the filled alert model to the export manager."""
LOG.info('Alert model to be exported: %s.', alert_model)

14 changes: 7 additions & 7 deletions dolphin/alert_manager/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
TRAP_RECEIVER_CLASS = 'dolphin.alert_manager.trap_receiver.TrapReceiver'

# Temporary snmp community and user configurations
SNMP_COMMUNITY_STR='public'
SNMP_USM_USER='test1'
SNMP_V3_AUTHKEY='abcd123456'
SNMP_V3_PRIVKEY='abcd123456'
SNMP_V3_AUTH_PROTOCOL='usmHMACMD5AuthProtocol'
SNMP_V3_PRIV_PROTOCOL='usmDESPrivProtocol'
SNMP_ENGINE_ID='800000d30300000e112245'
SNMP_COMMUNITY_STR = 'public'
SNMP_USM_USER = 'test1'
SNMP_V3_AUTHKEY = 'abcd123456'
SNMP_V3_PRIVKEY = 'abcd123456'
SNMP_V3_AUTH_PROTOCOL = 'usmHMACMD5AuthProtocol'
SNMP_V3_PRIV_PROTOCOL = 'usmDESPrivProtocol'
SNMP_ENGINE_ID = '800000d30300000e112245'

# Temporary mib lod dir. This mechanism to be changed later
SNMP_MIB_PATH = '/usr/local/lib/python3.6/dist-packages/pysnmp/smi/mibs'
Expand Down
6 changes: 3 additions & 3 deletions dolphin/alert_manager/trap_receiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

# Currently static mib file list is loaded
# Mechanism to be changed to load all mib file
MIB_LOAD_LIST = ['SNMPv2-MIB','IF_MIB']
MIB_LOAD_LIST = ['SNMPv2-MIB', 'IF_MIB']


class TrapReceiver(object):
Expand Down Expand Up @@ -109,8 +109,8 @@ def _cb_fun(self, state_reference, context_engine_id, context_name,
context_name.prettyPrint(), exec_context['securityModel'],
exec_context['securityName']))

var_binds = [rfc1902.ObjectType(rfc1902.ObjectIdentity(x[0]), x[1])
.resolveWithMib(self.mib_view_controller)
var_binds = [rfc1902.ObjectType(rfc1902.ObjectIdentity(x[0]),
x[1]).resolveWithMib(self.mib_view_controller)
for x in var_binds]
alert = {}

Expand Down
1 change: 1 addition & 0 deletions dolphin/api/api_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from oslo_utils import strutils

from dolphin.common import constants
from dolphin.i18n import _

api_common_opts = [
cfg.IntOpt('api_max_limit',
Expand Down
6 changes: 5 additions & 1 deletion dolphin/api/common/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def best_match_content_type(self):
content_type = self.accept.best_match(SUPPORTED_CONTENT_TYPES)

self.environ['dolphin.best_content_type'] = (content_type or
'application/json')
'application/json')

return self.environ['dolphin.best_content_type']

Expand Down Expand Up @@ -262,6 +262,7 @@ def decorator(func):
func.wsgi_serializers = {}
func.wsgi_serializers.update(serializers)
return func

return decorator


Expand All @@ -278,6 +279,7 @@ def decorator(func):
func.wsgi_deserializers = {}
func.wsgi_deserializers.update(deserializers)
return func

return decorator


Expand All @@ -292,6 +294,7 @@ def response(code):
def decorator(func):
func.wsgi_code = code
return func

return decorator


Expand Down Expand Up @@ -845,6 +848,7 @@ def action(name):
def decorator(func):
func.wsgi_action = name
return func

return decorator


Expand Down
1 change: 0 additions & 1 deletion dolphin/api/extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,4 +326,3 @@ def load_standard_extensions(ext_mgr, logger, path, package, ext_list=None):

# Update the list of directories we'll explore...
dirnames[:] = subdirs

1 change: 0 additions & 1 deletion dolphin/api/schemas/alert.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,3 @@
'required': ['host', 'version'],
'additionalProperties': False,
}

2 changes: 1 addition & 1 deletion dolphin/api/v1/alert.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def put(self, req, id, body):
alert_source = db.alert_source_update(ctx, id, alert_source)
else:
alert_source = db.alert_source_create(ctx, alert_source)
except exception.StorageNotFound as e:
except exception.StorageNotFound:
msg = (_("Alert source cannot be created or updated for a"
" non-existing storage %s.") % id)
raise exc.HTTPBadRequest(explanation=msg)
Expand Down
3 changes: 1 addition & 2 deletions dolphin/api/v1/pools.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from dolphin.api import api_utils
from dolphin.api.common import wsgi
from dolphin.api.views import pools as pool_view
from dolphin.i18n import _


class PoolController(wsgi.Controller):
Expand Down Expand Up @@ -53,7 +52,7 @@ def index(self, req):
try:
pools = db.pool_get_all(ctxt, marker, limit, sort_keys, sort_dirs,
query_params, offset)
except exception.InvalidInput as e:
except exception.InvalidInput as e:
raise exc.HTTPBadRequest(explanation=six.text_type(e))
return pool_view.build_pools(pools)

Expand Down
3 changes: 1 addition & 2 deletions dolphin/api/v1/storages.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ def _get_storages_search_options(self):

def index(self, req):
ctxt = req.environ['dolphin.context']
supported_filters = ['name', 'vendor', 'model', 'status']
query_params = {}
query_params.update(req.GET)
# update options other than filters
Expand All @@ -76,7 +75,7 @@ def index(self, req):
try:
storages = db.storage_get_all(context, marker, limit, sort_keys,
sort_dirs, query_params, offset)
except exception.InvalidInput as e:
except exception.InvalidInput as e:
raise exc.HTTPBadRequest(explanation=six.text_type(e))
return storage_view.build_storages(storages)

Expand Down
2 changes: 0 additions & 2 deletions dolphin/api/v1/volumes.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,3 @@ def show(self, req, id):

def create_resource():
return wsgi.Resource(VolumeController())


4 changes: 2 additions & 2 deletions dolphin/cmd/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from oslo_config import cfg
from oslo_log import log

from dolphin.common import config # Need to register global_opts
from dolphin.common import config # noqa
from dolphin import service
from dolphin import utils
from dolphin import version
Expand All @@ -47,7 +47,7 @@ def main():
launcher.launch_service(api_server, workers=api_server.workers or 1)
launcher.launch_service(task_server)

#Launch alert manager service
# Launch alert manager service
alert_manager = service.AlertMngrService()
launcher.launch_service(alert_manager)

Expand Down
7 changes: 4 additions & 3 deletions dolphin/coordination.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@
from dolphin import exception
from dolphin.i18n import _


LOG = log.getLogger(__name__)


coordination_opts = [
cfg.StrOpt('backend_url',
default='redis://127.0.0.1:6379',
Expand Down Expand Up @@ -117,6 +115,7 @@ class Lock(locking.Lock):

Available field names are keys of lock_data.
"""

def __init__(self, lock_name, lock_data=None, coordinator=None):
super(Lock, self).__init__(six.text_type(id(self)))
lock_data = lock_data or {}
Expand Down Expand Up @@ -191,13 +190,15 @@ def foo(self, shr, snap):
Available field names are: decorated function parameters and
`f_name` as a decorated function name.
"""

@decorator.decorator
def _synchronized(f, *a, **k):
call_args = inspect.getcallargs(f, *a, **k)
call_args['f_name'] = f.__name__
lock = Lock(lock_name, call_args, coordinator)
with lock(blocking):
LOG.info('Lock "%(name)s" acquired by "%(function)s".',
{'name': lock_name, 'function': f.__name__})
{'name': lock_name, 'function': f.__name__})
return f(*a, **k)

return _synchronized
19 changes: 7 additions & 12 deletions dolphin/db/sqlalchemy/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@

def apply_sorting(model, query, sort_key, sort_dir):
if sort_dir.lower() not in ('desc', 'asc'):
msg = ("Wrong sorting data provided: sort key is '%(sort_key)s' "
"and sort order is '%(sort_dir)s'.") % {
"sort_key": sort_key, "sort_dir": sort_dir}
msg = (("Wrong sorting data provided: sort key is '%(sort_key)s' "
"and sort order is '%(sort_dir)s'.") %
{"sort_key": sort_key, "sort_dir": sort_dir})
raise exception.InvalidInput(reason=msg)

sort_attr = getattr(model, sort_key)
Expand Down Expand Up @@ -181,7 +181,7 @@ def access_info_update(context, storage_id, values):

def access_info_delete(context, storage_id):
"""Delete a storage access information."""
_access_info_get_query(context).\
_access_info_get_query(context). \
filter_by(storage_id=storage_id).delete()


Expand Down Expand Up @@ -397,11 +397,7 @@ def volumes_update(context, volumes):

def volume_get(context, volume_id):
"""Get a volume or raise an exception if it does not exist."""
return _volume_get(context, vol_id)


def _volume_get_query(context, session=None):
return model_query(context, models.Volume, session=session)
return _volume_get(context, volume_id)


def volume_get_all(context, marker=None, limit=None, sort_keys=None,
Expand All @@ -412,8 +408,7 @@ def volume_get_all(context, marker=None, limit=None, sort_keys=None,
# Generate the query
query = _generate_paginate_query(context, session, models.Volume,
marker, limit, sort_keys, sort_dirs,
filters, offset
)
filters, offset)
# No volume would match, return empty list
if query is None:
return []
Expand Down Expand Up @@ -682,7 +677,7 @@ def alert_source_delete(context, storage_id):


def alert_source_get_all(context, marker=None, limit=None, sort_keys=None,
sort_dirs=None, filters=None, offset=None):
sort_dirs=None, filters=None, offset=None):
session = get_session()
with session.begin():
query = _generate_paginate_query(context, session, models.AlertSource,
Expand Down
1 change: 0 additions & 1 deletion dolphin/db/sqlalchemy/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"""
SQLAlchemy models for Dolphin data.
"""
import json

from oslo_config import cfg
from oslo_db.sqlalchemy import models
Expand Down
8 changes: 3 additions & 5 deletions dolphin/drivers/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ def remove_storage(self, context, storage_id):

def get_storage(self, context, storage_id):
"""Get storage device information from storage system"""
driver = self.driver_manager.get_driver(context, storage_id)
driver = self.driver_manager.get_driver(context, storage_id=storage_id)
return driver.get_storage(context)

def list_pools(self, context, storage_id):
"""List all storage pools from storage system."""
driver = self.driver_manager.get_driver(context, storage_id)
driver = self.driver_manager.get_driver(context, storage_id=storage_id)
return driver.list_pools(context)

def list_volumes(self, context, storage_id):
Expand All @@ -92,11 +92,9 @@ 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})
driver = self.driver_manager.get_driver(context, storage_id=storage_id)
driver.parse_alert(context, alert)

def clear_alert(self, context, storage_id, alert):
"""Clear alert from storage system."""
pass


13 changes: 7 additions & 6 deletions dolphin/drivers/dell_emc/vmax/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,22 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import json
import PyU4V

from dolphin import exception
from dolphin.common import constants
from oslo_log import log
from oslo_utils import units

from dolphin import exception
from dolphin.common import constants

LOG = log.getLogger(__name__)

SUPPORTED_VERSION='90'
SUPPORTED_VERSION = '90'


class VMAXClient(object):
""" Client class for communicating with VMAX storage """

def __init__(self):
self.conn = None
self.array_id = None
Expand All @@ -39,8 +40,8 @@ def __del__(self):

def init_connection(self, access_info):
""" Given the access_info get a connection to VMAX storage """
self.array_id = access_info.get('extra_attributes', {}).\
get('array_id', None)
self.array_id = access_info.get('extra_attributes', {}). \
get('array_id', None)
if not self.array_id:
raise exception.InvalidInput(reason='Input array_id is missing')

Expand Down
Loading