@@ -98,6 +98,10 @@ def init_host(self):
98
98
networks = self .get_all_networks (context .get_admin_context ())
99
99
cidrs = []
100
100
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
101
105
if net ['gateway' ]:
102
106
LOG .debug ("Initializing NAT: %s (cidr: %s, gw: %s)" % (
103
107
net ['label' ], net ['cidr' ], net ['gateway' ]))
@@ -284,9 +288,20 @@ def delete_network(self, context, fixed_range, uuid):
284
288
self .ipam .delete_subnets_by_net_id (context , net_uuid , project_id )
285
289
# Get rid of dnsmasq
286
290
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 )
290
305
291
306
def allocate_for_instance (self , context , ** kwargs ):
292
307
"""Called by compute when it is creating a new VM.
@@ -370,8 +385,18 @@ def allocate_for_instance(self, context, **kwargs):
370
385
allowed_address_pairs = pairs )
371
386
# Set up/start the dhcp server for this network if necessary
372
387
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
+
375
400
return self .get_instance_nw_info (context , instance_id ,
376
401
instance ['uuid' ],
377
402
rxtx_factor , host ,
@@ -579,8 +604,17 @@ def deallocate_for_instance(self, context, **kwargs):
579
604
network ['uuid' ], project_id , vif , instance_id )
580
605
581
606
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 ,
583
609
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' ]}})
584
618
585
619
db .virtual_interface_delete (admin_context , vif ['id' ])
586
620
0 commit comments