本文整理汇总了Python中neutron.common.rpc.init函数的典型用法代码示例。如果您正苦于以下问题:Python init函数的具体用法?Python init怎么用?Python init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了init函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup_rpc_mocks
def setup_rpc_mocks(self):
# don't actually start RPC listeners when testing
self.useFixture(fixtures.MonkeyPatch(
'neutron.common.rpc.Connection.consume_in_threads',
fake_consume_in_threads))
# immediately return RPC calls
self.useFixture(fixtures.MonkeyPatch(
'neutron.common.rpc.RpcProxy._RpcProxy__call_rpc_method',
mock.MagicMock()))
self.useFixture(fixtures.MonkeyPatch(
'oslo.messaging.Notifier', fake_notifier.FakeNotifier))
self.messaging_conf = messaging_conffixture.ConfFixture(CONF)
self.messaging_conf.transport_driver = 'fake'
# NOTE(russellb) We want all calls to return immediately.
self.messaging_conf.response_timeout = 0
self.useFixture(self.messaging_conf)
self.addCleanup(n_rpc.clear_extra_exmods)
n_rpc.add_extra_exmods('neutron.test')
self.addCleanup(n_rpc.cleanup)
n_rpc.init(CONF)
示例2: test_init
def test_init(self, mock_not, mock_noti_trans, mock_trans, mock_ser,
mock_exmods):
notifier = mock.Mock()
transport = mock.Mock()
noti_transport = mock.Mock()
serializer = mock.Mock()
conf = mock.Mock()
mock_exmods.return_value = ['foo']
mock_trans.return_value = transport
mock_noti_trans.return_value = noti_transport
mock_ser.return_value = serializer
mock_not.return_value = notifier
rpc.init(conf)
mock_exmods.assert_called_once_with()
mock_trans.assert_called_once_with(conf, allowed_remote_exmods=['foo'],
aliases=rpc.TRANSPORT_ALIASES)
mock_noti_trans.assert_called_once_with(conf,
allowed_remote_exmods=['foo'],
aliases=rpc.TRANSPORT_ALIASES)
mock_not.assert_called_once_with(noti_transport,
serializer=serializer)
self.assertIsNotNone(rpc.TRANSPORT)
self.assertIsNotNone(rpc.NOTIFICATION_TRANSPORT)
self.assertIsNotNone(rpc.NOTIFIER)
示例3: setUp
def setUp(self):
n_rpc.init(cfg.CONF)
self.p_notification = pull_notification('sc', 'conf')
self.context = TestContext().get_context_dict()
self.ev = ''
self.import_lib = 'gbpservice.nfp.lib.transport'
self.import_cast = 'oslo_messaging.rpc.client._CallContext.cast'
示例4: setUp
def setUp(self):
super(QuarkIpamBaseFunctionalTest, self).setUp()
patcher = mock.patch("neutron.common.rpc.oslo_messaging")
patcher.start()
self.addCleanup(patcher.stop)
rpc.init(mock.MagicMock())
示例5: __init__
def __init__(self):
# Required to bypass an error when instantiating Midonet plugin.
rpc.init(cfg.CONF)
self.ctx = ncntxt.get_admin_context()
self.client = plugin.MidonetPluginV2()
self.lb_client = loadbalancer_db.LoadBalancerPluginDb()
示例6: init
def init(args, **kwargs):
product_name = 'bambuk-dispatcher-agent'
log.register_options(cfg.CONF)
cfg.CONF(args=args, project=product_name,
version='%%(prog)s %s' % version.version_info.release_string(),
**kwargs)
log.setup(cfg.CONF, product_name)
rpc.init(cfg.CONF)
示例7: setUp
def setUp(self, f1, f2, f3, f4, f5):
super(TestNWAAgentBase, self).setUp()
cli = mock.patch('networking_nec.nwa.nwalib.client.NwaClient').start()
self.nwacli = cli.return_value
_init_nwa_client_patch(self.nwacli)
self.agent = nwa_agent.NECNWANeutronAgent(10)
rpc.init(cfg.ConfigOpts())
示例8: init
def init(args, default_config_files=None, **kwargs):
cfg.CONF(args=args, project='neutron',
version='%%(prog)s %s' % version.version_info.release_string(),
default_config_files=default_config_files,
**kwargs)
n_rpc.init(cfg.CONF)
# Validate that the base_mac is of the correct format
msg = validators.validate_regex(cfg.CONF.base_mac, validators.MAC_PATTERN)
if msg:
msg = _("Base MAC: %s") % msg
raise Exception(msg)
示例9: init
def init(args, **kwargs):
cfg.CONF(args=args, project="neutron", version="%%(prog)s %s" % version.version_info.release_string(), **kwargs)
# FIXME(ihrachys): if import is put in global, circular import
# failure occurs
from neutron.common import rpc as n_rpc
n_rpc.init(cfg.CONF)
# Validate that the base_mac is of the correct format
msg = attributes._validate_regex(cfg.CONF.base_mac, attributes.MAC_PATTERN)
if msg:
msg = _("Base MAC: %s") % msg
raise Exception(msg)
示例10: setUp
def setUp(self):
super(CastExceptionTestCase, self).setUp()
self.messaging_conf = messaging_conffixture.ConfFixture(CONF)
self.messaging_conf.transport_url = 'fake://'
self.messaging_conf.response_timeout = 0
self.useFixture(self.messaging_conf)
self.addCleanup(rpc.cleanup)
rpc.init(CONF)
rpc.TRANSPORT = mock.MagicMock()
rpc.TRANSPORT._send.side_effect = Exception
target = messaging.Target(version='1.0', topic='testing')
self.client = rpc.get_client(target)
self.cast_context = mock.Mock()
示例11: setUp
def setUp(self):
super(ServiceTestCase, self).setUp()
self.host = 'foo'
self.topic = 'neutron-agent'
self.target_mock = mock.patch('oslo_messaging.Target')
self.target_mock.start()
self.messaging_conf = messaging_conffixture.ConfFixture(CONF)
self.messaging_conf.transport_driver = 'fake'
self.messaging_conf.response_timeout = 0
self.useFixture(self.messaging_conf)
self.addCleanup(rpc.cleanup)
rpc.init(CONF)
示例12: setUp
def setUp(self):
super(TimeoutTestCase, self).setUp()
self.messaging_conf = messaging_conffixture.ConfFixture(CONF)
self.messaging_conf.transport_driver = 'fake'
self.messaging_conf.response_timeout = 0
self.useFixture(self.messaging_conf)
self.addCleanup(rpc.cleanup)
rpc.init(CONF)
rpc.TRANSPORT = mock.MagicMock()
rpc.TRANSPORT._send.side_effect = messaging.MessagingTimeout
target = messaging.Target(version='1.0', topic='testing')
self.client = rpc.get_client(target)
self.call_context = mock.Mock()
self.sleep = mock.patch('time.sleep').start()
rpc.TRANSPORT.conf.rpc_response_timeout = 10
示例13: setup_rpc_mocks
def setup_rpc_mocks(self):
# don't actually start RPC listeners when testing
mock.patch("neutron.common.rpc.Connection.consume_in_threads", return_value=[]).start()
self.useFixture(fixtures.MonkeyPatch("oslo_messaging.Notifier", fake_notifier.FakeNotifier))
self.messaging_conf = messaging_conffixture.ConfFixture(CONF)
self.messaging_conf.transport_driver = "fake"
# NOTE(russellb) We want all calls to return immediately.
self.messaging_conf.response_timeout = 0
self.useFixture(self.messaging_conf)
self.addCleanup(n_rpc.clear_extra_exmods)
n_rpc.add_extra_exmods("neutron.test")
self.addCleanup(n_rpc.cleanup)
n_rpc.init(CONF)
示例14: __init__
def __init__(self, **kwargs):
super(TestRpcReportState, self).__init__(**kwargs)
cfg.CONF([], project='neutron', default_config_files=['/etc/neutron/neutron.conf'])
rpc.init(cfg.CONF)
self.ctxt = context.get_admin_context_without_session()
self.agent_state = {
'binary': 'neutron-openvswitch-agent',
'host': 'fakehost.com',
'topic': 'N/A',
'configurations': {'bridge_mappings': {"physnet2": "br-bond1"},
'tunnel_types': [],
'tunneling_ip': "",
'l2_population': False},
'agent_type': "Open vSwitch agent",
'start_flag': True
}
self.state_rpc = nu_rpc.PluginReportStateAPI('q-plugin')
示例15: init
def init(args, **kwargs):
cfg.CONF(args=args, project='neutron',
version='%%(prog)s %s' % version.version_info.release_string(),
**kwargs)
# FIXME(ihrachys): if import is put in global, circular import
# failure occurs
from neutron.common import rpc as n_rpc
# 进行notification的初始化操作,此时没有指定publish_ip
n_rpc.init(cfg.CONF)
# Validate that the base_mac is of the correct format
# Checking mac format is right or not
msg = attributes._validate_regex(cfg.CONF.base_mac,
attributes.MAC_PATTERN)
if msg:
msg = _("Base MAC: %s") % msg
raise Exception(msg)