Use agent OVO for bgp_dragent_scheduler

Neutron agent scheduler has been switched to use Agent OVO[1].
So this patch uses agent OVO for bgp_dragent_scheduler.

[1] https://review.openstack.org/#/c/495810

Change-Id: I7e5da95ab3c28c00f3be9eca2c92a772492cfa69
Closes-Bug: #1732603
This commit is contained in:
Nguyen Phuong An 2017-11-16 16:31:23 +07:00
parent 972756f603
commit 39699184d8
1 changed files with 6 additions and 8 deletions

View File

@ -18,11 +18,11 @@ from neutron_lib.callbacks import registry
from neutron_lib import context as nl_context from neutron_lib import context as nl_context
from oslo_db import exception as db_exc from oslo_db import exception as db_exc
from oslo_log import log as logging from oslo_log import log as logging
from sqlalchemy.orm import exc
from sqlalchemy import sql from sqlalchemy import sql
from neutron.agent.common import utils from neutron.agent.common import utils
from neutron.db.models import agent as agent_model from neutron.db.models import agent as agent_model
from neutron.objects import agent as agent_object
from neutron.scheduler import base_resource_filter from neutron.scheduler import base_resource_filter
from neutron.scheduler import base_scheduler from neutron.scheduler import base_scheduler
@ -75,7 +75,7 @@ class BgpDrAgentFilter(base_resource_filter.BaseResourceFilter):
def _get_active_dragents(self, plugin, context): def _get_active_dragents(self, plugin, context):
"""Return a list of active BgpDrAgents.""" """Return a list of active BgpDrAgents."""
with context.session.begin(subtransactions=True): with context.session.begin(subtransactions=True):
active_dragents = plugin.get_agents_db( active_dragents = plugin.get_agent_objects(
context, filters={ context, filters={
'agent_type': [bgp_consts.AGENT_TYPE_BGP_ROUTING], 'agent_type': [bgp_consts.AGENT_TYPE_BGP_ROUTING],
'admin_state_up': [True]}) 'admin_state_up': [True]})
@ -148,14 +148,12 @@ class BgpDrAgentSchedulerBase(BgpDrAgentFilter):
LOG.debug('Started auto-scheduling on host %s', host) LOG.debug('Started auto-scheduling on host %s', host)
with context.session.begin(subtransactions=True): with context.session.begin(subtransactions=True):
query = context.session.query(agent_model.Agent) bgp_dragent = agent_object.Agent.get_object(
query = query.filter_by( context,
agent_type=bgp_consts.AGENT_TYPE_BGP_ROUTING, agent_type=bgp_consts.AGENT_TYPE_BGP_ROUTING,
host=host, host=host,
admin_state_up=sql.true()) admin_state_up=True)
try: if not bgp_dragent:
bgp_dragent = query.one()
except (exc.NoResultFound):
LOG.debug('No enabled BgpDrAgent on host %s', host) LOG.debug('No enabled BgpDrAgent on host %s', host)
return False return False