Define self.client in MessagingCore
Currently self.client is referenced within MessagingCore, but no definition is made in its constructor. Additionally self.client is defined in children classes of MessagingCore. This patchset defines self.client in the constructor of MessagingCore and removes the redefinition in its children. -self.client lazily loaded Co-Authored-By: v-francoise <Vincent.FRANCOISE@b-com.com> Change-Id: I14525a175bf1ebde3d2636024ad2f2219c79d6e1 Closes-Bug: #1521636
This commit is contained in:
committed by
Vincent Françoise
parent
7406a1e713
commit
2f0c1c12cf
@@ -19,10 +19,10 @@
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log
|
||||
import oslo_messaging as om
|
||||
|
||||
from watcher.common import exception
|
||||
from watcher.common.messaging.messaging_core import MessagingCore
|
||||
from watcher.common.messaging.notification_handler import NotificationHandler
|
||||
from watcher.common import utils
|
||||
from watcher.decision_engine.manager import decision_engine_opt_group
|
||||
from watcher.decision_engine.manager import WATCHER_DECISION_ENGINE_OPTS
|
||||
@@ -40,22 +40,16 @@ class DecisionEngineAPI(MessagingCore):
|
||||
def __init__(self):
|
||||
super(DecisionEngineAPI, self).__init__(
|
||||
CONF.watcher_decision_engine.publisher_id,
|
||||
CONF.watcher_decision_engine.topic_control,
|
||||
CONF.watcher_decision_engine.topic_status,
|
||||
CONF.watcher_decision_engine.conductor_topic,
|
||||
CONF.watcher_decision_engine.status_topic,
|
||||
api_version=self.API_VERSION,
|
||||
)
|
||||
|
||||
transport = om.get_transport(CONF)
|
||||
target = om.Target(
|
||||
topic=CONF.watcher_decision_engine.topic_control,
|
||||
version=self.API_VERSION,
|
||||
)
|
||||
self.client = om.RPCClient(transport, target,
|
||||
serializer=self.serializer)
|
||||
self.handler = NotificationHandler(self.publisher_id)
|
||||
self.status_topic_handler.add_endpoint(self.handler)
|
||||
|
||||
def trigger_audit(self, context, audit_uuid=None):
|
||||
if not utils.is_uuid_like(audit_uuid):
|
||||
raise exception.InvalidUuidOrName(name=audit_uuid)
|
||||
|
||||
return self.client.call(
|
||||
return self.conductor_client.call(
|
||||
context.to_dict(), 'trigger_audit', audit_uuid=audit_uuid)
|
||||
|
||||
Reference in New Issue
Block a user