From: armando-migliaccio Date: Thu, 21 Aug 2014 01:04:33 +0000 (-0700) Subject: Do not use auto_schedule_routers to add router to agent X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=76f4d7db9f44022667d347dfe0474a3abb3b1bb7;p=openstack-build%2Fneutron-build.git Do not use auto_schedule_routers to add router to agent auto_schedule_routers makes a number of DB calls that are unnecessary as they are already made during the validation phase of add_router_to_l3_agent. Once the validation is done, the only business left is to create the binding: this is what this patch does. Partial-bug: #1356121 Change-Id: Ia9be998c2b94416bc46ef78415099f0099b08c2a --- diff --git a/neutron/db/l3_agentschedulers_db.py b/neutron/db/l3_agentschedulers_db.py index 1543779de..fc4ad2c9b 100644 --- a/neutron/db/l3_agentschedulers_db.py +++ b/neutron/db/l3_agentschedulers_db.py @@ -17,6 +17,7 @@ import random import time from oslo.config import cfg +from oslo.db import exception as db_exc import sqlalchemy as sa from sqlalchemy import func from sqlalchemy import orm @@ -181,10 +182,12 @@ class L3AgentSchedulerDbMixin(l3agentscheduler.L3AgentSchedulerPluginBase, """Create router to agent binding.""" router_id = router['id'] agent_id = agent['id'] - result = self.auto_schedule_routers(context, agent.host, [router_id]) - if not result: - raise l3agentscheduler.RouterSchedulingFailed( - router_id=router_id, agent_id=agent_id) + if self.router_scheduler: + try: + self.router_scheduler.bind_router(context, router_id, agent) + except db_exc.DBError: + raise l3agentscheduler.RouterSchedulingFailed( + router_id=router_id, agent_id=agent_id) def add_router_to_l3_agent(self, context, agent_id, router_id): """Add a l3 agent to host a router."""