Fix uniform airflow strategy config parameter

'datasource' should be 'datasources'

Change-Id: I2bd183e020298a93029f38008619a5bebaed3de4
This commit is contained in:
licanwei
2019-02-20 09:35:07 +08:00
parent e74ab79e81
commit 4590c47aec
4 changed files with 22 additions and 12 deletions

View File

@@ -90,12 +90,6 @@ class UniformAirflow(base.BaseStrategy):
super(UniformAirflow, self).__init__(config, osc)
# The migration plan will be triggered when the airflow reaches
# threshold
self.meter_name_airflow = self.METRIC_NAMES[
self.config.datasource]['host_airflow']
self.meter_name_inlet_t = self.METRIC_NAMES[
self.config.datasource]['host_inlet_temp']
self.meter_name_power = self.METRIC_NAMES[
self.config.datasource]['host_power']
self._period = self.PERIOD
@classmethod
@@ -158,11 +152,14 @@ class UniformAirflow(base.BaseStrategy):
@classmethod
def get_config_opts(cls):
return [
cfg.StrOpt(
"datasource",
help="Data source to use in order to query the needed metrics",
default="gnocchi",
choices=["ceilometer", "gnocchi"])
cfg.ListOpt(
"datasources",
help="Datasources to use in order to query the needed metrics."
" If one of strategy metric isn't available in the first"
" datasource, the next datasource will be chosen.",
item_type=cfg.types.String(choices=['gnocchi', 'ceilometer',
'monasca']),
default=['gnocchi', 'ceilometer', 'monasca']),
]
def get_available_compute_nodes(self):
@@ -317,6 +314,13 @@ class UniformAirflow(base.BaseStrategy):
if self.compute_model.stale:
raise wexc.ClusterStateStale()
self.meter_name_airflow = self.METRIC_NAMES[
self.datasource_backend.NAME]['host_airflow']
self.meter_name_inlet_t = self.METRIC_NAMES[
self.datasource_backend.NAME]['host_inlet_temp']
self.meter_name_power = self.METRIC_NAMES[
self.datasource_backend.NAME]['host_power']
LOG.debug(self.compute_model.to_string())
def do_execute(self):

View File

@@ -20,6 +20,8 @@ import oslo_utils
class FakeCeilometerMetrics(object):
NAME = 'ceilometer'
def __init__(self):
self.emptytype = ""

View File

@@ -15,6 +15,8 @@ import oslo_utils
class FakeGnocchiMetrics(object):
NAME = 'gnocchi'
def __init__(self):
self.emptytype = ""

View File

@@ -71,7 +71,8 @@ class TestUniformAirflow(base.TestCase):
self.m_model.return_value = model_root.ModelRoot()
self.m_datasource.return_value = mock.Mock(
statistic_aggregation=self.fake_metrics.mock_get_statistics)
statistic_aggregation=self.fake_metrics.mock_get_statistics,
NAME=self.fake_metrics.NAME)
self.strategy = strategies.UniformAirflow(
config=mock.Mock(datasource=self.datasource))
self.strategy.input_parameters = utils.Struct()
@@ -83,6 +84,7 @@ class TestUniformAirflow(base.TestCase):
self.strategy.threshold_inlet_t = 28
self.strategy.threshold_power = 350
self._period = 300
self.strategy.pre_execute()
def test_calc_used_resource(self):
model = self.fake_cluster.generate_scenario_7_with_2_nodes()