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

Python db.update_segment_host_mapping函数代码示例

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

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



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

示例1: test_auto_schedule_one_network_two_segments_with_one_subnet_each

    def test_auto_schedule_one_network_two_segments_with_one_subnet_each(self):
        net_id = self._create_network()
        seg1_id = self._create_segment(net_id)
        self._create_subnet(seg1_id, net_id)
        helpers.register_dhcp_agent(HOST_D)
        segments_service_db.update_segment_host_mapping(
            self.ctx, HOST_D, {seg1_id})
        scheduler = dhcp_agent_scheduler.ChanceScheduler()
        observed_val_first_segment = scheduler.auto_schedule_networks(
            self.plugin, self.ctx, HOST_D)
        self.assertTrue(observed_val_first_segment)
        agents = self.plugin.get_dhcp_agents_hosting_networks(
            self.ctx, [net_id])
        self.assertEqual(1, len(agents))

        seg2_id = self._create_segment(net_id)
        self._create_subnet(seg2_id, net_id, '192.168.11.0/24')
        helpers.register_dhcp_agent(HOST_C)
        segments_service_db.update_segment_host_mapping(
            self.ctx, HOST_C, {seg2_id})
        observed_val_second_segment = scheduler.auto_schedule_networks(
            self.plugin, self.ctx, HOST_C)
        self.assertTrue(observed_val_second_segment)
        agents = self.plugin.get_dhcp_agents_hosting_networks(
            self.ctx, [net_id])
        self.assertEqual(2, len(agents))
开发者ID:AradhanaSingh,项目名称:neutron,代码行数:26,代码来源:test_dhcp_agent_scheduler.py


示例2: update_segment_host_mapping

    def update_segment_host_mapping(self, host, phy_nets):
        """Update SegmentHostMapping in DB"""
        if not host:
            return

        ctx = n_context.get_admin_context()
        segments = segment_service_db.get_segments_with_phys_nets(ctx, phy_nets)

        available_seg_ids = {segment["id"] for segment in segments if segment["network_type"] in ("flat", "vlan")}

        segment_service_db.update_segment_host_mapping(ctx, host, available_seg_ids)
开发者ID:hzhou8,项目名称:networking-ovn,代码行数:11,代码来源:mech_driver.py


示例3: test_schedule_segment_one_hostable_agent

 def test_schedule_segment_one_hostable_agent(self):
     net_id = self._create_network()
     seg_id = self._create_segment(net_id)
     helpers.register_dhcp_agent(HOST_C)
     helpers.register_dhcp_agent(HOST_D)
     segments_service_db.update_segment_host_mapping(
         self.ctx, HOST_C, {seg_id})
     net = self._get_network_with_candidate_hosts(net_id, seg_id)
     agents = self.plugin.network_scheduler.schedule(
         self.plugin, self.ctx, net)
     self.assertEqual(1, len(agents))
     self.assertEqual(HOST_C, agents[0].host)
开发者ID:AradhanaSingh,项目名称:neutron,代码行数:12,代码来源:test_dhcp_agent_scheduler.py


示例4: test_ovn_sb_sync_update_existing_host

 def test_ovn_sb_sync_update_existing_host(self):
     with self.network() as network:
         network_id = network['network']['id']
     segment = self.create_segment(network_id, 'physnet1', 50)
     segments_db.update_segment_host_mapping(
         self.ctx, 'host1', {segment['id']})
     segment_hosts = segments_db.get_hosts_mapped_with_segments(self.ctx)
     self.assertEqual({'host1'}, segment_hosts)
     self.add_fake_chassis('host1', ['physnet2'])
     self._sync_resources()
     segment_hosts = segments_db.get_hosts_mapped_with_segments(self.ctx)
     self.assertFalse(segment_hosts)
开发者ID:muraliran,项目名称:networking-ovn,代码行数:12,代码来源:test_ovn_db_sync.py


示例5: test_ovn_sb_sync_delete_stale_host

 def test_ovn_sb_sync_delete_stale_host(self):
     with self.network() as network:
         network_id = network['network']['id']
     segment = self.create_segment(network_id, 'physnet1', 50)
     segments_db.update_segment_host_mapping(
         self.ctx, 'host1', {segment['id']})
     segment_hosts = segments_db.get_hosts_mapped_with_segments(self.ctx)
     self.assertEqual({'host1'}, segment_hosts)
     # Since there is no chassis in the sb DB, host1 is the stale host
     # recorded in neutron DB. It should be deleted after sync.
     self._sync_resources()
     segment_hosts = segments_db.get_hosts_mapped_with_segments(self.ctx)
     self.assertFalse(segment_hosts)
开发者ID:muraliran,项目名称:networking-ovn,代码行数:13,代码来源:test_ovn_db_sync.py


示例6: test_auto_schedule_one_network_one_segment_one_subnet

 def test_auto_schedule_one_network_one_segment_one_subnet(self):
     net_id = self._create_network()
     seg_id = self._create_segment(net_id)
     self._create_subnet(seg_id, net_id)
     helpers.register_dhcp_agent(HOST_C)
     segments_service_db.update_segment_host_mapping(
         self.ctx, HOST_C, {seg_id})
     scheduler = dhcp_agent_scheduler.ChanceScheduler()
     observed_return_val = scheduler.auto_schedule_networks(
         self.plugin, self.ctx, HOST_C)
     self.assertTrue(observed_return_val)
     agent1 = self.plugin.get_dhcp_agents_hosting_networks(
         self.ctx, [net_id])
     self.assertEqual(1, len(agent1))
     self.assertEqual('host-c', agent1[0]['host'])
开发者ID:AradhanaSingh,项目名称:neutron,代码行数:15,代码来源:test_dhcp_agent_scheduler.py


示例7: test_schedule_segment_two_agents_per_segment_one_hostable_agent

 def test_schedule_segment_two_agents_per_segment_one_hostable_agent(self):
     cfg.CONF.set_override('dhcp_agents_per_network', 2)
     net_id = self._create_network()
     seg_id = self._create_segment(net_id)
     helpers.register_dhcp_agent(HOST_C)
     helpers.register_dhcp_agent(HOST_D)
     segments_service_db.update_segment_host_mapping(
         self.ctx, HOST_C, {seg_id})
     net = self.plugin.get_network(self.ctx, net_id)
     seg = self.segments_plugin.get_segment(self.ctx, seg_id)
     net['candidate_hosts'] = seg['hosts']
     agents = self.plugin.network_scheduler.schedule(
         self.plugin, self.ctx, net)
     self.assertEqual(1, len(agents))
     self.assertEqual(HOST_C, agents[0].host)
开发者ID:annp,项目名称:neutron,代码行数:15,代码来源:test_dhcp_agent_scheduler.py


示例8: test_schedule_segment_two_agents_per_segment

 def test_schedule_segment_two_agents_per_segment(self):
     cfg.CONF.set_override('dhcp_agents_per_network', 2)
     net_id = self._create_network()
     seg_id = self._create_segment(net_id)
     helpers.register_dhcp_agent(HOST_C)
     helpers.register_dhcp_agent(HOST_D)
     segments_service_db.update_segment_host_mapping(
         self.ctx, HOST_C, {seg_id})
     segments_service_db.update_segment_host_mapping(
         self.ctx, HOST_D, {seg_id})
     net = self._get_network_with_candidate_hosts(net_id, seg_id)
     agents = self.plugin.network_scheduler.schedule(
         self.plugin, self.ctx, net)
     self.assertEqual(2, len(agents))
     self.assertIn(agents[0].host, [HOST_C, HOST_D])
     self.assertIn(agents[1].host, [HOST_C, HOST_D])
开发者ID:AradhanaSingh,项目名称:neutron,代码行数:16,代码来源:test_dhcp_agent_scheduler.py


示例9: test_schedule_segment_many_hostable_agents

 def test_schedule_segment_many_hostable_agents(self):
     net_id = self._create_network()
     seg_id = self._create_segment(net_id)
     helpers.register_dhcp_agent(HOST_C)
     helpers.register_dhcp_agent(HOST_D)
     segments_service_db.update_segment_host_mapping(
         self.ctx, HOST_C, {seg_id})
     segments_service_db.update_segment_host_mapping(
         self.ctx, HOST_D, {seg_id})
     net = self.plugin.get_network(self.ctx, net_id)
     seg = self.segments_plugin.get_segment(self.ctx, seg_id)
     net['candidate_hosts'] = seg['hosts']
     agents = self.plugin.network_scheduler.schedule(
         self.plugin, self.ctx, net)
     self.assertEqual(1, len(agents))
     self.assertIn(agents[0].host, [HOST_C, HOST_D])
开发者ID:annp,项目名称:neutron,代码行数:16,代码来源:test_dhcp_agent_scheduler.py


示例10: test_update_segment_host_mapping

 def test_update_segment_host_mapping(self):
     ctx = context.get_admin_context()
     host = 'host1'
     physnets = ['phys_net1']
     with self.network() as network:
         network = network['network']
     segment = self._test_create_segment(
         network_id=network['id'], physical_network='phys_net1',
         segmentation_id=200, network_type=p_constants.TYPE_VLAN)['segment']
     self._test_create_segment(
         network_id=network['id'], physical_network='phys_net2',
         segmentation_id=201, network_type=p_constants.TYPE_VLAN)['segment']
     segments = db.get_segments_with_phys_nets(ctx, physnets)
     segment_ids = {segment['id'] for segment in segments}
     db.update_segment_host_mapping(ctx, host, segment_ids)
     segments_host_db = self._get_segments_for_host(host)
     self.assertEqual(1, len(segments_host_db))
     self.assertEqual(segment['id'],
                      segments_host_db[segment['id']]['segment_id'])
     self.assertEqual(host, segments_host_db[segment['id']]['host'])
开发者ID:landpack,项目名称:neutron,代码行数:20,代码来源:test_segment.py


示例11: test_ovn_sb_sync

 def test_ovn_sb_sync(self):
     with self.network() as network:
         network_id = network['network']['id']
     seg1 = self.create_segment(network_id, 'physnet1', 50)
     self.create_segment(network_id, 'physnet2', 51)
     segments_db.update_segment_host_mapping(
         self.ctx, 'host1', {seg1['id']})
     segments_db.update_segment_host_mapping(
         self.ctx, 'host2', {seg1['id']})
     segments_db.update_segment_host_mapping(
         self.ctx, 'host3', {seg1['id']})
     segment_hosts = segments_db.get_hosts_mapped_with_segments(self.ctx)
     self.assertEqual({'host1', 'host2', 'host3'}, segment_hosts)
     self.add_fake_chassis('host2', ['physnet2'])
     self.add_fake_chassis('host3', ['physnet3'])
     self.add_fake_chassis('host4', ['physnet1'])
     self._sync_resources()
     segment_hosts = segments_db.get_hosts_mapped_with_segments(self.ctx)
     # host1 should be cleared since it is not in the chassis DB. host3
     # should be cleared since there is no segment for mapping.
     self.assertEqual({'host2', 'host4'}, segment_hosts)
开发者ID:muraliran,项目名称:networking-ovn,代码行数:21,代码来源:test_ovn_db_sync.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python base._run函数代码示例发布时间:2022-05-27
下一篇:
Python provider_configuration.parse_service_provider_opt函数代码示例发布时间: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