Example #1
0
 def test_schedule_router_distributed(self):
     scheduler = l3_agent_scheduler.ChanceScheduler()
     agent = agents_db.Agent()
     agent.admin_state_up = True
     agent.heartbeat_timestamp = timeutils.utcnow()
     sync_router = {'id': 'foo_router_id', 'distributed': True}
     plugin = mock.Mock()
     plugin.get_router.return_value = sync_router
     plugin.get_l3_agents_hosting_routers.return_value = []
     plugin.get_l3_agents.return_value = [agent]
     plugin.get_l3_agent_candidates.return_value = [agent]
     with mock.patch.object(scheduler, 'bind_router'):
         scheduler._schedule_router(plugin, self.adminContext,
                                    'foo_router_id', None,
                                    {'gw_exists': True})
     expected_calls = [
         mock.call.get_router(mock.ANY, 'foo_router_id'),
         mock.call.schedule_snat_router(mock.ANY, 'foo_router_id',
                                        sync_router, True),
         mock.call.get_l3_agents_hosting_routers(mock.ANY,
                                                 ['foo_router_id'],
                                                 admin_state_up=True),
         mock.call.get_l3_agents(mock.ANY, active=True),
         mock.call.get_l3_agent_candidates(mock.ANY, sync_router, [agent],
                                           None),
     ]
     plugin.assert_has_calls(expected_calls)
 def _bind_router(self, router_id):
     with self.admin_ctx.session.begin(subtransactions=True):
         scheduler = l3_agent_scheduler.ChanceScheduler()
         agents_db = self.plugin.get_agents_db(self.admin_ctx)
         scheduler._bind_ha_router_to_agents(
             self.plugin,
             self.admin_ctx,
             router_id,
             agents_db)
Example #3
0
    def _test_schedule_bind_router(self, agent, router):
        ctx = self.adminContext
        session = ctx.session
        db = l3_agentschedulers_db.RouterL3AgentBinding
        scheduler = l3_agent_scheduler.ChanceScheduler()

        rid = router['router']['id']
        scheduler.bind_router(ctx, rid, agent)
        results = (session.query(db).filter_by(router_id=rid).all())
        self.assertTrue(len(results) > 0)
        self.assertIn(agent.id, [bind.l3_agent_id for bind in results])
Example #4
0
    def setUp(self):
        super(L3HATestFramework, self).setUp()

        self.admin_ctx = context.get_admin_context()
        self.setup_coreplugin('neutron.plugins.ml2.plugin.Ml2Plugin')
        self.core_plugin = manager.NeutronManager.get_plugin()
        notif_p = mock.patch.object(l3_hamode_db.L3_HA_NAT_db_mixin,
                                    '_notify_ha_interfaces_updated')
        self.notif_m = notif_p.start()
        cfg.CONF.set_override('allow_overlapping_ips', True)

        self.plugin = FakeL3PluginWithAgents()
        self.plugin.router_scheduler = l3_agent_scheduler.ChanceScheduler()
        self.agent1 = helpers.register_l3_agent()
        self.agent2 = helpers.register_l3_agent(
            'host_2', constants.L3_AGENT_MODE_DVR_SNAT)
 def test_chance_auto_schedule_routers(self):
     self.scheduler = l3_agent_scheduler.ChanceScheduler()
     self._test_auto_schedule_routers()
 def setUp(self):
     super(L3ChanceSchedulerTestCase, self).setUp()
     self._create_legacy_agents(self.agent_count, self.down_agent_count)
     self.routers = self._create_routers(
         self.scheduled_router_count, self.expected_scheduled_router_count)
     self.scheduler = l3_agent_scheduler.ChanceScheduler()
Example #7
0
 def test_bind_absent_router(self):
     scheduler = l3_agent_scheduler.ChanceScheduler()
     # checking that bind_router() is not throwing
     # when supplied with router_id of non-existing router
     scheduler.bind_router(self.adminContext, "dummyID", self.agent1)