Fix to reuse RabbitMQ connection
Currently RabbitMQ connection gradually increases by CONTINUOUS audit with auto-trigger option. This patch fixes watcher to reuse RabbitMQ connection. Change-Id: I818fc1ce982f67bac08c815821f1ad67f8f3c893
This commit is contained in:
@@ -320,6 +320,7 @@ class ActionPlansController(rest.RestController):
|
||||
|
||||
def __init__(self):
|
||||
super(ActionPlansController, self).__init__()
|
||||
self.applier_client = rpcapi.ApplierAPI()
|
||||
|
||||
from_actionsPlans = False
|
||||
"""A flag to indicate if the requests to this controller are coming
|
||||
@@ -553,9 +554,8 @@ class ActionPlansController(rest.RestController):
|
||||
a.save()
|
||||
|
||||
if launch_action_plan:
|
||||
applier_client = rpcapi.ApplierAPI()
|
||||
applier_client.launch_action_plan(pecan.request.context,
|
||||
action_plan.uuid)
|
||||
self.applier_client.launch_action_plan(pecan.request.context,
|
||||
action_plan.uuid)
|
||||
|
||||
action_plan_to_update = objects.ActionPlan.get_by_uuid(
|
||||
pecan.request.context,
|
||||
@@ -584,9 +584,8 @@ class ActionPlansController(rest.RestController):
|
||||
action_plan_to_start['state'] = objects.action_plan.State.PENDING
|
||||
action_plan_to_start.save()
|
||||
|
||||
applier_client = rpcapi.ApplierAPI()
|
||||
applier_client.launch_action_plan(pecan.request.context,
|
||||
action_plan_uuid)
|
||||
self.applier_client.launch_action_plan(pecan.request.context,
|
||||
action_plan_uuid)
|
||||
action_plan_to_start = objects.ActionPlan.get_by_uuid(
|
||||
pecan.request.context, action_plan_uuid)
|
||||
|
||||
|
||||
@@ -403,6 +403,7 @@ class AuditsController(rest.RestController):
|
||||
"""REST controller for Audits."""
|
||||
def __init__(self):
|
||||
super(AuditsController, self).__init__()
|
||||
self.dc_client = rpcapi.DecisionEngineAPI()
|
||||
|
||||
from_audits = False
|
||||
"""A flag to indicate if the requests to this controller are coming
|
||||
@@ -575,8 +576,7 @@ class AuditsController(rest.RestController):
|
||||
|
||||
# trigger decision-engine to run the audit
|
||||
if new_audit.audit_type == objects.audit.AuditType.ONESHOT.value:
|
||||
dc_client = rpcapi.DecisionEngineAPI()
|
||||
dc_client.trigger_audit(context, new_audit.uuid)
|
||||
self.dc_client.trigger_audit(context, new_audit.uuid)
|
||||
|
||||
return Audit.convert_with_links(new_audit)
|
||||
|
||||
|
||||
@@ -63,6 +63,7 @@ class AuditHandler(BaseAuditHandler):
|
||||
self._strategy_context = default_context.DefaultStrategyContext()
|
||||
self._planner_manager = planner_manager.PlannerManager()
|
||||
self._planner = None
|
||||
self.applier_client = rpcapi.ApplierAPI()
|
||||
|
||||
@property
|
||||
def planner(self):
|
||||
@@ -125,9 +126,8 @@ class AuditHandler(BaseAuditHandler):
|
||||
def post_execute(self, audit, solution, request_context):
|
||||
action_plan = self.do_schedule(request_context, audit, solution)
|
||||
if audit.auto_trigger:
|
||||
applier_client = rpcapi.ApplierAPI()
|
||||
applier_client.launch_action_plan(request_context,
|
||||
action_plan.uuid)
|
||||
self.applier_client.launch_action_plan(request_context,
|
||||
action_plan.uuid)
|
||||
|
||||
def execute(self, audit, request_context):
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user