summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--nova/network/linux_net.py21
-rw-r--r--nova/network/manager.py10
2 files changed, 20 insertions, 11 deletions
diff --git a/nova/network/linux_net.py b/nova/network/linux_net.py
index 37993d34a..df54606db 100644
--- a/nova/network/linux_net.py
+++ b/nova/network/linux_net.py
@@ -168,10 +168,10 @@ def remove_floating_forward(floating_ip, fixed_ip):
% (fixed_ip, floating_ip))
-def ensure_vlan_bridge(vlan_num, bridge, net_attrs, set_ip=False):
+def ensure_vlan_bridge(vlan_num, bridge, net_attrs=None):
"""Create a vlan and bridge unless they already exist"""
interface = ensure_vlan(vlan_num)
- ensure_bridge(bridge, interface, net_attrs, set_ip)
+ ensure_bridge(bridge, interface, net_attrs)
def ensure_vlan(vlan_num):
@@ -185,8 +185,19 @@ def ensure_vlan(vlan_num):
return interface
-def ensure_bridge(bridge, interface, net_attrs, set_ip=False):
- """Create a bridge unless it already exists"""
+def ensure_bridge(bridge, interface, net_attrs=None):
+ """Create a bridge unless it already exists.
+
+ :param interface: the interface to create the bridge on.
+ :param net_attrs: dictionary with attributes used to create the bridge.
+
+ If net_attrs is set, it will add the net_attrs['gateway'] to the bridge
+ using net_attrs['broadcast'] and net_attrs['cidr']. It will also add
+ the ip_v6 address specified in net_attrs['cidr_v6'] if use_ipv6 is set.
+
+ The code will attempt to move any ips that already exist on the interface
+ onto the bridge and reset the default gateway if necessary.
+ """
if not _device_exists(bridge):
LOG.debug(_("Starting Bridge interface for %s"), interface)
_execute("sudo brctl addbr %s" % bridge)
@@ -194,7 +205,7 @@ def ensure_bridge(bridge, interface, net_attrs, set_ip=False):
# _execute("sudo brctl setageing %s 10" % bridge)
_execute("sudo brctl stp %s off" % bridge)
_execute("sudo ip link set %s up" % bridge)
- if set_ip:
+ if net_attrs:
# NOTE(vish): The ip for dnsmasq has to be the first address on the
# bridge for it to respond to reqests properly
suffix = net_attrs['cidr'].rpartition('/')[2]
diff --git a/nova/network/manager.py b/nova/network/manager.py
index 735327230..fbcbea131 100644
--- a/nova/network/manager.py
+++ b/nova/network/manager.py
@@ -402,8 +402,7 @@ class FlatDHCPManager(FlatManager):
"""Sets up matching network for compute hosts."""
network_ref = db.network_get_by_instance(context, instance_id)
self.driver.ensure_bridge(network_ref['bridge'],
- FLAGS.flat_interface,
- network_ref)
+ FLAGS.flat_interface)
def allocate_fixed_ip(self, context, instance_id, *args, **kwargs):
"""Setup dhcp for this network."""
@@ -428,7 +427,7 @@ class FlatDHCPManager(FlatManager):
network_ref = db.network_get(context, network_id)
self.driver.ensure_bridge(network_ref['bridge'],
FLAGS.flat_interface,
- network_ref, True)
+ network_ref)
if not FLAGS.fake_network:
self.driver.update_dhcp(context, network_id)
if(FLAGS.use_ipv6):
@@ -499,8 +498,7 @@ class VlanManager(NetworkManager):
"""Sets up matching network for compute hosts."""
network_ref = db.network_get_by_instance(context, instance_id)
self.driver.ensure_vlan_bridge(network_ref['vlan'],
- network_ref['bridge'],
- network_ref)
+ network_ref['bridge'])
def create_networks(self, context, cidr, num_networks, network_size,
cidr_v6, vlan_start, vpn_start):
@@ -567,7 +565,7 @@ class VlanManager(NetworkManager):
address = network_ref['vpn_public_address']
self.driver.ensure_vlan_bridge(network_ref['vlan'],
network_ref['bridge'],
- network_ref, True)
+ network_ref)
# NOTE(vish): only ensure this forward if the address hasn't been set
# manually.