Fix a bit.

This commit is contained in:
Hui Xiang 2014-12-17 12:33:51 +08:00
parent 4fe79bdbc0
commit bf70e61579

View File

@ -251,35 +251,35 @@ class MonitorNeutronAgentsDaemon(Daemon):
l3_agents = [] l3_agents = []
networks = {} networks = {}
for agent in agents['agents']: for agent in agents['agents']:
for network in \ hosted_networks = quantum.list_networks_on_dhcp_agent(
quantum.list_networks_on_dhcp_agent( agent['id'])['networks']
agent['id'])['networks']:
networks[network['id']] = agent['id']
if not agent['alive']: if not agent['alive']:
LOG.info('DHCP Agent %s down' % agent['id']) LOG.info('DHCP Agent %s down' % agent['id'])
for network in hosted_networks:
networks[network['id']] = agent['id']
if self.is_same_host(agent['host']) and networks: if self.is_same_host(agent['host']) and networks:
self.cleanup_dhcp(networks) self.cleanup_dhcp(networks)
else: else:
dhcp_agents.append(agent) dhcp_agents.append(agent)
LOG.info('Active dhcp agents: %s' % dhcp_agents) LOG.info('Active dhcp agents: %s' % agent['id'])
if not networks: if not hosted_networks and self.is_same_host(agent['host']):
self.cleanup_dhcp(None) self.cleanup_dhcp(None)
agents = quantum.list_agents(agent_type=L3_AGENT) agents = quantum.list_agents(agent_type=L3_AGENT)
routers = {} routers = {}
for agent in agents['agents']: for agent in agents['agents']:
for router in \ hosted_routers = quantum.list_routers_on_l3_agent(
quantum.list_routers_on_l3_agent( agent['id'])['routers']
agent['id'])['routers']:
routers[router['id']] = agent['id']
if not agent['alive']: if not agent['alive']:
LOG.info('L3 Agent %s down' % agent['id']) LOG.info('L3 Agent %s down' % agent['id'])
for router in hosted_routers:
routers[router['id']] = agent['id']
if self.is_same_host(agent['host']) and routers: if self.is_same_host(agent['host']) and routers:
self.cleanup_router(routers) self.cleanup_router(routers)
else: else:
l3_agents.append(agent) l3_agents.append(agent)
LOG.info('Active l3 agents: %s' % l3_agents) LOG.info('Active l3 agents: %s' % agent['id'])
if not routers: if not hosted_routers and self.is_same_host(agent['host']):
self.cleanup_router(None) self.cleanup_router(None)
if not networks and not routers: if not networks and not routers:
@ -293,10 +293,10 @@ class MonitorNeutronAgentsDaemon(Daemon):
return return
if len(l3_agents) != 0: if len(l3_agents) != 0:
self.l3_agents_reschedule(l3_agents, routers) self.l3_agents_reschedule(l3_agents, routers, quantum)
if len(dhcp_agents) != 0: if len(dhcp_agents) != 0:
self.dhcp_agents_reschedule(dhcp_agents, networks) self.dhcp_agents_reschedule(dhcp_agents, networks, quantum)
def run(self): def run(self):
while True: while True: