Remove ceilometer datasource
This datasource requires Ceilometer API which was already removed some
years ago. The implementation should have been removed when dependency
on ceilometerclient was removed by [1].
Also remove some job definitions which are not actually used.
[1] 01d74d0a87
Change-Id: I29c3865dc1207f1bbbb266e4217cf8888afebfb6
This commit is contained in:
54
.zuul.yaml
54
.zuul.yaml
@@ -21,66 +21,12 @@
|
|||||||
- watcher-tempest-functional-jammy
|
- watcher-tempest-functional-jammy
|
||||||
- watcher-tempest-functional-ipv6-only
|
- watcher-tempest-functional-ipv6-only
|
||||||
|
|
||||||
- job:
|
|
||||||
name: watcher-tempest-dummy_optim
|
|
||||||
parent: watcher-tempest-multinode
|
|
||||||
vars:
|
|
||||||
tempest_test_regex: watcher_tempest_plugin.tests.scenario.test_execute_dummy_optim
|
|
||||||
|
|
||||||
- job:
|
- job:
|
||||||
name: watcher-tempest-actuator
|
name: watcher-tempest-actuator
|
||||||
parent: watcher-tempest-multinode
|
parent: watcher-tempest-multinode
|
||||||
vars:
|
vars:
|
||||||
tempest_test_regex: watcher_tempest_plugin.tests.scenario.test_execute_actuator
|
tempest_test_regex: watcher_tempest_plugin.tests.scenario.test_execute_actuator
|
||||||
|
|
||||||
- job:
|
|
||||||
name: watcher-tempest-basic_optim
|
|
||||||
parent: watcher-tempest-multinode
|
|
||||||
vars:
|
|
||||||
tempest_test_regex: watcher_tempest_plugin.tests.scenario.test_execute_basic_optim
|
|
||||||
|
|
||||||
- job:
|
|
||||||
name: watcher-tempest-vm_workload_consolidation
|
|
||||||
parent: watcher-tempest-multinode
|
|
||||||
vars:
|
|
||||||
tempest_test_regex: watcher_tempest_plugin.tests.scenario.test_execute_vm_workload_consolidation
|
|
||||||
devstack_local_conf:
|
|
||||||
test-config:
|
|
||||||
$WATCHER_CONFIG:
|
|
||||||
watcher_strategies.vm_workload_consolidation:
|
|
||||||
datasource: ceilometer
|
|
||||||
|
|
||||||
- job:
|
|
||||||
name: watcher-tempest-workload_balancing
|
|
||||||
parent: watcher-tempest-multinode
|
|
||||||
vars:
|
|
||||||
tempest_test_regex: watcher_tempest_plugin.tests.scenario.test_execute_workload_balancing
|
|
||||||
|
|
||||||
- job:
|
|
||||||
name: watcher-tempest-zone_migration
|
|
||||||
parent: watcher-tempest-multinode
|
|
||||||
vars:
|
|
||||||
tempest_test_regex: watcher_tempest_plugin.tests.scenario.test_execute_zone_migration
|
|
||||||
|
|
||||||
- job:
|
|
||||||
name: watcher-tempest-host_maintenance
|
|
||||||
parent: watcher-tempest-multinode
|
|
||||||
vars:
|
|
||||||
tempest_test_regex: watcher_tempest_plugin.tests.scenario.test_execute_host_maintenance
|
|
||||||
|
|
||||||
- job:
|
|
||||||
name: watcher-tempest-storage_balance
|
|
||||||
parent: watcher-tempest-multinode
|
|
||||||
vars:
|
|
||||||
tempest_test_regex: watcher_tempest_plugin.tests.scenario.test_execute_storage_balance
|
|
||||||
devstack_local_conf:
|
|
||||||
test-config:
|
|
||||||
$TEMPEST_CONFIG:
|
|
||||||
volume:
|
|
||||||
backend_names: ['BACKEND_1', 'BACKEND_2']
|
|
||||||
volume-feature-enabled:
|
|
||||||
multi_backend: true
|
|
||||||
|
|
||||||
- job:
|
- job:
|
||||||
name: watcher-tempest-strategies
|
name: watcher-tempest-strategies
|
||||||
parent: watcher-tempest-multinode
|
parent: watcher-tempest-multinode
|
||||||
|
|||||||
@@ -194,11 +194,14 @@ The configuration file is organized into the following sections:
|
|||||||
* ``[watcher_applier]`` - Watcher Applier module configuration
|
* ``[watcher_applier]`` - Watcher Applier module configuration
|
||||||
* ``[watcher_decision_engine]`` - Watcher Decision Engine module configuration
|
* ``[watcher_decision_engine]`` - Watcher Decision Engine module configuration
|
||||||
* ``[oslo_messaging_rabbit]`` - Oslo Messaging RabbitMQ driver configuration
|
* ``[oslo_messaging_rabbit]`` - Oslo Messaging RabbitMQ driver configuration
|
||||||
* ``[ceilometer_client]`` - Ceilometer client configuration
|
|
||||||
* ``[cinder_client]`` - Cinder client configuration
|
* ``[cinder_client]`` - Cinder client configuration
|
||||||
* ``[glance_client]`` - Glance client configuration
|
* ``[glance_client]`` - Glance client configuration
|
||||||
|
* ``[gnocchi_client]`` - Gnocchi client configuration
|
||||||
|
* ``[ironic_client]`` - Ironic client configuration
|
||||||
|
* ``[keystone_client]`` - Keystone client configuration
|
||||||
* ``[nova_client]`` - Nova client configuration
|
* ``[nova_client]`` - Nova client configuration
|
||||||
* ``[neutron_client]`` - Neutron client configuration
|
* ``[neutron_client]`` - Neutron client configuration
|
||||||
|
* ``[placement_client]`` - Placement client configuration
|
||||||
|
|
||||||
The Watcher configuration file is expected to be named
|
The Watcher configuration file is expected to be named
|
||||||
``watcher.conf``. When starting Watcher, you can specify a different
|
``watcher.conf``. When starting Watcher, you can specify a different
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
upgrade:
|
||||||
|
- |
|
||||||
|
Ceilometer datasource has been completely removed. The datasource requires
|
||||||
|
ceilometer API which was already removed from Ceilometer. Use the other
|
||||||
|
datasources such as Gnocchi.
|
||||||
@@ -27,12 +27,6 @@ from novaclient import client as nvclient
|
|||||||
from watcher.common import exception
|
from watcher.common import exception
|
||||||
from watcher.common import utils
|
from watcher.common import utils
|
||||||
|
|
||||||
try:
|
|
||||||
from ceilometerclient import client as ceclient
|
|
||||||
HAS_CEILCLIENT = True
|
|
||||||
except ImportError:
|
|
||||||
HAS_CEILCLIENT = False
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from maas import client as maas_client
|
from maas import client as maas_client
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@@ -77,7 +71,6 @@ class OpenStackClients(object):
|
|||||||
self._glance = None
|
self._glance = None
|
||||||
self._gnocchi = None
|
self._gnocchi = None
|
||||||
self._cinder = None
|
self._cinder = None
|
||||||
self._ceilometer = None
|
|
||||||
self._monasca = None
|
self._monasca = None
|
||||||
self._neutron = None
|
self._neutron = None
|
||||||
self._ironic = None
|
self._ironic = None
|
||||||
@@ -188,24 +181,6 @@ class OpenStackClients(object):
|
|||||||
session=self.session)
|
session=self.session)
|
||||||
return self._cinder
|
return self._cinder
|
||||||
|
|
||||||
@exception.wrap_keystone_exception
|
|
||||||
def ceilometer(self):
|
|
||||||
if self._ceilometer:
|
|
||||||
return self._ceilometer
|
|
||||||
|
|
||||||
ceilometerclient_version = self._get_client_option('ceilometer',
|
|
||||||
'api_version')
|
|
||||||
ceilometer_endpoint_type = self._get_client_option('ceilometer',
|
|
||||||
'endpoint_type')
|
|
||||||
ceilometer_region_name = self._get_client_option('ceilometer',
|
|
||||||
'region_name')
|
|
||||||
self._ceilometer = ceclient.get_client(
|
|
||||||
ceilometerclient_version,
|
|
||||||
endpoint_type=ceilometer_endpoint_type,
|
|
||||||
region_name=ceilometer_region_name,
|
|
||||||
session=self.session)
|
|
||||||
return self._ceilometer
|
|
||||||
|
|
||||||
@exception.wrap_keystone_exception
|
@exception.wrap_keystone_exception
|
||||||
def monasca(self):
|
def monasca(self):
|
||||||
if self._monasca:
|
if self._monasca:
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ from oslo_config import cfg
|
|||||||
|
|
||||||
from watcher.conf import api
|
from watcher.conf import api
|
||||||
from watcher.conf import applier
|
from watcher.conf import applier
|
||||||
from watcher.conf import ceilometer_client
|
|
||||||
from watcher.conf import cinder_client
|
from watcher.conf import cinder_client
|
||||||
from watcher.conf import clients_auth
|
from watcher.conf import clients_auth
|
||||||
from watcher.conf import collector
|
from watcher.conf import collector
|
||||||
@@ -64,7 +63,6 @@ keystone_client.register_opts(CONF)
|
|||||||
grafana_client.register_opts(CONF)
|
grafana_client.register_opts(CONF)
|
||||||
grafana_translators.register_opts(CONF)
|
grafana_translators.register_opts(CONF)
|
||||||
cinder_client.register_opts(CONF)
|
cinder_client.register_opts(CONF)
|
||||||
ceilometer_client.register_opts(CONF)
|
|
||||||
neutron_client.register_opts(CONF)
|
neutron_client.register_opts(CONF)
|
||||||
clients_auth.register_opts(CONF)
|
clients_auth.register_opts(CONF)
|
||||||
ironic_client.register_opts(CONF)
|
ironic_client.register_opts(CONF)
|
||||||
|
|||||||
@@ -1,63 +0,0 @@
|
|||||||
# -*- encoding: utf-8 -*-
|
|
||||||
# Copyright (c) 2016 Intel Corp
|
|
||||||
#
|
|
||||||
# Authors: Prudhvi Rao Shedimbi <prudhvi.rao.shedimbi@intel.com>
|
|
||||||
#
|
|
||||||
# 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.
|
|
||||||
|
|
||||||
from oslo_config import cfg
|
|
||||||
|
|
||||||
ceilometer_client = cfg.OptGroup(name='ceilometer_client',
|
|
||||||
title='Configuration Options for Ceilometer')
|
|
||||||
|
|
||||||
CEILOMETER_CLIENT_OPTS = [
|
|
||||||
cfg.StrOpt('api_version',
|
|
||||||
default='2',
|
|
||||||
deprecated_for_removal=True,
|
|
||||||
deprecated_since="1.13.0",
|
|
||||||
deprecated_reason="""
|
|
||||||
Ceilometer API is deprecated since Ocata release.
|
|
||||||
Any related configuration options are deprecated too.
|
|
||||||
""",
|
|
||||||
help='Version of Ceilometer API to use in '
|
|
||||||
'ceilometerclient.'),
|
|
||||||
cfg.StrOpt('endpoint_type',
|
|
||||||
default='internalURL',
|
|
||||||
deprecated_for_removal=True,
|
|
||||||
deprecated_since="1.13.0",
|
|
||||||
deprecated_reason="""
|
|
||||||
Ceilometer API is deprecated since Ocata release.
|
|
||||||
Any related configuration options are deprecated too.
|
|
||||||
""",
|
|
||||||
help='Type of endpoint to use in ceilometerclient. '
|
|
||||||
'Supported values: internalURL, publicURL, adminURL. '
|
|
||||||
'The default is internalURL.'),
|
|
||||||
cfg.StrOpt('region_name',
|
|
||||||
deprecated_for_removal=True,
|
|
||||||
deprecated_since="1.13.0",
|
|
||||||
deprecated_reason="""
|
|
||||||
Ceilometer API is deprecated since Ocata release.
|
|
||||||
Any related configuration options are deprecated too.
|
|
||||||
""",
|
|
||||||
help='Region in Identity service catalog to use for '
|
|
||||||
'communication with the OpenStack service.')]
|
|
||||||
|
|
||||||
|
|
||||||
def register_opts(conf):
|
|
||||||
conf.register_group(ceilometer_client)
|
|
||||||
conf.register_opts(CEILOMETER_CLIENT_OPTS, group=ceilometer_client)
|
|
||||||
|
|
||||||
|
|
||||||
def list_opts():
|
|
||||||
return [(ceilometer_client, CEILOMETER_CLIENT_OPTS)]
|
|
||||||
@@ -1,276 +0,0 @@
|
|||||||
# -*- encoding: utf-8 -*-
|
|
||||||
# Copyright (c) 2015 b<>com
|
|
||||||
#
|
|
||||||
# Authors: Jean-Emile DARTOIS <jean-emile.dartois@b-com.com>
|
|
||||||
#
|
|
||||||
# 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.
|
|
||||||
|
|
||||||
import datetime
|
|
||||||
|
|
||||||
from oslo_log import log
|
|
||||||
from oslo_utils import timeutils
|
|
||||||
|
|
||||||
from watcher._i18n import _
|
|
||||||
from watcher.common import clients
|
|
||||||
from watcher.common import exception
|
|
||||||
from watcher.decision_engine.datasources import base
|
|
||||||
|
|
||||||
|
|
||||||
LOG = log.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
try:
|
|
||||||
from ceilometerclient import exc
|
|
||||||
HAS_CEILCLIENT = True
|
|
||||||
except ImportError:
|
|
||||||
HAS_CEILCLIENT = False
|
|
||||||
|
|
||||||
|
|
||||||
class CeilometerHelper(base.DataSourceBase):
|
|
||||||
|
|
||||||
NAME = 'ceilometer'
|
|
||||||
METRIC_MAP = dict(host_cpu_usage='compute.node.cpu.percent',
|
|
||||||
host_ram_usage='hardware.memory.used',
|
|
||||||
host_outlet_temp='hardware.ipmi.node.outlet_temperature',
|
|
||||||
host_inlet_temp='hardware.ipmi.node.temperature',
|
|
||||||
host_airflow='hardware.ipmi.node.airflow',
|
|
||||||
host_power='hardware.ipmi.node.power',
|
|
||||||
instance_cpu_usage='cpu_util',
|
|
||||||
instance_ram_usage='memory.resident',
|
|
||||||
instance_ram_allocated='memory',
|
|
||||||
instance_l3_cache_usage='cpu_l3_cache',
|
|
||||||
instance_root_disk_size='disk.root.size',
|
|
||||||
)
|
|
||||||
|
|
||||||
def __init__(self, osc=None):
|
|
||||||
""":param osc: an OpenStackClients instance"""
|
|
||||||
self.osc = osc if osc else clients.OpenStackClients()
|
|
||||||
self.ceilometer = self.osc.ceilometer()
|
|
||||||
LOG.warning("Ceilometer API is deprecated and Ceilometer Datasource "
|
|
||||||
"module is no longer maintained. We recommend to use "
|
|
||||||
"Gnocchi instead.")
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def format_query(user_id, tenant_id, resource_id,
|
|
||||||
user_ids, tenant_ids, resource_ids):
|
|
||||||
query = []
|
|
||||||
|
|
||||||
def query_append(query, _id, _ids, field):
|
|
||||||
if _id:
|
|
||||||
_ids = [_id]
|
|
||||||
for x_id in _ids:
|
|
||||||
query.append({"field": field, "op": "eq", "value": x_id})
|
|
||||||
|
|
||||||
query_append(query, user_id, (user_ids or []), "user_id")
|
|
||||||
query_append(query, tenant_id, (tenant_ids or []), "project_id")
|
|
||||||
query_append(query, resource_id, (resource_ids or []), "resource_id")
|
|
||||||
|
|
||||||
return query
|
|
||||||
|
|
||||||
def _timestamps(self, start_time, end_time):
|
|
||||||
|
|
||||||
def _format_timestamp(_time):
|
|
||||||
if _time:
|
|
||||||
if isinstance(_time, datetime.datetime):
|
|
||||||
return _time.isoformat()
|
|
||||||
return _time
|
|
||||||
return None
|
|
||||||
|
|
||||||
start_timestamp = _format_timestamp(start_time)
|
|
||||||
end_timestamp = _format_timestamp(end_time)
|
|
||||||
|
|
||||||
if ((start_timestamp is not None) and (end_timestamp is not None) and
|
|
||||||
(timeutils.parse_isotime(start_timestamp) >
|
|
||||||
timeutils.parse_isotime(end_timestamp))):
|
|
||||||
raise exception.Invalid(
|
|
||||||
_("Invalid query: %(start_time)s > %(end_time)s") % dict(
|
|
||||||
start_time=start_timestamp, end_time=end_timestamp))
|
|
||||||
return start_timestamp, end_timestamp
|
|
||||||
|
|
||||||
def build_query(self, user_id=None, tenant_id=None, resource_id=None,
|
|
||||||
user_ids=None, tenant_ids=None, resource_ids=None,
|
|
||||||
start_time=None, end_time=None):
|
|
||||||
"""Returns query built from given parameters.
|
|
||||||
|
|
||||||
This query can be then used for querying resources, meters and
|
|
||||||
statistics.
|
|
||||||
:param user_id: user_id, has a priority over list of ids
|
|
||||||
:param tenant_id: tenant_id, has a priority over list of ids
|
|
||||||
:param resource_id: resource_id, has a priority over list of ids
|
|
||||||
:param user_ids: list of user_ids
|
|
||||||
:param tenant_ids: list of tenant_ids
|
|
||||||
:param resource_ids: list of resource_ids
|
|
||||||
:param start_time: datetime from which measurements should be collected
|
|
||||||
:param end_time: datetime until which measurements should be collected
|
|
||||||
"""
|
|
||||||
|
|
||||||
query = self.format_query(user_id, tenant_id, resource_id,
|
|
||||||
user_ids, tenant_ids, resource_ids)
|
|
||||||
|
|
||||||
start_timestamp, end_timestamp = self._timestamps(start_time,
|
|
||||||
end_time)
|
|
||||||
|
|
||||||
if start_timestamp:
|
|
||||||
query.append({"field": "timestamp", "op": "ge",
|
|
||||||
"value": start_timestamp})
|
|
||||||
if end_timestamp:
|
|
||||||
query.append({"field": "timestamp", "op": "le",
|
|
||||||
"value": end_timestamp})
|
|
||||||
return query
|
|
||||||
|
|
||||||
def query_retry_reset(self, exception_instance):
|
|
||||||
if isinstance(exception_instance, exc.HTTPUnauthorized):
|
|
||||||
self.osc.reset_clients()
|
|
||||||
self.ceilometer = self.osc.ceilometer()
|
|
||||||
|
|
||||||
def list_metrics(self):
|
|
||||||
"""List the user's meters."""
|
|
||||||
meters = self.query_retry(f=self.ceilometer.meters.list)
|
|
||||||
if not meters:
|
|
||||||
return set()
|
|
||||||
else:
|
|
||||||
return meters
|
|
||||||
|
|
||||||
def check_availability(self):
|
|
||||||
status = self.query_retry(self.ceilometer.resources.list)
|
|
||||||
if status:
|
|
||||||
return 'available'
|
|
||||||
else:
|
|
||||||
return 'not available'
|
|
||||||
|
|
||||||
def query_sample(self, meter_name, query, limit=1):
|
|
||||||
return self.query_retry(f=self.ceilometer.samples.list,
|
|
||||||
meter_name=meter_name,
|
|
||||||
limit=limit,
|
|
||||||
q=query)
|
|
||||||
|
|
||||||
def statistic_aggregation(self, resource=None, resource_type=None,
|
|
||||||
meter_name=None, period=300, granularity=300,
|
|
||||||
aggregate='mean'):
|
|
||||||
end_time = timeutils.utcnow()
|
|
||||||
start_time = end_time - datetime.timedelta(seconds=int(period))
|
|
||||||
|
|
||||||
meter = self._get_meter(meter_name)
|
|
||||||
|
|
||||||
if aggregate == 'mean':
|
|
||||||
aggregate = 'avg'
|
|
||||||
elif aggregate == 'count':
|
|
||||||
aggregate = 'avg'
|
|
||||||
LOG.warning('aggregate type count not supported by ceilometer,'
|
|
||||||
' replaced with mean.')
|
|
||||||
|
|
||||||
resource_id = resource.uuid
|
|
||||||
if resource_type == 'compute_node':
|
|
||||||
resource_id = "%s_%s" % (resource.hostname, resource.hostname)
|
|
||||||
|
|
||||||
query = self.build_query(
|
|
||||||
resource_id=resource_id, start_time=start_time, end_time=end_time)
|
|
||||||
statistic = self.query_retry(f=self.ceilometer.statistics.list,
|
|
||||||
meter_name=meter,
|
|
||||||
q=query,
|
|
||||||
period=period,
|
|
||||||
aggregates=[
|
|
||||||
{'func': aggregate}])
|
|
||||||
|
|
||||||
item_value = None
|
|
||||||
if statistic:
|
|
||||||
item_value = statistic[-1]._info.get('aggregate').get(aggregate)
|
|
||||||
if meter_name == 'host_airflow':
|
|
||||||
# Airflow from hardware.ipmi.node.airflow is reported as
|
|
||||||
# 1/10 th of actual CFM
|
|
||||||
item_value *= 10
|
|
||||||
return item_value
|
|
||||||
|
|
||||||
def statistic_series(self, resource=None, resource_type=None,
|
|
||||||
meter_name=None, start_time=None, end_time=None,
|
|
||||||
granularity=300):
|
|
||||||
raise NotImplementedError(
|
|
||||||
_('Ceilometer helper does not support statistic series method'))
|
|
||||||
|
|
||||||
def get_host_cpu_usage(self, resource, period,
|
|
||||||
aggregate, granularity=None):
|
|
||||||
|
|
||||||
return self.statistic_aggregation(
|
|
||||||
resource, 'compute_node', 'host_cpu_usage', period,
|
|
||||||
aggregate, granularity)
|
|
||||||
|
|
||||||
def get_host_ram_usage(self, resource, period,
|
|
||||||
aggregate, granularity=None):
|
|
||||||
|
|
||||||
return self.statistic_aggregation(
|
|
||||||
resource, 'compute_node', 'host_ram_usage', period,
|
|
||||||
aggregate, granularity)
|
|
||||||
|
|
||||||
def get_host_outlet_temp(self, resource, period,
|
|
||||||
aggregate, granularity=None):
|
|
||||||
|
|
||||||
return self.statistic_aggregation(
|
|
||||||
resource, 'compute_node', 'host_outlet_temp', period,
|
|
||||||
aggregate, granularity)
|
|
||||||
|
|
||||||
def get_host_inlet_temp(self, resource, period,
|
|
||||||
aggregate, granularity=None):
|
|
||||||
|
|
||||||
return self.statistic_aggregation(
|
|
||||||
resource, 'compute_node', 'host_inlet_temp', period,
|
|
||||||
aggregate, granularity)
|
|
||||||
|
|
||||||
def get_host_airflow(self, resource, period,
|
|
||||||
aggregate, granularity=None):
|
|
||||||
|
|
||||||
return self.statistic_aggregation(
|
|
||||||
resource, 'compute_node', 'host_airflow', period,
|
|
||||||
aggregate, granularity)
|
|
||||||
|
|
||||||
def get_host_power(self, resource, period,
|
|
||||||
aggregate, granularity=None):
|
|
||||||
|
|
||||||
return self.statistic_aggregation(
|
|
||||||
resource, 'compute_node', 'host_power', period,
|
|
||||||
aggregate, granularity)
|
|
||||||
|
|
||||||
def get_instance_cpu_usage(self, resource, period,
|
|
||||||
aggregate, granularity=None):
|
|
||||||
|
|
||||||
return self.statistic_aggregation(
|
|
||||||
resource, 'instance', 'instance_cpu_usage', period,
|
|
||||||
aggregate, granularity)
|
|
||||||
|
|
||||||
def get_instance_ram_usage(self, resource, period,
|
|
||||||
aggregate, granularity=None):
|
|
||||||
|
|
||||||
return self.statistic_aggregation(
|
|
||||||
resource, 'instance', 'instance_ram_usage', period,
|
|
||||||
aggregate, granularity)
|
|
||||||
|
|
||||||
def get_instance_ram_allocated(self, resource, period,
|
|
||||||
aggregate, granularity=None):
|
|
||||||
|
|
||||||
return self.statistic_aggregation(
|
|
||||||
resource, 'instance', 'instance_ram_allocated', period,
|
|
||||||
aggregate, granularity)
|
|
||||||
|
|
||||||
def get_instance_l3_cache_usage(self, resource, period,
|
|
||||||
aggregate, granularity=None):
|
|
||||||
|
|
||||||
return self.statistic_aggregation(
|
|
||||||
resource, 'instance', 'instance_l3_cache_usage', period,
|
|
||||||
aggregate, granularity)
|
|
||||||
|
|
||||||
def get_instance_root_disk_size(self, resource, period,
|
|
||||||
aggregate, granularity=None):
|
|
||||||
|
|
||||||
return self.statistic_aggregation(
|
|
||||||
resource, 'instance', 'instance_root_disk_size', period,
|
|
||||||
aggregate, granularity)
|
|
||||||
@@ -21,7 +21,6 @@ from oslo_config import cfg
|
|||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
|
|
||||||
from watcher.common import exception
|
from watcher.common import exception
|
||||||
from watcher.decision_engine.datasources import ceilometer as ceil
|
|
||||||
from watcher.decision_engine.datasources import gnocchi as gnoc
|
from watcher.decision_engine.datasources import gnocchi as gnoc
|
||||||
from watcher.decision_engine.datasources import grafana as graf
|
from watcher.decision_engine.datasources import grafana as graf
|
||||||
from watcher.decision_engine.datasources import monasca as mon
|
from watcher.decision_engine.datasources import monasca as mon
|
||||||
@@ -33,7 +32,6 @@ class DataSourceManager(object):
|
|||||||
|
|
||||||
metric_map = OrderedDict([
|
metric_map = OrderedDict([
|
||||||
(gnoc.GnocchiHelper.NAME, gnoc.GnocchiHelper.METRIC_MAP),
|
(gnoc.GnocchiHelper.NAME, gnoc.GnocchiHelper.METRIC_MAP),
|
||||||
(ceil.CeilometerHelper.NAME, ceil.CeilometerHelper.METRIC_MAP),
|
|
||||||
(mon.MonascaHelper.NAME, mon.MonascaHelper.METRIC_MAP),
|
(mon.MonascaHelper.NAME, mon.MonascaHelper.METRIC_MAP),
|
||||||
(graf.GrafanaHelper.NAME, graf.GrafanaHelper.METRIC_MAP),
|
(graf.GrafanaHelper.NAME, graf.GrafanaHelper.METRIC_MAP),
|
||||||
])
|
])
|
||||||
@@ -44,7 +42,6 @@ class DataSourceManager(object):
|
|||||||
def __init__(self, config=None, osc=None):
|
def __init__(self, config=None, osc=None):
|
||||||
self.osc = osc
|
self.osc = osc
|
||||||
self.config = config
|
self.config = config
|
||||||
self._ceilometer = None
|
|
||||||
self._monasca = None
|
self._monasca = None
|
||||||
self._gnocchi = None
|
self._gnocchi = None
|
||||||
self._grafana = None
|
self._grafana = None
|
||||||
@@ -64,16 +61,6 @@ class DataSourceManager(object):
|
|||||||
|
|
||||||
self.datasources = self.config.datasources
|
self.datasources = self.config.datasources
|
||||||
|
|
||||||
@property
|
|
||||||
def ceilometer(self):
|
|
||||||
if self._ceilometer is None:
|
|
||||||
self.ceilometer = ceil.CeilometerHelper(osc=self.osc)
|
|
||||||
return self._ceilometer
|
|
||||||
|
|
||||||
@ceilometer.setter
|
|
||||||
def ceilometer(self, ceilometer):
|
|
||||||
self._ceilometer = ceilometer
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def monasca(self):
|
def monasca(self):
|
||||||
if self._monasca is None:
|
if self._monasca is None:
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class TestListOpts(base.TestCase):
|
|||||||
'DEFAULT', 'api', 'database', 'watcher_decision_engine',
|
'DEFAULT', 'api', 'database', 'watcher_decision_engine',
|
||||||
'watcher_applier', 'watcher_datasources', 'watcher_planner',
|
'watcher_applier', 'watcher_datasources', 'watcher_planner',
|
||||||
'nova_client', 'glance_client', 'gnocchi_client', 'grafana_client',
|
'nova_client', 'glance_client', 'gnocchi_client', 'grafana_client',
|
||||||
'grafana_translators', 'cinder_client', 'ceilometer_client',
|
'grafana_translators', 'cinder_client',
|
||||||
'monasca_client', 'ironic_client', 'keystone_client',
|
'monasca_client', 'ironic_client', 'keystone_client',
|
||||||
'neutron_client', 'watcher_clients_auth', 'collector',
|
'neutron_client', 'watcher_clients_auth', 'collector',
|
||||||
'placement_client']
|
'placement_client']
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ from watcher.tests import base
|
|||||||
class TestDataSourceManager(base.BaseTestCase):
|
class TestDataSourceManager(base.BaseTestCase):
|
||||||
|
|
||||||
def _dsm_config(self, **kwargs):
|
def _dsm_config(self, **kwargs):
|
||||||
dss = ['gnocchi', 'ceilometer', 'monasca']
|
dss = ['gnocchi', 'monasca']
|
||||||
opts = dict(datasources=dss, metric_map_path=None)
|
opts = dict(datasources=dss, metric_map_path=None)
|
||||||
opts.update(kwargs)
|
opts.update(kwargs)
|
||||||
return MagicMock(**opts)
|
return MagicMock(**opts)
|
||||||
@@ -96,7 +96,7 @@ class TestDataSourceManager(base.BaseTestCase):
|
|||||||
self.assertEqual(backend, manager.gnocchi)
|
self.assertEqual(backend, manager.gnocchi)
|
||||||
|
|
||||||
def test_get_backend_order(self):
|
def test_get_backend_order(self):
|
||||||
dss = ['monasca', 'ceilometer', 'gnocchi']
|
dss = ['monasca', 'gnocchi']
|
||||||
dsmcfg = self._dsm_config(datasources=dss)
|
dsmcfg = self._dsm_config(datasources=dss)
|
||||||
manager = self._dsm(config=dsmcfg)
|
manager = self._dsm(config=dsmcfg)
|
||||||
backend = manager.get_backend(['host_cpu_usage', 'instance_cpu_usage'])
|
backend = manager.get_backend(['host_cpu_usage', 'instance_cpu_usage'])
|
||||||
@@ -112,12 +112,12 @@ class TestDataSourceManager(base.BaseTestCase):
|
|||||||
m_gnocchi.side_effect = exception.DataSourceNotAvailable
|
m_gnocchi.side_effect = exception.DataSourceNotAvailable
|
||||||
manager = self._dsm()
|
manager = self._dsm()
|
||||||
backend = manager.get_backend(['host_cpu_usage', 'instance_cpu_usage'])
|
backend = manager.get_backend(['host_cpu_usage', 'instance_cpu_usage'])
|
||||||
self.assertEqual(backend, manager.ceilometer)
|
self.assertEqual(backend, manager.monasca)
|
||||||
|
|
||||||
@mock.patch.object(grafana.GrafanaHelper, 'METRIC_MAP',
|
@mock.patch.object(grafana.GrafanaHelper, 'METRIC_MAP',
|
||||||
{'host_cpu_usage': 'test'})
|
{'host_cpu_usage': 'test'})
|
||||||
def test_get_backend_grafana(self):
|
def test_get_backend_grafana(self):
|
||||||
dss = ['grafana', 'ceilometer', 'gnocchi']
|
dss = ['grafana', 'gnocchi']
|
||||||
dsmcfg = self._dsm_config(datasources=dss)
|
dsmcfg = self._dsm_config(datasources=dss)
|
||||||
manager = self._dsm(config=dsmcfg)
|
manager = self._dsm(config=dsmcfg)
|
||||||
backend = manager.get_backend(['host_cpu_usage'])
|
backend = manager.get_backend(['host_cpu_usage'])
|
||||||
@@ -135,7 +135,7 @@ class TestDataSourceManager(base.BaseTestCase):
|
|||||||
m_config.grafana_client.query_map = {
|
m_config.grafana_client.query_map = {
|
||||||
'host_cpu_usage': 'SHOW SERIES'
|
'host_cpu_usage': 'SHOW SERIES'
|
||||||
}
|
}
|
||||||
dss = ['grafana', 'ceilometer', 'gnocchi']
|
dss = ['grafana', 'gnocchi']
|
||||||
dsmcfg = self._dsm_config(datasources=dss)
|
dsmcfg = self._dsm_config(datasources=dss)
|
||||||
manager = self._dsm(config=dsmcfg)
|
manager = self._dsm(config=dsmcfg)
|
||||||
backend = manager.get_backend(['host_cpu_usage'])
|
backend = manager.get_backend(['host_cpu_usage'])
|
||||||
|
|||||||
@@ -1,319 +0,0 @@
|
|||||||
# -*- encoding: utf-8 -*-
|
|
||||||
# Copyright (c) 2015 b<>com
|
|
||||||
#
|
|
||||||
# Authors: Jean-Emile DARTOIS <jean-emile.dartois@b-com.com>
|
|
||||||
#
|
|
||||||
# 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.
|
|
||||||
|
|
||||||
import oslo_utils
|
|
||||||
|
|
||||||
|
|
||||||
class FakeCeilometerMetrics(object):
|
|
||||||
NAME = 'ceilometer'
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
self.emptytype = ""
|
|
||||||
|
|
||||||
def empty_one_metric(self, emptytype):
|
|
||||||
self.emptytype = emptytype
|
|
||||||
|
|
||||||
def mock_get_statistics(self, resource=None, resource_type=None,
|
|
||||||
meter_name=None, period=None, aggregate='mean',
|
|
||||||
granularity=None):
|
|
||||||
result = 0
|
|
||||||
if meter_name == 'host_cpu_usage':
|
|
||||||
result = self.get_usage_compute_node_cpu(resource)
|
|
||||||
elif meter_name == 'host_ram_usage':
|
|
||||||
result = self.get_usage_compute_node_ram(resource)
|
|
||||||
elif meter_name == 'host_outlet_temp':
|
|
||||||
result = self.get_average_outlet_temp(resource)
|
|
||||||
elif meter_name == 'host_inlet_temp':
|
|
||||||
result = self.get_average_inlet_temp(resource)
|
|
||||||
elif meter_name == 'host_airflow':
|
|
||||||
result = self.get_average_airflow(resource)
|
|
||||||
elif meter_name == 'host_power':
|
|
||||||
result = self.get_average_power(resource)
|
|
||||||
elif meter_name == 'instance_cpu_usage':
|
|
||||||
result = self.get_average_usage_instance_cpu(resource)
|
|
||||||
elif meter_name == 'instance_ram_usage':
|
|
||||||
result = self.get_average_usage_instance_memory(resource)
|
|
||||||
return result
|
|
||||||
|
|
||||||
def mock_get_statistics_nn(self, resource=None, meter_name=None,
|
|
||||||
period=None, aggregate='mean', granularity=300):
|
|
||||||
"""Statistics for noisy neighbor strategy
|
|
||||||
|
|
||||||
Signature should match DataSourceBase.get_instance_l3_cache_usage
|
|
||||||
"""
|
|
||||||
|
|
||||||
result = 0.0
|
|
||||||
if period == 100:
|
|
||||||
result = self.get_average_l3_cache_current(resource)
|
|
||||||
if period == 200:
|
|
||||||
result = self.get_average_l3_cache_previous(resource)
|
|
||||||
return result
|
|
||||||
|
|
||||||
def mock_get_statistics_wb(self, resource=None, resource_type=None,
|
|
||||||
meter_name=None, period=None, aggregate='mean',
|
|
||||||
granularity=None):
|
|
||||||
"""Statistics for workload balance strategy"""
|
|
||||||
|
|
||||||
result = 0.0
|
|
||||||
if meter_name == 'instance_cpu_usage':
|
|
||||||
result = self.get_average_usage_instance_cpu_wb(resource)
|
|
||||||
elif meter_name == 'instance_ram_usage':
|
|
||||||
result = self.get_average_usage_instance_memory_wb(resource)
|
|
||||||
return result
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def get_average_l3_cache_current(resource):
|
|
||||||
"""The average l3 cache used by instance"""
|
|
||||||
|
|
||||||
uuid = resource.uuid
|
|
||||||
|
|
||||||
mock = {}
|
|
||||||
mock['73b09e16-35b7-4922-804e-e8f5d9b740fc'] = 35 * oslo_utils.units.Ki
|
|
||||||
mock['cae81432-1631-4d4e-b29c-6f3acdcde906'] = 30 * oslo_utils.units.Ki
|
|
||||||
mock['INSTANCE_3'] = 40 * oslo_utils.units.Ki
|
|
||||||
mock['INSTANCE_4'] = 35 * oslo_utils.units.Ki
|
|
||||||
|
|
||||||
return mock[str(uuid)]
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def get_average_l3_cache_previous(resource):
|
|
||||||
"""The average l3 cache used by instance"""
|
|
||||||
|
|
||||||
uuid = resource.uuid
|
|
||||||
|
|
||||||
mock = {}
|
|
||||||
mock['73b09e16-35b7-4922-804e-e8f5d9b740fc'] = 34.5 * (
|
|
||||||
oslo_utils.units.Ki)
|
|
||||||
mock['cae81432-1631-4d4e-b29c-6f3acdcde906'] = 30.5 * (
|
|
||||||
oslo_utils.units.Ki)
|
|
||||||
mock['INSTANCE_3'] = 60 * oslo_utils.units.Ki
|
|
||||||
mock['INSTANCE_4'] = 22.5 * oslo_utils.units.Ki
|
|
||||||
|
|
||||||
return mock[str(uuid)]
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def get_average_outlet_temp(resource):
|
|
||||||
"""The average outlet temperature for host"""
|
|
||||||
|
|
||||||
uuid = resource.uuid
|
|
||||||
mock = {}
|
|
||||||
mock["fa69c544-906b-4a6a-a9c6-c1f7a8078c73"] = 30
|
|
||||||
# use a big value to make sure it exceeds threshold
|
|
||||||
mock["af69c544-906b-4a6a-a9c6-c1f7a8078c73"] = 100
|
|
||||||
if uuid not in mock.keys():
|
|
||||||
mock[uuid] = 100
|
|
||||||
return float(mock[str(uuid)])
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def get_usage_compute_node_ram(resource):
|
|
||||||
|
|
||||||
uuid = resource.uuid
|
|
||||||
mock = {}
|
|
||||||
# Ceilometer returns hardware.memory.used samples in KB.
|
|
||||||
mock['Node_0'] = 7 * oslo_utils.units.Ki
|
|
||||||
mock['Node_1'] = 5 * oslo_utils.units.Ki
|
|
||||||
mock['Node_2'] = 29 * oslo_utils.units.Ki
|
|
||||||
mock['Node_3'] = 8 * oslo_utils.units.Ki
|
|
||||||
mock['Node_4'] = 4 * oslo_utils.units.Ki
|
|
||||||
|
|
||||||
if uuid not in mock.keys():
|
|
||||||
# mock[uuid] = random.randint(1, 4)
|
|
||||||
mock[uuid] = 8
|
|
||||||
|
|
||||||
return float(mock[str(uuid)])
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def get_average_airflow(resource):
|
|
||||||
"""The average outlet temperature for host"""
|
|
||||||
|
|
||||||
uuid = resource.uuid
|
|
||||||
mock = {}
|
|
||||||
mock['Node_0'] = 400
|
|
||||||
# use a big value to make sure it exceeds threshold
|
|
||||||
mock['Node_1'] = 100
|
|
||||||
if uuid not in mock.keys():
|
|
||||||
mock[uuid] = 200
|
|
||||||
return mock[str(uuid)]
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def get_average_inlet_temp(resource):
|
|
||||||
"""The average outlet temperature for host"""
|
|
||||||
|
|
||||||
uuid = resource.uuid
|
|
||||||
mock = {}
|
|
||||||
mock['Node_0'] = 24
|
|
||||||
mock['Node_1'] = 26
|
|
||||||
if uuid not in mock.keys():
|
|
||||||
mock[uuid] = 28
|
|
||||||
return mock[str(uuid)]
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def get_average_power(resource):
|
|
||||||
"""The average outlet temperature for host"""
|
|
||||||
|
|
||||||
uuid = resource.uuid
|
|
||||||
mock = {}
|
|
||||||
mock['Node_0'] = 260
|
|
||||||
mock['Node_1'] = 240
|
|
||||||
if uuid not in mock.keys():
|
|
||||||
mock[uuid] = 200
|
|
||||||
return mock[str(uuid)]
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def get_usage_compute_node_cpu(*args, **kwargs):
|
|
||||||
"""The last VM CPU usage values to average
|
|
||||||
|
|
||||||
:param uuid:00
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
|
|
||||||
resource = args[0]
|
|
||||||
uuid = "%s_%s" % (resource.uuid, resource.hostname)
|
|
||||||
|
|
||||||
measurements = {}
|
|
||||||
# node 0
|
|
||||||
measurements['Node_0_hostname_0'] = 7
|
|
||||||
measurements['Node_1_hostname_1'] = 7
|
|
||||||
measurements['fa69c544-906b-4a6a-a9c6-c1f7a8078c73_hostname_0'] = 7
|
|
||||||
measurements['af69c544-906b-4a6a-a9c6-c1f7a8078c73_hostname_1'] = 7
|
|
||||||
# node 1
|
|
||||||
measurements['Node_2_hostname_2'] = 80
|
|
||||||
# node 2
|
|
||||||
measurements['Node_3_hostname_3'] = 5
|
|
||||||
measurements['Node_4_hostname_4'] = 5
|
|
||||||
measurements['Node_5_hostname_5'] = 10
|
|
||||||
|
|
||||||
# node 3
|
|
||||||
measurements['Node_6_hostname_6'] = 8
|
|
||||||
# This node doesn't send metrics
|
|
||||||
measurements['LOST_NODE_hostname_7'] = None
|
|
||||||
measurements['Node_19_hostname_19'] = 10
|
|
||||||
# node 4
|
|
||||||
measurements['INSTANCE_7_hostname_7'] = 4
|
|
||||||
|
|
||||||
result = measurements[uuid]
|
|
||||||
return float(result) if result is not None else None
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def get_average_usage_instance_cpu_wb(resource):
|
|
||||||
"""The last VM CPU usage values to average
|
|
||||||
|
|
||||||
:param resource:
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
|
|
||||||
uuid = resource.uuid
|
|
||||||
|
|
||||||
mock = {}
|
|
||||||
# node 0
|
|
||||||
mock['INSTANCE_1'] = 80
|
|
||||||
mock['73b09e16-35b7-4922-804e-e8f5d9b740fc'] = 50
|
|
||||||
# node 1
|
|
||||||
mock['INSTANCE_3'] = 20
|
|
||||||
mock['INSTANCE_4'] = 10
|
|
||||||
|
|
||||||
return float(mock[str(uuid)])
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def get_average_usage_instance_memory_wb(resource):
|
|
||||||
uuid = resource.uuid
|
|
||||||
|
|
||||||
mock = {}
|
|
||||||
# node 0
|
|
||||||
mock['INSTANCE_1'] = 30
|
|
||||||
mock['73b09e16-35b7-4922-804e-e8f5d9b740fc'] = 12
|
|
||||||
# node 1
|
|
||||||
mock['INSTANCE_3'] = 12
|
|
||||||
mock['INSTANCE_4'] = 12
|
|
||||||
|
|
||||||
return mock[str(uuid)]
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def get_average_usage_instance_cpu(*args, **kwargs):
|
|
||||||
"""The last VM CPU usage values to average
|
|
||||||
|
|
||||||
:param uuid:00
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
|
|
||||||
resource = args[0]
|
|
||||||
uuid = resource.uuid
|
|
||||||
|
|
||||||
mock = {}
|
|
||||||
# node 0
|
|
||||||
mock['INSTANCE_0'] = 7
|
|
||||||
mock['INSTANCE_1'] = 7
|
|
||||||
# node 1
|
|
||||||
mock['INSTANCE_2'] = 10
|
|
||||||
# node 2
|
|
||||||
mock['INSTANCE_3'] = 5
|
|
||||||
mock['INSTANCE_4'] = 5
|
|
||||||
mock['INSTANCE_5'] = 10
|
|
||||||
# node 3
|
|
||||||
mock['INSTANCE_6'] = 8
|
|
||||||
# node 4
|
|
||||||
mock['INSTANCE_7'] = 4
|
|
||||||
mock['LOST_INSTANCE'] = None
|
|
||||||
|
|
||||||
# metrics might be missing in scenarios which do not do computations
|
|
||||||
if uuid not in mock.keys():
|
|
||||||
mock[uuid] = 0
|
|
||||||
|
|
||||||
return mock[str(uuid)]
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def get_average_usage_instance_memory(resource):
|
|
||||||
uuid = resource.uuid
|
|
||||||
|
|
||||||
mock = {}
|
|
||||||
# node 0
|
|
||||||
mock['INSTANCE_0'] = 2
|
|
||||||
mock['INSTANCE_1'] = 5
|
|
||||||
# node 1
|
|
||||||
mock['INSTANCE_2'] = 5
|
|
||||||
# node 2
|
|
||||||
mock['INSTANCE_3'] = 8
|
|
||||||
mock['INSTANCE_4'] = 5
|
|
||||||
mock['INSTANCE_5'] = 16
|
|
||||||
# node 3
|
|
||||||
mock['INSTANCE_6'] = 8
|
|
||||||
# node 4
|
|
||||||
mock['INSTANCE_7'] = 4
|
|
||||||
|
|
||||||
return mock[str(uuid)]
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def get_average_usage_instance_disk(resource):
|
|
||||||
uuid = resource.uuid
|
|
||||||
|
|
||||||
mock = {}
|
|
||||||
# node 0
|
|
||||||
mock['INSTANCE_0'] = 2
|
|
||||||
mock['INSTANCE_1'] = 2
|
|
||||||
# node 1
|
|
||||||
mock['INSTANCE_2'] = 2
|
|
||||||
# node 2
|
|
||||||
mock['INSTANCE_3'] = 10
|
|
||||||
mock['INSTANCE_4'] = 15
|
|
||||||
mock['INSTANCE_5'] = 20
|
|
||||||
# node 3
|
|
||||||
mock['INSTANCE_6'] = 8
|
|
||||||
# node 4
|
|
||||||
mock['INSTANCE_7'] = 4
|
|
||||||
|
|
||||||
return mock[str(uuid)]
|
|
||||||
@@ -25,8 +25,8 @@ from watcher.decision_engine.strategy import strategies
|
|||||||
from watcher import objects
|
from watcher import objects
|
||||||
from watcher.tests.db import base
|
from watcher.tests.db import base
|
||||||
from watcher.tests.db import utils as db_utils
|
from watcher.tests.db import utils as db_utils
|
||||||
from watcher.tests.decision_engine.model import ceilometer_metrics as fake
|
|
||||||
from watcher.tests.decision_engine.model import faker_cluster_state
|
from watcher.tests.decision_engine.model import faker_cluster_state
|
||||||
|
from watcher.tests.decision_engine.model import gnocchi_metrics as fake
|
||||||
from watcher.tests.objects import utils as obj_utils
|
from watcher.tests.objects import utils as obj_utils
|
||||||
|
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ class SolutionFaker(object):
|
|||||||
current_state_cluster = faker_cluster_state.FakerModelCollector()
|
current_state_cluster = faker_cluster_state.FakerModelCollector()
|
||||||
sercon = strategies.BasicConsolidation(config=mock.Mock())
|
sercon = strategies.BasicConsolidation(config=mock.Mock())
|
||||||
sercon.compute_model = current_state_cluster.generate_scenario_1()
|
sercon.compute_model = current_state_cluster.generate_scenario_1()
|
||||||
sercon.ceilometer = mock.MagicMock(
|
sercon.gnocchi = mock.MagicMock(
|
||||||
get_statistics=metrics.mock_get_statistics)
|
get_statistics=metrics.mock_get_statistics)
|
||||||
return sercon.execute()
|
return sercon.execute()
|
||||||
|
|
||||||
@@ -50,7 +50,7 @@ class SolutionFakerSingleHyp(object):
|
|||||||
sercon = strategies.BasicConsolidation(config=mock.Mock())
|
sercon = strategies.BasicConsolidation(config=mock.Mock())
|
||||||
sercon.compute_model = (
|
sercon.compute_model = (
|
||||||
current_state_cluster.generate_scenario_3_with_2_nodes())
|
current_state_cluster.generate_scenario_3_with_2_nodes())
|
||||||
sercon.ceilometer = mock.MagicMock(
|
sercon.gnocchi = mock.MagicMock(
|
||||||
get_statistics=metrics.mock_get_statistics)
|
get_statistics=metrics.mock_get_statistics)
|
||||||
|
|
||||||
return sercon.execute()
|
return sercon.execute()
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ from watcher.decision_engine.strategy import strategies
|
|||||||
from watcher import objects
|
from watcher import objects
|
||||||
from watcher.tests.db import base
|
from watcher.tests.db import base
|
||||||
from watcher.tests.db import utils as db_utils
|
from watcher.tests.db import utils as db_utils
|
||||||
from watcher.tests.decision_engine.model import ceilometer_metrics as fake
|
|
||||||
from watcher.tests.decision_engine.model import faker_cluster_state
|
from watcher.tests.decision_engine.model import faker_cluster_state
|
||||||
|
from watcher.tests.decision_engine.model import gnocchi_metrics as fake
|
||||||
from watcher.tests.objects import utils as obj_utils
|
from watcher.tests.objects import utils as obj_utils
|
||||||
|
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ class SolutionFaker(object):
|
|||||||
current_state_cluster = faker_cluster_state.FakerModelCollector()
|
current_state_cluster = faker_cluster_state.FakerModelCollector()
|
||||||
sercon = strategies.BasicConsolidation(config=mock.Mock())
|
sercon = strategies.BasicConsolidation(config=mock.Mock())
|
||||||
sercon._compute_model = current_state_cluster.generate_scenario_1()
|
sercon._compute_model = current_state_cluster.generate_scenario_1()
|
||||||
sercon.ceilometer = mock.MagicMock(
|
sercon.gnocchi = mock.MagicMock(
|
||||||
get_statistics=metrics.mock_get_statistics)
|
get_statistics=metrics.mock_get_statistics)
|
||||||
return sercon.execute()
|
return sercon.execute()
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ class SolutionFakerSingleHyp(object):
|
|||||||
sercon = strategies.BasicConsolidation(config=mock.Mock())
|
sercon = strategies.BasicConsolidation(config=mock.Mock())
|
||||||
sercon._compute_model = (
|
sercon._compute_model = (
|
||||||
current_state_cluster.generate_scenario_3_with_2_nodes())
|
current_state_cluster.generate_scenario_3_with_2_nodes())
|
||||||
sercon.ceilometer = mock.MagicMock(
|
sercon.gnocchi = mock.MagicMock(
|
||||||
get_statistics=metrics.mock_get_statistics)
|
get_statistics=metrics.mock_get_statistics)
|
||||||
|
|
||||||
return sercon.execute()
|
return sercon.execute()
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ class TestBaseStrategyDatasource(TestBaseStrategy):
|
|||||||
"""Test if the global preference is used"""
|
"""Test if the global preference is used"""
|
||||||
|
|
||||||
m_conf.watcher_datasources.datasources = \
|
m_conf.watcher_datasources.datasources = \
|
||||||
['gnocchi', 'monasca', 'ceilometer']
|
['gnocchi', 'monasca']
|
||||||
|
|
||||||
# Make sure we access the property and not the underlying function.
|
# Make sure we access the property and not the underlying function.
|
||||||
m_manager.return_value.get_backend.return_value = \
|
m_manager.return_value.get_backend.return_value = \
|
||||||
@@ -84,7 +84,7 @@ class TestBaseStrategyDatasource(TestBaseStrategy):
|
|||||||
"""Test if the global preference is used with another order"""
|
"""Test if the global preference is used with another order"""
|
||||||
|
|
||||||
m_conf.watcher_datasources.datasources = \
|
m_conf.watcher_datasources.datasources = \
|
||||||
['ceilometer', 'monasca', 'gnocchi']
|
['monasca', 'gnocchi']
|
||||||
|
|
||||||
# Make sure we access the property and not the underlying function.
|
# Make sure we access the property and not the underlying function.
|
||||||
m_manager.return_value.get_backend.return_value = \
|
m_manager.return_value.get_backend.return_value = \
|
||||||
@@ -103,13 +103,13 @@ class TestBaseStrategyDatasource(TestBaseStrategy):
|
|||||||
def test_strategy_preference_override(self, m_conf, m_manager):
|
def test_strategy_preference_override(self, m_conf, m_manager):
|
||||||
"""Test if the global preference can be overridden"""
|
"""Test if the global preference can be overridden"""
|
||||||
|
|
||||||
datasources = mock.Mock(datasources=['ceilometer'])
|
datasources = mock.Mock(datasources=['gnocchi'])
|
||||||
|
|
||||||
self.strategy = strategies.DummyStrategy(
|
self.strategy = strategies.DummyStrategy(
|
||||||
config=datasources)
|
config=datasources)
|
||||||
|
|
||||||
m_conf.watcher_datasources.datasources = \
|
m_conf.watcher_datasources.datasources = \
|
||||||
['ceilometer', 'monasca', 'gnocchi']
|
['monasca', 'gnocchi']
|
||||||
|
|
||||||
# Access the property so that the configuration is read in order to
|
# Access the property so that the configuration is read in order to
|
||||||
# get the correct datasource
|
# get the correct datasource
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ from watcher.applier.loading import default
|
|||||||
from watcher.common import clients
|
from watcher.common import clients
|
||||||
from watcher.decision_engine.model import model_root
|
from watcher.decision_engine.model import model_root
|
||||||
from watcher.decision_engine.strategy import strategies
|
from watcher.decision_engine.strategy import strategies
|
||||||
from watcher.tests.decision_engine.model import ceilometer_metrics
|
|
||||||
from watcher.tests.decision_engine.model import gnocchi_metrics
|
from watcher.tests.decision_engine.model import gnocchi_metrics
|
||||||
from watcher.tests.decision_engine.model import monasca_metrics
|
from watcher.tests.decision_engine.model import monasca_metrics
|
||||||
from watcher.tests.decision_engine.strategy.strategies.test_base \
|
from watcher.tests.decision_engine.strategy.strategies.test_base \
|
||||||
@@ -34,9 +33,6 @@ from watcher.tests.decision_engine.strategy.strategies.test_base \
|
|||||||
class TestBasicConsolidation(TestBaseStrategy):
|
class TestBasicConsolidation(TestBaseStrategy):
|
||||||
|
|
||||||
scenarios = [
|
scenarios = [
|
||||||
("Ceilometer",
|
|
||||||
{"datasource": "ceilometer",
|
|
||||||
"fake_datasource_cls": ceilometer_metrics.FakeCeilometerMetrics}),
|
|
||||||
("Monasca",
|
("Monasca",
|
||||||
{"datasource": "monasca",
|
{"datasource": "monasca",
|
||||||
"fake_datasource_cls": monasca_metrics.FakeMonascaMetrics}),
|
"fake_datasource_cls": monasca_metrics.FakeMonascaMetrics}),
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ from unittest import mock
|
|||||||
from watcher.applier.loading import default
|
from watcher.applier.loading import default
|
||||||
from watcher.common import utils
|
from watcher.common import utils
|
||||||
from watcher.decision_engine.strategy import strategies
|
from watcher.decision_engine.strategy import strategies
|
||||||
from watcher.tests.decision_engine.model import ceilometer_metrics
|
|
||||||
from watcher.tests.decision_engine.model import gnocchi_metrics
|
from watcher.tests.decision_engine.model import gnocchi_metrics
|
||||||
from watcher.tests.decision_engine.strategy.strategies.test_base \
|
from watcher.tests.decision_engine.strategy.strategies.test_base \
|
||||||
import TestBaseStrategy
|
import TestBaseStrategy
|
||||||
@@ -31,9 +30,6 @@ from watcher.tests.decision_engine.strategy.strategies.test_base \
|
|||||||
class TestNoisyNeighbor(TestBaseStrategy):
|
class TestNoisyNeighbor(TestBaseStrategy):
|
||||||
|
|
||||||
scenarios = [
|
scenarios = [
|
||||||
("Ceilometer",
|
|
||||||
{"datasource": "ceilometer",
|
|
||||||
"fake_datasource_cls": ceilometer_metrics.FakeCeilometerMetrics}),
|
|
||||||
("Gnocchi",
|
("Gnocchi",
|
||||||
{"datasource": "gnocchi",
|
{"datasource": "gnocchi",
|
||||||
"fake_datasource_cls": gnocchi_metrics.FakeGnocchiMetrics}),
|
"fake_datasource_cls": gnocchi_metrics.FakeGnocchiMetrics}),
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ from unittest import mock
|
|||||||
from watcher.applier.loading import default
|
from watcher.applier.loading import default
|
||||||
from watcher.common import utils
|
from watcher.common import utils
|
||||||
from watcher.decision_engine.strategy import strategies
|
from watcher.decision_engine.strategy import strategies
|
||||||
from watcher.tests.decision_engine.model import ceilometer_metrics
|
|
||||||
from watcher.tests.decision_engine.model import gnocchi_metrics
|
from watcher.tests.decision_engine.model import gnocchi_metrics
|
||||||
from watcher.tests.decision_engine.strategy.strategies.test_base \
|
from watcher.tests.decision_engine.strategy.strategies.test_base \
|
||||||
import TestBaseStrategy
|
import TestBaseStrategy
|
||||||
@@ -31,9 +30,6 @@ from watcher.tests.decision_engine.strategy.strategies.test_base \
|
|||||||
class TestOutletTempControl(TestBaseStrategy):
|
class TestOutletTempControl(TestBaseStrategy):
|
||||||
|
|
||||||
scenarios = [
|
scenarios = [
|
||||||
("Ceilometer",
|
|
||||||
{"datasource": "ceilometer",
|
|
||||||
"fake_datasource_cls": ceilometer_metrics.FakeCeilometerMetrics}),
|
|
||||||
("Gnocchi",
|
("Gnocchi",
|
||||||
{"datasource": "gnocchi",
|
{"datasource": "gnocchi",
|
||||||
"fake_datasource_cls": gnocchi_metrics.FakeGnocchiMetrics}),
|
"fake_datasource_cls": gnocchi_metrics.FakeGnocchiMetrics}),
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ from unittest import mock
|
|||||||
from watcher.applier.loading import default
|
from watcher.applier.loading import default
|
||||||
from watcher.common import utils
|
from watcher.common import utils
|
||||||
from watcher.decision_engine.strategy import strategies
|
from watcher.decision_engine.strategy import strategies
|
||||||
from watcher.tests.decision_engine.model import ceilometer_metrics
|
|
||||||
from watcher.tests.decision_engine.model import gnocchi_metrics
|
from watcher.tests.decision_engine.model import gnocchi_metrics
|
||||||
from watcher.tests.decision_engine.strategy.strategies.test_base \
|
from watcher.tests.decision_engine.strategy.strategies.test_base \
|
||||||
import TestBaseStrategy
|
import TestBaseStrategy
|
||||||
@@ -31,9 +30,6 @@ from watcher.tests.decision_engine.strategy.strategies.test_base \
|
|||||||
class TestUniformAirflow(TestBaseStrategy):
|
class TestUniformAirflow(TestBaseStrategy):
|
||||||
|
|
||||||
scenarios = [
|
scenarios = [
|
||||||
("Ceilometer",
|
|
||||||
{"datasource": "ceilometer",
|
|
||||||
"fake_datasource_cls": ceilometer_metrics.FakeCeilometerMetrics}),
|
|
||||||
("Gnocchi",
|
("Gnocchi",
|
||||||
{"datasource": "gnocchi",
|
{"datasource": "gnocchi",
|
||||||
"fake_datasource_cls": gnocchi_metrics.FakeGnocchiMetrics}),
|
"fake_datasource_cls": gnocchi_metrics.FakeGnocchiMetrics}),
|
||||||
|
|||||||
@@ -31,10 +31,6 @@ from watcher.tests.decision_engine.strategy.strategies.test_base \
|
|||||||
class TestVMWorkloadConsolidation(TestBaseStrategy):
|
class TestVMWorkloadConsolidation(TestBaseStrategy):
|
||||||
|
|
||||||
scenarios = [
|
scenarios = [
|
||||||
("Ceilometer",
|
|
||||||
{"datasource": "ceilometer",
|
|
||||||
"fake_datasource_cls":
|
|
||||||
faker_cluster_and_metrics.FakeCeilometerMetrics}),
|
|
||||||
("Gnocchi",
|
("Gnocchi",
|
||||||
{"datasource": "gnocchi",
|
{"datasource": "gnocchi",
|
||||||
"fake_datasource_cls":
|
"fake_datasource_cls":
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ from unittest import mock
|
|||||||
from watcher.applier.loading import default
|
from watcher.applier.loading import default
|
||||||
from watcher.common import utils
|
from watcher.common import utils
|
||||||
from watcher.decision_engine.strategy import strategies
|
from watcher.decision_engine.strategy import strategies
|
||||||
from watcher.tests.decision_engine.model import ceilometer_metrics
|
|
||||||
from watcher.tests.decision_engine.model import gnocchi_metrics
|
from watcher.tests.decision_engine.model import gnocchi_metrics
|
||||||
from watcher.tests.decision_engine.strategy.strategies.test_base \
|
from watcher.tests.decision_engine.strategy.strategies.test_base \
|
||||||
import TestBaseStrategy
|
import TestBaseStrategy
|
||||||
@@ -31,9 +30,6 @@ from watcher.tests.decision_engine.strategy.strategies.test_base \
|
|||||||
class TestWorkloadBalance(TestBaseStrategy):
|
class TestWorkloadBalance(TestBaseStrategy):
|
||||||
|
|
||||||
scenarios = [
|
scenarios = [
|
||||||
("Ceilometer",
|
|
||||||
{"datasource": "ceilometer",
|
|
||||||
"fake_datasource_cls": ceilometer_metrics.FakeCeilometerMetrics}),
|
|
||||||
("Gnocchi",
|
("Gnocchi",
|
||||||
{"datasource": "gnocchi",
|
{"datasource": "gnocchi",
|
||||||
"fake_datasource_cls": gnocchi_metrics.FakeGnocchiMetrics}),
|
"fake_datasource_cls": gnocchi_metrics.FakeGnocchiMetrics}),
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ from unittest import mock
|
|||||||
from watcher.common import clients
|
from watcher.common import clients
|
||||||
from watcher.common import utils
|
from watcher.common import utils
|
||||||
from watcher.decision_engine.strategy import strategies
|
from watcher.decision_engine.strategy import strategies
|
||||||
from watcher.tests.decision_engine.model import ceilometer_metrics
|
|
||||||
from watcher.tests.decision_engine.model import gnocchi_metrics
|
from watcher.tests.decision_engine.model import gnocchi_metrics
|
||||||
from watcher.tests.decision_engine.strategy.strategies.test_base \
|
from watcher.tests.decision_engine.strategy.strategies.test_base \
|
||||||
import TestBaseStrategy
|
import TestBaseStrategy
|
||||||
@@ -31,9 +30,6 @@ from watcher.tests.decision_engine.strategy.strategies.test_base \
|
|||||||
class TestWorkloadStabilization(TestBaseStrategy):
|
class TestWorkloadStabilization(TestBaseStrategy):
|
||||||
|
|
||||||
scenarios = [
|
scenarios = [
|
||||||
("Ceilometer",
|
|
||||||
{"datasource": "ceilometer",
|
|
||||||
"fake_datasource_cls": ceilometer_metrics.FakeCeilometerMetrics}),
|
|
||||||
("Gnocchi",
|
("Gnocchi",
|
||||||
{"datasource": "gnocchi",
|
{"datasource": "gnocchi",
|
||||||
"fake_datasource_cls": gnocchi_metrics.FakeGnocchiMetrics}),
|
"fake_datasource_cls": gnocchi_metrics.FakeGnocchiMetrics}),
|
||||||
|
|||||||
Reference in New Issue
Block a user