예제 #1
0
파일: rpc.py 프로젝트: mjzhou/neutron-lib
from neutron_lib.utils import runtime
from oslo_config import cfg
from oslo_log import log as logging
import oslo_messaging
from oslo_messaging.rpc import dispatcher
from oslo_messaging import serializer as om_serializer
from oslo_service import service
from oslo_utils import excutils
from osprofiler import profiler

LOG = logging.getLogger(__name__)
TRANSPORT = None
NOTIFICATION_TRANSPORT = None
NOTIFIER = None

_DFT_EXMODS = runtime.list_package_modules(exceptions.__name__)


def init(conf, rpc_ext_mods=None):
    """Initialize the global RPC objects.

    :param conf: The oslo conf to use for initialization.
    :param rpc_ext_mods: Exception modules to expose via RPC.
    :returns: None.
    """
    global TRANSPORT, NOTIFICATION_TRANSPORT, NOTIFIER

    if rpc_ext_mods is None:
        rpc_ext_mods = _DFT_EXMODS
    else:
        rpc_ext_mods = list(set(rpc_ext_mods + _DFT_EXMODS))
예제 #2
0
 def test_list_package_modules(self):
     # mainly just to ensure we can import modules for both PY2/PY3
     self.assertGreater(
         len(runtime.list_package_modules('neutron_lib.exceptions')), 3)