Deprecate agent commands and APIs

The os-agents APIs have been removed by the following change.

  I9512f605dd2b3b0e88c951ed086250d57056303d

This patch makes commands related to the APIs deprecated
in accordance with the following policy.

* https://docs.openstack.org/python-novaclient/latest/contributor/deprecation-policy.html

The API bindings related to the APIs remains as they are
because python-openstackclient depends on the API bindings.

Change-Id: I89d7877e23e8802fe77987a7b24ea247e08d5218
Signed-off-by: Takashi Natsume <takanattie@gmail.com>
This commit is contained in:
Takashi Natsume 2021-01-03 23:06:46 +09:00
parent e85d845b1a
commit 9b474afdb2
5 changed files with 65 additions and 12 deletions

View File

@ -91,11 +91,19 @@ class SimpleReadOnlyNovaClientTest(base.ClientTestBase):
self.assertIn(
"This resource is no longer available. "
"No forwarding address is given. (HTTP 410)", str(ex))
self.assertIn(
"This command has been deprecated since 23.0.0 Wallaby Release "
"and will be removed in the first major release "
"after the Nova server 24.0.0 X release.", str(ex.stderr))
ex = self.assertRaises(exceptions.CommandFailed,
self.nova, 'agent-list', flags='--debug')
self.assertIn(
"This resource is no longer available. "
"No forwarding address is given. (HTTP 410)", str(ex))
self.assertIn(
"This command has been deprecated since 23.0.0 Wallaby Release "
"and will be removed in the first major release "
"after the Nova server 24.0.0 X release.", str(ex.stderr))
def test_migration_list(self):
self.nova('migration-list')

View File

@ -118,14 +118,18 @@ class ShellTest(utils.TestCase):
return self.shell.cs.assert_not_called(method, url, body)
def test_agents_list_with_hypervisor(self):
self.run_command('agent-list --hypervisor xen')
_, err = self.run_command('agent-list --hypervisor xen')
self.assert_called('GET', '/os-agents?hypervisor=xen')
self.assertIn(
'This command has been deprecated since 23.0.0 Wallaby Release '
'and will be removed in the first major release '
'after the Nova server 24.0.0 X release.', err)
def test_agents_create(self):
self.run_command('agent-create win x86 7.0 '
'/xxx/xxx/xxx '
'add6bb58e139be103324d04d82d8f546 '
'kvm')
_, err = self.run_command('agent-create win x86 7.0 '
'/xxx/xxx/xxx '
'add6bb58e139be103324d04d82d8f546 '
'kvm')
self.assert_called(
'POST', '/os-agents',
{'agent': {
@ -135,19 +139,31 @@ class ShellTest(utils.TestCase):
'version': '7.0',
'url': '/xxx/xxx/xxx',
'md5hash': 'add6bb58e139be103324d04d82d8f546'}})
self.assertIn(
'This command has been deprecated since 23.0.0 Wallaby Release '
'and will be removed in the first major release '
'after the Nova server 24.0.0 X release.', err)
def test_agents_delete(self):
self.run_command('agent-delete 1')
_, err = self.run_command('agent-delete 1')
self.assert_called('DELETE', '/os-agents/1')
self.assertIn(
'This command has been deprecated since 23.0.0 Wallaby Release '
'and will be removed in the first major release '
'after the Nova server 24.0.0 X release.', err)
def test_agents_modify(self):
self.run_command('agent-modify 1 8.0 /yyy/yyyy/yyyy '
'add6bb58e139be103324d04d82d8f546')
_, err = self.run_command('agent-modify 1 8.0 /yyy/yyyy/yyyy '
'add6bb58e139be103324d04d82d8f546')
self.assert_called('PUT', '/os-agents/1',
{"para": {
"url": "/yyy/yyyy/yyyy",
"version": "8.0",
"md5hash": "add6bb58e139be103324d04d82d8f546"}})
self.assertIn(
'This command has been deprecated since 23.0.0 Wallaby Release '
'and will be removed in the first major release '
'after the Nova server 24.0.0 X release.', err)
def test_boot(self):
self.run_command('boot --flavor 1 --image %s '

View File

@ -19,6 +19,11 @@ agent interface
from novaclient import base
# NOTE(takashin): The os-agents APIs have been removed
# in https://review.opendev.org/c/openstack/nova/+/749309 .
# But the following API bindings remains as ther are
# because the python-openstackclient depends on them.
class Agent(base.Resource):
def __repr__(self):

View File

@ -55,6 +55,14 @@ def emit_duplicated_image_with_warning(img, image_with):
file=sys.stderr)
# TODO(takashin): Remove this along with the deprecated commands in the first
# major python-novaclient release AFTER the nova server 24.0.0 X release.
def _emit_agent_deprecation_warning():
print('This command has been deprecated since 23.0.0 Wallaby Release '
'and will be removed in the first major release '
'after the Nova server 24.0.0 X release.', file=sys.stderr)
CLIENT_BDM2_KEYS = {
'id': 'uuid',
'source': 'source_type',
@ -3411,7 +3419,8 @@ def do_usage(cs, args):
default=None,
help=_('Type of hypervisor.'))
def do_agent_list(cs, args):
"""List all builds."""
"""DEPRECATED List all builds."""
_emit_agent_deprecation_warning()
result = cs.agents.list(args.hypervisor)
columns = ["Agent_id", "Hypervisor", "OS", "Architecture", "Version",
'Md5hash', 'Url']
@ -3432,7 +3441,8 @@ def do_agent_list(cs, args):
default='xen',
help=_('Type of hypervisor.'))
def do_agent_create(cs, args):
"""Create new agent build."""
"""DEPRECATED Create new agent build."""
_emit_agent_deprecation_warning()
result = cs.agents.create(args.os, args.architecture,
args.version, args.url,
args.md5hash, args.hypervisor)
@ -3441,7 +3451,8 @@ def do_agent_create(cs, args):
@utils.arg('id', metavar='<id>', help=_('ID of the agent-build.'))
def do_agent_delete(cs, args):
"""Delete existing agent build."""
"""DEPRECATED Delete existing agent build."""
_emit_agent_deprecation_warning()
cs.agents.delete(args.id)
@ -3450,7 +3461,8 @@ def do_agent_delete(cs, args):
@utils.arg('url', metavar='<url>', help=_('URL'))
@utils.arg('md5hash', metavar='<md5hash>', help=_('MD5 hash.'))
def do_agent_modify(cs, args):
"""Modify existing agent build."""
"""DEPRECATED Modify existing agent build."""
_emit_agent_deprecation_warning()
result = cs.agents.update(args.id, args.version,
args.url, args.md5hash)
utils.print_dict(result.to_dict())

View File

@ -0,0 +1,12 @@
---
deprecations:
- |
The following CLIs are deprecated.
- ``nova agent-create``
- ``nova agent-delete``
- ``nova agent-list``
- ``nova agent-modify``
The CLIs will be removed in the first major release after Nova 24.0.0 X
is released.