Browse Source
Goodbye Quantum! Change-Id: Idbd0384a892beaff3a937444f04cfc433cb805eb Closes-Bug:1299046changes/67/84367/1
21 changed files with 5 additions and 322 deletions
@ -1,95 +0,0 @@
|
||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4 |
||||
# |
||||
# Copyright 2013 New Dream Network, LLC (DreamHost) |
||||
# All Rights Reserved. |
||||
# |
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may |
||||
# not use this file except in compliance with the License. You may obtain |
||||
# a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
||||
# License for the specific language governing permissions and limitations |
||||
# under the License. |
||||
|
||||
# @author Mark McClain (DreamHost) |
||||
|
||||
from oslo.config import cfg |
||||
|
||||
from neutron.openstack.common import log as logging |
||||
|
||||
LOG = logging.getLogger(__name__) |
||||
|
||||
|
||||
def scrub_class_path(cls_path): |
||||
"""Scrub from Quantum from old class_path references.""" |
||||
|
||||
if isinstance(cls_path, basestring): |
||||
if cls_path.startswith('quantum'): |
||||
new_path = cls_path.replace('quantum', 'neutron') |
||||
new_path = new_path.replace('Quantum', 'Neutron') |
||||
LOG.warn( |
||||
_("Old class module path in use. Please change '%(old)s' " |
||||
"to '%(new)s'."), |
||||
{'old': cls_path, 'new': new_path} |
||||
) |
||||
cls_path = new_path |
||||
return cls_path |
||||
|
||||
|
||||
def override_config(config, config_keys=None): |
||||
"""Attempt to override config_key with Neutron compatible values.""" |
||||
|
||||
for key in config_keys: |
||||
group = None |
||||
if not isinstance(key, basestring): |
||||
try: |
||||
group, key, module_str = key |
||||
old_value = getattr(getattr(config, group), key, None) |
||||
except AttributeError: |
||||
try: |
||||
config.import_opt(key, module_str, group) |
||||
old_value = getattr(getattr(config, group), key, None) |
||||
except (cfg.NoSuchOptError, |
||||
cfg.NoSuchGroupError, |
||||
AttributeError): |
||||
LOG.warn(_('Key %(key)s in group %(group)s is unknown. ' |
||||
'It may not be defined or needed by this ' |
||||
'service.') % {'key': key, 'group': group}) |
||||
continue |
||||
else: |
||||
old_value = getattr(config, key, None) |
||||
if not old_value: |
||||
continue |
||||
elif isinstance(old_value, list): |
||||
new_value = [scrub_class_path(v) for v in old_value] |
||||
else: |
||||
new_value = scrub_class_path(old_value) |
||||
|
||||
if new_value != old_value: |
||||
config.set_override(key, new_value, group=group) |
||||
|
||||
|
||||
def modernize_quantum_config(config): |
||||
"""Updates keys from old Quantum configurations for Neutron.""" |
||||
config_keys = [ |
||||
'allowed_rpc_exception_modules', |
||||
'core_plugin', |
||||
'device_driver', |
||||
'dhcp_driver', |
||||
'driver_fqn', |
||||
'interface_driver', |
||||
'network_scheduler_driver', |
||||
'notification_driver', |
||||
'router_scheduler_driver', |
||||
'rpc_backend', |
||||
'service_plugins', |
||||
('SECURITYGROUP', |
||||
'firewall_driver', |
||||
'neutron.agent.securitygroups_rpc'), |
||||
] |
||||
|
||||
override_config(config, config_keys) |
@ -1,83 +0,0 @@
|
||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4 |
||||
# |
||||
# Copyright 2013 New Dream Network, LLC (DreamHost) |
||||
# All Rights Reserved. |
||||
# |
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may |
||||
# not use this file except in compliance with the License. You may obtain |
||||
# a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
||||
# License for the specific language governing permissions and limitations |
||||
# under the License. |
||||
|
||||
# @author Mark McClain (DreamHost) |
||||
|
||||
import mock |
||||
from oslo.config import cfg |
||||
|
||||
from neutron.common import legacy |
||||
from neutron.tests import base |
||||
|
||||
|
||||
class TestLegacyScrubPath(base.BaseTestCase): |
||||
def test_neutron_path(self): |
||||
self.assertEqual( |
||||
'neutron.foo.NeutronPlugin', |
||||
legacy.scrub_class_path('neutron.foo.NeutronPlugin') |
||||
) |
||||
|
||||
def test_quantum_path(self): |
||||
with mock.patch.object(legacy, 'LOG') as log: |
||||
self.assertEqual( |
||||
'neutron.foo.NeutronPlugin', |
||||
legacy.scrub_class_path('quantum.foo.QuantumPlugin') |
||||
) |
||||
|
||||
log.assert_has_calls([mock.call.warn(mock.ANY, mock.ANY)]) |
||||
|
||||
def test_third_party_path(self): |
||||
self.assertEqual( |
||||
'third.party.quantum.QuantumPlugin', |
||||
legacy.scrub_class_path('third.party.quantum.QuantumPlugin') |
||||
) |
||||
|
||||
|
||||
class TestLegacyConfigOverride(base.BaseTestCase): |
||||
def setUp(self): |
||||
super(TestLegacyConfigOverride, self).setUp() |
||||
self.cfg = cfg.ConfigOpts() |
||||
self.cfg.register_cli_opts([cfg.StrOpt('foo'), cfg.ListOpt('thelist')]) |
||||
self.cfg.register_cli_opts([cfg.StrOpt('baz')], group='bar') |
||||
|
||||
def test_override_config_simple_key(self): |
||||
self.cfg(args=['--foo=quantum']) |
||||
legacy.override_config(self.cfg, ['foo']) |
||||
self.assertEqual(self.cfg.foo, 'neutron') |
||||
|
||||
def test_override_config_simple_key_unchanged(self): |
||||
self.cfg(args=['--foo=something.else']) |
||||
legacy.override_config(self.cfg, ['foo']) |
||||
self.assertEqual(self.cfg.foo, 'something.else') |
||||
|
||||
def test_override_config_missing_key(self): |
||||
self.cfg(args=[]) |
||||
legacy.override_config(self.cfg, ['foo']) |
||||
self.assertIsNone(self.cfg.foo) |
||||
|
||||
def test_override_config_group_key(self): |
||||
self.cfg(args=['--bar-baz=quantum']) |
||||
legacy.override_config(self.cfg, [('bar', 'baz', 'mod')]) |
||||
self.assertEqual(self.cfg.bar.baz, 'neutron') |
||||
|
||||
def test_override_config_list_value(self): |
||||
self.cfg(args=['--thelist=quantum,neutron,quantum.Quantum']) |
||||
legacy.override_config(self.cfg, ['thelist']) |
||||
self.assertEqual( |
||||
self.cfg.thelist, |
||||
['neutron', 'neutron', 'neutron.Neutron'] |
||||
) |
@ -1,18 +0,0 @@
|
||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4 |
||||
# |
||||
# Copyright 2013 New Dream Network, LLC (DreamHost) |
||||
# All Rights Reserved. |
||||
# |
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may |
||||
# not use this file except in compliance with the License. You may obtain |
||||
# a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
||||
# License for the specific language governing permissions and limitations |
||||
# under the License. |
||||
|
||||
# @author Mark McClain (DreamHost) |
@ -1,36 +0,0 @@
|
||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4 |
||||
# |
||||
# Copyright 2013 New Dream Network, LLC (DreamHost) |
||||
# All Rights Reserved. |
||||
# |
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may |
||||
# not use this file except in compliance with the License. You may obtain |
||||
# a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
||||
# License for the specific language governing permissions and limitations |
||||
# under the License. |
||||
|
||||
# @author Mark McClain (DreamHost) |
||||
|
||||
import sys |
||||
import warnings |
||||
|
||||
from neutron import api |
||||
from neutron.api import extensions |
||||
from neutron.api import v2 |
||||
|
||||
|
||||
warnings.warn( |
||||
_('You are using old configuration values for the api-paste config. ' |
||||
'Please update for Neutron.') |
||||
) |
||||
sys.modules['quantum.api.extensions'] = extensions |
||||
sys.modules['quantum.api.v2'] = v2 |
||||
# The following assigment must be performed at the end of the module. |
||||
# Otherwise local variables will be overwritten. |
||||
sys.modules['quantum.api'] = api |
@ -1,32 +0,0 @@
|
||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4 |
||||
# |
||||
# Copyright 2013 New Dream Network, LLC (DreamHost) |
||||
# All Rights Reserved. |
||||
# |
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may |
||||
# not use this file except in compliance with the License. You may obtain |
||||
# a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
||||
# License for the specific language governing permissions and limitations |
||||
# under the License. |
||||
|
||||
# @author Mark McClain (DreamHost) |
||||
|
||||
import warnings |
||||
|
||||
from neutron import auth |
||||
|
||||
|
||||
warnings.warn( |
||||
_('You are using old configuration values for the api-paste config. ' |
||||
'Please update for Neutron.') |
||||
) |
||||
|
||||
# For compatibility with old configurations |
||||
QuantumKeystoneContext = auth.NeutronKeystoneContext |
||||
pipeline_factory = auth.pipeline_factory |
Loading…
Reference in new issue