summaryrefslogtreecommitdiffstats
path: root/nova
diff options
context:
space:
mode:
authorTrey Morris <trey.morris@rackspace.com>2011-07-27 23:19:11 +0000
committerTarmac <>2011-07-27 23:19:11 +0000
commit26fd6c3f309a2febd7538684a470d462ab83dab3 (patch)
tree822856144c2bc2ab95bd305f83cf5809f5f3b628 /nova
parent0fc7f1220139318cfb9cd181324cce653cc27f58 (diff)
parent7f5437a435cb7d98c65749488b9a45bfb8bd6fec (diff)
updates handling of arguments in nova-manage network create.
updates a few of the arguments to nova-manage and related help. updates nova-manage to raise proper exceptions. updates network manager create_networks to handle ipv6 more correctly and efficiently. flat_network_bridge FLAG now defaults to None.
Diffstat (limited to 'nova')
-rw-r--r--nova/exception.py4
-rw-r--r--nova/network/manager.py18
-rw-r--r--nova/tests/fake_flags.py1
-rw-r--r--nova/virt/libvirt/vif.py2
4 files changed, 16 insertions, 9 deletions
diff --git a/nova/exception.py b/nova/exception.py
index ea046b712..8c9b45a80 100644
--- a/nova/exception.py
+++ b/nova/exception.py
@@ -373,6 +373,10 @@ class StorageRepositoryNotFound(NotFound):
message = _("Cannot find SR to read/write VDI.")
+class NetworkNotCreated(NovaException):
+ message = _("%(req)s is required to create a network.")
+
+
class NetworkNotFound(NotFound):
message = _("Network %(network_id)s could not be found.")
diff --git a/nova/network/manager.py b/nova/network/manager.py
index 6f7573f66..4a3791d8a 100644
--- a/nova/network/manager.py
+++ b/nova/network/manager.py
@@ -68,7 +68,7 @@ LOG = logging.getLogger("nova.network.manager")
FLAGS = flags.FLAGS
-flags.DEFINE_string('flat_network_bridge', 'br100',
+flags.DEFINE_string('flat_network_bridge', None,
'Bridge for simple network instances')
flags.DEFINE_string('flat_network_dns', '8.8.4.4',
'Dns for simple network')
@@ -614,12 +614,13 @@ class NetworkManager(manager.SchedulerDependentManager):
bridge_interface, dns1=None, dns2=None, **kwargs):
"""Create networks based on parameters."""
fixed_net = netaddr.IPNetwork(cidr)
- fixed_net_v6 = netaddr.IPNetwork(cidr_v6)
- significant_bits_v6 = 64
- network_size_v6 = 1 << 64
+ if FLAGS.use_ipv6:
+ fixed_net_v6 = netaddr.IPNetwork(cidr_v6)
+ significant_bits_v6 = 64
+ network_size_v6 = 1 << 64
+
for index in range(num_networks):
start = index * network_size
- start_v6 = index * network_size_v6
significant_bits = 32 - int(math.log(network_size, 2))
cidr = '%s/%s' % (fixed_net[start], significant_bits)
project_net = netaddr.IPNetwork(cidr)
@@ -640,6 +641,7 @@ class NetworkManager(manager.SchedulerDependentManager):
net['label'] = label
if FLAGS.use_ipv6:
+ start_v6 = index * network_size_v6
cidr_v6 = '%s/%s' % (fixed_net_v6[start_v6],
significant_bits_v6)
net['cidr_v6'] = cidr_v6
@@ -720,9 +722,9 @@ class FlatManager(NetworkManager):
"""Basic network where no vlans are used.
FlatManager does not do any bridge or vlan creation. The user is
- responsible for setting up whatever bridge is specified in
- flat_network_bridge (br100 by default). This bridge needs to be created
- on all compute hosts.
+ responsible for setting up whatever bridges are specified when creating
+ networks through nova-manage. This bridge needs to be created on all
+ compute hosts.
The idea is to create a single network for the host with a command like:
nova-manage network create 192.168.0.0/24 1 256. Creating multiple
diff --git a/nova/tests/fake_flags.py b/nova/tests/fake_flags.py
index 2297d2f0e..073216495 100644
--- a/nova/tests/fake_flags.py
+++ b/nova/tests/fake_flags.py
@@ -42,3 +42,4 @@ FLAGS['iscsi_num_targets'].SetDefault(8)
FLAGS['verbose'].SetDefault(True)
FLAGS['sqlite_db'].SetDefault("tests.sqlite")
FLAGS['use_ipv6'].SetDefault(True)
+FLAGS['flat_network_bridge'].SetDefault('br100')
diff --git a/nova/virt/libvirt/vif.py b/nova/virt/libvirt/vif.py
index 24d45d1a7..eef582fac 100644
--- a/nova/virt/libvirt/vif.py
+++ b/nova/virt/libvirt/vif.py
@@ -126,7 +126,7 @@ class LibvirtOpenVswitchDriver(VIFDriver):
dev = "tap-%s" % vif_id
try:
utils.execute('sudo', 'ovs-vsctl', 'del-port',
- FLAGS.flat_network_bridge, dev)
+ network['bridge'], dev)
utils.execute('sudo', 'ip', 'link', 'delete', dev)
except:
LOG.warning(_("Failed while unplugging vif of instance '%s'"),