Commit d7c854a9 authored by David Johnson's avatar David Johnson

Use DB filters appropriate in agent lookup paths.

parent b8f68588
Pipeline #1891 passed with stage
in 2 seconds
......@@ -53,9 +53,10 @@ class CapnetDBMixin(agents_db.AgentDbMixin):
if not hasattr(self.__plugin,'get_agents'):
raise n_exc.NeutronException("current Neutron plugin doesn't support"
" agents; Capnet requires agents!")
# XXX: this filter doesn't work at all!?
afilters = { 'agent_type' : cn_const.AGENT_TYPE_CAPNET } #,alive=[True])
agents = self.__plugin.get_agents(context,filters=None)
afilters = { 'agent_type' : [cn_const.AGENT_TYPE_CAPNET],
'admin_state_up' : [True],
'alive': [True] }
agents = self.__plugin.get_agents(context,filters=afilters)
# XXX: for now, just find the agent that is both the controller
# host and workflow app host:
......@@ -63,9 +64,7 @@ class CapnetDBMixin(agents_db.AgentDbMixin):
for agent in agents:
conf = agent['configurations']
LOG.debug("considering agent: %s///%s" % (str(agent),str(conf)))
if agent['agent_type'] == cn_const.AGENT_TYPE_CAPNET \
and agent['alive'] \
and 'hosts_controllers' in conf and conf['hosts_controllers'] \
if 'hosts_controllers' in conf and conf['hosts_controllers'] \
and 'hosts_workflow_apps' in conf and conf['hosts_workflow_apps']:
ret = agent
break
......@@ -84,9 +83,10 @@ class CapnetDBMixin(agents_db.AgentDbMixin):
if not hasattr(self.__plugin,'get_agents'):
raise n_exc.NeutronException("current Neutron plugin doesn't support"
" agents; Capnet requires agents!")
# XXX: this filter doesn't work at all!?
afilters = { 'agent_type' : cn_const.AGENT_TYPE_CAPNET } #,alive=[True])
agents = self.__plugin.get_agents(context,filters=None)
afilters = { 'agent_type' : [cn_const.AGENT_TYPE_CAPNET],
'admin_state_up' : [True],
'alive': [True] }
agents = self.__plugin.get_agents(context,filters=afilters)
# XXX: for now, just find the agent that is both the controller
# host and workflow app host:
......@@ -94,9 +94,7 @@ class CapnetDBMixin(agents_db.AgentDbMixin):
for agent in agents:
conf = agent['configurations']
LOG.debug("considering agent: %s///%s" % (str(agent),str(conf)))
if agent['agent_type'] == cn_const.AGENT_TYPE_CAPNET \
and agent['alive'] \
and 'hosts_controllers' in conf and conf['hosts_controllers'] \
if 'hosts_controllers' in conf and conf['hosts_controllers'] \
and 'is_master' in conf and conf['is_master']:
if master:
LOG.debug("multiple masters found!")
......@@ -286,9 +284,8 @@ class CapnetDBMixin(agents_db.AgentDbMixin):
if not hasattr(self.__plugin,'get_agents'):
raise n_exc.NeutronException("current Neutron plugin doesn't support"
" agents; Capnet requires agents!")
# XXX: this filter doesn't work at all!?
afilters = { 'agent_type' : cn_const.AGENT_TYPE_CAPNET } #,alive=[True])
agents = self.__plugin.get_agents(context,filters=None)
afilters = { 'agent_type' : [cn_const.AGENT_TYPE_CAPNET] } #,alive=[True])
agents = self.__plugin.get_agents(context,filters=afilters)
retval = []
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment