Skip to content

Commit

Permalink
fixed review comment
Browse files Browse the repository at this point in the history
  • Loading branch information
Amit Roushan committed Mar 13, 2021
1 parent d8eea00 commit c1be218
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 731 deletions.
30 changes: 0 additions & 30 deletions delfin/api/schemas/perf_collection.py

This file was deleted.

17 changes: 8 additions & 9 deletions delfin/api/v1/storages.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

import copy
import six

from oslo_config import cfg
from oslo_log import log
Expand Down Expand Up @@ -106,15 +107,16 @@ def create(self, req, body):
# Trigger Performance monitoring
capabilities = self.driver_api.get_capabilities(
context=ctxt, storage_id=storage['id'])
# ignore if capabilities is empty
if capabilities:
_create_performance_monitoring_task(ctxt, storage['id'],
capabilities)
# validate capabilities
validation.validate_capabilities(capabilities)
# trigger performance monitoring
_create_performance_monitoring_task(ctxt, storage['id'],
capabilities)
except Exception as e:
# Unexpected error occurred, while performance monitoring.
msg = _('Failed to trigger performance monitoring for storage: '
'%(storage)s. Error: %(err)s') % {'storage': storage['id'],
'err': e}
'err': six.text_type(e)}
LOG.error(msg)
return storage_view.build_storage(storage)

Expand Down Expand Up @@ -207,7 +209,6 @@ def _storage_exist(self, context, access_info):

return False


@wsgi.response(200)
def get_capabilities(self, req, id):
"""
Expand Down Expand Up @@ -261,9 +262,7 @@ def _create_performance_monitoring_task(context, storage_id, capabilities):
# check if resource_metric is empty
if 'resource_metrics' not in capabilities \
or not bool(capabilities.get('resource_metrics')):
msg = _('Skipping performance monitoring as resource metric is empty '
'for storage: %(storage)s.') % {'storage': storage_id}
LOG.warning(msg)
raise exception.EmptyResourceMetrics()

task = dict()
task.update(storage_id=storage_id)
Expand Down
20 changes: 2 additions & 18 deletions delfin/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@
stepping stone.
"""
import json
import socket
from delfin import exception

from apscheduler.schedulers.background import BackgroundScheduler
from oslo_config import cfg
from oslo_log import log
from oslo_middleware import cors
from oslo_utils import netutils
from apscheduler.schedulers.background import BackgroundScheduler

LOG = log.getLogger(__name__)

Expand Down Expand Up @@ -132,21 +131,6 @@ def set_middleware_defaults():
)


def load_json_file(config_file):
try:
with open(config_file) as f:
data = json.load(f)
return data
except json.decoder.JSONDecodeError as e:
msg = ("{0} file is not correct. Please check the configuration file"
.format(config_file))
LOG.error(msg)
raise exception.InvalidInput(e.msg)
except FileNotFoundError as e:
LOG.error(e)
raise exception.ConfigNotFound(e)


class Scheduler:
__instance = None

Expand Down
7 changes: 2 additions & 5 deletions delfin/common/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
# Valid access type supported currently.
ACCESS_TYPE = ['rest', 'ssh', 'cli', 'smis']

RESOURCE_CLASS_TYPE = {'array_polling': 'ArrayPerformanceCollection'}
SCHEDULING_MIN_INTERVAL = 5


# Custom fields for Delfin objects
class StorageStatus(object):
Expand Down Expand Up @@ -293,6 +290,6 @@ class ResourceSync(object):
class Task(object):
DEFAULT_TASK_INTERVAL = 30
"""Default task interval"""
PERFORMANCE_TASK_METHOD = "delfin.task_manager.tasks." \
"performance_monitoring"
PERFORMANCE_TASK_METHOD = "delfin.task_manager.tasks.telemetry." \
"PerformanceCollectionTask"
"""Performance monitoring task name"""
Loading

0 comments on commit c1be218

Please sign in to comment.