Skip to content

Commit

Permalink
Add cpu usage metric of controller.
Browse files Browse the repository at this point in the history
  • Loading branch information
JiuyunZhao committed Jul 26, 2022
1 parent 6729541 commit 0cc17b8
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 29 deletions.
12 changes: 12 additions & 0 deletions delfin/api/schemas/storage_capabilities_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,18 @@
'maxLength': 255}
},
},
ControllerMetric.CPU_USAGE.name: {
'type': 'object',
'properties': {
'unit': {'type': 'string',
'enum': [ControllerMetric.CPU_USAGE
.unit]
},
'description': {'type': 'string',
'minLength': 1,
'maxLength': 255}
},
}
},
'additionalProperties': False
},
Expand Down
5 changes: 4 additions & 1 deletion delfin/drivers/fake_storage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,10 @@ def get_capabilities(context, filters=None):
"unit": ControllerMetric.WRITE_IOPS.unit,
"description": ControllerMetric.WRITE_IOPS.description
},

ControllerMetric.CPU_USAGE.name: {
"unit": ControllerMetric.CPU_USAGE.unit,
"description": ControllerMetric.CPU_USAGE.description
}
},
ResourceType.PORT: {
PortMetric.THROUGHPUT.name: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def _handle_task_failure(self, start_time, end_time):

if capabilities.get('failed_job_collect_interval'):
failed_task_interval = \
TelemetryCollection.FAILED_JOB_SCHEDULE_INTERVAL
capabilities.get('failed_job_collect_interval')

if performance_metric_retention_window:
collection_window = performance_metric_retention_window \
Expand Down
5 changes: 4 additions & 1 deletion delfin/tests/unit/api/fakes.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,10 @@ def fake_get_capabilities(context, storage_id):
"unit": ControllerMetric.WRITE_IOPS.unit,
"description": ControllerMetric.WRITE_IOPS.description
},

ControllerMetric.CPU_USAGE.name: {
"unit": ControllerMetric.CPU_USAGE.unit,
"description": ControllerMetric.CPU_USAGE.description
}
},
ResourceType.PORT: {
PortMetric.THROUGHPUT.name: {
Expand Down
26 changes: 0 additions & 26 deletions delfin/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,13 @@

"""Utilities and helper functions."""

import contextlib
import functools
import inspect
import os
import pyclbr
import random
import re
import shutil
import sys
import tempfile
import threading

from eventlet import pools
Expand Down Expand Up @@ -123,17 +120,6 @@ def create(self): # pylint: disable=method-hidden
elif self.password:
look_for_keys = False
try:
LOG.debug("ssh.connect: ip: %s, port: %s, username: %s, "
"password: %s, key_filename: %s, look_for_keys: %s, "
"timeout: %s, banner_timeout: %s",
self.ip,
self.port,
self.login,
self.password,
self.path_to_private_key,
look_for_keys,
self.conn_timeout,
self.conn_timeout)
ssh.connect(self.ip,
port=self.port,
username=self.login,
Expand Down Expand Up @@ -310,18 +296,6 @@ def service_is_up(service):
return abs(elapsed) <= CONF.service_down_time


@contextlib.contextmanager
def tempdir(**kwargs):
tmpdir = tempfile.mkdtemp(**kwargs)
try:
yield tmpdir
finally:
try:
shutil.rmtree(tmpdir)
except OSError as e:
LOG.debug('Could not remove tmpdir: %s', e)


def walk_class_hierarchy(clazz, encountered=None):
"""Walk class hierarchy, yielding most derived classes first."""
if not encountered:
Expand Down

0 comments on commit 0cc17b8

Please sign in to comment.