summaryrefslogtreecommitdiffstats
path: root/nova
diff options
context:
space:
mode:
authorVishvananda Ishaya <vishvananda@gmail.com>2010-12-16 23:25:21 +0000
committerVishvananda Ishaya <vishvananda@gmail.com>2010-12-16 23:25:21 +0000
commita6f90bacda223add276698958b2e7479bb6841e9 (patch)
treeb889ea40da9674689209387f0ccf9ef623e7992f /nova
parentcd460a1f661eea7e050891f50a8218fdf24f2c6f (diff)
make sure all network data is recreated when nova-network is rebooted
Diffstat (limited to 'nova')
-rw-r--r--nova/network/manager.py34
1 files changed, 25 insertions, 9 deletions
diff --git a/nova/network/manager.py b/nova/network/manager.py
index 6a30f30b7..815fbfdc2 100644
--- a/nova/network/manager.py
+++ b/nova/network/manager.py
@@ -112,6 +112,16 @@ class NetworkManager(manager.Manager):
ctxt = context.get_admin_context()
for network in self.db.host_get_networks(ctxt, self.host):
self._on_set_network_host(ctxt, network['id'])
+ floating_ips = self.db.floating_ip_get_all_by_host(ctxt,
+ self.host)
+ for floating_ip in floating_ips:
+ if floating_ip.get('fixed_ip', None):
+ fixed_address = floating_ip['fixed_ip']['address']
+ # NOTE(vish): The False here is because we ignore the case
+ # that the ip is already bound.
+ self.driver.bind_floating_ip(floating_ip['address'], False)
+ self.driver.ensure_floating_forward(floating_ip['address'],
+ fixed_address)
def set_network_host(self, context, network_id):
"""Safely sets the host of the network."""
@@ -444,12 +454,7 @@ class VlanManager(NetworkManager):
def setup_fixed_ip(self, context, address):
"""Sets forwarding rules and dhcp for fixed ip."""
- fixed_ip_ref = self.db.fixed_ip_get_by_address(context, address)
network_ref = self.db.fixed_ip_get_network(context, address)
- if self.db.instance_is_vpn(context, fixed_ip_ref['instance_id']):
- self.driver.ensure_vlan_forward(network_ref['vpn_public_address'],
- network_ref['vpn_public_port'],
- network_ref['vpn_private_address'])
self.driver.update_dhcp(context, network_ref['id'])
def setup_compute_network(self, context, instance_id):
@@ -497,13 +502,24 @@ class VlanManager(NetworkManager):
def _on_set_network_host(self, context, network_id):
"""Called when this host becomes the host for a network."""
network_ref = self.db.network_get(context, network_id)
- net = {}
- net['vpn_public_address'] = FLAGS.vpn_ip
- db.network_update(context, network_id, net)
+ if not network_ref['vpn_public_address']:
+ net = {}
+ address = FLAGS.vpn_ip
+ net['vpn_public_address'] = address
+ db.network_update(context, network_id, net)
+ else:
+ address = network_ref['vpn_public_address']
self.driver.ensure_vlan_bridge(network_ref['vlan'],
network_ref['bridge'],
network_ref)
- self.driver.update_dhcp(context, network_id)
+ # NOTE(vish): only ensure this forward if the address hasn't been set
+ # manually.
+ if address == FLAGS.vpn_ip:
+ self.driver.ensure_vlan_forward(FLAGS.vpn_ip,
+ network_ref['vpn_public_port'],
+ network_ref['vpn_private_address'])
+ if not FLAGS.fake_network:
+ self.driver.update_dhcp(context, network_id)
@property
def _bottom_reserved_ips(self):