Permalink
Browse files

Key requested_networks off of network extension

partially implements blueprint disable-server-extensions

Change-Id: Id6abe827b0d0bbf04dc25bed9a92296b24f34f5f
  • Loading branch information...
1 parent 649d3ce commit 80724254edec09f6cd8f217c9ea695b7374d89b8 Nachi Ueno committed Aug 10, 2012
Showing with 34 additions and 2 deletions.
  1. +5 −2 nova/api/openstack/compute/servers.py
  2. +29 −0 nova/tests/api/openstack/compute/test_servers.py
@@ -623,10 +623,13 @@ def create(self, req, body):
sg_names = list(set(sg_names))
- requested_networks = server_dict.get('networks')
+ requested_networks = None
+ if self.ext_mgr.is_loaded('os-networks'):
+ requested_networks = server_dict.get('networks')
+
if requested_networks is not None:
requested_networks = self._get_requested_networks(
- requested_networks)
+ requested_networks)
(access_ip_v4, ) = server_dict.get('accessIPv4'),
if access_ip_v4 is not None:
@@ -1961,6 +1961,35 @@ def create(*args, **kwargs):
self.stubs.Set(nova.compute.api.API, 'create', create)
self._test_create_extra(params)
+ def test_create_instance_with_networks_enabled(self):
+ self.ext_mgr.extensions = {'os-networks': 'fake'}
+ net_uuid = '76fa36fc-c930-4bf3-8c8a-ea2a2420deb6'
+ requested_networks = [{'uuid': net_uuid}]
+ params = {'networks': requested_networks}
+ old_create = nova.compute.api.API.create
+
+ def create(*args, **kwargs):
+ result = [('76fa36fc-c930-4bf3-8c8a-ea2a2420deb6', None)]
+ self.assertEqual(kwargs['requested_networks'], result)
+ return old_create(*args, **kwargs)
+
+ self.stubs.Set(nova.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'
+ requested_networks = [{'uuid': net_uuid}]
+ params = {'networks': requested_networks}
+ old_create = nova.compute.api.API.create
+
+ def create(*args, **kwargs):
+ self.assertEqual(kwargs['requested_networks'], None)
+ return old_create(*args, **kwargs)
+
+ self.stubs.Set(nova.compute.api.API, 'create', create)
+ self._test_create_extra(params)
+
def test_create_instance_with_access_ip(self):
# proper local hrefs must start with 'http://localhost/v2/'
image_uuid = '76fa36fc-c930-4bf3-8c8a-ea2a2420deb6'

0 comments on commit 8072425

Please sign in to comment.