Move network schedule to first port creation.

blueprint quantum-scheduler

we remove scheduling network
to dhcp agent when creating network so that we can give admin
the chance to allocate the given network to a given dhcp agent after
network creation.

Change-Id: I228870669825405277de0505a3f2ece074918524
This commit is contained in:
gongysh
2013-03-01 16:23:32 +08:00
parent 9db3ea0b07
commit 7c8d2ad3a9
7 changed files with 169 additions and 59 deletions

View File

@@ -62,6 +62,19 @@ class DhcpAgentNotifyAPI(proxy.RpcProxy):
plugin = manager.QuantumManager.get_plugin()
if (method != 'network_delete_end' and utils.is_extension_supported(
plugin, constants.AGENT_SCHEDULER_EXT_ALIAS)):
if method == 'port_create_end':
# we don't schedule when we create network
# because we want to give admin a chance to
# schedule network manually by API
adminContext = (context if context.is_admin else
context.elevated())
network = plugin.get_network(adminContext, network_id)
chosen_agent = plugin.schedule_network(adminContext, network)
if chosen_agent:
self._notification_host(
context, 'network_create_end',
{'network': {'id': network_id}},
chosen_agent['host'])
for (host, topic) in self._get_dhcp_agents(context, network_id):
self.cast(
context, self.make_msg(method,