Merge "Multiple global efficacy"
This commit is contained in:
commit
f8aa02c4a7
@ -199,7 +199,7 @@ class ActionPlan(Base):
|
||||
audit_id = Column(Integer, ForeignKey('audits.id'), nullable=False)
|
||||
strategy_id = Column(Integer, ForeignKey('strategies.id'), nullable=False)
|
||||
state = Column(String(20), nullable=True)
|
||||
global_efficacy = Column(JSONEncodedDict, nullable=True)
|
||||
global_efficacy = Column(JSONEncodedList, nullable=True)
|
||||
|
||||
audit = orm.relationship(Audit, foreign_keys=audit_id, lazy=None)
|
||||
strategy = orm.relationship(Strategy, foreign_keys=strategy_id, lazy=None)
|
||||
|
@ -57,7 +57,8 @@ class EfficacySpecification(object):
|
||||
efficacy indicators related to this spec
|
||||
:type indicators_map: :py:class:`~.IndicatorsMap` instance
|
||||
:raises: NotImplementedError
|
||||
:returns: :py:class:`~.Indicator` instance
|
||||
:returns: :py:class:`~.Indicator` instance list, each instance specify
|
||||
global efficacy for different openstack resource.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
|
@ -40,14 +40,16 @@ class ServerConsolidation(base.EfficacySpecification):
|
||||
|
||||
def get_global_efficacy_indicator(self, indicators_map=None):
|
||||
value = 0
|
||||
global_efficacy = []
|
||||
if indicators_map and indicators_map.compute_nodes_count > 0:
|
||||
value = (float(indicators_map.released_compute_nodes_count) /
|
||||
float(indicators_map.compute_nodes_count)) * 100
|
||||
|
||||
return efficacy.Indicator(
|
||||
global_efficacy.append(efficacy.Indicator(
|
||||
name="released_nodes_ratio",
|
||||
description=_("Ratio of released compute nodes divided by the "
|
||||
"total number of enabled compute nodes."),
|
||||
unit='%',
|
||||
value=value,
|
||||
)
|
||||
))
|
||||
|
||||
return global_efficacy
|
||||
|
@ -62,7 +62,7 @@ class Efficacy(object):
|
||||
self.indicators = []
|
||||
# Used to compute the global efficacy
|
||||
self._indicators_mapping = IndicatorsMap()
|
||||
self.global_efficacy = None
|
||||
self.global_efficacy = []
|
||||
|
||||
def set_efficacy_indicators(self, **indicators_map):
|
||||
"""Set the efficacy indicators
|
||||
|
@ -105,7 +105,8 @@ class ActionPlan(base.WatcherPersistentObject, base.WatcherObject,
|
||||
# Version 1.1: Added 'audit' and 'strategy' object field
|
||||
# Version 1.2: audit_id is not nullable anymore
|
||||
# Version 2.0: Removed 'first_action_id' object field
|
||||
VERSION = '2.0'
|
||||
# Version 2.1: Changed global_efficacy type
|
||||
VERSION = '2.1'
|
||||
|
||||
dbapi = db_api.get_instance()
|
||||
|
||||
@ -115,7 +116,7 @@ class ActionPlan(base.WatcherPersistentObject, base.WatcherObject,
|
||||
'audit_id': wfields.IntegerField(),
|
||||
'strategy_id': wfields.IntegerField(),
|
||||
'state': wfields.StringField(nullable=True),
|
||||
'global_efficacy': wfields.FlexibleDictField(nullable=True),
|
||||
'global_efficacy': wfields.FlexibleListOfDictField(nullable=True),
|
||||
|
||||
'audit': wfields.ObjectField('Audit', nullable=True),
|
||||
'strategy': wfields.ObjectField('Strategy', nullable=True),
|
||||
|
@ -167,7 +167,7 @@ def get_test_action_plan(**kwargs):
|
||||
'state': kwargs.get('state', objects.action_plan.State.ONGOING),
|
||||
'audit_id': kwargs.get('audit_id', 1),
|
||||
'strategy_id': kwargs.get('strategy_id', 1),
|
||||
'global_efficacy': kwargs.get('global_efficacy', {}),
|
||||
'global_efficacy': kwargs.get('global_efficacy', []),
|
||||
'created_at': kwargs.get('created_at'),
|
||||
'updated_at': kwargs.get('updated_at'),
|
||||
'deleted_at': kwargs.get('deleted_at'),
|
||||
|
@ -232,7 +232,7 @@ class TestBasicConsolidation(base.TestCase):
|
||||
num_node_state_change = actions_counter.get(
|
||||
"change_nova_service_state", 0)
|
||||
|
||||
global_efficacy_value = solution.global_efficacy.get("value", 0)
|
||||
global_efficacy_value = solution.global_efficacy[0].get('value', 0)
|
||||
|
||||
self.assertEqual(expected_num_migrations, num_migrations)
|
||||
self.assertEqual(expected_power_state, num_node_state_change)
|
||||
@ -258,7 +258,9 @@ class TestBasicConsolidation(base.TestCase):
|
||||
) as mock_score_call:
|
||||
mock_score_call.return_value = 0
|
||||
solution = self.strategy.execute()
|
||||
self.assertEqual(0, solution.efficacy.global_efficacy.value)
|
||||
|
||||
self.assertEqual(0,
|
||||
solution.efficacy.global_efficacy[0].get('value'))
|
||||
|
||||
def test_check_parameters(self):
|
||||
model = self.fake_cluster.generate_scenario_3_with_2_nodes()
|
||||
|
@ -413,7 +413,7 @@ expected_object_fingerprints = {
|
||||
'Strategy': '1.1-73f164491bdd4c034f48083a51bdeb7b',
|
||||
'AuditTemplate': '1.1-b291973ffc5efa2c61b24fe34fdccc0b',
|
||||
'Audit': '1.4-f5f27510b8090bce7d1fb45416d58ff1',
|
||||
'ActionPlan': '2.0-394f1abbf5d73d7b6675a118fe1a0284',
|
||||
'ActionPlan': '2.1-d573f34f2e15da0743afcc38ae62cd22',
|
||||
'Action': '2.0-1dd4959a7e7ac30c62ef170fe08dd935',
|
||||
'EfficacyIndicator': '1.0-655b71234a82bc7478aff964639c4bb0',
|
||||
'ScoringEngine': '1.0-4abbe833544000728e17bd9e83f97576',
|
||||
|
Loading…
x
Reference in New Issue
Block a user