Get planner from solution

support Strategy select different planner
Implements: bp watcher-planner-selector

Change-Id: I586e67f782e2965234826634ba3ff51681af4df8
This commit is contained in:
licanwei
2019-09-17 19:36:07 -07:00
parent 62020cac30
commit 0c191a2da9
3 changed files with 15 additions and 8 deletions

View File

@@ -66,12 +66,10 @@ class AuditHandler(BaseAuditHandler):
self._planner_loader = loader.DefaultPlannerLoader()
self.applier_client = rpcapi.ApplierAPI()
def get_planner(self, audit, request_context):
def get_planner(self, solution):
# because AuditHandler is a singletone we need to avoid race condition.
# thus we need to load planner every time
strategy = self.strategy_context.select_strategy(
audit, request_context)
planner_name = strategy.planner
planner_name = solution.strategy.planner
LOG.debug("Loading %s", planner_name)
planner = self._planner_loader.load(name=planner_name)
return planner
@@ -93,7 +91,7 @@ class AuditHandler(BaseAuditHandler):
request_context, audit,
action=fields.NotificationAction.PLANNER,
phase=fields.NotificationPhase.START)
planner = self.get_planner(audit, request_context)
planner = self.get_planner(solution)
action_plan = planner.schedule(request_context, audit.id, solution)
notifications.audit.send_action_notification(
request_context, audit,