From c2e957ceb555b88084033d9a1c15a4f338b1476e Mon Sep 17 00:00:00 2001 From: Derek Higgins Date: Mon, 23 Jul 2012 10:46:41 +0100 Subject: Adding networking rules to vm's on compute service startup Fixes bug 1027105 Restarting nova-compute resulted in a new empty iptables chain "nova-compute-FORWARD" being create. This commit adds a single call to plug_vifs which ensures the appropriate filters (and bridge) are present on service startup. Change-Id: I51cbb56acbb244ddddd951a26d3168cf5a9c0314 --- nova/compute/manager.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 034bce09e..a61fe567f 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -289,7 +289,7 @@ class ComputeManager(manager.SchedulerDependentManager): self.driver.init_host(host=self.host) context = nova.context.get_admin_context() instances = self.db.instance_get_all_by_host(context, self.host) - for instance in instances: + for count, instance in enumerate(instances): db_state = instance['power_state'] drv_state = self._get_power_state(context, instance) @@ -300,6 +300,13 @@ class ComputeManager(manager.SchedulerDependentManager): '%(db_state)s.'), locals(), instance=instance) net_info = compute_utils.get_nw_info_for_instance(instance) + + # We're calling plug_vifs to ensure bridge and iptables + # filters are present, calling it once is enough. + if count == 0: + legacy_net_info = self._legacy_nw_info(net_info) + self.driver.plug_vifs(instance, legacy_net_info) + if ((expect_running and FLAGS.resume_guests_state_on_host_boot) or FLAGS.start_guests_on_host_boot): LOG.info(_('Rebooting instance after nova-compute restart.'), -- cgit