• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python helpers.register_l3_agent函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中neutron.tests.common.helpers.register_l3_agent函数的典型用法代码示例。如果您正苦于以下问题:Python register_l3_agent函数的具体用法?Python register_l3_agent怎么用?Python register_l3_agent使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: test_get_agent_by_host

 def test_get_agent_by_host(self):
     helpers.register_l3_agent()
     helpers.register_dhcp_agent()
     helpers.register_ovs_agent()
     agent = l2pop_db.get_agent_by_host(
         self.ctx.session, helpers.HOST)
     self.assertEqual(constants.AGENT_TYPE_OVS, agent.agent_type)
开发者ID:sebrandon1,项目名称:neutron,代码行数:7,代码来源:test_db.py


示例2: _register_agent_states

    def _register_agent_states(self, lbaas_agents=False):
        """Register two L3 agents and two DHCP agents."""
        l3_hosta = helpers._get_l3_agent_dict(
            L3_HOSTA, constants.L3_AGENT_MODE_LEGACY)
        l3_hostb = helpers._get_l3_agent_dict(
            L3_HOSTB, constants.L3_AGENT_MODE_LEGACY)
        dhcp_hosta = helpers._get_dhcp_agent_dict(DHCP_HOSTA)
        dhcp_hostc = helpers._get_dhcp_agent_dict(DHCP_HOSTC)
        helpers.register_l3_agent(host=L3_HOSTA)
        helpers.register_l3_agent(host=L3_HOSTB)
        helpers.register_dhcp_agent(host=DHCP_HOSTA)
        helpers.register_dhcp_agent(host=DHCP_HOSTC)

        res = [l3_hosta, l3_hostb, dhcp_hosta, dhcp_hostc]
        if lbaas_agents:
            lbaas_hosta = {
                'binary': 'neutron-loadbalancer-agent',
                'host': LBAAS_HOSTA,
                'topic': 'LOADBALANCER_AGENT',
                'configurations': {'device_drivers': ['haproxy_ns']},
                'agent_type': constants.AGENT_TYPE_LOADBALANCER}
            lbaas_hostb = copy.deepcopy(lbaas_hosta)
            lbaas_hostb['host'] = LBAAS_HOSTB
            callback = agents_db.AgentExtRpcCallback()
            callback.report_state(
                self.adminContext,
                agent_state={'agent_state': lbaas_hosta},
                time=datetime.utcnow().strftime(constants.ISO8601_TIME_FORMAT))
            callback.report_state(
                self.adminContext,
                agent_state={'agent_state': lbaas_hostb},
                time=datetime.utcnow().strftime(constants.ISO8601_TIME_FORMAT))
            res += [lbaas_hosta, lbaas_hostb]

        return res
开发者ID:openstack,项目名称:neutron,代码行数:35,代码来源:test_agent.py


示例3: setUp

    def setUp(self):
        ml2_config.cfg.CONF.set_override('mechanism_drivers',
                                         ['logger', 'fake_agent'],
                                         'ml2')

        super(TestBagpipeServiceDriverCallbacks, self).setUp(self._plugin_name)

        self.port_create_status = 'DOWN'
        self.plugin = manager.NeutronManager.get_plugin()
        self.plugin.start_rpc_listeners()

        self.bagpipe_driver = self.bgpvpn_plugin.driver

        self.patched_driver = mock.patch.object(
            self.bgpvpn_plugin.driver,
            '_retrieve_bgpvpn_network_info_for_port',
            return_value=BGPVPN_INFO)
        self.patched_driver.start()

        self.mock_attach_rpc = self.mocked_bagpipeAPI.attach_port_on_bgpvpn
        self.mock_detach_rpc = self.mocked_bagpipeAPI.detach_port_from_bgpvpn
        self.mock_update_bgpvpn_rpc = self.mocked_bagpipeAPI.update_bgpvpn
        self.mock_delete_bgpvpn_rpc = self.mocked_bagpipeAPI.delete_bgpvpn

        # we choose an agent of type const.AGENT_TYPE_OFA
        # because this is the type used by the fake_agent mech driver
        helpers.register_ovs_agent(helpers.HOST, const.AGENT_TYPE_OFA)
        helpers.register_l3_agent()
开发者ID:rasta-rocket,项目名称:networking-bgpvpn,代码行数:28,代码来源:test_bagpipe.py


示例4: test_get_agent_by_host_no_candidate

 def test_get_agent_by_host_no_candidate(self):
     # Register a bunch of non-L2 agents on the same host
     helpers.register_l3_agent()
     helpers.register_dhcp_agent()
     agent = self.db_mixin.get_agent_by_host(
         self.ctx.session, helpers.HOST)
     self.assertIsNone(agent)
开发者ID:abhilabh,项目名称:neutron,代码行数:7,代码来源:test_db.py


示例5: test_remove_router_interface

    def test_remove_router_interface(self):
        HOST1 = 'host1'
        helpers.register_l3_agent(
            host=HOST1, agent_mode=constants.L3_AGENT_MODE_DVR)
        router = self._create_router()
        arg_list = (portbindings.HOST_ID,)
        with self.subnet() as subnet,\
                self.port(subnet=subnet,
                          device_owner=DEVICE_OWNER_COMPUTE,
                          arg_list=arg_list,
                          **{portbindings.HOST_ID: HOST1}):
            l3_notifier = mock.Mock()
            self.l3_plugin.l3_rpc_notifier = l3_notifier
            self.l3_plugin.agent_notifiers[
                    constants.AGENT_TYPE_L3] = l3_notifier

            self.l3_plugin.add_router_interface(
                self.context, router['id'],
                {'subnet_id': subnet['subnet']['id']})
            self.l3_plugin.schedule_router(self.context, router['id'])

            self.l3_plugin.remove_router_interface(
                self.context, router['id'],
                {'subnet_id': subnet['subnet']['id']})

            l3_notifier.router_removed_from_agent.assert_called_once_with(
                self.context, router['id'], HOST1)
开发者ID:shooteras,项目名称:neutron,代码行数:27,代码来源:test_l3_dvr_router_plugin.py


示例6: _test_router_remove_from_agent_on_vm_port_deletion

    def _test_router_remove_from_agent_on_vm_port_deletion(
            self, non_admin_port=False):
        # register l3 agent in dvr mode in addition to existing dvr_snat agent
        HOST = 'host1'
        non_admin_tenant = 'tenant1'
        helpers.register_l3_agent(
            host=HOST, agent_mode=constants.L3_AGENT_MODE_DVR)
        router = self._create_router()
        with self.network(shared=True) as net,\
                self.subnet(network=net) as subnet,\
                self.port(subnet=subnet,
                          device_owner=DEVICE_OWNER_COMPUTE,
                          tenant_id=non_admin_tenant,
                          set_context=non_admin_port) as port:
            self.core_plugin.update_port(
                    self.context, port['port']['id'],
                    {'port': {portbindings.HOST_ID: HOST}})
            self.l3_plugin.add_router_interface(
                self.context, router['id'],
                {'subnet_id': subnet['subnet']['id']})

            with mock.patch.object(self.l3_plugin.l3_rpc_notifier,
                                   'router_removed_from_agent') as remove_mock:
                ctx = context.Context(
                    '', non_admin_tenant) if non_admin_port else self.context
                self._delete('ports', port['port']['id'], neutron_context=ctx)
                remove_mock.assert_called_once_with(
                    mock.ANY, router['id'], HOST)
开发者ID:shooteras,项目名称:neutron,代码行数:28,代码来源:test_l3_dvr_router_plugin.py


示例7: _test_update_floating_ip_agent_notification

    def _test_update_floating_ip_agent_notification(self, dvr=True):
        with self.subnet() as ext_subnet, self.subnet(cidr="20.0.0.0/24") as int_subnet1, self.subnet(
            cidr="30.0.0.0/24"
        ) as int_subnet2, self.port(subnet=int_subnet1, device_owner=DEVICE_OWNER_COMPUTE) as int_port1, self.port(
            subnet=int_subnet2, device_owner=DEVICE_OWNER_COMPUTE
        ) as int_port2:
            # locate internal ports on different hosts
            self.core_plugin.update_port(
                self.context, int_port1["port"]["id"], {"port": {portbindings.HOST_ID: "host1"}}
            )
            self.core_plugin.update_port(
                self.context, int_port2["port"]["id"], {"port": {portbindings.HOST_ID: "host2"}}
            )
            # and create l3 agents on corresponding hosts
            helpers.register_l3_agent(host="host1", agent_mode=constants.L3_AGENT_MODE_DVR)
            helpers.register_l3_agent(host="host2", agent_mode=constants.L3_AGENT_MODE_DVR)

            # make net external
            ext_net_id = ext_subnet["subnet"]["network_id"]
            self._update("networks", ext_net_id, {"network": {external_net.EXTERNAL: True}})

            router1 = self._create_router(distributed=dvr)
            router2 = self._create_router(distributed=dvr)
            for router in (router1, router2):
                self.l3_plugin.update_router(
                    self.context, router["id"], {"router": {"external_gateway_info": {"network_id": ext_net_id}}}
                )
            self.l3_plugin.add_router_interface(self.context, router1["id"], {"subnet_id": int_subnet1["subnet"]["id"]})
            self.l3_plugin.add_router_interface(self.context, router2["id"], {"subnet_id": int_subnet2["subnet"]["id"]})

            floating_ip = {
                "floating_network_id": ext_net_id,
                "router_id": router1["id"],
                "port_id": int_port1["port"]["id"],
                "tenant_id": int_port1["port"]["tenant_id"],
                "dns_name": "",
                "dns_domain": "",
            }
            floating_ip = self.l3_plugin.create_floatingip(self.context, {"floatingip": floating_ip})

            with mock.patch.object(self.l3_plugin, "_l3_rpc_notifier") as l3_notif:
                updated_floating_ip = {"router_id": router2["id"], "port_id": int_port2["port"]["id"]}
                self.l3_plugin.update_floatingip(self.context, floating_ip["id"], {"floatingip": updated_floating_ip})
                if dvr:
                    self.assertEqual(2, l3_notif.routers_updated_on_host.call_count)
                    expected_calls = [
                        mock.call(self.context, [router1["id"]], "host1"),
                        mock.call(self.context, [router2["id"]], "host2"),
                    ]
                    l3_notif.routers_updated_on_host.assert_has_calls(expected_calls)
                    self.assertFalse(l3_notif.routers_updated.called)
                else:
                    self.assertEqual(2, l3_notif.routers_updated.call_count)
                    expected_calls = [
                        mock.call(self.context, [router1["id"]], None),
                        mock.call(self.context, [router2["id"]], None),
                    ]
                    l3_notif.routers_updated.assert_has_calls(expected_calls)
                    self.assertFalse(l3_notif.routers_updated_on_host.called)
开发者ID:manjeetbhatia,项目名称:test_l3,代码行数:59,代码来源:test_l3_dvr_router_plugin.py


示例8: test_get_nondistributed_active_network_ports_no_candidate

 def test_get_nondistributed_active_network_ports_no_candidate(self):
     self._setup_port_binding(dvr=False)
     # Register a bunch of non-L2 agents on the same host
     helpers.register_l3_agent()
     helpers.register_dhcp_agent()
     fdb_network_ports = l2pop_db.get_nondistributed_active_network_ports(
         self.ctx.session, TEST_NETWORK_ID)
     self.assertEqual(0, len(fdb_network_ports))
开发者ID:sebrandon1,项目名称:neutron,代码行数:8,代码来源:test_db.py


示例9: test_get_dvr_active_network_ports_no_candidate

 def test_get_dvr_active_network_ports_no_candidate(self):
     self._setup_port_binding()
     # Register a bunch of non-L2 agents on the same host
     helpers.register_l3_agent()
     helpers.register_dhcp_agent()
     tunnel_network_ports = self.db_mixin.get_dvr_active_network_ports(
         self.ctx.session, 'network_id')
     self.assertEqual(0, len(tunnel_network_ports))
开发者ID:abhilabh,项目名称:neutron,代码行数:8,代码来源:test_db.py


示例10: test_get_agent_by_host

 def test_get_agent_by_host(self):
     # Register a L2 agent + A bunch of other agents on the same host
     helpers.register_l3_agent()
     helpers.register_dhcp_agent()
     helpers.register_ovs_agent()
     agent = self.db_mixin.get_agent_by_host(
         self.ctx.session, helpers.HOST)
     self.assertEqual(constants.AGENT_TYPE_OVS, agent.agent_type)
开发者ID:abhilabh,项目名称:neutron,代码行数:8,代码来源:test_db.py


示例11: test_get_distributed_active_network_ports_no_candidate

 def test_get_distributed_active_network_ports_no_candidate(self):
     self._setup_port_binding(
         device_owner=constants.DEVICE_OWNER_DVR_INTERFACE)
     # Register a bunch of non-L2 agents on the same host
     helpers.register_l3_agent()
     helpers.register_dhcp_agent()
     tunnel_network_ports = l2pop_db.get_distributed_active_network_ports(
         self.ctx.session, TEST_NETWORK_ID)
     self.assertEqual(0, len(tunnel_network_ports))
开发者ID:sebrandon1,项目名称:neutron,代码行数:9,代码来源:test_db.py


示例12: test_get_nondvr_active_network_ports

 def test_get_nondvr_active_network_ports(self):
     self._setup_port_binding(dvr=False)
     # Register a L2 agent + A bunch of other agents on the same host
     helpers.register_l3_agent()
     helpers.register_dhcp_agent()
     helpers.register_ovs_agent()
     fdb_network_ports = self.db_mixin.get_nondvr_active_network_ports(
         self.ctx.session, 'network_id')
     self.assertEqual(1, len(fdb_network_ports))
     _, agent = fdb_network_ports[0]
     self.assertEqual(constants.AGENT_TYPE_OVS, agent.agent_type)
开发者ID:abhilabh,项目名称:neutron,代码行数:11,代码来源:test_db.py


示例13: test_get_dvr_active_network_ports

 def test_get_dvr_active_network_ports(self):
     self._setup_port_binding()
     # Register a L2 agent + A bunch of other agents on the same host
     helpers.register_l3_agent()
     helpers.register_dhcp_agent()
     helpers.register_ovs_agent()
     tunnel_network_ports = l2pop_db.get_dvr_active_network_ports(
         self.ctx.session, 'network_id')
     self.assertEqual(1, len(tunnel_network_ports))
     _, agent = tunnel_network_ports[0]
     self.assertEqual(constants.AGENT_TYPE_OVS, agent.agent_type)
开发者ID:21atlas,项目名称:neutron,代码行数:11,代码来源:test_db.py


示例14: test__get_ha_router_interface_ids_with_ha_replicated_port

 def test__get_ha_router_interface_ids_with_ha_replicated_port(self):
     helpers.register_dhcp_agent()
     helpers.register_l3_agent()
     helpers.register_ovs_agent()
     self._create_ha_router()
     self._setup_port_binding(
         device_owner=constants.DEVICE_OWNER_HA_REPLICATED_INT,
         device_id=TEST_ROUTER_ID)
     ha_iface_ids = l2pop_db._get_ha_router_interface_ids(
         self.ctx.session, TEST_NETWORK_ID)
     self.assertEqual(1, len(list(ha_iface_ids)))
开发者ID:sebrandon1,项目名称:neutron,代码行数:11,代码来源:test_db.py


示例15: test_get_nondistributed_active_network_ports

 def test_get_nondistributed_active_network_ports(self):
     self._setup_port_binding(dvr=False)
     # Register a L2 agent + A bunch of other agents on the same host
     helpers.register_l3_agent()
     helpers.register_dhcp_agent()
     helpers.register_ovs_agent()
     fdb_network_ports = l2pop_db.get_nondistributed_active_network_ports(
         self.ctx.session, TEST_NETWORK_ID)
     self.assertEqual(1, len(fdb_network_ports))
     _, agent = fdb_network_ports[0]
     self.assertEqual(constants.AGENT_TYPE_OVS, agent.agent_type)
开发者ID:sebrandon1,项目名称:neutron,代码行数:11,代码来源:test_db.py


示例16: test_update_vm_port_host_router_update

    def test_update_vm_port_host_router_update(self):
        # register l3 agents in dvr mode in addition to existing dvr_snat agent
        HOST1 = 'host1'
        dvr_agent1 = helpers.register_l3_agent(
            host=HOST1, agent_mode=constants.L3_AGENT_MODE_DVR)
        HOST2 = 'host2'
        dvr_agent2 = helpers.register_l3_agent(
            host=HOST2, agent_mode=constants.L3_AGENT_MODE_DVR)
        router = self._create_router()
        with self.subnet() as subnet:
            self.l3_plugin.add_router_interface(
                self.context, router['id'],
                {'subnet_id': subnet['subnet']['id']})

            # since there are no vm ports on HOST, and the router
            # has no external gateway at this point the router
            # should neither be scheduled to dvr nor to dvr_snat agents
            agents = self.l3_plugin.list_l3_agents_hosting_router(
                self.context, router['id'])['agents']
            self.assertEqual(0, len(agents))
            with mock.patch.object(self.l3_plugin,
                                   '_l3_rpc_notifier') as l3_notifier,\
                    self.port(subnet=subnet,
                              device_owner=DEVICE_OWNER_COMPUTE) as port:
                self.l3_plugin.agent_notifiers[
                    constants.AGENT_TYPE_L3] = l3_notifier
                self.core_plugin.update_port(
                    self.context, port['port']['id'],
                    {'port': {portbindings.HOST_ID: HOST1}})

                # now router should be scheduled to agent on HOST1
                agents = self.l3_plugin.list_l3_agents_hosting_router(
                    self.context, router['id'])['agents']
                self.assertEqual(1, len(agents))
                self.assertEqual(dvr_agent1['id'], agents[0]['id'])
                # and notification should only be sent to the agent on HOST1
                l3_notifier.routers_updated_on_host.assert_called_once_with(
                    self.context, {router['id']}, HOST1)
                self.assertFalse(l3_notifier.routers_updated.called)

                # updating port's host (instance migration)
                l3_notifier.reset_mock()
                self.core_plugin.update_port(
                    self.context, port['port']['id'],
                    {'port': {portbindings.HOST_ID: HOST2}})
                # now router should only be scheduled to dvr agent on host2
                agents = self.l3_plugin.list_l3_agents_hosting_router(
                    self.context, router['id'])['agents']
                self.assertEqual(1, len(agents))
                self.assertEqual(dvr_agent2['id'], agents[0]['id'])
                l3_notifier.routers_updated_on_host.assert_called_once_with(
                    self.context, {router['id']}, HOST2)
                l3_notifier.router_removed_from_agent.assert_called_once_with(
                    mock.ANY, router['id'], HOST1)
开发者ID:siriusxh,项目名称:neutron,代码行数:54,代码来源:test_l3_dvr_router_plugin.py


示例17: test_include_dvr_snat_agents_for_ha_candidates

 def test_include_dvr_snat_agents_for_ha_candidates(self):
     """Test dvr agents configured with "dvr_snat" are excluded.
     This test case tests that when get_number_of_agents_for_scheduling
     is called, it ounts dvr_snat agents.
     """
     # Test setup registers two l3 agents.
     # Register another l3 agent with dvr mode and assert that
     # get_number_of_ha_agent_candidates return 2.
     helpers.register_l3_agent("host_3", constants.L3_AGENT_MODE_DVR_SNAT)
     num_ha_candidates = self.plugin.get_number_of_agents_for_scheduling(self.admin_ctx)
     self.assertEqual(3, num_ha_candidates)
开发者ID:FedericoRessi,项目名称:neutron,代码行数:11,代码来源:test_l3_hamode_db.py


示例18: test_get_distributed_active_network_ports

 def test_get_distributed_active_network_ports(self):
     self._setup_port_binding(
         device_owner=constants.DEVICE_OWNER_DVR_INTERFACE)
     # Register a L2 agent + A bunch of other agents on the same host
     helpers.register_l3_agent()
     helpers.register_dhcp_agent()
     helpers.register_ovs_agent()
     tunnel_network_ports = l2pop_db.get_distributed_active_network_ports(
         self.ctx.session, TEST_NETWORK_ID)
     self.assertEqual(1, len(tunnel_network_ports))
     _, agent = tunnel_network_ports[0]
     self.assertEqual(constants.AGENT_TYPE_OVS, agent.agent_type)
开发者ID:sebrandon1,项目名称:neutron,代码行数:12,代码来源:test_db.py


示例19: test_get_ha_agents_by_router_id

 def test_get_ha_agents_by_router_id(self):
     helpers.register_dhcp_agent()
     helpers.register_l3_agent()
     helpers.register_ovs_agent()
     self._create_ha_router()
     self._setup_port_binding(
         device_owner=constants.DEVICE_OWNER_ROUTER_SNAT,
         device_id=TEST_ROUTER_ID)
     agents = l2pop_db.get_ha_agents_by_router_id(
         self.ctx.session, TEST_ROUTER_ID)
     ha_agents = [agent.host for agent in agents]
     self.assertEqual(tools.UnorderedList([HOST, HOST_2]), ha_agents)
开发者ID:sebrandon1,项目名称:neutron,代码行数:12,代码来源:test_db.py


示例20: test_exclude_dvr_agents_for_ha_candidates

 def test_exclude_dvr_agents_for_ha_candidates(self):
     """Test dvr agents configured with "dvr" only, as opposed to "dvr_snat",
     are excluded.
     This test case tests that when get_number_of_agents_for_scheduling
     is called, it does not count dvr only agents.
     """
     # Test setup registers two l3 agents.
     # Register another l3 agent with dvr mode and assert that
     # get_number_of_ha_agent_candidates return 2.
     helpers.register_l3_agent('host_3', constants.L3_AGENT_MODE_DVR)
     num_ha_candidates = self.plugin.get_number_of_agents_for_scheduling(
         self.admin_ctx)
     self.assertEqual(2, num_ha_candidates)
开发者ID:hyxc,项目名称:neutron,代码行数:13,代码来源:test_l3_hamode_db.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python helpers.register_ovs_agent函数代码示例发布时间:2022-05-27
下一篇:
Python helpers.register_dhcp_agent函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap