当前位置: 首页>>代码示例>>Python>>正文


Python events.BEFORE_CREATE属性代码示例

本文整理汇总了Python中neutron_lib.callbacks.events.BEFORE_CREATE属性的典型用法代码示例。如果您正苦于以下问题:Python events.BEFORE_CREATE属性的具体用法?Python events.BEFORE_CREATE怎么用?Python events.BEFORE_CREATE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在neutron_lib.callbacks.events的用法示例。


在下文中一共展示了events.BEFORE_CREATE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _register_callbacks

# 需要导入模块: from neutron_lib.callbacks import events [as 别名]
# 或者: from neutron_lib.callbacks.events import BEFORE_CREATE [as 别名]
def _register_callbacks(self):
        registry.subscribe(self.floatingip_update_callback,
                           resources.FLOATING_IP,
                           events.AFTER_UPDATE)
        registry.subscribe(self.router_interface_callback,
                           resources.ROUTER_INTERFACE,
                           events.AFTER_CREATE)
        registry.subscribe(self.router_interface_callback,
                           resources.ROUTER_INTERFACE,
                           events.BEFORE_CREATE)
        registry.subscribe(self.router_interface_callback,
                           resources.ROUTER_INTERFACE,
                           events.AFTER_DELETE)
        registry.subscribe(self.router_gateway_callback,
                           resources.ROUTER_GATEWAY,
                           events.AFTER_CREATE)
        registry.subscribe(self.router_gateway_callback,
                           resources.ROUTER_GATEWAY,
                           events.AFTER_DELETE)
        registry.subscribe(self.port_callback,
                           resources.PORT,
                           events.AFTER_UPDATE) 
开发者ID:openstack,项目名称:neutron-dynamic-routing,代码行数:24,代码来源:bgp_plugin.py

示例2: test__register_callbacks

# 需要导入模块: from neutron_lib.callbacks import events [as 别名]
# 或者: from neutron_lib.callbacks.events import BEFORE_CREATE [as 别名]
def test__register_callbacks(self):
        with mock.patch.object(registry, 'subscribe') as subscribe:
            plugin = bgp_plugin.BgpPlugin()
            expected_calls = [
                mock.call(plugin.bgp_drscheduler.schedule_bgp_speaker_callback,
                          dr_resources.BGP_SPEAKER, events.AFTER_CREATE),
                mock.call(plugin.floatingip_update_callback,
                          resources.FLOATING_IP, events.AFTER_UPDATE),
                mock.call(plugin.router_interface_callback,
                          resources.ROUTER_INTERFACE, events.AFTER_CREATE),
                mock.call(plugin.router_interface_callback,
                          resources.ROUTER_INTERFACE, events.BEFORE_CREATE),
                mock.call(plugin.router_interface_callback,
                          resources.ROUTER_INTERFACE, events.AFTER_DELETE),
                mock.call(plugin.router_gateway_callback,
                          resources.ROUTER_GATEWAY, events.AFTER_CREATE),
                mock.call(plugin.router_gateway_callback,
                          resources.ROUTER_GATEWAY, events.AFTER_DELETE),
                mock.call(plugin.port_callback,
                          resources.PORT, events.AFTER_UPDATE),
            ]
            self.assertEqual(subscribe.call_args_list, expected_calls) 
开发者ID:openstack,项目名称:neutron-dynamic-routing,代码行数:24,代码来源:test_bgp_plugin.py

示例3: test_unsubscribe_by_resource

# 需要导入模块: from neutron_lib.callbacks import events [as 别名]
# 或者: from neutron_lib.callbacks.events import BEFORE_CREATE [as 别名]
def test_unsubscribe_by_resource(self):
        self.manager.subscribe(
            callback_1, resources.PORT, events.BEFORE_CREATE)
        self.manager.subscribe(
            callback_1, resources.PORT, events.BEFORE_DELETE)
        self.manager.subscribe(
            callback_2, resources.PORT, events.BEFORE_DELETE)
        self.manager.unsubscribe_by_resource(callback_1, resources.PORT)
        self.assertEqual(
            0,
            len(self.manager._callbacks
                [resources.PORT][events.BEFORE_CREATE]))
        self.assertEqual(
            1,
            len(self.manager._callbacks[resources.PORT][events.BEFORE_DELETE]))
        self.assertIn(
            callback_id_2,
            self.manager._callbacks
            [resources.PORT][events.BEFORE_DELETE][0][1])
        self.assertNotIn(callback_id_1, self.manager._index) 
开发者ID:openstack,项目名称:neutron-lib,代码行数:22,代码来源:test_manager.py

示例4: test_decorated_inst_method_receives

# 需要导入模块: from neutron_lib.callbacks import events [as 别名]
# 或者: from neutron_lib.callbacks.events import BEFORE_CREATE [as 别名]
def test_decorated_inst_method_receives(self):
        i1 = ObjectWithDecoratedCallback()
        registry.notify(resources.PORT, events.BEFORE_CREATE, self)
        self.assertEqual(0, i1.counter)
        registry.notify(resources.PORT, events.AFTER_CREATE, self)
        self.assertEqual(1, i1.counter)
        registry.notify(resources.PORT, events.AFTER_UPDATE, self)
        self.assertEqual(2, i1.counter)
        registry.notify(resources.NETWORK, events.AFTER_UPDATE, self)
        self.assertEqual(2, i1.counter)
        registry.notify(resources.NETWORK, events.AFTER_DELETE, self)
        self.assertEqual(3, i1.counter)
        i2 = ObjectWithDecoratedCallback()
        self.assertEqual(0, i2.counter)
        registry.notify(resources.NETWORK, events.AFTER_DELETE, self)
        self.assertEqual(4, i1.counter)
        self.assertEqual(1, i2.counter) 
开发者ID:openstack,项目名称:neutron-lib,代码行数:19,代码来源:test_registry.py

示例5: test_schedule_bgp_speaker_callback_with_invalid_event

# 需要导入模块: from neutron_lib.callbacks import events [as 别名]
# 或者: from neutron_lib.callbacks.events import BEFORE_CREATE [as 别名]
def test_schedule_bgp_speaker_callback_with_invalid_event(self):
        payload = self._create_test_payload()
        with mock.patch.object(self.plugin,
                               'schedule_bgp_speaker') as sched_bgp:
            self.scheduler.schedule_bgp_speaker_callback(
                dr_resources.BGP_SPEAKER,
                events.BEFORE_CREATE,
                self.scheduler, payload)
            sched_bgp.assert_not_called() 
开发者ID:openstack,项目名称:neutron-dynamic-routing,代码行数:11,代码来源:test_bgp_dragent_scheduler.py

示例6: _call_before_port_binding

# 需要导入模块: from neutron_lib.callbacks import events [as 别名]
# 或者: from neutron_lib.callbacks.events import BEFORE_CREATE [as 别名]
def _call_before_port_binding(self, host):
        kwargs = {
            'context': mock.Mock(),
            'port': {
                portbindings.HOST_ID: host
            }
        }
        registry.notify(resources.PORT, events.BEFORE_CREATE, self.ml2_plugin,
                        **kwargs) 
开发者ID:openstack,项目名称:networking-odl,代码行数:11,代码来源:test_pseudo_agentdb_binding.py

示例7: before_port_binding

# 需要导入模块: from neutron_lib.callbacks import events [as 别名]
# 或者: from neutron_lib.callbacks.events import BEFORE_CREATE [as 别名]
def before_port_binding(self, resource, event, trigger, **kwargs):
        LOG.debug("before_port resource %s event %s %s",
                  resource, event, kwargs)
        assert resource == resources.PORT
        assert event in [events.BEFORE_CREATE, events.BEFORE_UPDATE]
        ml2_plugin = trigger
        context = kwargs['context']
        port = kwargs['port']

        host = nl_const.ATTR_NOT_SPECIFIED
        if port and portbindings.HOST_ID in port:
            host = port.get(portbindings.HOST_ID)
        if host == nl_const.ATTR_NOT_SPECIFIED or not host:
            return
        agent_type = PseudoAgentDBBindingWorker.L2_TYPE
        if self._worker.known_agent(host, agent_type):
            return
        agents = ml2_plugin.get_agents(
            context, filters={'agent_type': [agent_type], 'host': [host]})
        if agents and all(agent['alive'] for agent in agents):
            self._worker.add_known_agents(agents)
            LOG.debug("agents %s", agents)
            return

        # This host may not be created/updated by worker.
        # try to populate it.
        urlpath = "hostconfig/{0}/{1}".format(
            host, PseudoAgentDBBindingWorker.L2_TYPE)
        try:
            response = self.odl_rest_client.get(urlpath)
            response.raise_for_status()
        except Exception:
            LOG.warning("REST/GET odl hostconfig/%s failed.", host,
                        exc_info=True)
            return
        LOG.debug("response %s", response.json())
        hostconfig = response.json().get('hostconfig', [])
        if hostconfig:
            self._worker.update_agents_db_row(hostconfig[0]) 
开发者ID:openstack,项目名称:networking-odl,代码行数:41,代码来源:pseudo_agentdb_binding.py

示例8: test_subscribe

# 需要导入模块: from neutron_lib.callbacks import events [as 别名]
# 或者: from neutron_lib.callbacks.events import BEFORE_CREATE [as 别名]
def test_subscribe(self):
        self.manager.subscribe(
            callback_1, resources.PORT, events.BEFORE_CREATE)
        self.assertIsNotNone(
            self.manager._callbacks[resources.PORT][events.BEFORE_CREATE])
        self.assertIn(callback_id_1, self.manager._index)
        self.assertEqual(self.__module__ + '.callback_1-%s' %
                         hash(callback_1), callback_id_1) 
开发者ID:openstack,项目名称:neutron-lib,代码行数:10,代码来源:test_manager.py

示例9: test_subscribe_is_idempotent

# 需要导入模块: from neutron_lib.callbacks import events [as 别名]
# 或者: from neutron_lib.callbacks.events import BEFORE_CREATE [as 别名]
def test_subscribe_is_idempotent(self):
        self.manager.subscribe(
            callback_1, resources.PORT, events.BEFORE_CREATE)
        self.manager.subscribe(
            callback_1, resources.PORT, events.BEFORE_CREATE)
        self.assertEqual(
            1,
            len(self.manager._callbacks[resources.PORT][events.BEFORE_CREATE]))
        callbacks = self.manager._index[callback_id_1][resources.PORT]
        self.assertEqual(1, len(callbacks)) 
开发者ID:openstack,项目名称:neutron-lib,代码行数:12,代码来源:test_manager.py

示例10: test_subscribe_multiple_callbacks

# 需要导入模块: from neutron_lib.callbacks import events [as 别名]
# 或者: from neutron_lib.callbacks.events import BEFORE_CREATE [as 别名]
def test_subscribe_multiple_callbacks(self):
        self.manager.subscribe(
            callback_1, resources.PORT, events.BEFORE_CREATE)
        self.manager.subscribe(
            callback_2, resources.PORT, events.BEFORE_CREATE)
        self.assertEqual(2, len(self.manager._index))
        self.assertEqual(
            1,
            len(self.manager._callbacks[resources.PORT][events.BEFORE_CREATE]))
        self.assertEqual(
            2,
            len(self.manager._callbacks
                [resources.PORT][events.BEFORE_CREATE][0][1])) 
开发者ID:openstack,项目名称:neutron-lib,代码行数:15,代码来源:test_manager.py

示例11: test_unsubscribe_during_iteration

# 需要导入模块: from neutron_lib.callbacks import events [as 别名]
# 或者: from neutron_lib.callbacks.events import BEFORE_CREATE [as 别名]
def test_unsubscribe_during_iteration(self):
        def unsub(r, e, *a, **k):
            return self.manager.unsubscribe(unsub, r, e)

        self.manager.subscribe(unsub, resources.PORT,
                               events.BEFORE_CREATE)
        self.manager.notify(resources.PORT, events.BEFORE_CREATE, mock.ANY)
        self.assertNotIn(unsub, self.manager._index) 
开发者ID:openstack,项目名称:neutron-lib,代码行数:10,代码来源:test_manager.py

示例12: test_unsubscribe

# 需要导入模块: from neutron_lib.callbacks import events [as 别名]
# 或者: from neutron_lib.callbacks.events import BEFORE_CREATE [as 别名]
def test_unsubscribe(self):
        self.manager.subscribe(
            callback_1, resources.PORT, events.BEFORE_CREATE)
        self.manager.unsubscribe(
            callback_1, resources.PORT, events.BEFORE_CREATE)
        self.assertNotIn(
            callback_id_1,
            self.manager._callbacks[resources.PORT][events.BEFORE_CREATE])
        self.assertNotIn(callback_id_1, self.manager._index) 
开发者ID:openstack,项目名称:neutron-lib,代码行数:11,代码来源:test_manager.py

示例13: test_fail_to_unsubscribe

# 需要导入模块: from neutron_lib.callbacks import events [as 别名]
# 或者: from neutron_lib.callbacks.events import BEFORE_CREATE [as 别名]
def test_fail_to_unsubscribe(self):
        self.manager.subscribe(
            callback_1, resources.PORT, events.BEFORE_CREATE)
        self.assertRaises(exceptions.Invalid,
                          self.manager.unsubscribe,
                          callback_1, resources.PORT, None)
        self.assertRaises(exceptions.Invalid,
                          self.manager.unsubscribe,
                          callback_1, None, events.BEFORE_CREATE) 
开发者ID:openstack,项目名称:neutron-lib,代码行数:11,代码来源:test_manager.py

示例14: test_unsubscribe_is_idempotent

# 需要导入模块: from neutron_lib.callbacks import events [as 别名]
# 或者: from neutron_lib.callbacks.events import BEFORE_CREATE [as 别名]
def test_unsubscribe_is_idempotent(self):
        self.manager.subscribe(
            callback_1, resources.PORT, events.BEFORE_CREATE)
        self.manager.unsubscribe(
            callback_1, resources.PORT, events.BEFORE_CREATE)
        self.manager.unsubscribe(
            callback_1, resources.PORT, events.BEFORE_CREATE)
        self.assertNotIn(callback_id_1, self.manager._index)
        self.assertNotIn(callback_id_1,
                         self.manager._callbacks[resources.PORT]
                                                [events.BEFORE_CREATE]) 
开发者ID:openstack,项目名称:neutron-lib,代码行数:13,代码来源:test_manager.py

示例15: test_unsubscribe_all

# 需要导入模块: from neutron_lib.callbacks import events [as 别名]
# 或者: from neutron_lib.callbacks.events import BEFORE_CREATE [as 别名]
def test_unsubscribe_all(self):
        self.manager.subscribe(
            callback_1, resources.PORT, events.BEFORE_CREATE)
        self.manager.subscribe(
            callback_1, resources.PORT, events.BEFORE_DELETE)
        self.manager.subscribe(
            callback_1, resources.ROUTER, events.BEFORE_CREATE)
        self.manager.unsubscribe_all(callback_1)
        self.assertNotIn(
            callback_id_1,
            self.manager._callbacks[resources.PORT][events.BEFORE_CREATE])
        self.assertNotIn(callback_id_1, self.manager._index) 
开发者ID:openstack,项目名称:neutron-lib,代码行数:14,代码来源:test_manager.py


注:本文中的neutron_lib.callbacks.events.BEFORE_CREATE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。