summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-05-09 22:18:23 +0000
committerGerrit Code Review <review@openstack.org>2013-05-09 22:18:23 +0000
commit20efc4170737f9b9db5f13651efe699da0ed5178 (patch)
treedab09e3ddbc0c46a72a9fce6d4026abfd47cf10a
parent7c74dafeb37efa7ec106bccbdbe67361e18f7610 (diff)
parent6cfc02531f92c2e98eb947bc7a46d6bed0158d82 (diff)
downloadnova-20efc4170737f9b9db5f13651efe699da0ed5178.tar.gz
nova-20efc4170737f9b9db5f13651efe699da0ed5178.tar.xz
nova-20efc4170737f9b9db5f13651efe699da0ed5178.zip
Merge "Fixes KeyError bug with network api associate"
-rw-r--r--nova/network/api.py2
-rw-r--r--nova/tests/network/test_api.py16
2 files changed, 16 insertions, 2 deletions
diff --git a/nova/network/api.py b/nova/network/api.py
index cb3a0f5db..3091a8fa1 100644
--- a/nova/network/api.py
+++ b/nova/network/api.py
@@ -346,7 +346,6 @@ class API(base.Base):
def associate(self, context, network_uuid, host=_sentinel,
project=_sentinel):
"""Associate or disassociate host or project to network."""
- associations = {}
network_id = self.get(context, network_uuid)['id']
if host is not API._sentinel:
if host is None:
@@ -356,7 +355,6 @@ class API(base.Base):
else:
self.db.network_set_host(context, network_id, host)
if project is not API._sentinel:
- project = associations['project']
if project is None:
self.db.network_disassociate(context, network_id,
disassociate_host=False,
diff --git a/nova/tests/network/test_api.py b/nova/tests/network/test_api.py
index 1e92fa286..871d26616 100644
--- a/nova/tests/network/test_api.py
+++ b/nova/tests/network/test_api.py
@@ -255,3 +255,19 @@ class ApiTestCase(test.TestCase):
instance = {'uuid': FAKE_UUID}
result = self.network_api._is_multi_host(self.context, instance)
self.assertEqual(is_multi_host, result)
+
+ def test_network_disassociate_project(self):
+ def fake_network_disassociate(ctx, network_id, disassociate_host,
+ disassociate_project):
+ self.assertEqual(network_id, 1)
+ self.assertEqual(disassociate_host, False)
+ self.assertEqual(disassociate_project, True)
+
+ def fake_get(context, network_uuid):
+ return {'id': 1}
+
+ self.stubs.Set(self.network_api.db, 'network_disassociate',
+ fake_network_disassociate)
+ self.stubs.Set(self.network_api, 'get', fake_get)
+
+ self.network_api.associate(self.context, FAKE_UUID, project=None)