Merge "Reference default_servicetype group in lowercase"
This commit is contained in:
commit
ee5519d545
@ -43,13 +43,13 @@ default_servicetype_opts = [
|
||||
'using the format: <service>:<plugin>[:<driver>]'))
|
||||
]
|
||||
|
||||
cfg.CONF.register_opts(default_servicetype_opts, 'DEFAULT_SERVICETYPE')
|
||||
cfg.CONF.register_opts(default_servicetype_opts, 'default_servicetype')
|
||||
|
||||
|
||||
def parse_service_definition_opt():
|
||||
"""Parse service definition opts and returns result."""
|
||||
results = []
|
||||
svc_def_opt = cfg.CONF.DEFAULT_SERVICETYPE.service_definition
|
||||
svc_def_opt = cfg.CONF.default_servicetype.service_definition
|
||||
try:
|
||||
for svc_def_str in svc_def_opt:
|
||||
split = svc_def_str.split(':')
|
||||
@ -72,7 +72,7 @@ def parse_service_definition_opt():
|
||||
class NoDefaultServiceDefinition(q_exc.QuantumException):
|
||||
message = _("No default service definition in configuration file. "
|
||||
"Please add service definitions using the service_definition "
|
||||
"variable in the [DEFAULT_SERVICETYPE] section")
|
||||
"variable in the [default_servicetype] section")
|
||||
|
||||
|
||||
class ServiceTypeNotFound(q_exc.NotFound):
|
||||
@ -129,12 +129,12 @@ class ServiceTypeManager(object):
|
||||
self._initialize_db()
|
||||
ctx = context.get_admin_context()
|
||||
# Init default service type from configuration file
|
||||
svc_defs = cfg.CONF.DEFAULT_SERVICETYPE.service_definition
|
||||
svc_defs = cfg.CONF.default_servicetype.service_definition
|
||||
if not svc_defs:
|
||||
raise NoDefaultServiceDefinition()
|
||||
def_service_type = {'name': DEFAULT_SVCTYPE_NAME,
|
||||
'description':
|
||||
cfg.CONF.DEFAULT_SERVICETYPE.description,
|
||||
cfg.CONF.default_servicetype.description,
|
||||
'service_definitions':
|
||||
parse_service_definition_opt(),
|
||||
'default': True}
|
||||
|
@ -19,7 +19,10 @@
|
||||
|
||||
import contextlib
|
||||
import logging
|
||||
import os
|
||||
import tempfile
|
||||
|
||||
import fixtures
|
||||
import mock
|
||||
from oslo.config import cfg
|
||||
import webob.exc as webexc
|
||||
@ -33,6 +36,7 @@ from quantum.db import servicetype_db
|
||||
from quantum.extensions import servicetype
|
||||
from quantum import manager
|
||||
from quantum.plugins.common import constants
|
||||
from quantum.tests import base
|
||||
from quantum.tests.unit import dummy_plugin as dp
|
||||
from quantum.tests.unit import test_api_v2
|
||||
from quantum.tests.unit import test_db_plugin
|
||||
@ -252,7 +256,7 @@ class ServiceTypeManagerTestCase(ServiceTypeTestCaseBase):
|
||||
servicetype_db.ServiceTypeManager._instance = None
|
||||
plugin_name = "%s.%s" % (dp.__name__, dp.DummyServicePlugin.__name__)
|
||||
cfg.CONF.set_override('service_definition', ['dummy:%s' % plugin_name],
|
||||
group='DEFAULT_SERVICETYPE')
|
||||
group='default_servicetype')
|
||||
self.addCleanup(db_api.clear_db)
|
||||
super(ServiceTypeManagerTestCase, self).setUp()
|
||||
|
||||
@ -467,3 +471,41 @@ class ServiceTypeManagerTestCase(ServiceTypeTestCaseBase):
|
||||
|
||||
class ServiceTypeManagerTestCaseXML(ServiceTypeManagerTestCase):
|
||||
fmt = 'xml'
|
||||
|
||||
|
||||
class CompatServiceTypeConfigTestCase(base.BaseTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(CompatServiceTypeConfigTestCase, self).setUp()
|
||||
self.useFixture(fixtures.NestedTempfile())
|
||||
self.conf = cfg.ConfigOpts()
|
||||
self.conf.register_opts(servicetype_db.default_servicetype_opts,
|
||||
'default_servicetype')
|
||||
|
||||
def _write_quantum_conf(self, contents):
|
||||
(fd, path) = tempfile.mkstemp(prefix='quantum-', suffix='.conf')
|
||||
try:
|
||||
os.write(fd, contents)
|
||||
finally:
|
||||
os.close(fd)
|
||||
return path
|
||||
|
||||
def _test_default_servicetype_section(self, section_name):
|
||||
path = self._write_quantum_conf(
|
||||
'[%(section_name)s]\n'
|
||||
'description = test service type\n'
|
||||
'service_definition=test:testing.QuantumTestPlugin\n' %
|
||||
{'section_name': section_name})
|
||||
|
||||
self.conf(['--config-file', path])
|
||||
|
||||
self.assertEqual(self.conf.default_servicetype.description,
|
||||
'test service type')
|
||||
self.assertEqual(self.conf.default_servicetype.service_definition,
|
||||
['test:testing.QuantumTestPlugin'])
|
||||
|
||||
def test_default_servicetype_lowercase(self):
|
||||
self._test_default_servicetype_section('default_servicetype')
|
||||
|
||||
def test_default_servicetype_uppercase(self):
|
||||
self._test_default_servicetype_section('DEFAULT_SERVICETYPE')
|
||||
|
Loading…
x
Reference in New Issue
Block a user