Browse Source

Merge "add audit parameter to do_execute"

changes/77/563477/4
Zuul 1 week ago
parent
commit
0e40e72b45

+ 1
- 1
watcher/decision_engine/strategy/context/default.py View File

@@ -65,4 +65,4 @@ class DefaultStrategyContext(base.StrategyContext):
65 65
             name: value for name, value in audit.parameters.items()
66 66
         })
67 67
 
68
-        return selected_strategy.execute()
68
+        return selected_strategy.execute(audit=audit)

+ 1
- 1
watcher/decision_engine/strategy/strategies/actuation.py View File

@@ -93,7 +93,7 @@ class Actuator(base.UnclassifiedStrategy):
93 93
     def pre_execute(self):
94 94
         self._pre_execute()
95 95
 
96
-    def do_execute(self):
96
+    def do_execute(self, audit=None):
97 97
         for action in self.actions:
98 98
             self.solution.add_action(**action)
99 99
 

+ 8
- 3
watcher/decision_engine/strategy/strategies/base.py View File

@@ -223,9 +223,12 @@ class BaseStrategy(loadable.Loadable):
223 223
         raise NotImplementedError()
224 224
 
225 225
     @abc.abstractmethod
226
-    def do_execute(self):
226
+    def do_execute(self, audit=None):
227 227
         """Strategy execution phase
228 228
 
229
+        :param audit: An Audit instance
230
+        :type audit: :py:class:`~.Audit` instance
231
+
229 232
         This phase is where you should put the main logic of your strategy.
230 233
         """
231 234
         raise NotImplementedError()
@@ -255,14 +258,16 @@ class BaseStrategy(loadable.Loadable):
255 258
 
256 259
         LOG.debug(self.compute_model.to_string())
257 260
 
258
-    def execute(self):
261
+    def execute(self, audit=None):
259 262
         """Execute a strategy
260 263
 
264
+        :param audit: An Audit instance
265
+        :type audit: :py:class:`~.Audit` instance
261 266
         :return: A computed solution (via a placement algorithm)
262 267
         :rtype: :py:class:`~.BaseSolution` instance
263 268
         """
264 269
         self.pre_execute()
265
-        self.do_execute()
270
+        self.do_execute(audit=audit)
266 271
         self.post_execute()
267 272
 
268 273
         self.solution.compute_global_efficacy()

+ 1
- 1
watcher/decision_engine/strategy/strategies/basic_consolidation.py View File

@@ -413,7 +413,7 @@ class BasicConsolidation(base.ServerConsolidationBaseStrategy):
413 413
             self.aggregation_method['compute_node'] = \
414 414
                 self.aggregation_method['node']
415 415
 
416
-    def do_execute(self):
416
+    def do_execute(self, audit=None):
417 417
         unsuccessful_migration = 0
418 418
 
419 419
         scores = self.compute_score_of_nodes()

+ 1
- 1
watcher/decision_engine/strategy/strategies/dummy_strategy.py View File

@@ -51,7 +51,7 @@ class DummyStrategy(base.DummyBaseStrategy):
51 51
     def pre_execute(self):
52 52
         self._pre_execute()
53 53
 
54
-    def do_execute(self):
54
+    def do_execute(self, audit=None):
55 55
         para1 = self.input_parameters.para1
56 56
         para2 = self.input_parameters.para2
57 57
         LOG.debug("Executing Dummy strategy with para1=%(p1)f, para2=%(p2)s",

+ 1
- 1
watcher/decision_engine/strategy/strategies/dummy_with_resize.py View File

@@ -48,7 +48,7 @@ class DummyWithResize(base.DummyBaseStrategy):
48 48
     def pre_execute(self):
49 49
         self._pre_execute()
50 50
 
51
-    def do_execute(self):
51
+    def do_execute(self, audit=None):
52 52
         para1 = self.input_parameters.para1
53 53
         para2 = self.input_parameters.para2
54 54
         LOG.debug("Executing Dummy strategy with para1=%(p1)f, para2=%(p2)s",

+ 1
- 1
watcher/decision_engine/strategy/strategies/dummy_with_scorer.py View File

@@ -78,7 +78,7 @@ class DummyWithScorer(base.DummyBaseStrategy):
78 78
     def pre_execute(self):
79 79
         self._pre_execute()
80 80
 
81
-    def do_execute(self):
81
+    def do_execute(self, audit=None):
82 82
         # Simple "hello world" from strategy
83 83
         param1 = self.input_parameters.param1
84 84
         param2 = self.input_parameters.param2

+ 1
- 1
watcher/decision_engine/strategy/strategies/host_maintenance.py View File

@@ -297,7 +297,7 @@ class HostMaintenance(base.HostMaintenanceBaseStrategy):
297 297
     def pre_execute(self):
298 298
         self._pre_execute()
299 299
 
300
-    def do_execute(self):
300
+    def do_execute(self, audit=None):
301 301
         LOG.info(_('Executing Host Maintenance Migration Strategy'))
302 302
 
303 303
         maintenance_node = self.input_parameters.get('maintenance_node')

+ 1
- 1
watcher/decision_engine/strategy/strategies/noisy_neighbor.py View File

@@ -241,7 +241,7 @@ class NoisyNeighbor(base.NoisyNeighborBaseStrategy):
241 241
     def pre_execute(self):
242 242
         self._pre_execute()
243 243
 
244
-    def do_execute(self):
244
+    def do_execute(self, audit=None):
245 245
         self.cache_threshold = self.input_parameters.cache_threshold
246 246
         self.period = self.input_parameters.period
247 247
 

+ 1
- 1
watcher/decision_engine/strategy/strategies/outlet_temp_control.py View File

@@ -241,7 +241,7 @@ class OutletTempControl(base.ThermalOptimizationBaseStrategy):
241 241
         LOG.info("Outlet temperature strategy threshold=%d",
242 242
                  self.threshold)
243 243
 
244
-    def do_execute(self):
244
+    def do_execute(self, audit=None):
245 245
         hosts_need_release, hosts_target = self.group_hosts_by_outlet_temp()
246 246
 
247 247
         if len(hosts_need_release) == 0:

+ 1
- 1
watcher/decision_engine/strategy/strategies/saving_energy.py View File

@@ -219,7 +219,7 @@ class SavingEnergy(base.SavingEnergyBaseStrategy):
219 219
         self.free_used_percent = self.input_parameters.free_used_percent
220 220
         self.min_free_hosts_num = self.input_parameters.min_free_hosts_num
221 221
 
222
-    def do_execute(self):
222
+    def do_execute(self, audit=None):
223 223
         """Strategy execution phase
224 224
 
225 225
         This phase is where you should put the main logic of your strategy.

+ 1
- 1
watcher/decision_engine/strategy/strategies/uniform_airflow.py View File

@@ -280,7 +280,7 @@ class UniformAirflow(base.BaseStrategy):
280 280
         self.threshold_power = self.input_parameters.threshold_power
281 281
         self._period = self.input_parameters.period
282 282
 
283
-    def do_execute(self):
283
+    def do_execute(self, audit=None):
284 284
         source_nodes, target_nodes = self.group_hosts_by_airflow()
285 285
 
286 286
         if not source_nodes:

+ 1
- 1
watcher/decision_engine/strategy/strategies/vm_workload_consolidation.py View File

@@ -518,7 +518,7 @@ class VMWorkloadConsolidation(base.ServerConsolidationBaseStrategy):
518 518
     def pre_execute(self):
519 519
         self._pre_execute()
520 520
 
521
-    def do_execute(self):
521
+    def do_execute(self, audit=None):
522 522
         """Execute strategy.
523 523
 
524 524
         This strategy produces a solution resulting in more

+ 1
- 1
watcher/decision_engine/strategy/strategies/workload_balance.py View File

@@ -295,7 +295,7 @@ class WorkloadBalance(base.WorkloadStabilizationBaseStrategy):
295 295
         self._meter = self.input_parameters.metrics
296 296
         self._granularity = self.input_parameters.granularity
297 297
 
298
-    def do_execute(self):
298
+    def do_execute(self, audit=None):
299 299
         """Strategy execution phase
300 300
 
301 301
         This phase is where you should put the main logic of your strategy.

+ 1
- 1
watcher/decision_engine/strategy/strategies/workload_stabilization.py View File

@@ -519,7 +519,7 @@ class WorkloadStabilization(base.WorkloadStabilizationBaseStrategy):
519 519
                         'will be removed in next release.')
520 520
             self.periods['compute_node'] = self.periods['node']
521 521
 
522
-    def do_execute(self):
522
+    def do_execute(self, audit=None):
523 523
         migration = self.check_threshold()
524 524
         if migration:
525 525
             hosts_load = self.get_hosts_load()

+ 1
- 1
watcher/decision_engine/strategy/strategies/zone_migration.py View File

@@ -269,7 +269,7 @@ class ZoneMigration(base.ZoneMigrationBaseStrategy):
269 269
         self._pre_execute()
270 270
         LOG.debug(self.storage_model.to_string())
271 271
 
272
-    def do_execute(self):
272
+    def do_execute(self, audit=None):
273 273
         """Strategy execution phase
274 274
 
275 275
         """

Loading…
Cancel
Save