]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Do not use auto_schedule_routers to add router to agent
authorarmando-migliaccio <armamig@gmail.com>
Thu, 21 Aug 2014 01:04:33 +0000 (18:04 -0700)
committerarmando-migliaccio <armamig@gmail.com>
Wed, 27 Aug 2014 15:58:38 +0000 (08:58 -0700)
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

neutron/db/l3_agentschedulers_db.py

index 1543779de03b27702f7dccc9d662fe185b7d2904..fc4ad2c9bb4c430336de404f07498b687fdced8f 100644 (file)
@@ -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."""