Skip to content

Commit

Permalink
Fixes bug 983024
Browse files Browse the repository at this point in the history
enable_dhcp, kill_dhcp and update_dhcp calls are sent to remote
nova-network, when a network is not associated with current host.

Change-Id: If7c7c6e58700cc171a8f56669e6455037df7f7e7
  • Loading branch information
Mandar Vaze committed Apr 26, 2012
1 parent caa1b28 commit d901b44
Showing 1 changed file with 40 additions and 6 deletions.
46 changes: 40 additions & 6 deletions nova/network/quantum/manager.py
Expand Up @@ -98,6 +98,10 @@ def init_host(self):
networks = self.get_all_networks(context.get_admin_context())
cidrs = []
for net in networks:
# Don't update host information for network that does not
# belong to you
if net['host'] != self.host:
continue
if net['gateway']:
LOG.debug("Initializing NAT: %s (cidr: %s, gw: %s)" % (
net['label'], net['cidr'], net['gateway']))
Expand Down Expand Up @@ -284,9 +288,20 @@ def delete_network(self, context, fixed_range, uuid):
self.ipam.delete_subnets_by_net_id(context, net_uuid, project_id)
# Get rid of dnsmasq
if FLAGS.quantum_use_dhcp:
dev = self.driver.get_dev(net_ref)
if self.driver._device_exists(dev):
self.driver.kill_dhcp(dev)
if net_ref['host'] == self.host:
self.kill_dhcp(net_ref)
else:
topic = self.db.queue_get_for(context,
FLAGS.network_topic,
net_ref['host'])

rpc.call(context, topic, {'method': 'kill_dhcp',
'args': {'net_ref': net_ref}})

def kill_dhcp(self, net_ref):
dev = self.driver.get_dev(net_ref)
if self.driver._device_exists(dev):
self.driver.kill_dhcp(dev)

def allocate_for_instance(self, context, **kwargs):
"""Called by compute when it is creating a new VM.
Expand Down Expand Up @@ -370,8 +385,18 @@ def allocate_for_instance(self, context, **kwargs):
allowed_address_pairs=pairs)
# Set up/start the dhcp server for this network if necessary
if FLAGS.quantum_use_dhcp:
self.enable_dhcp(context, network['quantum_net_id'], network,
vif_rec, network['net_tenant_id'])
if network['host'] == self.host:
self.enable_dhcp(context, network['quantum_net_id'],
network, vif_rec, network['net_tenant_id'])
else:
topic = self.db.queue_get_for(context,
FLAGS.network_topic, network['host'])
rpc.call(context, topic, {'method': 'enable_dhcp',
'args': {'quantum_net_id': network['quantum_net_id'],
'network_ref': network,
'vif_rec': vif_rec,
'project_id': network['net_tenant_id']}})

return self.get_instance_nw_info(context, instance_id,
instance['uuid'],
rxtx_factor, host,
Expand Down Expand Up @@ -579,8 +604,17 @@ def deallocate_for_instance(self, context, **kwargs):
network['uuid'], project_id, vif, instance_id)

if FLAGS.quantum_use_dhcp:
self.update_dhcp(context, ipam_tenant_id, network,
if network['host'] == self.host:
self.update_dhcp(context, ipam_tenant_id, network,
vif, project_id)
else:
topic = self.db.queue_get_for(context,
FLAGS.network_topic, network['host'])
rpc.call(context, topic, {'method': 'update_dhcp',
'args': {'ipam_tenant_id': ipam_tenant_id,
'network_ref': network,
'vif_ref': vif,
'project_id': network['project_id']}})

db.virtual_interface_delete(admin_context, vif['id'])

Expand Down

0 comments on commit d901b44

Please sign in to comment.