Merge "add audit parameter to do_execute"
This commit is contained in:
commit
0e40e72b45
|
@ -65,4 +65,4 @@ class DefaultStrategyContext(base.StrategyContext):
|
|||
name: value for name, value in audit.parameters.items()
|
||||
})
|
||||
|
||||
return selected_strategy.execute()
|
||||
return selected_strategy.execute(audit=audit)
|
||||
|
|
|
@ -93,7 +93,7 @@ class Actuator(base.UnclassifiedStrategy):
|
|||
def pre_execute(self):
|
||||
self._pre_execute()
|
||||
|
||||
def do_execute(self):
|
||||
def do_execute(self, audit=None):
|
||||
for action in self.actions:
|
||||
self.solution.add_action(**action)
|
||||
|
||||
|
|
|
@ -223,9 +223,12 @@ class BaseStrategy(loadable.Loadable):
|
|||
raise NotImplementedError()
|
||||
|
||||
@abc.abstractmethod
|
||||
def do_execute(self):
|
||||
def do_execute(self, audit=None):
|
||||
"""Strategy execution phase
|
||||
|
||||
:param audit: An Audit instance
|
||||
:type audit: :py:class:`~.Audit` instance
|
||||
|
||||
This phase is where you should put the main logic of your strategy.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
@ -255,14 +258,16 @@ class BaseStrategy(loadable.Loadable):
|
|||
|
||||
LOG.debug(self.compute_model.to_string())
|
||||
|
||||
def execute(self):
|
||||
def execute(self, audit=None):
|
||||
"""Execute a strategy
|
||||
|
||||
:param audit: An Audit instance
|
||||
:type audit: :py:class:`~.Audit` instance
|
||||
:return: A computed solution (via a placement algorithm)
|
||||
:rtype: :py:class:`~.BaseSolution` instance
|
||||
"""
|
||||
self.pre_execute()
|
||||
self.do_execute()
|
||||
self.do_execute(audit=audit)
|
||||
self.post_execute()
|
||||
|
||||
self.solution.compute_global_efficacy()
|
||||
|
|
|
@ -413,7 +413,7 @@ class BasicConsolidation(base.ServerConsolidationBaseStrategy):
|
|||
self.aggregation_method['compute_node'] = \
|
||||
self.aggregation_method['node']
|
||||
|
||||
def do_execute(self):
|
||||
def do_execute(self, audit=None):
|
||||
unsuccessful_migration = 0
|
||||
|
||||
scores = self.compute_score_of_nodes()
|
||||
|
|
|
@ -51,7 +51,7 @@ class DummyStrategy(base.DummyBaseStrategy):
|
|||
def pre_execute(self):
|
||||
self._pre_execute()
|
||||
|
||||
def do_execute(self):
|
||||
def do_execute(self, audit=None):
|
||||
para1 = self.input_parameters.para1
|
||||
para2 = self.input_parameters.para2
|
||||
LOG.debug("Executing Dummy strategy with para1=%(p1)f, para2=%(p2)s",
|
||||
|
|
|
@ -48,7 +48,7 @@ class DummyWithResize(base.DummyBaseStrategy):
|
|||
def pre_execute(self):
|
||||
self._pre_execute()
|
||||
|
||||
def do_execute(self):
|
||||
def do_execute(self, audit=None):
|
||||
para1 = self.input_parameters.para1
|
||||
para2 = self.input_parameters.para2
|
||||
LOG.debug("Executing Dummy strategy with para1=%(p1)f, para2=%(p2)s",
|
||||
|
|
|
@ -78,7 +78,7 @@ class DummyWithScorer(base.DummyBaseStrategy):
|
|||
def pre_execute(self):
|
||||
self._pre_execute()
|
||||
|
||||
def do_execute(self):
|
||||
def do_execute(self, audit=None):
|
||||
# Simple "hello world" from strategy
|
||||
param1 = self.input_parameters.param1
|
||||
param2 = self.input_parameters.param2
|
||||
|
|
|
@ -297,7 +297,7 @@ class HostMaintenance(base.HostMaintenanceBaseStrategy):
|
|||
def pre_execute(self):
|
||||
self._pre_execute()
|
||||
|
||||
def do_execute(self):
|
||||
def do_execute(self, audit=None):
|
||||
LOG.info(_('Executing Host Maintenance Migration Strategy'))
|
||||
|
||||
maintenance_node = self.input_parameters.get('maintenance_node')
|
||||
|
|
|
@ -241,7 +241,7 @@ class NoisyNeighbor(base.NoisyNeighborBaseStrategy):
|
|||
def pre_execute(self):
|
||||
self._pre_execute()
|
||||
|
||||
def do_execute(self):
|
||||
def do_execute(self, audit=None):
|
||||
self.cache_threshold = self.input_parameters.cache_threshold
|
||||
self.period = self.input_parameters.period
|
||||
|
||||
|
|
|
@ -241,7 +241,7 @@ class OutletTempControl(base.ThermalOptimizationBaseStrategy):
|
|||
LOG.info("Outlet temperature strategy threshold=%d",
|
||||
self.threshold)
|
||||
|
||||
def do_execute(self):
|
||||
def do_execute(self, audit=None):
|
||||
hosts_need_release, hosts_target = self.group_hosts_by_outlet_temp()
|
||||
|
||||
if len(hosts_need_release) == 0:
|
||||
|
|
|
@ -219,7 +219,7 @@ class SavingEnergy(base.SavingEnergyBaseStrategy):
|
|||
self.free_used_percent = self.input_parameters.free_used_percent
|
||||
self.min_free_hosts_num = self.input_parameters.min_free_hosts_num
|
||||
|
||||
def do_execute(self):
|
||||
def do_execute(self, audit=None):
|
||||
"""Strategy execution phase
|
||||
|
||||
This phase is where you should put the main logic of your strategy.
|
||||
|
|
|
@ -280,7 +280,7 @@ class UniformAirflow(base.BaseStrategy):
|
|||
self.threshold_power = self.input_parameters.threshold_power
|
||||
self._period = self.input_parameters.period
|
||||
|
||||
def do_execute(self):
|
||||
def do_execute(self, audit=None):
|
||||
source_nodes, target_nodes = self.group_hosts_by_airflow()
|
||||
|
||||
if not source_nodes:
|
||||
|
|
|
@ -518,7 +518,7 @@ class VMWorkloadConsolidation(base.ServerConsolidationBaseStrategy):
|
|||
def pre_execute(self):
|
||||
self._pre_execute()
|
||||
|
||||
def do_execute(self):
|
||||
def do_execute(self, audit=None):
|
||||
"""Execute strategy.
|
||||
|
||||
This strategy produces a solution resulting in more
|
||||
|
|
|
@ -295,7 +295,7 @@ class WorkloadBalance(base.WorkloadStabilizationBaseStrategy):
|
|||
self._meter = self.input_parameters.metrics
|
||||
self._granularity = self.input_parameters.granularity
|
||||
|
||||
def do_execute(self):
|
||||
def do_execute(self, audit=None):
|
||||
"""Strategy execution phase
|
||||
|
||||
This phase is where you should put the main logic of your strategy.
|
||||
|
|
|
@ -519,7 +519,7 @@ class WorkloadStabilization(base.WorkloadStabilizationBaseStrategy):
|
|||
'will be removed in next release.')
|
||||
self.periods['compute_node'] = self.periods['node']
|
||||
|
||||
def do_execute(self):
|
||||
def do_execute(self, audit=None):
|
||||
migration = self.check_threshold()
|
||||
if migration:
|
||||
hosts_load = self.get_hosts_load()
|
||||
|
|
|
@ -269,7 +269,7 @@ class ZoneMigration(base.ZoneMigrationBaseStrategy):
|
|||
self._pre_execute()
|
||||
LOG.debug(self.storage_model.to_string())
|
||||
|
||||
def do_execute(self):
|
||||
def do_execute(self, audit=None):
|
||||
"""Strategy execution phase
|
||||
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue