From dd3c4d5507b9c0533d9e43c98479a0503f22e876 Mon Sep 17 00:00:00 2001 From: licanwei Date: Wed, 20 Feb 2019 09:53:11 +0800 Subject: [PATCH] Fix outlet_temp_control config parameter 'datasource' should be 'datasources' Change-Id: Iad337313f5d03b2fef34902950a4b5e41b3e980f Depends-On: I2bd183e020298a93029f38008619a5bebaed3de4 --- .../strategy/strategies/outlet_temp_control.py | 15 +++++++++------ .../strategies/test_outlet_temp_control.py | 3 ++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/watcher/decision_engine/strategy/strategies/outlet_temp_control.py b/watcher/decision_engine/strategy/strategies/outlet_temp_control.py index 1b5249eab..c0412a952 100644 --- a/watcher/decision_engine/strategy/strategies/outlet_temp_control.py +++ b/watcher/decision_engine/strategy/strategies/outlet_temp_control.py @@ -144,11 +144,14 @@ class OutletTempControl(base.ThermalOptimizationBaseStrategy): @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): @@ -181,7 +184,7 @@ class OutletTempControl(base.ThermalOptimizationBaseStrategy): hosts_need_release = [] hosts_target = [] metric_name = self.METRIC_NAMES[ - self.config.datasource]['host_outlet_temp'] + self.datasource_backend.NAME]['host_outlet_temp'] for node in nodes.values(): resource_id = node.uuid outlet_temp = None diff --git a/watcher/tests/decision_engine/strategy/strategies/test_outlet_temp_control.py b/watcher/tests/decision_engine/strategy/strategies/test_outlet_temp_control.py index cc4559c54..4b38c9c92 100644 --- a/watcher/tests/decision_engine/strategy/strategies/test_outlet_temp_control.py +++ b/watcher/tests/decision_engine/strategy/strategies/test_outlet_temp_control.py @@ -72,7 +72,8 @@ class TestOutletTempControl(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.OutletTempControl( config=mock.Mock(datasource=self.datasource))