summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2019-07-15 13:24:14 +0000
committerGerrit Code Review <review@openstack.org>2019-07-15 13:24:14 +0000
commitd354c76bd22debaceac987adcc235ae14bc8ff8f (patch)
treebaaed0eee4a1fc735eeb1e768e6337cb5ff14cd2
parent0b02be574322374bf1975be1ea38526764edd843 (diff)
parent3ac90a52737039fa027502376575d5ce792a018d (diff)
downloadpython-novaclient-d354c76bd22debaceac987adcc235ae14bc8ff8f.tar.gz
Merge "Deprecate cells v1 and extension commands and APIs"
-rw-r--r--novaclient/tests/functional/v2/legacy/test_readonly_nova.py6
-rw-r--r--novaclient/tests/unit/v2/test_cells.py20
-rw-r--r--novaclient/tests/unit/v2/test_list_extensions.py13
-rw-r--r--novaclient/tests/unit/v2/test_shell.py18
-rw-r--r--novaclient/v2/cells.py16
-rw-r--r--novaclient/v2/list_extensions.py14
-rw-r--r--novaclient/v2/shell.py24
-rw-r--r--releasenotes/notes/deprecate-cellsv1-extension-16482759993d112f.yaml11
8 files changed, 109 insertions, 13 deletions
diff --git a/novaclient/tests/functional/v2/legacy/test_readonly_nova.py b/novaclient/tests/functional/v2/legacy/test_readonly_nova.py
index a31982e5..7f81e41a 100644
--- a/novaclient/tests/functional/v2/legacy/test_readonly_nova.py
+++ b/novaclient/tests/functional/v2/legacy/test_readonly_nova.py
@@ -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')
diff --git a/novaclient/tests/unit/v2/test_cells.py b/novaclient/tests/unit/v2/test_cells.py
index 5a47e1c6..ff898f53 100644
--- a/novaclient/tests/unit/v2/test_cells.py
+++ b/novaclient/tests/unit/v2/test_cells.py
@@ -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)
diff --git a/novaclient/tests/unit/v2/test_list_extensions.py b/novaclient/tests/unit/v2/test_list_extensions.py
index 60783b31..de299cd0 100644
--- a/novaclient/tests/unit/v2/test_list_extensions.py
+++ b/novaclient/tests/unit/v2/test_list_extensions.py
@@ -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)
diff --git a/novaclient/tests/unit/v2/test_shell.py b/novaclient/tests/unit/v2/test_shell.py
index 30ee8bc7..801ac43c 100644
--- a/novaclient/tests/unit/v2/test_shell.py
+++ b/novaclient/tests/unit/v2/test_shell.py
@@ -3888,16 +3888,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')
diff --git a/novaclient/v2/cells.py b/novaclient/v2/cells.py
index e6a16667..44cadddb 100644
--- a/novaclient/v2/cells.py
+++ b/novaclient/v2/cells.py
@@ -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")
diff --git a/novaclient/v2/list_extensions.py b/novaclient/v2/list_extensions.py
index faeead60..e7043e31 100644
--- a/novaclient/v2/list_extensions.py
+++ b/novaclient/v2/list_extensions.py
@@ -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')
diff --git a/novaclient/v2/shell.py b/novaclient/v2/shell.py
index 3ab22032..649097be 100644
--- a/novaclient/v2/shell.py
+++ b/novaclient/v2/shell.py
@@ -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]
@@ -4876,7 +4891,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())
@@ -4887,7 +4903,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'],
@@ -5321,8 +5338,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)
diff --git a/releasenotes/notes/deprecate-cellsv1-extension-16482759993d112f.yaml b/releasenotes/notes/deprecate-cellsv1-extension-16482759993d112f.yaml
new file mode 100644
index 00000000..a26ad849
--- /dev/null
+++ b/releasenotes/notes/deprecate-cellsv1-extension-16482759993d112f.yaml
@@ -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.