Switch to new engine facade in neutron/db/agents_db.py

This patch changed the old engine facade to new engine
fade in neutron/db/agents_db.py.

Partially-Implements blueprint: enginefacade-switch

Change-Id: Iee6fbee98fae41d75b4e8eb0fbcf2283da545023
This commit is contained in:
lujin 2018-10-17 16:08:59 -07:00
parent 5f36615700
commit 4ba87b06d7
1 changed files with 2 additions and 2 deletions

View File

@ -273,7 +273,7 @@ class AgentDbMixin(ext_agent.AgentPluginBase, AgentAvailabilityZoneMixin):
@db_api.retry_if_session_inactive()
def update_agent(self, context, id, agent):
agent_data = agent['agent']
with context.session.begin(subtransactions=True):
with db_api.CONTEXT_WRITER.using(context):
agent = self._get_agent(context, id)
agent.update_fields(agent_data)
agent.update()
@ -374,7 +374,7 @@ class AgentDbMixin(ext_agent.AgentPluginBase, AgentAvailabilityZoneMixin):
It could be used by agent to do some sync with the server if needed.
"""
status = agent_consts.AGENT_ALIVE
with context.session.begin(subtransactions=True):
with db_api.CONTEXT_WRITER.using(context):
res_keys = ['agent_type', 'binary', 'host', 'topic']
res = dict((k, agent_state[k]) for k in res_keys)
if 'availability_zone' in agent_state: