Merge "Network/Router agent rebalancing bug fix."
This commit is contained in:
commit
9b600d7b9e
@ -45,10 +45,15 @@ def build_get_agents_response():
|
|||||||
NUM_AGENTS = random.randint(2, MAX_AGENTS - 1)
|
NUM_AGENTS = random.randint(2, MAX_AGENTS - 1)
|
||||||
for x in range(0, NUM_AGENTS):
|
for x in range(0, NUM_AGENTS):
|
||||||
host_name = "compute-" + str(x)
|
host_name = "compute-" + str(x)
|
||||||
|
admin_state_up = True
|
||||||
|
# randomly set admin_state_up on some agents to False
|
||||||
|
admin_state_down = random.randint(0, 5)
|
||||||
|
if admin_state_down == 0:
|
||||||
|
admin_state_up = False
|
||||||
get_agents_response_entry = \
|
get_agents_response_entry = \
|
||||||
{"host": host_name, "agent_type": "DHCP agent",
|
{"host": host_name, "agent_type": "DHCP agent",
|
||||||
"id": host_name + "_id", "alive": True,
|
"id": host_name + "_id", "alive": True,
|
||||||
"admin_state_up": True}
|
"admin_state_up": admin_state_up}
|
||||||
get_agents_response['result-data'].append(get_agents_response_entry)
|
get_agents_response['result-data'].append(get_agents_response_entry)
|
||||||
add_to_fake_host_table(host_name)
|
add_to_fake_host_table(host_name)
|
||||||
|
|
||||||
|
@ -49,10 +49,15 @@ def build_get_agents_response():
|
|||||||
NUM_AGENTS = random.randint(0, MAX_AGENTS - 1)
|
NUM_AGENTS = random.randint(0, MAX_AGENTS - 1)
|
||||||
for x in range(0, NUM_AGENTS):
|
for x in range(0, NUM_AGENTS):
|
||||||
host_name = "compute-" + str(x)
|
host_name = "compute-" + str(x)
|
||||||
|
admin_state_up = True
|
||||||
|
# randomly set admin_state_up on some agents to False
|
||||||
|
admin_state_down = random.randint(0, 5)
|
||||||
|
if admin_state_down == 0:
|
||||||
|
admin_state_up = False
|
||||||
get_agents_response_entry = \
|
get_agents_response_entry = \
|
||||||
{"host": host_name, "agent_type": "L3 agent",
|
{"host": host_name, "agent_type": "L3 agent",
|
||||||
"id": host_name + "_id", "alive": True,
|
"id": host_name + "_id", "alive": True,
|
||||||
"admin_state_up": True}
|
"admin_state_up": admin_state_up}
|
||||||
get_agents_response['result-data'].append(get_agents_response_entry)
|
get_agents_response['result-data'].append(get_agents_response_entry)
|
||||||
add_to_fake_host_table(host_name)
|
add_to_fake_host_table(host_name)
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ class DHCPAgentRebalance(object):
|
|||||||
_DHCPRebalance.num_networks_on_agents.append(
|
_DHCPRebalance.num_networks_on_agents.append(
|
||||||
len(_DHCPRebalance.network_ids_per_agent[agent_id]))
|
len(_DHCPRebalance.network_ids_per_agent[agent_id]))
|
||||||
self.dhcpagent_idx += 1
|
self.dhcpagent_idx += 1
|
||||||
return self.dhcpagent_idx == self.num_dhcp_agents
|
return self.dhcpagent_idx >= self.num_dhcp_agents
|
||||||
|
|
||||||
def get_host_id_of_current_dhcp_agent(self):
|
def get_host_id_of_current_dhcp_agent(self):
|
||||||
return self.dhcp_agents[self.dhcpagent_idx]['host_uuid']
|
return self.dhcp_agents[self.dhcpagent_idx]['host_uuid']
|
||||||
@ -137,7 +137,7 @@ class DHCPAgentRebalance(object):
|
|||||||
|
|
||||||
def datanetworks_done(self):
|
def datanetworks_done(self):
|
||||||
self.dhcpagent_idx += 1
|
self.dhcpagent_idx += 1
|
||||||
if self.dhcpagent_idx == self.num_dhcp_agents:
|
if self.dhcpagent_idx >= self.num_dhcp_agents:
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
@ -187,9 +187,10 @@ class DHCPAgentRebalance(object):
|
|||||||
# (if applicable) first in the list.
|
# (if applicable) first in the list.
|
||||||
if agent['host'] == self.get_working_host():
|
if agent['host'] == self.get_working_host():
|
||||||
self.dhcp_agents.insert(0, agent_info_dict)
|
self.dhcp_agents.insert(0, agent_info_dict)
|
||||||
|
self.add_agent(agent['id'])
|
||||||
elif agent['alive'] and agent['admin_state_up']:
|
elif agent['alive'] and agent['admin_state_up']:
|
||||||
self.dhcp_agents.append(agent_info_dict)
|
self.dhcp_agents.append(agent_info_dict)
|
||||||
self.add_agent(agent['id'])
|
self.add_agent(agent['id'])
|
||||||
|
|
||||||
DLOG.debug("self.dhcp_agents = %s" % self.dhcp_agents)
|
DLOG.debug("self.dhcp_agents = %s" % self.dhcp_agents)
|
||||||
return len(self.dhcp_agents)
|
return len(self.dhcp_agents)
|
||||||
|
@ -129,7 +129,7 @@ class L3AgentRebalance(object):
|
|||||||
_L3Rebalance.num_routers_on_agents.append(
|
_L3Rebalance.num_routers_on_agents.append(
|
||||||
len(_L3Rebalance.router_ids_per_agent[agent_id]))
|
len(_L3Rebalance.router_ids_per_agent[agent_id]))
|
||||||
self.l3agent_idx += 1
|
self.l3agent_idx += 1
|
||||||
return self.l3agent_idx == self.num_l3agents
|
return self.l3agent_idx >= self.num_l3agents
|
||||||
|
|
||||||
def add_network_to_router(self, router_to_resched, network_id):
|
def add_network_to_router(self, router_to_resched, network_id):
|
||||||
self.networks_per_router[router_to_resched].append(network_id)
|
self.networks_per_router[router_to_resched].append(network_id)
|
||||||
@ -145,7 +145,7 @@ class L3AgentRebalance(object):
|
|||||||
self.router_idx = 0
|
self.router_idx = 0
|
||||||
self.l3agent_idx += 1
|
self.l3agent_idx += 1
|
||||||
if (((self.working_host is not None) and (self.l3agent_idx == 1))
|
if (((self.working_host is not None) and (self.l3agent_idx == 1))
|
||||||
or (self.l3agent_idx == self.num_l3agents)):
|
or (self.l3agent_idx >= self.num_l3agents)):
|
||||||
# We have router port info for all routers on all agents
|
# We have router port info for all routers on all agents
|
||||||
# that we care about. Get the Physical Network info for these.
|
# that we care about. Get the Physical Network info for these.
|
||||||
return True
|
return True
|
||||||
@ -223,7 +223,7 @@ class L3AgentRebalance(object):
|
|||||||
|
|
||||||
def datanetworks_done(self):
|
def datanetworks_done(self):
|
||||||
self.l3agent_idx += 1
|
self.l3agent_idx += 1
|
||||||
if self.l3agent_idx == self.num_l3agents:
|
if self.l3agent_idx >= self.num_l3agents:
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
@ -278,9 +278,10 @@ class L3AgentRebalance(object):
|
|||||||
# (if applicable) first in the list.
|
# (if applicable) first in the list.
|
||||||
if agent['host'] == self.get_working_host():
|
if agent['host'] == self.get_working_host():
|
||||||
self.l3agents.insert(0, agent_info_dict)
|
self.l3agents.insert(0, agent_info_dict)
|
||||||
|
self.add_agent(agent['id'])
|
||||||
elif agent['alive'] and agent['admin_state_up']:
|
elif agent['alive'] and agent['admin_state_up']:
|
||||||
self.l3agents.append(agent_info_dict)
|
self.l3agents.append(agent_info_dict)
|
||||||
self.add_agent(agent['id'])
|
self.add_agent(agent['id'])
|
||||||
|
|
||||||
return len(self.l3agents)
|
return len(self.l3agents)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user