Deprecate cells v1 and extension commands and APIs

The API extension has been deprecated since 12.0.0 Liberty release (*1)
and the cells v1 has been deprecated since 16.0.0 Pike release (*2)
in the nova side.
The API extension has already been removed (merged into main
controllers and schema) since 19.0.0 Stein release (*3) and
the cells v1 APIs has already been removed since
Iddb519008515f591cf1d884872a5887afbe766f2.

In the python-novaclient side,
deprecate commands and API bindings related to
the API extension and the cells v1 at first.
Then the CLIs and API bindings will be removed in the first major
release after Nova 20.0.0 Train is released.

*1: I084444b11dceda7cf8f88c157aa67d36490fce49
*2: I1a173f7ce0715e684850e030c358e8175fa8724c
*3: https://review.opendev.org/#/q/topic:bp/api-extensions-merge-stein

Change-Id: I8dc4df95ac7f6974c5280e4107e449d04cd1402e
Closes-Bug: #1835699
This commit is contained in:
Takashi NATSUME 2019-07-08 10:34:37 +09:00
parent 66611f26d3
commit 3ac90a5273
8 changed files with 109 additions and 13 deletions

View File

@ -86,7 +86,11 @@ class SimpleReadOnlyNovaClientTest(base.ClientTestBase):
self.nova('help')
def test_admin_list_extensions(self):
self.nova('list-extensions')
output = self.nova('list-extensions', merge_stderr=True)
self.assertIn(
'The API extension interface has been deprecated. This command '
'will be removed in the first major release after '
'the Nova server 20.0.0 Train release.', output)
def test_agent_list(self):
self.nova('agent-list')

View File

@ -13,29 +13,43 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from novaclient import api_versions
from novaclient.tests.unit import utils
from novaclient.tests.unit.v2 import fakes
CELL_V1_DEPRECATION_WARNING = (
'The cells v1 interface has been deprecated in Nova since 16.0.0 Pike '
'Release. This API binding will be removed in the first major release '
'after the Nova server 20.0.0 Train release.')
@mock.patch('warnings.warn')
class CellsExtensionTests(utils.TestCase):
def setUp(self):
super(CellsExtensionTests, self).setUp()
self.cs = fakes.FakeClient(api_versions.APIVersion("2.1"))
def test_get_cells(self):
def test_get_cells(self, mock_warn):
cell_name = 'child_cell'
cell = self.cs.cells.get(cell_name)
self.assert_request_id(cell, fakes.FAKE_REQUEST_ID_LIST)
self.cs.assert_called('GET', '/os-cells/%s' % cell_name)
mock_warn.assert_called_once_with(CELL_V1_DEPRECATION_WARNING,
DeprecationWarning)
def test_get_capacities_for_a_given_cell(self):
def test_get_capacities_for_a_given_cell(self, mock_warn):
cell_name = 'child_cell'
ca = self.cs.cells.capacities(cell_name)
self.assert_request_id(ca, fakes.FAKE_REQUEST_ID_LIST)
self.cs.assert_called('GET', '/os-cells/%s/capacities' % cell_name)
mock_warn.assert_called_once_with(CELL_V1_DEPRECATION_WARNING,
DeprecationWarning)
def test_get_capacities_for_all_cells(self):
def test_get_capacities_for_all_cells(self, mock_warn):
ca = self.cs.cells.capacities()
self.assert_request_id(ca, fakes.FAKE_REQUEST_ID_LIST)
self.cs.assert_called('GET', '/os-cells/capacities')
mock_warn.assert_called_once_with(CELL_V1_DEPRECATION_WARNING,
DeprecationWarning)

View File

@ -11,6 +11,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from novaclient import api_versions
from novaclient.tests.unit import utils
from novaclient.tests.unit.v2 import fakes
@ -21,10 +23,19 @@ class ListExtensionsTests(utils.TestCase):
super(ListExtensionsTests, self).setUp()
self.cs = fakes.FakeClient(api_versions.APIVersion("2.1"))
def test_list_extensions(self):
@mock.patch('warnings.warn')
def test_list_extensions(self, mock_warn):
all_exts = self.cs.list_extensions.show_all()
self.assert_request_id(all_exts, fakes.FAKE_REQUEST_ID_LIST)
self.cs.assert_called('GET', '/extensions')
self.assertGreater(len(all_exts), 0)
warning_message = (
'The API extension interface has been deprecated since 12.0.0 '
'Liberty Release. This API binding will be removed in the first '
'major release after the Nova server 20.0.0 Train release.')
mock_warn.assert_called_once_with(warning_message, DeprecationWarning)
for r in all_exts:
mock_warn.reset_mock()
self.assertGreater(len(r.summary), 0)
mock_warn.assert_called_once_with(warning_message,
DeprecationWarning)

View File

@ -3811,16 +3811,28 @@ class ShellTest(utils.TestCase):
'/2016-12-10%2013%3A59%3A59.999999')
def test_cell_show(self):
self.run_command('cell-show child_cell')
_, err = self.run_command('cell-show child_cell')
self.assert_called('GET', '/os-cells/child_cell')
self.assertIn(
'The cells v1 interface has been deprecated. This command will be '
'removed in the first major release after the Nova server 20.0.0 '
'Train release.', err)
def test_cell_capacities_with_cell_name(self):
self.run_command('cell-capacities --cell child_cell')
_, err = self.run_command('cell-capacities --cell child_cell')
self.assert_called('GET', '/os-cells/child_cell/capacities')
self.assertIn(
'The cells v1 interface has been deprecated. This command will be '
'removed in the first major release after the Nova server 20.0.0 '
'Train release.', err)
def test_cell_capacities_without_cell_name(self):
self.run_command('cell-capacities')
_, err = self.run_command('cell-capacities')
self.assert_called('GET', '/os-cells/capacities')
self.assertIn(
'The cells v1 interface has been deprecated. This command will be '
'removed in the first major release after the Nova server 20.0.0 '
'Train release.', err)
def test_migration_list(self):
self.run_command('migration-list')

View File

@ -13,32 +13,44 @@
# License for the specific language governing permissions and limitations
# under the License.
import warnings
from novaclient import base
from novaclient.i18n import _
CELL_V1_DEPRECATION_WARNING = _(
'The cells v1 interface has been deprecated in Nova since 16.0.0 Pike '
'Release. This API binding will be removed in the first major release '
'after the Nova server 20.0.0 Train release.')
class Cell(base.Resource):
"""DEPRECATED"""
def __repr__(self):
return "<Cell: %s>" % self.name
class CellsManager(base.Manager):
"""DEPRECATED"""
resource_class = Cell
def get(self, cell_name):
"""
Get a cell.
DEPRECATED Get a cell.
:param cell_name: Name of the :class:`Cell` to get.
:rtype: :class:`Cell`
"""
warnings.warn(CELL_V1_DEPRECATION_WARNING, DeprecationWarning)
return self._get("/os-cells/%s" % cell_name, "cell")
def capacities(self, cell_name=None):
"""
Get capacities for a cell.
DEPRECATED Get capacities for a cell.
:param cell_name: Name of the :class:`Cell` to get capacities for.
:rtype: :class:`Cell`
"""
warnings.warn(CELL_V1_DEPRECATION_WARNING, DeprecationWarning)
path = ["%s/capacities" % cell_name, "capacities"][cell_name is None]
return self._get("/os-cells/%s" % path, "cell")

View File

@ -13,12 +13,23 @@
# License for the specific language governing permissions and limitations
# under the License.
import warnings
from novaclient import base
from novaclient.i18n import _
EXTENSION_DEPRECATION_WARNING = _(
'The API extension interface has been deprecated since 12.0.0 Liberty '
'Release. This API binding will be removed in the first major release '
'after the Nova server 20.0.0 Train release.')
class ListExtResource(base.Resource):
"""DEPRECATED"""
@property
def summary(self):
"""DEPRECATED"""
warnings.warn(EXTENSION_DEPRECATION_WARNING, DeprecationWarning)
descr = self.description.strip()
if not descr:
return '??'
@ -30,7 +41,10 @@ class ListExtResource(base.Resource):
class ListExtManager(base.Manager):
"""DEPRECATED"""
resource_class = ListExtResource
def show_all(self):
"""DEPRECATED"""
warnings.warn(EXTENSION_DEPRECATION_WARNING, DeprecationWarning)
return self._list("/extensions", 'extensions')

View File

@ -48,6 +48,21 @@ from novaclient.v2 import servers
logger = logging.getLogger(__name__)
CELL_V1_DEPRECATION_WARNING = _(
'The cells v1 interface has been deprecated. This command will be removed '
'in the first major release after the Nova server 20.0.0 Train release.')
EXTENSION_DEPRECATION_WARNING = _(
'The API extension interface has been deprecated. This command will be '
'removed in the first major release after the Nova server 20.0.0 Train '
'release.')
# NOTE(takashin): Remove this along with the deprecated commands in the first
# major python-novaclient release AFTER the nova server 20.0.0 Train release.
def _emit_deprecation_warning(message):
print(message, file=sys.stderr)
def emit_duplicated_image_with_warning(img, image_with):
img_uuid_list = [str(image.id) for image in img]
@ -4855,7 +4870,8 @@ def do_server_tag_delete_all(cs, args):
metavar='<cell-name>',
help=_('Name of the cell.'))
def do_cell_show(cs, args):
"""Show details of a given cell."""
"""DEPRECATED Show details of a given cell."""
_emit_deprecation_warning(CELL_V1_DEPRECATION_WARNING)
cell = cs.cells.get(args.cell)
utils.print_dict(cell.to_dict())
@ -4866,7 +4882,8 @@ def do_cell_show(cs, args):
help=_("Name of the cell to get the capacities."),
default=None)
def do_cell_capacities(cs, args):
"""Get cell capacities for all cells or a given cell."""
"""DEPRECATED Get cell capacities for all cells or a given cell."""
_emit_deprecation_warning(CELL_V1_DEPRECATION_WARNING)
cell = cs.cells.capacities(args.cell)
print(_("Ram Available: %s MiB") % cell.capacities['ram_free']['total_mb'])
utils.print_dict(cell.capacities['ram_free']['units_by_mb'],
@ -5300,8 +5317,9 @@ def do_instance_action_list(cs, args):
def do_list_extensions(cs, _args):
"""
List all the os-api extensions that are available.
DEPRECATED List all the os-api extensions that are available.
"""
_emit_deprecation_warning(EXTENSION_DEPRECATION_WARNING)
extensions = cs.list_extensions.show_all()
fields = ["Name", "Summary", "Alias", "Updated"]
utils.print_list(extensions, fields)

View File

@ -0,0 +1,11 @@
---
deprecations:
- |
The following CLIs and their backing API bindings are deprecated.
- ``nova list-extensions``
- ``nova cell-capacities``
- ``nova cell-show``
The CLIs and API bindings will be removed in the first major release after
Nova 20.0.0 Train is released.