Remove deprecated novaclient.v2.contrib modules

All modules of novaclient.v2.contrib have been removed.
The 'only_contrib' parameter for the
'novaclient.client.discover_extensions' method is no longer valid.

Change-Id: I6da83057dda1f27afe98a2412bc0815f100f34a4
This commit is contained in:
Takashi NATSUME 2019-02-07 13:22:00 +09:00
parent 85e9b58e9b
commit 8eb7d1c5cc
17 changed files with 6 additions and 341 deletions

View File

@ -26,8 +26,7 @@ extensions = [
apidoc_module_dir = '../../novaclient'
apidoc_output_dir = 'reference/api'
apidoc_excluded_paths = [
'tests/*',
'v2/contrib/*']
'tests/*']
apidoc_separate_modules = True
# The content that will be inserted into the main body of an autoclass

View File

@ -40,11 +40,6 @@ from novaclient import utils
osprofiler_profiler = importutils.try_import("osprofiler.profiler")
osprofiler_web = importutils.try_import("osprofiler.web")
# TODO(jichenjc): when an extension in contrib is moved to core extension,
# Add the name into the following list, then after last patch merged,
# remove the whole function
extensions_ignored_name = ["__init__"]
class SessionClient(adapter.LegacyJsonAdapter):
@ -178,14 +173,6 @@ def discover_extensions(*args, **kwargs):
"""Returns the list of extensions, which can be discovered by python path
and by entry-point 'novaclient.extension'.
"""
# TODO(mriedem): Remove support for 'only_contrib' in Queens.
if 'only_contrib' in kwargs and kwargs['only_contrib']:
warnings.warn(_('Discovering extensions only by contrib path is no '
'longer supported since all contrib extensions '
'have either been made required or removed. The '
'only_contrib argument is deprecated and will be '
'removed in a future release.'))
return []
chain = itertools.chain(_discover_via_python_path(),
_discover_via_entry_points())
return [ext.Extension(name, module) for name, module in chain]

View File

@ -109,23 +109,6 @@ class ClientsUtilsTest(utils.TestCase):
mock_discover_via_entry_points.assert_called_once_with()
self.assertEqual([mock_extension()] * 4, result)
@mock.patch('novaclient.client.warnings')
@mock.patch("novaclient.client._discover_via_entry_points")
@mock.patch("novaclient.client._discover_via_python_path")
@mock.patch("novaclient.extension.Extension")
def test_discover_extensions_only_contrib(
self, mock_extension, mock_discover_via_python_path,
mock_discover_via_entry_points, mock_warnings):
version = novaclient.api_versions.APIVersion("2.0")
self.assertEqual([], novaclient.client.discover_extensions(
version, only_contrib=True))
self.assertFalse(mock_discover_via_python_path.called)
self.assertFalse(mock_discover_via_entry_points.called)
self.assertFalse(mock_extension.called)
self.assertTrue(mock_warnings.warn.called)
@mock.patch("novaclient.client.warnings")
def test__check_arguments(self, mock_warnings):
release = "Coolest"

View File

@ -23,7 +23,6 @@ from novaclient.v2 import aggregates
from novaclient.v2 import assisted_volume_snapshots
from novaclient.v2 import availability_zones
from novaclient.v2 import cells
from novaclient.v2 import contrib
from novaclient.v2 import flavor_access
from novaclient.v2 import flavors
from novaclient.v2 import hypervisors
@ -182,15 +181,6 @@ class Client(object):
# Add in any extensions...
if extensions:
for extension in extensions:
# do not import extensions from contrib directory twice.
if extension.name in contrib.V2_0_EXTENSIONS:
# NOTE(andreykurilin): this message looks more like
# warning or note, but it is not critical, so let's do
# not flood "warning" logging level and use just debug..
self.logger.debug("Nova 2.0 extenstion '%s' is auto-loaded"
" by default. You do not need to specify"
" it manually.", extension.name)
continue
if extension.manager_class:
setattr(self, extension.name,
extension.manager_class(self))

View File

@ -1,51 +0,0 @@
# 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.
import inspect
import warnings
from novaclient.i18n import _
# NOTE(andreykurilin): "tenant_networks" extension excluded
# here deliberately. It was deprecated separately from deprecation
# extension mechanism and I prefer to not auto-load it by default
# (V2_0_EXTENSIONS is designed for such behaviour).
V2_0_EXTENSIONS = {
'assisted_volume_snapshots':
'novaclient.v2.assisted_volume_snapshots',
'cells': 'novaclient.v2.cells',
'instance_action': 'novaclient.v2.instance_action',
'list_extensions': 'novaclient.v2.list_extensions',
'migrations': 'novaclient.v2.migrations',
'server_external_events': 'novaclient.v2.server_external_events',
}
def warn(alternative=True):
"""Prints warning msg for contrib modules."""
frm = inspect.stack()[1]
module_name = inspect.getmodule(frm[0]).__name__
if module_name.startswith("novaclient.v2.contrib."):
if alternative:
new_module_name = module_name.replace("contrib.", "")
msg = _("Module `%(module)s` is deprecated as of OpenStack "
"Ocata in favor of `%(new_module)s` and will be "
"removed after OpenStack Pike.") % {
"module": module_name, "new_module": new_module_name}
if not alternative:
msg = _("Module `%s` is deprecated as of OpenStack Ocata "
"All shell commands were moved to "
"`novaclient.v2.shell` and will be automatically "
"loaded.") % module_name
warnings.warn(msg)

View File

@ -1,29 +0,0 @@
# Copyright (C) 2013, Red Hat, Inc.
#
# 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.
"""
Assisted volume snapshots - to be used by Cinder and not end users.
"""
from novaclient.v2 import assisted_volume_snapshots
from novaclient.v2 import contrib
AssistedSnapshotManager = assisted_volume_snapshots.AssistedSnapshotManager
Snapshot = assisted_volume_snapshots.Snapshot
manager_class = AssistedSnapshotManager
name = 'assisted_volume_snapshots'
contrib.warn()

View File

@ -1,23 +0,0 @@
# Copyright 2013 Rackspace Hosting
# 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.
from novaclient.v2 import cells
from novaclient.v2 import contrib
Cell = cells.Cell
CellsManager = cells.CellsManager
contrib.warn()

View File

@ -1,17 +0,0 @@
# Copyright 2013 OpenStack Foundation
#
# 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.
from novaclient.v2 import contrib
contrib.warn(alternative=False)

View File

@ -1,22 +0,0 @@
# Copyright 2013 Rackspace Hosting
# 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.
from novaclient.v2 import contrib
from novaclient.v2 import shell
EvacuateHostResponse = shell.EvacuateHostResponse
contrib.warn(alternative=False)

View File

@ -1,18 +0,0 @@
# Copyright 2014 OpenStack Foundation
# 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.
from novaclient.v2 import contrib
contrib.warn(alternative=False)

View File

@ -1,22 +0,0 @@
# Copyright 2013 Rackspace Hosting
# 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.
from novaclient.v2 import contrib
from novaclient.v2 import shell
HostServersMigrateResponse = shell.HostServersMigrateResponse
contrib.warn(alternative=False)

View File

@ -1,22 +0,0 @@
# Copyright 2013 Rackspace Hosting
# 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.
from novaclient.v2 import contrib
from novaclient.v2 import instance_action
InstanceActionManager = instance_action.InstanceActionManager
contrib.warn()

View File

@ -1,23 +0,0 @@
# Copyright 2011 OpenStack Foundation
# 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.
from novaclient.v2 import contrib
from novaclient.v2 import list_extensions
ListExtResource = list_extensions.ListExtResource
ListExtManager = list_extensions.ListExtManager
contrib.warn()

View File

@ -1,19 +0,0 @@
# Copyright 2013 Rackspace Hosting
# 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.
from novaclient.v2 import contrib
contrib.warn(alternative=False)

View File

@ -1,24 +0,0 @@
# 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.
"""
migration interface
"""
from novaclient.v2 import contrib
from novaclient.v2 import migrations
Migration = migrations.Migration
MigrationManager = migrations.MigrationManager
contrib.warn()

View File

@ -1,29 +0,0 @@
# Copyright (C) 2014, Red Hat, Inc.
#
# 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.
"""
External event triggering for servers, not to be used by users.
"""
from novaclient.v2 import contrib
from novaclient.v2 import server_external_events
Event = server_external_events.Event
ServerExternalEventManager = server_external_events.ServerExternalEventManager
manager_class = ServerExternalEventManager
name = 'server_external_events'
contrib.warn()

View File

@ -0,0 +1,5 @@
---
upgrade:
- All modules of ``novaclient.v2.contrib`` have been removed.
- The ``only_contrib`` parameter for the
``novaclient.client.discover_extensions`` method is no longer valid.