summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-07-01 21:37:58 +0000
committerGerrit Code Review <review@openstack.org>2013-07-01 21:37:58 +0000
commita4d5ca1cb5e426cd187421b9e7e875442e81e5ae (patch)
tree7dde10a796a79deee80910c6be937066001f369f
parent5f7e79cd75f9b6ac66ba98873465e2d908ccf973 (diff)
parent8f3b3db9b04bb5ff7b9486dc6fc211745b983855 (diff)
downloadnova-a4d5ca1cb5e426cd187421b9e7e875442e81e5ae.tar.gz
nova-a4d5ca1cb5e426cd187421b9e7e875442e81e5ae.tar.xz
nova-a4d5ca1cb5e426cd187421b9e7e875442e81e5ae.zip
Merge "Skip security group code when there is no network."
-rw-r--r--nova/network/quantumv2/api.py5
-rw-r--r--nova/tests/network/test_quantumv2.py13
2 files changed, 18 insertions, 0 deletions
diff --git a/nova/network/quantumv2/api.py b/nova/network/quantumv2/api.py
index c7f4ffd58..814b66ee0 100644
--- a/nova/network/quantumv2/api.py
+++ b/nova/network/quantumv2/api.py
@@ -182,6 +182,11 @@ class API(base.Base):
nets = self._get_available_networks(context, instance['project_id'],
net_ids)
+
+ if not nets:
+ LOG.warn(_("No network configured!"), instance=instance)
+ return []
+
security_groups = kwargs.get('security_groups', [])
security_group_ids = []
diff --git a/nova/tests/network/test_quantumv2.py b/nova/tests/network/test_quantumv2.py
index 2ddeb72bf..a2e7efcc0 100644
--- a/nova/tests/network/test_quantumv2.py
+++ b/nova/tests/network/test_quantumv2.py
@@ -594,6 +594,19 @@ class TestQuantumv2(test.TestCase):
self._allocate_for_instance(net_idx=1,
requested_networks=requested_networks)
+ def test_allocate_for_instance_no_networks(self):
+ """verify the exception thrown when there are no networks defined."""
+ api = quantumapi.API()
+ self.moxed_client.list_networks(
+ tenant_id=self.instance['project_id'],
+ shared=False).AndReturn(
+ {'networks': []})
+ self.moxed_client.list_networks(shared=True).AndReturn(
+ {'networks': []})
+ self.mox.ReplayAll()
+ nwinfo = api.allocate_for_instance(self.context, self.instance)
+ self.assertEqual(len(nwinfo), 0)
+
def test_allocate_for_instance_ex1(self):
"""verify we will delete created ports
if we fail to allocate all net resources.