Example #1
0
def notify(method, engine_id=None, **kwargs):
    '''Send notification to dispatcher

    :param method: remote method to call
    :param engine_id: dispatcher to notify; None implies broadcast
    '''

    client = rpc_messaging.get_rpc_client(version=consts.RPC_API_VERSION)

    if engine_id:
        # Notify specific dispatcher identified by engine_id
        call_context = client.prepare(
            version=consts.RPC_API_VERSION,
            topic=consts.ENGINE_DISPATCHER_TOPIC,
            server=engine_id)
    else:
        # Broadcast to all disptachers
        call_context = client.prepare(
            version=consts.RPC_API_VERSION,
            topic=consts.ENGINE_DISPATCHER_TOPIC)

    try:
        # We don't use ctext parameter in action progress
        # actually. But since RPCClient.call needs this param,
        # we use oslo current context here.
        call_context.call(oslo_context.get_current(), method, **kwargs)
        return True
    except oslo_messaging.MessagingTimeout:
        return False
Example #2
0
def notify(method, scheduler_id=None, **kwargs):
    '''Send notification to scheduler

    :param method: remote method to call
    :param scheduler_id: specify scheduler to notify; None implies broadcast
    '''
    if scheduler_id:
        # Notify specific scheduler identified by scheduler_id
        client = messaging.get_rpc_client(
            topic=consts.SCHEDULER_TOPIC,
            server=scheduler_id,
            version=consts.RPC_API_VERSION)
    else:
        # Broadcast to all schedulers
        client = messaging.get_rpc_client(
            topic=consts.SCHEDULER_TOPIC,
            version=consts.RPC_API_VERSION)
    try:
        client.call(oslo_context.get_current(), method, **kwargs)
        return True
    except oslo_messaging.MessagingTimeout:
        return False
Example #3
0
 def __init__(self):
     self._client = messaging.get_rpc_client(
         topic=consts.ENGINE_TOPIC,
         server=cfg.CONF.host,
         version=self.BASE_RPC_API_VERSION)
Example #4
0
 def __init__(self):
     cfg.CONF.import_opt('host', 'bilean.common.config')
     self._client = messaging.get_rpc_client(
         topic=consts.ENGINE_TOPIC,
         server=cfg.CONF.host,
         version=self.BASE_RPC_API_VERSION)