summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhil Day <philip.day@hp.com>2013-03-07 13:19:09 +0000
committerPhil Day <philip.day@hp.com>2013-03-11 09:30:51 +0000
commite0fd027d2d0cb0939998204b200059061771bc07 (patch)
treeda6493285b3b21ddbe8cc37b184a91c1131840e4
parentca490d48a762a423449c654d5a7caeadecf2f6ca (diff)
downloadnova-e0fd027d2d0cb0939998204b200059061771bc07.tar.gz
nova-e0fd027d2d0cb0939998204b200059061771bc07.tar.xz
nova-e0fd027d2d0cb0939998204b200059061771bc07.zip
Server create will only process "networks" if os-networks is loaded.
When working with a quantum configuration and multiple networks you have to be able to pass in the requested network to avoid instances being attached to all networks, so this part of the request isn't really optional in practice However the os-network extension is not fully compatible with quantum, and the operations do map very well. For example: - Network creation has a set of options that are pretty nova-nets centric (such as VLAN) - Network creation is limited to admins - Network association and dis-association from projects is not the quantum model - cidr from quantum is not shown correctly in the output of nova network-list and network-show Rather than needing the os-networks extension to loaded and thereby exposing a bunch of calls that don't really map to quantum, it would be better to also allow processing of "networks" when the network api is configured to be quantum Fixes bug #1150250 Change-Id: I0cc1faf6417d7a004dd9f0ff772860237fc94c57
-rw-r--r--nova/api/openstack/compute/servers.py3
-rw-r--r--nova/tests/api/openstack/compute/test_servers.py16
2 files changed, 18 insertions, 1 deletions
diff --git a/nova/api/openstack/compute/servers.py b/nova/api/openstack/compute/servers.py
index 3464cfdbd..73ca63ec2 100644
--- a/nova/api/openstack/compute/servers.py
+++ b/nova/api/openstack/compute/servers.py
@@ -768,7 +768,8 @@ class Controller(wsgi.Controller):
sg_names = list(set(sg_names))
requested_networks = None
- if self.ext_mgr.is_loaded('os-networks'):
+ if (self.ext_mgr.is_loaded('os-networks')
+ or self._is_quantum_v2()):
requested_networks = server_dict.get('networks')
if requested_networks is not None:
diff --git a/nova/tests/api/openstack/compute/test_servers.py b/nova/tests/api/openstack/compute/test_servers.py
index 638ef79b0..c833639db 100644
--- a/nova/tests/api/openstack/compute/test_servers.py
+++ b/nova/tests/api/openstack/compute/test_servers.py
@@ -2522,6 +2522,22 @@ class ServersControllerCreateTest(test.TestCase):
self.stubs.Set(compute_api.API, 'create', create)
self._test_create_extra(params)
+ def test_create_instance_with_networks_disabled_quantumv2(self):
+ self.flags(network_api_class='nova.network.quantumv2.api.API')
+ net_uuid = '76fa36fc-c930-4bf3-8c8a-ea2a2420deb6'
+ requested_networks = [{'uuid': net_uuid}]
+ params = {'networks': requested_networks}
+ old_create = compute_api.API.create
+
+ def create(*args, **kwargs):
+ result = [('76fa36fc-c930-4bf3-8c8a-ea2a2420deb6', None,
+ None)]
+ self.assertEqual(kwargs['requested_networks'], result)
+ return old_create(*args, **kwargs)
+
+ self.stubs.Set(compute_api.API, 'create', create)
+ self._test_create_extra(params)
+
def test_create_instance_with_networks_disabled(self):
self.ext_mgr.extensions = {}
net_uuid = '76fa36fc-c930-4bf3-8c8a-ea2a2420deb6'