Make datasource methods match names of metrics
Metrics for datasources now match the name of their corresponding abstract methods. This ensures that developers know how the method is named if they know the name of the metric and vice versa. Change-Id: I0f9d400432d8182b3f10a0da97155e6cb786690e
This commit is contained in:
parent
ab03bf9bb0
commit
c8e4efcd0b
@ -19,16 +19,16 @@ import abc
|
|||||||
class DataSourceBase(object):
|
class DataSourceBase(object):
|
||||||
|
|
||||||
METRIC_MAP = dict(host_cpu_usage=None,
|
METRIC_MAP = dict(host_cpu_usage=None,
|
||||||
instance_cpu_usage=None,
|
host_memory_usage=None,
|
||||||
instance_l3_cache_usage=None,
|
|
||||||
host_outlet_temp=None,
|
host_outlet_temp=None,
|
||||||
host_airflow=None,
|
|
||||||
host_inlet_temp=None,
|
host_inlet_temp=None,
|
||||||
|
host_airflow=None,
|
||||||
host_power=None,
|
host_power=None,
|
||||||
|
instance_cpu_usage=None,
|
||||||
instance_ram_usage=None,
|
instance_ram_usage=None,
|
||||||
instance_ram_allocated=None,
|
instance_ram_allocated=None,
|
||||||
|
instance_l3_cache_usage=None,
|
||||||
instance_root_disk_size=None,
|
instance_root_disk_size=None,
|
||||||
host_memory_usage=None
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
@ -50,44 +50,19 @@ class DataSourceBase(object):
|
|||||||
granularity=None):
|
granularity=None):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@abc.abstractmethod
|
|
||||||
def get_instance_cpu_usage(self, resource_id, period, aggregate,
|
|
||||||
granularity=None):
|
|
||||||
pass
|
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def get_host_memory_usage(self, resource_id, period, aggregate,
|
def get_host_memory_usage(self, resource_id, period, aggregate,
|
||||||
granularity=None):
|
granularity=None):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def get_instance_memory_usage(self, resource_id, period, aggregate,
|
def get_host_outlet_temp(self, resource_id, period, aggregate,
|
||||||
granularity=None):
|
granularity=None):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def get_instance_l3_cache_usage(self, resource_id, period, aggregate,
|
def get_host_inlet_temp(self, resource_id, period, aggregate,
|
||||||
granularity=None):
|
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):
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
@ -98,3 +73,28 @@ class DataSourceBase(object):
|
|||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def get_host_power(self, resource_id, period, aggregate, granularity=None):
|
def get_host_power(self, resource_id, period, aggregate, granularity=None):
|
||||||
pass
|
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
|
||||||
|
@ -240,8 +240,8 @@ class CeilometerHelper(base.DataSourceBase):
|
|||||||
return self.statistic_aggregation(resource_id, meter_name, period,
|
return self.statistic_aggregation(resource_id, meter_name, period,
|
||||||
granularity, aggregate=aggregate)
|
granularity, aggregate=aggregate)
|
||||||
|
|
||||||
def get_instance_memory_usage(self, resource_id, period, aggregate,
|
def get_instance_ram_usage(self, resource_id, period, aggregate,
|
||||||
granularity=None):
|
granularity=None):
|
||||||
meter_name = self.METRIC_MAP.get('instance_ram_usage')
|
meter_name = self.METRIC_MAP.get('instance_ram_usage')
|
||||||
return self.statistic_aggregation(resource_id, meter_name, period,
|
return self.statistic_aggregation(resource_id, meter_name, period,
|
||||||
granularity, aggregate=aggregate)
|
granularity, aggregate=aggregate)
|
||||||
@ -258,20 +258,20 @@ class CeilometerHelper(base.DataSourceBase):
|
|||||||
return self.statistic_aggregation(resource_id, meter_name, period,
|
return self.statistic_aggregation(resource_id, meter_name, period,
|
||||||
granularity, aggregate=aggregate)
|
granularity, aggregate=aggregate)
|
||||||
|
|
||||||
def get_instance_root_disk_allocated(self, resource_id, period, aggregate,
|
def get_instance_root_disk_size(self, resource_id, period, aggregate,
|
||||||
granularity=None):
|
granularity=None):
|
||||||
meter_name = self.METRIC_MAP.get('instance_root_disk_size')
|
meter_name = self.METRIC_MAP.get('instance_root_disk_size')
|
||||||
return self.statistic_aggregation(resource_id, meter_name, period,
|
return self.statistic_aggregation(resource_id, meter_name, period,
|
||||||
granularity, aggregate=aggregate)
|
granularity, aggregate=aggregate)
|
||||||
|
|
||||||
def get_host_outlet_temperature(self, resource_id, period, aggregate,
|
def get_host_outlet_temp(self, resource_id, period, aggregate,
|
||||||
granularity=None):
|
granularity=None):
|
||||||
meter_name = self.METRIC_MAP.get('host_outlet_temp')
|
meter_name = self.METRIC_MAP.get('host_outlet_temp')
|
||||||
return self.statistic_aggregation(resource_id, meter_name, period,
|
return self.statistic_aggregation(resource_id, meter_name, period,
|
||||||
granularity, aggregate=aggregate)
|
granularity, aggregate=aggregate)
|
||||||
|
|
||||||
def get_host_inlet_temperature(self, resource_id, period, aggregate,
|
def get_host_inlet_temp(self, resource_id, period, aggregate,
|
||||||
granularity=None):
|
granularity=None):
|
||||||
meter_name = self.METRIC_MAP.get('host_inlet_temp')
|
meter_name = self.METRIC_MAP.get('host_inlet_temp')
|
||||||
return self.statistic_aggregation(resource_id, meter_name, period,
|
return self.statistic_aggregation(resource_id, meter_name, period,
|
||||||
granularity, aggregate=aggregate)
|
granularity, aggregate=aggregate)
|
||||||
|
@ -148,8 +148,8 @@ class GnocchiHelper(base.DataSourceBase):
|
|||||||
return self.statistic_aggregation(resource_id, meter_name, period,
|
return self.statistic_aggregation(resource_id, meter_name, period,
|
||||||
granularity, aggregation=aggregate)
|
granularity, aggregation=aggregate)
|
||||||
|
|
||||||
def get_instance_memory_usage(self, resource_id, period, aggregate,
|
def get_instance_ram_usage(self, resource_id, period, aggregate,
|
||||||
granularity=300):
|
granularity=300):
|
||||||
meter_name = self.METRIC_MAP.get('instance_ram_usage')
|
meter_name = self.METRIC_MAP.get('instance_ram_usage')
|
||||||
return self.statistic_aggregation(resource_id, meter_name, period,
|
return self.statistic_aggregation(resource_id, meter_name, period,
|
||||||
granularity, aggregation=aggregate)
|
granularity, aggregation=aggregate)
|
||||||
@ -166,20 +166,20 @@ class GnocchiHelper(base.DataSourceBase):
|
|||||||
return self.statistic_aggregation(resource_id, meter_name, period,
|
return self.statistic_aggregation(resource_id, meter_name, period,
|
||||||
granularity, aggregation=aggregate)
|
granularity, aggregation=aggregate)
|
||||||
|
|
||||||
def get_instance_root_disk_allocated(self, resource_id, period, aggregate,
|
def get_instance_root_disk_size(self, resource_id, period, aggregate,
|
||||||
granularity=300):
|
granularity=300):
|
||||||
meter_name = self.METRIC_MAP.get('instance_root_disk_size')
|
meter_name = self.METRIC_MAP.get('instance_root_disk_size')
|
||||||
return self.statistic_aggregation(resource_id, meter_name, period,
|
return self.statistic_aggregation(resource_id, meter_name, period,
|
||||||
granularity, aggregation=aggregate)
|
granularity, aggregation=aggregate)
|
||||||
|
|
||||||
def get_host_outlet_temperature(self, resource_id, period, aggregate,
|
def get_host_outlet_temp(self, resource_id, period, aggregate,
|
||||||
granularity=300):
|
granularity=300):
|
||||||
meter_name = self.METRIC_MAP.get('host_outlet_temp')
|
meter_name = self.METRIC_MAP.get('host_outlet_temp')
|
||||||
return self.statistic_aggregation(resource_id, meter_name, period,
|
return self.statistic_aggregation(resource_id, meter_name, period,
|
||||||
granularity, aggregation=aggregate)
|
granularity, aggregation=aggregate)
|
||||||
|
|
||||||
def get_host_inlet_temperature(self, resource_id, period, aggregate,
|
def get_host_inlet_temp(self, resource_id, period, aggregate,
|
||||||
granularity=300):
|
granularity=300):
|
||||||
meter_name = self.METRIC_MAP.get('host_inlet_temp')
|
meter_name = self.METRIC_MAP.get('host_inlet_temp')
|
||||||
return self.statistic_aggregation(resource_id, meter_name, period,
|
return self.statistic_aggregation(resource_id, meter_name, period,
|
||||||
granularity, aggregation=aggregate)
|
granularity, aggregation=aggregate)
|
||||||
|
@ -188,8 +188,8 @@ class MonascaHelper(base.DataSourceBase):
|
|||||||
granularity=None):
|
granularity=None):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
def get_instance_memory_usage(self, resource_id, period, aggregate,
|
def get_instance_ram_usage(self, resource_id, period, aggregate,
|
||||||
granularity=None):
|
granularity=None):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
def get_instance_l3_cache_usage(self, resource_id, period, aggregate,
|
def get_instance_l3_cache_usage(self, resource_id, period, aggregate,
|
||||||
@ -200,16 +200,16 @@ class MonascaHelper(base.DataSourceBase):
|
|||||||
granularity=None):
|
granularity=None):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
def get_instance_root_disk_allocated(self, resource_id, period, aggregate,
|
def get_instance_root_disk_size(self, resource_id, period, aggregate,
|
||||||
granularity=None):
|
|
||||||
raise NotImplementedError
|
|
||||||
|
|
||||||
def get_host_outlet_temperature(self, resource_id, period, aggregate,
|
|
||||||
granularity=None):
|
granularity=None):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
def get_host_inlet_temperature(self, resource_id, period, aggregate,
|
def get_host_outlet_temp(self, resource_id, period, aggregate,
|
||||||
granularity=None):
|
granularity=None):
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def get_host_inlet_temp(self, resource_id, period, aggregate,
|
||||||
|
granularity=None):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
def get_host_airflow(self, resource_id, period, aggregate,
|
def get_host_airflow(self, resource_id, period, aggregate,
|
||||||
|
@ -291,7 +291,7 @@ class VMWorkloadConsolidation(base.ServerConsolidationBaseStrategy):
|
|||||||
self.period,
|
self.period,
|
||||||
self.AGGREGATION,
|
self.AGGREGATION,
|
||||||
granularity=self.granularity)
|
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,
|
instance.uuid,
|
||||||
self.period,
|
self.period,
|
||||||
self.AGGREGATION,
|
self.AGGREGATION,
|
||||||
@ -304,7 +304,7 @@ class VMWorkloadConsolidation(base.ServerConsolidationBaseStrategy):
|
|||||||
self.AGGREGATION,
|
self.AGGREGATION,
|
||||||
granularity=self.granularity))
|
granularity=self.granularity))
|
||||||
instance_disk_util = (
|
instance_disk_util = (
|
||||||
self.datasource_backend.get_instance_root_disk_allocated(
|
self.datasource_backend.get_instance_root_disk_size(
|
||||||
instance.uuid,
|
instance.uuid,
|
||||||
self.period,
|
self.period,
|
||||||
self.AGGREGATION,
|
self.AGGREGATION,
|
||||||
|
@ -127,7 +127,7 @@ class TestCeilometerHelper(base.BaseTestCase):
|
|||||||
def test_get_instance_memory_usage(self, mock_aggregation,
|
def test_get_instance_memory_usage(self, mock_aggregation,
|
||||||
mock_ceilometer):
|
mock_ceilometer):
|
||||||
helper = ceilometer_helper.CeilometerHelper()
|
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(
|
mock_aggregation.assert_called_once_with(
|
||||||
'compute1', helper.METRIC_MAP['instance_ram_usage'], 600, None,
|
'compute1', helper.METRIC_MAP['instance_ram_usage'], 600, None,
|
||||||
aggregate='mean')
|
aggregate='mean')
|
||||||
@ -157,7 +157,7 @@ class TestCeilometerHelper(base.BaseTestCase):
|
|||||||
def test_get_instance_root_disk_allocated(self, mock_aggregation,
|
def test_get_instance_root_disk_allocated(self, mock_aggregation,
|
||||||
mock_ceilometer):
|
mock_ceilometer):
|
||||||
helper = ceilometer_helper.CeilometerHelper()
|
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(
|
mock_aggregation.assert_called_once_with(
|
||||||
'compute1', helper.METRIC_MAP['instance_root_disk_size'], 600,
|
'compute1', helper.METRIC_MAP['instance_root_disk_size'], 600,
|
||||||
None, aggregate='mean')
|
None, aggregate='mean')
|
||||||
@ -167,7 +167,7 @@ class TestCeilometerHelper(base.BaseTestCase):
|
|||||||
def test_get_host_outlet_temperature(self, mock_aggregation,
|
def test_get_host_outlet_temperature(self, mock_aggregation,
|
||||||
mock_ceilometer):
|
mock_ceilometer):
|
||||||
helper = ceilometer_helper.CeilometerHelper()
|
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(
|
mock_aggregation.assert_called_once_with(
|
||||||
'compute1', helper.METRIC_MAP['host_outlet_temp'], 600, None,
|
'compute1', helper.METRIC_MAP['host_outlet_temp'], 600, None,
|
||||||
aggregate='mean')
|
aggregate='mean')
|
||||||
@ -177,7 +177,7 @@ class TestCeilometerHelper(base.BaseTestCase):
|
|||||||
def test_get_host_inlet_temperature(self, mock_aggregation,
|
def test_get_host_inlet_temperature(self, mock_aggregation,
|
||||||
mock_ceilometer):
|
mock_ceilometer):
|
||||||
helper = ceilometer_helper.CeilometerHelper()
|
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(
|
mock_aggregation.assert_called_once_with(
|
||||||
'compute1', helper.METRIC_MAP['host_inlet_temp'], 600, None,
|
'compute1', helper.METRIC_MAP['host_inlet_temp'], 600, None,
|
||||||
aggregate='mean')
|
aggregate='mean')
|
||||||
|
@ -75,8 +75,8 @@ class TestGnocchiHelper(base.BaseTestCase):
|
|||||||
@mock.patch.object(gnocchi_helper.GnocchiHelper, 'statistic_aggregation')
|
@mock.patch.object(gnocchi_helper.GnocchiHelper, 'statistic_aggregation')
|
||||||
def test_get_instance_memory_usage(self, mock_aggregation, mock_gnocchi):
|
def test_get_instance_memory_usage(self, mock_aggregation, mock_gnocchi):
|
||||||
helper = gnocchi_helper.GnocchiHelper()
|
helper = gnocchi_helper.GnocchiHelper()
|
||||||
helper.get_instance_memory_usage('compute1', 600, 'mean',
|
helper.get_instance_ram_usage('compute1', 600, 'mean',
|
||||||
granularity=300)
|
granularity=300)
|
||||||
mock_aggregation.assert_called_once_with(
|
mock_aggregation.assert_called_once_with(
|
||||||
'compute1', helper.METRIC_MAP['instance_ram_usage'], 600, 300,
|
'compute1', helper.METRIC_MAP['instance_ram_usage'], 600, 300,
|
||||||
aggregation='mean')
|
aggregation='mean')
|
||||||
@ -94,8 +94,8 @@ class TestGnocchiHelper(base.BaseTestCase):
|
|||||||
def test_get_instance_root_disk_allocated(self, mock_aggregation,
|
def test_get_instance_root_disk_allocated(self, mock_aggregation,
|
||||||
mock_gnocchi):
|
mock_gnocchi):
|
||||||
helper = gnocchi_helper.GnocchiHelper()
|
helper = gnocchi_helper.GnocchiHelper()
|
||||||
helper.get_instance_root_disk_allocated('compute1', 600, 'mean',
|
helper.get_instance_root_disk_size('compute1', 600, 'mean',
|
||||||
granularity=300)
|
granularity=300)
|
||||||
mock_aggregation.assert_called_once_with(
|
mock_aggregation.assert_called_once_with(
|
||||||
'compute1', helper.METRIC_MAP['instance_root_disk_size'], 600,
|
'compute1', helper.METRIC_MAP['instance_root_disk_size'], 600,
|
||||||
300, aggregation='mean')
|
300, aggregation='mean')
|
||||||
@ -103,8 +103,8 @@ class TestGnocchiHelper(base.BaseTestCase):
|
|||||||
@mock.patch.object(gnocchi_helper.GnocchiHelper, 'statistic_aggregation')
|
@mock.patch.object(gnocchi_helper.GnocchiHelper, 'statistic_aggregation')
|
||||||
def test_get_host_outlet_temperature(self, mock_aggregation, mock_gnocchi):
|
def test_get_host_outlet_temperature(self, mock_aggregation, mock_gnocchi):
|
||||||
helper = gnocchi_helper.GnocchiHelper()
|
helper = gnocchi_helper.GnocchiHelper()
|
||||||
helper.get_host_outlet_temperature('compute1', 600, 'mean',
|
helper.get_host_outlet_temp('compute1', 600, 'mean',
|
||||||
granularity=300)
|
granularity=300)
|
||||||
mock_aggregation.assert_called_once_with(
|
mock_aggregation.assert_called_once_with(
|
||||||
'compute1', helper.METRIC_MAP['host_outlet_temp'], 600, 300,
|
'compute1', helper.METRIC_MAP['host_outlet_temp'], 600, 300,
|
||||||
aggregation='mean')
|
aggregation='mean')
|
||||||
@ -112,8 +112,8 @@ class TestGnocchiHelper(base.BaseTestCase):
|
|||||||
@mock.patch.object(gnocchi_helper.GnocchiHelper, 'statistic_aggregation')
|
@mock.patch.object(gnocchi_helper.GnocchiHelper, 'statistic_aggregation')
|
||||||
def test_get_host_inlet_temperature(self, mock_aggregation, mock_gnocchi):
|
def test_get_host_inlet_temperature(self, mock_aggregation, mock_gnocchi):
|
||||||
helper = gnocchi_helper.GnocchiHelper()
|
helper = gnocchi_helper.GnocchiHelper()
|
||||||
helper.get_host_inlet_temperature('compute1', 600, 'mean',
|
helper.get_host_inlet_temp('compute1', 600, 'mean',
|
||||||
granularity=300)
|
granularity=300)
|
||||||
mock_aggregation.assert_called_once_with(
|
mock_aggregation.assert_called_once_with(
|
||||||
'compute1', helper.METRIC_MAP['host_inlet_temp'], 600, 300,
|
'compute1', helper.METRIC_MAP['host_inlet_temp'], 600, 300,
|
||||||
aggregation='mean')
|
aggregation='mean')
|
||||||
|
@ -60,9 +60,9 @@ class TestVMWorkloadConsolidation(TestBaseStrategy):
|
|||||||
self.m_datasource.return_value = mock.Mock(
|
self.m_datasource.return_value = mock.Mock(
|
||||||
get_instance_cpu_usage=(
|
get_instance_cpu_usage=(
|
||||||
self.fake_metrics.get_instance_cpu_util),
|
self.fake_metrics.get_instance_cpu_util),
|
||||||
get_instance_memory_usage=(
|
get_instance_ram_usage=(
|
||||||
self.fake_metrics.get_instance_ram_util),
|
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.fake_metrics.get_instance_disk_root_size),
|
||||||
)
|
)
|
||||||
self.strategy = strategies.VMWorkloadConsolidation(
|
self.strategy = strategies.VMWorkloadConsolidation(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user