From: Kevin Benton Date: Thu, 24 Dec 2015 08:29:08 +0000 (-0800) Subject: Ensure agent binding modules are loaded X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=89f96e627fc1e402ca456d60127ccde5bd534415;p=openstack-build%2Fneutron-build.git Ensure agent binding modules are loaded This patch ensures that models_v2 and the router db module import the agent binding modules so their models are defined in the sqlalchemy metadata. Otherwise, using an agentless core/L3 plugin may result in a failure to initialize if nothing imported the agent module. Change-Id: I77240462b618d6e95c7c5862441d6d179e371f4f Closes-Bug: #1529022 --- diff --git a/neutron/db/l3_attrs_db.py b/neutron/db/l3_attrs_db.py index 2f1b79a6a..258f39d3f 100644 --- a/neutron/db/l3_attrs_db.py +++ b/neutron/db/l3_attrs_db.py @@ -16,7 +16,6 @@ import sqlalchemy as sa from sqlalchemy import orm from neutron.db import db_base_plugin_v2 -from neutron.db import l3_db from neutron.db import model_base from neutron.extensions import l3 @@ -48,7 +47,7 @@ class RouterExtraAttributes(model_base.BASEV2): availability_zone_hints = sa.Column(sa.String(255)) router = orm.relationship( - l3_db.Router, + 'Router', backref=orm.backref("extra_attributes", lazy='joined', uselist=False, cascade='delete')) diff --git a/neutron/db/l3_db.py b/neutron/db/l3_db.py index 5726a385c..c116da9b6 100644 --- a/neutron/db/l3_db.py +++ b/neutron/db/l3_db.py @@ -35,6 +35,7 @@ from neutron.common import exceptions as n_exc from neutron.common import ipv6_utils from neutron.common import rpc as n_rpc from neutron.common import utils +from neutron.db import l3_agentschedulers_db as l3_agt from neutron.db import model_base from neutron.db import models_v2 from neutron.extensions import external_net @@ -92,8 +93,9 @@ class Router(model_base.HasStandardAttributes, model_base.BASEV2, RouterPort, backref='router', lazy='dynamic') - l3_agents = orm.relationship('Agent', lazy='joined', viewonly=True, - secondary='routerl3agentbindings') + l3_agents = orm.relationship( + 'Agent', lazy='joined', viewonly=True, + secondary=l3_agt.RouterL3AgentBinding.__table__) class FloatingIP(model_base.HasStandardAttributes, model_base.BASEV2, diff --git a/neutron/db/models_v2.py b/neutron/db/models_v2.py index f4e75a5d2..03a3a82dc 100644 --- a/neutron/db/models_v2.py +++ b/neutron/db/models_v2.py @@ -18,6 +18,7 @@ from sqlalchemy import orm from neutron.api.v2 import attributes as attr from neutron.common import constants +from neutron.db import agentschedulers_db as agt from neutron.db import model_base from neutron.db import rbac_db_models @@ -267,5 +268,6 @@ class Network(model_base.HasStandardAttributes, model_base.BASEV2, backref='network', lazy='joined', cascade='all, delete, delete-orphan') availability_zone_hints = sa.Column(sa.String(255)) - dhcp_agents = orm.relationship('Agent', lazy='joined', viewonly=True, - secondary='networkdhcpagentbindings') + dhcp_agents = orm.relationship( + 'Agent', lazy='joined', viewonly=True, + secondary=agt.NetworkDhcpAgentBinding.__table__)