Merge "Make datasource methods match names of metrics"

This commit is contained in:
Zuul 2019-04-11 03:13:51 +00:00 committed by Gerrit Code Review
commit 721b710e2f
8 changed files with 74 additions and 74 deletions

View File

@ -19,16 +19,16 @@ import abc
class DataSourceBase(object):
METRIC_MAP = dict(host_cpu_usage=None,
instance_cpu_usage=None,
instance_l3_cache_usage=None,
host_memory_usage=None,
host_outlet_temp=None,
host_airflow=None,
host_inlet_temp=None,
host_airflow=None,
host_power=None,
instance_cpu_usage=None,
instance_ram_usage=None,
instance_ram_allocated=None,
instance_l3_cache_usage=None,
instance_root_disk_size=None,
host_memory_usage=None
)
@abc.abstractmethod
@ -50,44 +50,19 @@ class DataSourceBase(object):
granularity=None):
pass
@abc.abstractmethod
def get_instance_cpu_usage(self, resource_id, period, aggregate,
granularity=None):
pass
@abc.abstractmethod
def get_host_memory_usage(self, resource_id, period, aggregate,
granularity=None):
pass
@abc.abstractmethod
def get_instance_memory_usage(self, resource_id, period, aggregate,
granularity=None):
def get_host_outlet_temp(self, resource_id, period, aggregate,
granularity=None):
pass
@abc.abstractmethod
def get_instance_l3_cache_usage(self, resource_id, period, aggregate,
granularity=None):
pass
@abc.abstractmethod
def get_instance_ram_allocated(self, resource_id, period, aggregate,
granularity=None):
pass
@abc.abstractmethod
def get_instance_root_disk_allocated(self, resource_id, period, aggregate,
granularity=None):
pass
@abc.abstractmethod
def get_host_outlet_temperature(self, resource_id, period, aggregate,
granularity=None):
pass
@abc.abstractmethod
def get_host_inlet_temperature(self, resource_id, period, aggregate,
granularity=None):
def get_host_inlet_temp(self, resource_id, period, aggregate,
granularity=None):
pass
@abc.abstractmethod
@ -98,3 +73,28 @@ class DataSourceBase(object):
@abc.abstractmethod
def get_host_power(self, resource_id, period, aggregate, granularity=None):
pass
@abc.abstractmethod
def get_instance_cpu_usage(self, resource_id, period, aggregate,
granularity=None):
pass
@abc.abstractmethod
def get_instance_ram_usage(self, resource_id, period, aggregate,
granularity=None):
pass
@abc.abstractmethod
def get_instance_ram_allocated(self, resource_id, period, aggregate,
granularity=None):
pass
@abc.abstractmethod
def get_instance_l3_cache_usage(self, resource_id, period, aggregate,
granularity=None):
pass
@abc.abstractmethod
def get_instance_root_disk_size(self, resource_id, period, aggregate,
granularity=None):
pass

View File

@ -240,8 +240,8 @@ class CeilometerHelper(base.DataSourceBase):
return self.statistic_aggregation(resource_id, meter_name, period,
granularity, aggregate=aggregate)
def get_instance_memory_usage(self, resource_id, period, aggregate,
granularity=None):
def get_instance_ram_usage(self, resource_id, period, aggregate,
granularity=None):
meter_name = self.METRIC_MAP.get('instance_ram_usage')
return self.statistic_aggregation(resource_id, meter_name, period,
granularity, aggregate=aggregate)
@ -258,20 +258,20 @@ class CeilometerHelper(base.DataSourceBase):
return self.statistic_aggregation(resource_id, meter_name, period,
granularity, aggregate=aggregate)
def get_instance_root_disk_allocated(self, resource_id, period, aggregate,
granularity=None):
def get_instance_root_disk_size(self, resource_id, period, aggregate,
granularity=None):
meter_name = self.METRIC_MAP.get('instance_root_disk_size')
return self.statistic_aggregation(resource_id, meter_name, period,
granularity, aggregate=aggregate)
def get_host_outlet_temperature(self, resource_id, period, aggregate,
granularity=None):
def get_host_outlet_temp(self, resource_id, period, aggregate,
granularity=None):
meter_name = self.METRIC_MAP.get('host_outlet_temp')
return self.statistic_aggregation(resource_id, meter_name, period,
granularity, aggregate=aggregate)
def get_host_inlet_temperature(self, resource_id, period, aggregate,
granularity=None):
def get_host_inlet_temp(self, resource_id, period, aggregate,
granularity=None):
meter_name = self.METRIC_MAP.get('host_inlet_temp')
return self.statistic_aggregation(resource_id, meter_name, period,
granularity, aggregate=aggregate)

View File

@ -148,8 +148,8 @@ class GnocchiHelper(base.DataSourceBase):
return self.statistic_aggregation(resource_id, meter_name, period,
granularity, aggregation=aggregate)
def get_instance_memory_usage(self, resource_id, period, aggregate,
granularity=300):
def get_instance_ram_usage(self, resource_id, period, aggregate,
granularity=300):
meter_name = self.METRIC_MAP.get('instance_ram_usage')
return self.statistic_aggregation(resource_id, meter_name, period,
granularity, aggregation=aggregate)
@ -166,20 +166,20 @@ class GnocchiHelper(base.DataSourceBase):
return self.statistic_aggregation(resource_id, meter_name, period,
granularity, aggregation=aggregate)
def get_instance_root_disk_allocated(self, resource_id, period, aggregate,
granularity=300):
def get_instance_root_disk_size(self, resource_id, period, aggregate,
granularity=300):
meter_name = self.METRIC_MAP.get('instance_root_disk_size')
return self.statistic_aggregation(resource_id, meter_name, period,
granularity, aggregation=aggregate)
def get_host_outlet_temperature(self, resource_id, period, aggregate,
granularity=300):
def get_host_outlet_temp(self, resource_id, period, aggregate,
granularity=300):
meter_name = self.METRIC_MAP.get('host_outlet_temp')
return self.statistic_aggregation(resource_id, meter_name, period,
granularity, aggregation=aggregate)
def get_host_inlet_temperature(self, resource_id, period, aggregate,
granularity=300):
def get_host_inlet_temp(self, resource_id, period, aggregate,
granularity=300):
meter_name = self.METRIC_MAP.get('host_inlet_temp')
return self.statistic_aggregation(resource_id, meter_name, period,
granularity, aggregation=aggregate)

View File

@ -188,8 +188,8 @@ class MonascaHelper(base.DataSourceBase):
granularity=None):
raise NotImplementedError
def get_instance_memory_usage(self, resource_id, period, aggregate,
granularity=None):
def get_instance_ram_usage(self, resource_id, period, aggregate,
granularity=None):
raise NotImplementedError
def get_instance_l3_cache_usage(self, resource_id, period, aggregate,
@ -200,16 +200,16 @@ class MonascaHelper(base.DataSourceBase):
granularity=None):
raise NotImplementedError
def get_instance_root_disk_allocated(self, resource_id, period, aggregate,
granularity=None):
raise NotImplementedError
def get_host_outlet_temperature(self, resource_id, period, aggregate,
def get_instance_root_disk_size(self, resource_id, period, aggregate,
granularity=None):
raise NotImplementedError
def get_host_inlet_temperature(self, resource_id, period, aggregate,
granularity=None):
def get_host_outlet_temp(self, resource_id, period, aggregate,
granularity=None):
raise NotImplementedError
def get_host_inlet_temp(self, resource_id, period, aggregate,
granularity=None):
raise NotImplementedError
def get_host_airflow(self, resource_id, period, aggregate,

View File

@ -291,7 +291,7 @@ class VMWorkloadConsolidation(base.ServerConsolidationBaseStrategy):
self.period,
self.AGGREGATION,
granularity=self.granularity)
instance_ram_util = self.datasource_backend.get_instance_memory_usage(
instance_ram_util = self.datasource_backend.get_instance_ram_usage(
instance.uuid,
self.period,
self.AGGREGATION,
@ -304,7 +304,7 @@ class VMWorkloadConsolidation(base.ServerConsolidationBaseStrategy):
self.AGGREGATION,
granularity=self.granularity))
instance_disk_util = (
self.datasource_backend.get_instance_root_disk_allocated(
self.datasource_backend.get_instance_root_disk_size(
instance.uuid,
self.period,
self.AGGREGATION,

View File

@ -127,7 +127,7 @@ class TestCeilometerHelper(base.BaseTestCase):
def test_get_instance_memory_usage(self, mock_aggregation,
mock_ceilometer):
helper = ceilometer_helper.CeilometerHelper()
helper.get_instance_memory_usage('compute1', 600, 'mean')
helper.get_instance_ram_usage('compute1', 600, 'mean')
mock_aggregation.assert_called_once_with(
'compute1', helper.METRIC_MAP['instance_ram_usage'], 600, None,
aggregate='mean')
@ -157,7 +157,7 @@ class TestCeilometerHelper(base.BaseTestCase):
def test_get_instance_root_disk_allocated(self, mock_aggregation,
mock_ceilometer):
helper = ceilometer_helper.CeilometerHelper()
helper.get_instance_root_disk_allocated('compute1', 600, 'mean')
helper.get_instance_root_disk_size('compute1', 600, 'mean')
mock_aggregation.assert_called_once_with(
'compute1', helper.METRIC_MAP['instance_root_disk_size'], 600,
None, aggregate='mean')
@ -167,7 +167,7 @@ class TestCeilometerHelper(base.BaseTestCase):
def test_get_host_outlet_temperature(self, mock_aggregation,
mock_ceilometer):
helper = ceilometer_helper.CeilometerHelper()
helper.get_host_outlet_temperature('compute1', 600, 'mean')
helper.get_host_outlet_temp('compute1', 600, 'mean')
mock_aggregation.assert_called_once_with(
'compute1', helper.METRIC_MAP['host_outlet_temp'], 600, None,
aggregate='mean')
@ -177,7 +177,7 @@ class TestCeilometerHelper(base.BaseTestCase):
def test_get_host_inlet_temperature(self, mock_aggregation,
mock_ceilometer):
helper = ceilometer_helper.CeilometerHelper()
helper.get_host_inlet_temperature('compute1', 600, 'mean')
helper.get_host_inlet_temp('compute1', 600, 'mean')
mock_aggregation.assert_called_once_with(
'compute1', helper.METRIC_MAP['host_inlet_temp'], 600, None,
aggregate='mean')

View File

@ -75,8 +75,8 @@ class TestGnocchiHelper(base.BaseTestCase):
@mock.patch.object(gnocchi_helper.GnocchiHelper, 'statistic_aggregation')
def test_get_instance_memory_usage(self, mock_aggregation, mock_gnocchi):
helper = gnocchi_helper.GnocchiHelper()
helper.get_instance_memory_usage('compute1', 600, 'mean',
granularity=300)
helper.get_instance_ram_usage('compute1', 600, 'mean',
granularity=300)
mock_aggregation.assert_called_once_with(
'compute1', helper.METRIC_MAP['instance_ram_usage'], 600, 300,
aggregation='mean')
@ -94,8 +94,8 @@ class TestGnocchiHelper(base.BaseTestCase):
def test_get_instance_root_disk_allocated(self, mock_aggregation,
mock_gnocchi):
helper = gnocchi_helper.GnocchiHelper()
helper.get_instance_root_disk_allocated('compute1', 600, 'mean',
granularity=300)
helper.get_instance_root_disk_size('compute1', 600, 'mean',
granularity=300)
mock_aggregation.assert_called_once_with(
'compute1', helper.METRIC_MAP['instance_root_disk_size'], 600,
300, aggregation='mean')
@ -103,8 +103,8 @@ class TestGnocchiHelper(base.BaseTestCase):
@mock.patch.object(gnocchi_helper.GnocchiHelper, 'statistic_aggregation')
def test_get_host_outlet_temperature(self, mock_aggregation, mock_gnocchi):
helper = gnocchi_helper.GnocchiHelper()
helper.get_host_outlet_temperature('compute1', 600, 'mean',
granularity=300)
helper.get_host_outlet_temp('compute1', 600, 'mean',
granularity=300)
mock_aggregation.assert_called_once_with(
'compute1', helper.METRIC_MAP['host_outlet_temp'], 600, 300,
aggregation='mean')
@ -112,8 +112,8 @@ class TestGnocchiHelper(base.BaseTestCase):
@mock.patch.object(gnocchi_helper.GnocchiHelper, 'statistic_aggregation')
def test_get_host_inlet_temperature(self, mock_aggregation, mock_gnocchi):
helper = gnocchi_helper.GnocchiHelper()
helper.get_host_inlet_temperature('compute1', 600, 'mean',
granularity=300)
helper.get_host_inlet_temp('compute1', 600, 'mean',
granularity=300)
mock_aggregation.assert_called_once_with(
'compute1', helper.METRIC_MAP['host_inlet_temp'], 600, 300,
aggregation='mean')

View File

@ -60,9 +60,9 @@ class TestVMWorkloadConsolidation(TestBaseStrategy):
self.m_datasource.return_value = mock.Mock(
get_instance_cpu_usage=(
self.fake_metrics.get_instance_cpu_util),
get_instance_memory_usage=(
get_instance_ram_usage=(
self.fake_metrics.get_instance_ram_util),
get_instance_root_disk_allocated=(
get_instance_root_disk_size=(
self.fake_metrics.get_instance_disk_root_size),
)
self.strategy = strategies.VMWorkloadConsolidation(