Python oslo_messaging.Target() Examples
The following are 30
code examples of oslo_messaging.Target().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
oslo_messaging
, or try the search function
.
Example #1
Source File: service.py From cyborg with Apache License 2.0 | 6 votes |
def start(self): super(RPCService, self).start() target = messaging.Target(topic=self.topic, server=self.host) endpoints = [self.manager] serializer = objects_base.CyborgObjectSerializer() self.rpcserver = rpc.get_server(target, endpoints, serializer) self.rpcserver.start() admin_context = context.get_admin_context() self.tg.add_dynamic_timer( self.manager.periodic_tasks, periodic_interval_max=CONF.periodic_interval, context=admin_context) LOG.info('Created RPC server for service %(service)s on host ' '%(host)s.', {'service': self.topic, 'host': self.host})
Example #2
Source File: plugin_rpc.py From f5-openstack-agent with Apache License 2.0 | 6 votes |
def __init__(self, topic, context, env, group, host): """Initialize LBaaSv2PluginRPC.""" super(LBaaSv2PluginRPC, self).__init__() if topic: self.topic = topic else: self.topic = constants.TOPIC_PROCESS_ON_HOST_V2 self.target = messaging.Target(topic=self.topic, version=constants.RPC_API_VERSION) self._client = rpc.get_client(self.target, version_cap=None) self.context = context self.env = env self.group = group self.host = host
Example #3
Source File: service.py From senlin with Apache License 2.0 | 6 votes |
def start(self): super(HealthManagerService, self).start() self.service_id = uuidutils.generate_uuid() self.health_registry = health_manager.RuntimeHealthRegistry( ctx=self.ctx, engine_id=self.service_id, thread_group=self.tg ) # create service record ctx = senlin_context.get_admin_context() service_obj.Service.create(ctx, self.service_id, self.host, self.service_name, self.topic) self.tg.add_timer(CONF.periodic_interval, self.service_manage_report) self.target = messaging.Target(server=self.service_id, topic=self.topic, version=self.version) self.server = rpc.get_rpc_server(self.target, self) self.server.start() self.tg.add_dynamic_timer(self.task, None, cfg.CONF.periodic_interval)
Example #4
Source File: listener.py From searchlight with Apache License 2.0 | 6 votes |
def main(): if len(sys.argv) < 2: print("Supply an exchange") sys.exit(0) exchange = sys.argv[1] pool = sys.argv[2] if len(sys.argv) > 2 else None transport = oslo_messaging.get_notification_transport( cfg.CONF, url='rabbit://%s:%s@%s' % (username, password, host)) targets = [oslo_messaging.Target(topic=topic, exchange=exchange)] endpoints = [EP()] oslo_listener = oslo_messaging.get_notification_listener( transport, targets, endpoints, pool=pool, executor='threading') try: print("Started") oslo_listener.start() while True: time.sleep(1) except KeyboardInterrupt: print("Stopping") oslo_listener.stop() oslo_listener.wait()
Example #5
Source File: listener.py From searchlight with Apache License 2.0 | 6 votes |
def start(self): super(ListenerService, self).start() transport = oslo_messaging.get_notification_transport(CONF) targets = [ oslo_messaging.Target(topic=pl_topic, exchange=pl_exchange) for pl_topic, pl_exchange in self.topics_exchanges_set ] endpoints = [ NotificationEndpoint(self.plugins, PipelineManager(self.plugins)) ] listener = oslo_messaging.get_notification_listener( transport, targets, endpoints, executor='threading', pool=CONF.listener.notifications_pool) listener.start() self.listeners.append(listener)
Example #6
Source File: service.py From senlin with Apache License 2.0 | 6 votes |
def start(self): """Start the engine. Note that the engine is an internal server, we are not using versioned object for parameter passing. """ super(EngineService, self).start() self.service_id = uuidutils.generate_uuid() self.target = oslo_messaging.Target(server=self.service_id, topic=self.topic, version=self.version) self.server = messaging.get_rpc_server(self.target, self) self.server.start() # create service record ctx = senlin_context.get_admin_context() service_obj.Service.create(ctx, self.service_id, self.host, self.service_name, self.topic) self.tg.add_timer(CONF.periodic_interval, self.service_manage_report)
Example #7
Source File: service.py From designate with Apache License 2.0 | 6 votes |
def get_zone_transfer_request(self, context, zone_transfer_request_id): elevated_context = context.elevated(all_tenants=True) # Get zone transfer request zone_transfer_request = self.storage.get_zone_transfer_request( elevated_context, zone_transfer_request_id) LOG.info('Target Tenant ID found - using scoped policy') target = { 'target_tenant_id': zone_transfer_request.target_tenant_id, 'tenant_id': zone_transfer_request.tenant_id, } policy.check('get_zone_transfer_request', context, target) return zone_transfer_request
Example #8
Source File: service.py From senlin with Apache License 2.0 | 6 votes |
def start(self): super(ConductorService, self).start() self.service_id = uuidutils.generate_uuid() target = oslo_messaging.Target(version=consts.RPC_API_VERSION, server=self.host, topic=self.topic) serializer = obj_base.VersionedObjectSerializer() self.server = rpc_messaging.get_rpc_server( target, self, serializer=serializer) self.server.start() # create service record ctx = senlin_context.get_admin_context() service_obj.Service.create(ctx, self.service_id, self.host, self.service_name, self.topic) # we may want to make the clean-up attempts configurable. self.cleanup_timer = self.tg.add_timer(2 * CONF.periodic_interval, self.service_manage_cleanup) self.tg.add_timer(CONF.periodic_interval, self.service_manage_report)
Example #9
Source File: workers.py From vitrage with Apache License 2.0 | 6 votes |
def _init_instance(self): notifier = messaging.VitrageNotifier("vitrage.api", [EVALUATOR_TOPIC]) db = storage.get_connection_from_config() transport = messaging.get_rpc_transport() target = oslo_messaging.Target(topic=CONF.rpc_topic, server=uuidutils.generate_uuid()) self.api_lock = threading.RLock() endpoints = [ TopologyApis(self._entity_graph, self.api_lock), AlarmApis(self._entity_graph, self.api_lock, db), RcaApis(self._entity_graph, self.api_lock, db), ResourceApis(self._entity_graph, self.api_lock), TemplateApis(notifier, db), EventApis(), WebhookApis(db), OperationalApis(self._entity_graph), ] server = vitrage_rpc.get_server(target, endpoints, transport) server.start()
Example #10
Source File: agent_rpc.py From f5-openstack-lbaasv2-driver with Apache License 2.0 | 5 votes |
def _create_rpc_publisher(self): self.topic = constants.TOPIC_LOADBALANCER_AGENT_V2 if self.driver.env: self.topic = self.topic + "_" + self.driver.env target = messaging.Target(topic=self.topic, version=constants.BASE_RPC_API_VERSION) self._client = rpc.get_client(target, version_cap=None)
Example #11
Source File: rpcapi.py From karbor with Apache License 2.0 | 5 votes |
def __init__(self): super(OperationEngineAPI, self).__init__() target = messaging.Target(topic=CONF.operationengine_topic, version=self.RPC_API_VERSION) serializer = objects_base.KarborObjectSerializer() client = rpc.get_client(target, version_cap=None, serializer=serializer) self._client = client.prepare(version='1.0')
Example #12
Source File: rpc.py From qinling with Apache License 2.0 | 5 votes |
def __init__(self, transport): """Constructs an RPC client for engine. :param transport: Messaging transport. """ serializer = ContextSerializer( messaging.serializer.JsonPayloadSerializer()) self.topic = cfg.CONF.engine.topic self._client = messaging.RPCClient( transport, messaging.Target(topic=self.topic), serializer=serializer )
Example #13
Source File: rpc.py From ironic-inspector with Apache License 2.0 | 5 votes |
def get_client(topic=None): """Get a RPC client instance. :param topic: The topic of the message will be delivered to. This argument is ignored if CONF.standalone is True. """ assert TRANSPORT is not None if CONF.standalone: target = messaging.Target(topic=manager.MANAGER_TOPIC, server=CONF.host, version='1.3') else: target = messaging.Target(topic=topic, version='1.3') return messaging.RPCClient(TRANSPORT, target)
Example #14
Source File: service.py From watcher with Apache License 2.0 | 5 votes |
def build_notification_handler(self, topic_names, endpoints=()): serializer = rpc.RequestContextSerializer(rpc.JsonPayloadSerializer()) targets = [] for topic in topic_names: kwargs = {} if '.' in topic: exchange, topic = topic.split('.') kwargs['exchange'] = exchange kwargs['topic'] = topic targets.append(om.Target(**kwargs)) return om.get_notification_listener( self.notification_transport, targets, endpoints, executor='eventlet', serializer=serializer, allow_requeue=False, pool=CONF.host)
Example #15
Source File: service.py From watcher with Apache License 2.0 | 5 votes |
def build_topic_handler(self, topic_name, endpoints=()): access_policy = dispatcher.DefaultRPCAccessPolicy serializer = rpc.RequestContextSerializer(rpc.JsonPayloadSerializer()) target = om.Target( topic=topic_name, # For compatibility, we can override it with 'host' opt server=CONF.host or socket.gethostname(), version=self.api_version, ) return om.get_rpc_server( self.transport, target, endpoints, executor='eventlet', serializer=serializer, access_policy=access_policy)
Example #16
Source File: rpc.py From ironic-inspector with Apache License 2.0 | 5 votes |
def get_server(endpoints): """Get a RPC server instance.""" assert TRANSPORT is not None target = messaging.Target(topic=manager.MANAGER_TOPIC, server=CONF.host, version='1.3') return messaging.get_rpc_server( TRANSPORT, target, endpoints, executor='eventlet', access_policy=dispatcher.DefaultRPCAccessPolicy)
Example #17
Source File: event.py From aodh with Apache License 2.0 | 5 votes |
def __init__(self, worker_id, conf): super(EventAlarmEvaluationService, self).__init__(worker_id) self.conf = conf self.storage_conn = storage.get_connection_from_config(self.conf) self.evaluator = event.EventAlarmEvaluator(self.conf) self.listener = messaging.get_batch_notification_listener( messaging.get_transport(self.conf), [oslo_messaging.Target( topic=self.conf.listener.event_alarm_topic)], [EventAlarmEndpoint(self.evaluator)], False, self.conf.listener.batch_size, self.conf.listener.batch_timeout) self.listener.start()
Example #18
Source File: __init__.py From aodh with Apache License 2.0 | 5 votes |
def __init__(self, worker_id, conf): super(AlarmNotifierService, self).__init__(worker_id) self.conf = conf transport = messaging.get_transport(self.conf) self.notifiers = extension.ExtensionManager( self.NOTIFIER_EXTENSIONS_NAMESPACE, invoke_on_load=True, invoke_args=(self.conf,)) target = oslo_messaging.Target(topic=self.conf.notifier_topic) self.listener = messaging.get_batch_notification_listener( transport, [target], [AlarmEndpoint(self.notifiers)], False, self.conf.notifier.batch_size, self.conf.notifier.batch_timeout) self.listener.start()
Example #19
Source File: heat_endpoint.py From senlin with Apache License 2.0 | 5 votes |
def __init__(self, project_id, cluster_id, recover_action): super(HeatNotificationEndpoint, self).__init__( project_id, cluster_id, recover_action ) self.filter_rule = messaging.NotificationFilter( publisher_id='^orchestration.*', event_type='^orchestration\.stack\..*', context={'project_id': '^%s$' % project_id}) self.rpc = rpc_client.get_engine_client() self.target = messaging.Target( topic=cfg.CONF.health_manager.heat_notification_topic, exchange=cfg.CONF.health_manager.heat_control_exchange, )
Example #20
Source File: service.py From watcher with Apache License 2.0 | 5 votes |
def conductor_client(self): if self._conductor_client is None: target = om.Target( topic=self.conductor_topic, version=self.API_VERSION, ) self._conductor_client = om.RPCClient( self.transport, target, serializer=self.serializer) return self._conductor_client
Example #21
Source File: rpc.py From tacker with Apache License 2.0 | 5 votes |
def create_consumer(self, topic, endpoints, fanout=False, exchange='tacker', host=None): target = oslo_messaging.Target( topic=topic, server=host or cfg.CONF.host, fanout=fanout, exchange=exchange) serializer = objects_base.TackerObjectSerializer() server = get_server(target, endpoints, serializer) self.servers.append(server)
Example #22
Source File: fixtures.py From cloudkitty with Apache License 2.0 | 5 votes |
def start_fixture(self): messaging.setup() target = oslo_messaging.Target(topic='cloudkitty', server=cfg.CONF.host, version='1.0') endpoints = [ self.endpoint() ] self.server = messaging.get_server(target, endpoints) self.server.start()
Example #23
Source File: orchestrator.py From cloudkitty with Apache License 2.0 | 5 votes |
def _init_messaging(self): target = oslo_messaging.Target(topic='cloudkitty', server=CONF.host, version='1.0') endpoints = [ self._rating_endpoint, self._scope_endpoint, ] self.server = messaging.get_server(target, endpoints) self.server.start()
Example #24
Source File: messaging.py From cloudkitty with Apache License 2.0 | 5 votes |
def get_target(): global RPC_TARGET if RPC_TARGET is None: RPC_TARGET = oslo_messaging.Target(topic='cloudkitty', version='1.0') return RPC_TARGET
Example #25
Source File: service.py From vitrage with Apache License 2.0 | 5 votes |
def __init__(self, worker_id): super(MachineLearningService, self).__init__(worker_id) self.machine_learning_plugins = self.get_machine_learning_plugins() transport = messaging.get_transport() target = \ oslo_m.Target(topic=CONF.machine_learning.machine_learning_topic) self.listener = messaging.get_notification_listener( transport, [target], [VitrageEventEndpoint(self.machine_learning_plugins)])
Example #26
Source File: service.py From vitrage with Apache License 2.0 | 5 votes |
def __init__(self, worker_id, db_connection): super(PersistorService, self).__init__(worker_id) self.db_connection = db_connection transport = messaging.get_transport() target = \ oslo_m.Target(topic=CONF.persistency.persistor_topic) self.listener = messaging.get_notification_listener( transport, [target], [VitragePersistorEndpoint(self.db_connection)]) self.scheduler = Scheduler(db_connection)
Example #27
Source File: hooks.py From vitrage with Apache License 2.0 | 5 votes |
def __init__(self): transport = messaging.get_rpc_transport() target = oslo_messaging.Target(topic=CONF.rpc_topic) self.client = vitrage_rpc.get_client(transport, target) self.check_backend = CONF.api.check_backend
Example #28
Source File: driver_exec.py From vitrage with Apache License 2.0 | 5 votes |
def get_listener(self): topics = CONF.datasources.notification_topics exchange = CONF.datasources.notification_exchange transport = messaging.get_transport() targets = [oslo_messaging.Target(exchange=exchange, topic=topic) for topic in topics] return messaging.get_notification_listener(transport, targets, [self])
Example #29
Source File: graph_init.py From vitrage with Apache License 2.0 | 5 votes |
def _init_listener(self, topic, callback): if not topic: return return messaging.get_notification_listener( transport=messaging.get_transport(), targets=[oslo_messaging.Target(topic=topic)], endpoints=[PushNotificationsEndpoint(callback)])
Example #30
Source File: __init__.py From sgx-kms with Apache License 2.0 | 5 votes |
def get_notification_target(): conf_opts = getattr(CONF, KS_NOTIFICATIONS_GRP_NAME) return messaging.Target(exchange=conf_opts.control_exchange, topic=conf_opts.topic, version=conf_opts.version, fanout=True)