Removed status_topic config parameter

In this changeset, I removed the now obsolete status_topic config
option.

DocImpact
Partially Implements: blueprint watcher-notifications-ovo

Change-Id: Icfc03abd875b77fc456bfa286ac2b5774651e8fa
This commit is contained in:
Vincent Françoise 2016-11-09 17:04:50 +01:00
parent 395ccbd94c
commit cdda06c08c
9 changed files with 42 additions and 111 deletions

View File

@ -37,13 +37,6 @@ APPLIER_MANAGER_OPTS = [
help='The topic name used for'
'control events, this topic '
'used for rpc call '),
cfg.StrOpt('status_topic',
default='watcher.applier.status',
help='The topic name used for '
'status events, this topic '
'is used so as to notify'
'the others components '
'of the system'),
cfg.StrOpt('publisher_id',
default='watcher.applier.api',
help='The identifier used by watcher '
@ -61,7 +54,7 @@ CONF.register_group(opt_group)
CONF.register_opts(APPLIER_MANAGER_OPTS, opt_group)
class ApplierManager(service_manager.ServiceManagerBase):
class ApplierManager(service_manager.ServiceManager):
@property
def service_name(self):
@ -79,10 +72,6 @@ class ApplierManager(service_manager.ServiceManagerBase):
def conductor_topic(self):
return CONF.watcher_applier.conductor_topic
@property
def status_topic(self):
return CONF.watcher_applier.status_topic
@property
def notification_topics(self):
return []
@ -91,10 +80,6 @@ class ApplierManager(service_manager.ServiceManagerBase):
def conductor_endpoints(self):
return [trigger.TriggerActionPlan]
@property
def status_endpoints(self):
return []
@property
def notification_endpoints(self):
return []

View File

@ -15,12 +15,13 @@
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from oslo_config import cfg
from watcher.applier import manager
from watcher.common import exception
from watcher.common import service
from watcher.common import service_manager
from watcher.common import utils
@ -42,7 +43,7 @@ class ApplierAPI(service.Service):
context, 'launch_action_plan', action_plan_uuid=action_plan_uuid)
class ApplierAPIManager(object):
class ApplierAPIManager(service_manager.ServiceManager):
@property
def service_name(self):
@ -60,10 +61,6 @@ class ApplierAPIManager(object):
def conductor_topic(self):
return CONF.watcher_applier.conductor_topic
@property
def status_topic(self):
return CONF.watcher_applier.status_topic
@property
def notification_topics(self):
return []
@ -72,10 +69,6 @@ class ApplierAPIManager(object):
def conductor_endpoints(self):
return []
@property
def status_endpoints(self):
return []
@property
def notification_endpoints(self):
return []

View File

@ -171,15 +171,11 @@ class Service(service.ServiceBase):
self.api_version = self.manager.api_version
self.conductor_topic = self.manager.conductor_topic
self.status_topic = self.manager.status_topic
self.notification_topics = self.manager.notification_topics
self.conductor_endpoints = [
ep(self) for ep in self.manager.conductor_endpoints
]
self.status_endpoints = [
ep(self.publisher_id) for ep in self.manager.status_endpoints
]
self.notification_endpoints = self.manager.notification_endpoints
self.serializer = rpc.RequestContextSerializer(
@ -188,10 +184,8 @@ class Service(service.ServiceBase):
self._transport = None
self._notification_transport = None
self._conductor_client = None
self._status_client = None
self.conductor_topic_handler = None
self.status_topic_handler = None
self.notification_handler = None
self.heartbeat = None
@ -199,9 +193,6 @@ class Service(service.ServiceBase):
if self.conductor_topic and self.conductor_endpoints:
self.conductor_topic_handler = self.build_topic_handler(
self.conductor_topic, self.conductor_endpoints)
if self.status_topic and self.status_endpoints:
self.status_topic_handler = self.build_topic_handler(
self.status_topic, self.status_endpoints)
if self.notification_topics and self.notification_endpoints:
self.notification_handler = self.build_notification_handler(
self.notification_topics, self.notification_endpoints
@ -238,21 +229,6 @@ class Service(service.ServiceBase):
def conductor_client(self, c):
self.conductor_client = c
@property
def status_client(self):
if self._status_client is None:
target = om.Target(
topic=self.status_topic,
version=self.API_VERSION,
)
self._status_client = om.RPCClient(
self.transport, target, serializer=self.serializer)
return self._status_client
@status_client.setter
def status_client(self, c):
self.status_client = c
def build_topic_handler(self, topic_name, endpoints=()):
serializer = rpc.RequestContextSerializer(rpc.JsonPayloadSerializer())
target = om.Target(
@ -278,8 +254,6 @@ class Service(service.ServiceBase):
CONF.transport_url, CONF.rpc_backend)
if self.conductor_topic_handler:
self.conductor_topic_handler.start()
if self.status_topic_handler:
self.status_topic_handler.start()
if self.notification_handler:
self.notification_handler.start()
if self.heartbeat:
@ -290,8 +264,6 @@ class Service(service.ServiceBase):
CONF.transport_url, CONF.rpc_backend)
if self.conductor_topic_handler:
self.conductor_topic_handler.stop()
if self.status_topic_handler:
self.status_topic_handler.stop()
if self.notification_handler:
self.notification_handler.stop()
if self.heartbeat:

View File

@ -15,9 +15,11 @@
# under the License.
import abc
import six
class ServiceManagerBase(object):
@six.add_metaclass(abc.ABCMeta)
class ServiceManager(object):
@abc.abstractproperty
def service_name(self):
@ -35,10 +37,6 @@ class ServiceManagerBase(object):
def conductor_topic(self):
raise NotImplementedError()
@abc.abstractproperty
def status_topic(self):
raise NotImplementedError()
@abc.abstractproperty
def notification_topics(self):
raise NotImplementedError()
@ -47,10 +45,6 @@ class ServiceManagerBase(object):
def conductor_endpoints(self):
raise NotImplementedError()
@abc.abstractproperty
def status_endpoints(self):
raise NotImplementedError()
@abc.abstractproperty
def notification_endpoints(self):
raise NotImplementedError()

View File

@ -51,13 +51,6 @@ WATCHER_DECISION_ENGINE_OPTS = [
help='The topic name used for '
'control events, this topic '
'used for RPC calls'),
cfg.StrOpt('status_topic',
default='watcher.decision.status',
help='The topic name used for '
'status events; this topic '
'is used so as to notify'
'the others components '
'of the system'),
cfg.ListOpt('notification_topics',
default=['versioned_notifications', 'watcher_notifications'],
help='The topic names from which notification events '
@ -79,7 +72,7 @@ CONF.register_group(decision_engine_opt_group)
CONF.register_opts(WATCHER_DECISION_ENGINE_OPTS, decision_engine_opt_group)
class DecisionEngineManager(service_manager.ServiceManagerBase):
class DecisionEngineManager(service_manager.ServiceManager):
@property
def service_name(self):
@ -97,10 +90,6 @@ class DecisionEngineManager(service_manager.ServiceManagerBase):
def conductor_topic(self):
return CONF.watcher_decision_engine.conductor_topic
@property
def status_topic(self):
return CONF.watcher_decision_engine.status_topic
@property
def notification_topics(self):
return CONF.watcher_decision_engine.notification_topics
@ -109,10 +98,6 @@ class DecisionEngineManager(service_manager.ServiceManagerBase):
def conductor_endpoints(self):
return [audit_endpoint.AuditEndpoint]
@property
def status_endpoints(self):
return []
@property
def notification_endpoints(self):
return self.collector_manager.get_notification_endpoints()

View File

@ -21,6 +21,7 @@ from oslo_config import cfg
from watcher.common import exception
from watcher.common import service
from watcher.common import service_manager
from watcher.common import utils
from watcher.decision_engine import manager
@ -45,7 +46,7 @@ class DecisionEngineAPI(service.Service):
context, 'trigger_audit', audit_uuid=audit_uuid)
class DecisionEngineAPIManager(object):
class DecisionEngineAPIManager(service_manager.ServiceManager):
@property
def service_name(self):
@ -63,10 +64,6 @@ class DecisionEngineAPIManager(object):
def conductor_topic(self):
return CONF.watcher_decision_engine.conductor_topic
@property
def status_topic(self):
return CONF.watcher_decision_engine.status_topic
@property
def notification_topics(self):
return []
@ -75,10 +72,6 @@ class DecisionEngineAPIManager(object):
def conductor_endpoints(self):
return []
@property
def status_endpoints(self):
return []
@property
def notification_endpoints(self):
return []

View File

@ -33,13 +33,11 @@ class DummyManager(object):
API_VERSION = '1.0'
conductor_endpoints = [mock.Mock()]
status_endpoints = [mock.Mock()]
notification_endpoints = [mock.Mock()]
def __init__(self):
self.publisher_id = "pub_id"
self.conductor_topic = "conductor_topic"
self.status_topic = "status_topic"
self.notification_topics = []
self.api_version = self.API_VERSION
self.service_name = None
@ -85,13 +83,13 @@ class TestService(base.TestCase):
def test_start(self, m_handler):
dummy_service = service.Service(DummyManager)
dummy_service.start()
self.assertEqual(2, m_handler.call_count)
self.assertEqual(1, m_handler.call_count)
@mock.patch.object(om.rpc.server, "RPCServer")
def test_stop(self, m_handler):
dummy_service = service.Service(DummyManager)
dummy_service.stop()
self.assertEqual(2, m_handler.call_count)
self.assertEqual(1, m_handler.call_count)
def test_build_topic_handler(self):
topic_name = "mytopic"
@ -108,6 +106,3 @@ class TestService(base.TestCase):
self.assertIsInstance(
dummy_service.conductor_topic_handler,
om.rpc.server.RPCServer)
self.assertIsInstance(
dummy_service.status_topic_handler,
om.rpc.server.RPCServer)

View File

@ -16,30 +16,44 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from watcher.common import service_manager
from watcher.decision_engine.model.notification import nova as novanotification
from watcher.tests.decision_engine.model import faker_cluster_state
class FakeManager(object):
class FakeManager(service_manager.ServiceManager):
API_VERSION = '1.0'
def __init__(self):
self.api_version = self.API_VERSION
self.service_name = None
fake_cdmc = faker_cluster_state.FakerModelCollector()
# fake cluster instead on Nova CDM
self.fake_cdmc = faker_cluster_state.FakerModelCollector()
@property
def service_name(self):
return 'watcher-fake'
self.publisher_id = 'test_publisher_id'
self.conductor_topic = 'test_conductor_topic'
self.status_topic = 'test_status_topic'
self.notification_topics = ['nova']
@property
def api_version(self):
return self.API_VERSION
self.conductor_endpoints = [] # Disable audit endpoint
self.status_endpoints = []
@property
def publisher_id(self):
return 'test_publisher_id'
self.notification_endpoints = [
@property
def conductor_topic(self):
return 'test_conductor_topic'
@property
def notification_topics(self):
return ['nova']
@property
def conductor_endpoints(self):
return [] # Disable audit endpoint
@property
def notification_endpoints(self):
return [
novanotification.ServiceUpdated(self.fake_cdmc),
novanotification.InstanceCreated(self.fake_cdmc),

View File

@ -31,9 +31,9 @@ from watcher.tests.decision_engine.model.notification import fake_managers
class DummyManager(fake_managers.FakeManager):
def __init__(self):
super(DummyManager, self).__init__()
self.notification_endpoints = [DummyNotification(self.fake_cdmc)]
@property
def notification_endpoints(self):
return [DummyNotification(self.fake_cdmc)]
class DummyNotification(base.NotificationEndpoint):