summaryrefslogtreecommitdiff
path: root/nova
diff options
context:
space:
mode:
authorBrad Hall <brad@nicira.com>2012-02-28 13:57:01 -0800
committerBrad Hall <brad@nicira.com>2012-02-28 17:00:20 -0800
commit43f2492175d11a3f8ea4198e65b2a6a6b38cbbb6 (patch)
tree81fbcc3a6c0968aaccf4a10e12b40fc2933b2e57 /nova
parent315a45a35bd577129a49c4c3b08a1319f7d2e9a6 (diff)
downloadnova-43f2492175d11a3f8ea4198e65b2a6a6b38cbbb6.tar.gz
Fix for bug 942896: Make sure network['host'] is set
The floating ip mixin requires network['host'] to be set. We now set it during create_network and also update it at startup time to make sure it is set. Change-Id: Ide0fe265d08a2ef322d9f7b6bfed5ba8b510c246
Diffstat (limited to 'nova')
-rw-r--r--nova/network/quantum/manager.py19
-rw-r--r--nova/tests/test_quantum.py17
2 files changed, 33 insertions, 3 deletions
diff --git a/nova/network/quantum/manager.py b/nova/network/quantum/manager.py
index 7d0302c6dc..d7370db323 100644
--- a/nova/network/quantum/manager.py
+++ b/nova/network/quantum/manager.py
@@ -101,10 +101,21 @@ class QuantumManager(manager.FloatingIP, manager.FlatManager):
LOG.debug("Initializing NAT: %s (cidr: %s, gw: %s)" % (
net['label'], net['cidr'], net['gateway']))
cidrs.append(net['cidr'])
+ self._update_network_host(context.get_admin_context(),
+ net['uuid'])
# .. and for each network
for c in cidrs:
self.l3driver.initialize_network(c)
+ def _update_network_host(self, context, net_uuid):
+ """Set the host column in the networks table: note that this won't
+ work with multi-host but QuantumManager doesn't support that
+ anyways. The floating IPs mixin required network['host'] to be
+ set."""
+ entry = db.network_get_by_uuid(context.elevated(), net_uuid)
+ entry['host'] = self.host
+ db.network_update(context.elevated(), entry['id'], entry)
+
def _get_nova_id(self, instance=None):
# When creating the network we need to pass in an identifier for
# this zone. Some Quantum plugins need this information in order
@@ -202,9 +213,11 @@ class QuantumManager(manager.FloatingIP, manager.FlatManager):
ipam_tenant_id = kwargs.get("project_id", None)
priority = kwargs.get("priority", 0)
# NOTE(tr3buchet): this call creates a nova network in the nova db
- self.ipam.create_subnet(context, label, ipam_tenant_id, quantum_net_id,
- priority, cidr, gateway, gateway_v6,
- cidr_v6, dns1, dns2)
+ self.ipam.create_subnet(context, label, ipam_tenant_id,
+ quantum_net_id, priority, cidr,
+ gateway, gateway_v6, cidr_v6, dns1, dns2)
+
+ self._update_network_host(context, quantum_net_id)
# Initialize forwarding
self.l3driver.initialize_network(cidr)
diff --git a/nova/tests/test_quantum.py b/nova/tests/test_quantum.py
index e13ad03574..3d40f9701f 100644
--- a/nova/tests/test_quantum.py
+++ b/nova/tests/test_quantum.py
@@ -446,6 +446,23 @@ class QuantumManagerTestCase(QuantumNovaTestCase):
self.assertTrue(net is not None)
self.assertEquals(net['uuid'], net_id)
+ def test_create_net_external_uuid_and_host_is_set(self):
+ """Make sure network['host'] is set when creating a network via the
+ network manager"""
+ project_id = "foo_project"
+ ctx = context.RequestContext('user1', project_id)
+ net_id = self.net_man.q_conn.create_network(project_id, 'net2')
+ self.net_man.create_networks(
+ ctx, label='achtungbaby2', cidr="9.9.8.0/24", multi_host=False,
+ num_networks=1, network_size=256, cidr_v6=None,
+ gateway="9.9.8.1", gateway_v6=None, bridge=None,
+ bridge_interface=None, dns1="8.8.8.8", project_id=project_id,
+ priority=8, uuid=net_id)
+ net = db.network_get_by_uuid(ctx.elevated(), net_id)
+ self.assertTrue(net is not None)
+ self.assertEquals(net['uuid'], net_id)
+ self.assertTrue(net['host'] != None)
+
class QuantumNovaMACGenerationTestCase(QuantumNovaTestCase):
def test_local_mac_address_creation(self):