Merge "Avoid l3_hamode_db when creating HA router"

This commit is contained in:
Jenkins 2016-03-18 21:02:24 +00:00 committed by Gerrit Code Review
commit 78afd004c6
1 changed files with 18 additions and 0 deletions

View File

@ -17,6 +17,9 @@
import re
import netaddr
from oslo_config import cfg
from neutron.api.v2 import attributes
from neutron.common import constants as neutron_constants
from neutron.db import l3_db
from neutron.db import models_v2
@ -131,6 +134,10 @@ class L3RouterPlugin(l3_router_plugin.L3RouterPlugin):
add_router_interface = l3_db.L3_NAT_db_mixin.add_router_interface
remove_router_interface = l3_db.L3_NAT_db_mixin.remove_router_interface
# call this directly instead of through class hierarchy, to avoid
# the l3_hamode_db from doing agent-based HA setup and checks
_create_router = l3_db.L3_NAT_dbonly_mixin.create_router
def list_routers_on_l3_agent(self, context, agent_id):
return {
'routers': self.get_routers(context),
@ -151,3 +158,14 @@ class L3RouterPlugin(l3_router_plugin.L3RouterPlugin):
active=True,
)
return []
@classmethod
def _is_ha(cls, router):
ha = router.get('ha')
if not attributes.is_attr_set(ha):
ha = cfg.CONF.l3_ha
return ha
def create_router(self, context, router):
router['router']['ha'] = self._is_ha(router['router'])
return self._create_router(context, router)