Correct update extension point's check_func for v3 server's controller

When loading update extension point, it should check the extension has
'server_update' function. But current code check with wrong function
name 'server_resize'. And this patch adds testcase for servers extension
point.

Change-Id: I2bee7ff306b3337d24047e471fac9485fec9a6f7
Closes-bug: #1240351
This commit is contained in:
He Jie Xu 2013-10-16 13:56:03 +08:00
parent b2ade54e82
commit edcc7dcbcb
2 changed files with 73 additions and 1 deletions

View File

@ -468,7 +468,7 @@ class ServersController(wsgi.Controller):
self.update_extension_manager = \
stevedore.enabled.EnabledExtensionManager(
namespace=self.EXTENSION_UPDATE_NAMESPACE,
check_func=_check_load_extension('server_resize'),
check_func=_check_load_extension('server_update'),
invoke_on_load=True,
invoke_kwds={"extension_info": self.extension_info},
propagate_map_exceptions=True)

View File

@ -31,10 +31,12 @@ import webob
from nova.api.openstack import compute
from nova.api.openstack.compute import plugins
from nova.api.openstack.compute.plugins.v3 import availability_zone
from nova.api.openstack.compute.plugins.v3 import disk_config
from nova.api.openstack.compute.plugins.v3 import ips
from nova.api.openstack.compute.plugins.v3 import keypairs
from nova.api.openstack.compute.plugins.v3 import servers
from nova.api.openstack.compute import views
from nova.api.openstack import extensions
from nova.api.openstack import xmlutil
from nova.compute import api as compute_api
from nova.compute import flavors
@ -4469,3 +4471,73 @@ class TestServerRebuildXMLDeserializer(test.TestCase):
},
}
self.assertThat(request['body'], matchers.DictMatches(expected))
class FakeDiskConfigExt(extensions.V3APIExtensionBase):
name = "DiskConfig"
alias = 'os-disk-config'
namespace = "http://docs.openstack.org/compute/ext/disk_config/api/v3"
version = 1
def fake_extension_point(self, *args, **kwargs):
pass
def get_controller_extensions(self):
return []
def get_resources(self):
return []
class TestServersExtensionPoint(test.NoDBTestCase):
def setUp(self):
super(TestServersExtensionPoint, self).setUp()
CONF.set_override('extensions_whitelist', ['os-disk-config'],
'osapi_v3')
self.stubs.Set(disk_config, 'DiskConfig', FakeDiskConfigExt)
def _test_load_extension_point(self, name):
setattr(FakeDiskConfigExt, 'server_%s' % name,
FakeDiskConfigExt.fake_extension_point)
ext_info = plugins.LoadedExtensionInfo()
controller = servers.ServersController(extension_info=ext_info)
self.assertEqual(
'os-disk-config',
list(getattr(controller,
'%s_extension_manager' % name))[0].obj.alias)
delattr(FakeDiskConfigExt, 'server_%s' % name)
def test_load_resize_extension_point(self):
self._test_load_extension_point('resize')
def test_load_update_extension_point(self):
self._test_load_extension_point('update')
def test_load_rebuild_extension_point(self):
self._test_load_extension_point('rebuild')
def test_load_create_extension_point(self):
self._test_load_extension_point('rebuild')
def _test_load_deserialize_extension_point(self, name):
extension_point_func = 'server_xml_extract_%s_deserialize' % name
if name == 'create':
extension_point_func = 'server_xml_extract_server_deserialize'
setattr(FakeDiskConfigExt, extension_point_func,
FakeDiskConfigExt.fake_extension_point)
ext_info = plugins.LoadedExtensionInfo()
controller = servers.ServersController(extension_info=ext_info)
self.assertEqual(
'os-disk-config',
list(getattr(controller,
'%s_xml_deserialize_manager' % name))[0].obj.alias)
delattr(FakeDiskConfigExt, extension_point_func)
def test_load_create_xml_deserialize_extension_point(self):
self._test_load_deserialize_extension_point('create')
def test_load_resize_xml_deserialize_extension_point(self):
self._test_load_deserialize_extension_point('resize')
def test_load_rebuild_xml_deserialize_extension_point(self):
self._test_load_deserialize_extension_point('rebuild')