Skip to content

Commit d901b44

Browse files
author
Mandar Vaze
committed
Fixes bug 983024
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
1 parent caa1b28 commit d901b44

File tree

1 file changed

+40
-6
lines changed

1 file changed

+40
-6
lines changed

nova/network/quantum/manager.py

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ def init_host(self):
9898
networks = self.get_all_networks(context.get_admin_context())
9999
cidrs = []
100100
for net in networks:
101+
# Don't update host information for network that does not
102+
# belong to you
103+
if net['host'] != self.host:
104+
continue
101105
if net['gateway']:
102106
LOG.debug("Initializing NAT: %s (cidr: %s, gw: %s)" % (
103107
net['label'], net['cidr'], net['gateway']))
@@ -284,9 +288,20 @@ def delete_network(self, context, fixed_range, uuid):
284288
self.ipam.delete_subnets_by_net_id(context, net_uuid, project_id)
285289
# Get rid of dnsmasq
286290
if FLAGS.quantum_use_dhcp:
287-
dev = self.driver.get_dev(net_ref)
288-
if self.driver._device_exists(dev):
289-
self.driver.kill_dhcp(dev)
291+
if net_ref['host'] == self.host:
292+
self.kill_dhcp(net_ref)
293+
else:
294+
topic = self.db.queue_get_for(context,
295+
FLAGS.network_topic,
296+
net_ref['host'])
297+
298+
rpc.call(context, topic, {'method': 'kill_dhcp',
299+
'args': {'net_ref': net_ref}})
300+
301+
def kill_dhcp(self, net_ref):
302+
dev = self.driver.get_dev(net_ref)
303+
if self.driver._device_exists(dev):
304+
self.driver.kill_dhcp(dev)
290305

291306
def allocate_for_instance(self, context, **kwargs):
292307
"""Called by compute when it is creating a new VM.
@@ -370,8 +385,18 @@ def allocate_for_instance(self, context, **kwargs):
370385
allowed_address_pairs=pairs)
371386
# Set up/start the dhcp server for this network if necessary
372387
if FLAGS.quantum_use_dhcp:
373-
self.enable_dhcp(context, network['quantum_net_id'], network,
374-
vif_rec, network['net_tenant_id'])
388+
if network['host'] == self.host:
389+
self.enable_dhcp(context, network['quantum_net_id'],
390+
network, vif_rec, network['net_tenant_id'])
391+
else:
392+
topic = self.db.queue_get_for(context,
393+
FLAGS.network_topic, network['host'])
394+
rpc.call(context, topic, {'method': 'enable_dhcp',
395+
'args': {'quantum_net_id': network['quantum_net_id'],
396+
'network_ref': network,
397+
'vif_rec': vif_rec,
398+
'project_id': network['net_tenant_id']}})
399+
375400
return self.get_instance_nw_info(context, instance_id,
376401
instance['uuid'],
377402
rxtx_factor, host,
@@ -579,8 +604,17 @@ def deallocate_for_instance(self, context, **kwargs):
579604
network['uuid'], project_id, vif, instance_id)
580605

581606
if FLAGS.quantum_use_dhcp:
582-
self.update_dhcp(context, ipam_tenant_id, network,
607+
if network['host'] == self.host:
608+
self.update_dhcp(context, ipam_tenant_id, network,
583609
vif, project_id)
610+
else:
611+
topic = self.db.queue_get_for(context,
612+
FLAGS.network_topic, network['host'])
613+
rpc.call(context, topic, {'method': 'update_dhcp',
614+
'args': {'ipam_tenant_id': ipam_tenant_id,
615+
'network_ref': network,
616+
'vif_ref': vif,
617+
'project_id': network['project_id']}})
584618

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

0 commit comments

Comments
 (0)