From 9b474afdb2e15d058babe82e50efe6c93c2e94a2 Mon Sep 17 00:00:00 2001 From: Takashi Natsume Date: Sun, 3 Jan 2021 23:06:46 +0900 Subject: 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 --- .../functional/v2/legacy/test_readonly_nova.py | 8 ++++++ novaclient/tests/unit/v2/test_shell.py | 32 ++++++++++++++++------ novaclient/v2/agents.py | 5 ++++ novaclient/v2/shell.py | 20 +++++++++++--- 4 files changed, 53 insertions(+), 12 deletions(-) (limited to 'novaclient') diff --git a/novaclient/tests/functional/v2/legacy/test_readonly_nova.py b/novaclient/tests/functional/v2/legacy/test_readonly_nova.py index a91188b8..57d4107a 100644 --- a/novaclient/tests/functional/v2/legacy/test_readonly_nova.py +++ b/novaclient/tests/functional/v2/legacy/test_readonly_nova.py @@ -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') diff --git a/novaclient/tests/unit/v2/test_shell.py b/novaclient/tests/unit/v2/test_shell.py index aeb8a560..fd9cbfac 100644 --- a/novaclient/tests/unit/v2/test_shell.py +++ b/novaclient/tests/unit/v2/test_shell.py @@ -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 ' diff --git a/novaclient/v2/agents.py b/novaclient/v2/agents.py index 0a6c223e..d71bf194 100644 --- a/novaclient/v2/agents.py +++ b/novaclient/v2/agents.py @@ -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): diff --git a/novaclient/v2/shell.py b/novaclient/v2/shell.py index 753dd127..23f5486f 100644 --- a/novaclient/v2/shell.py +++ b/novaclient/v2/shell.py @@ -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='', 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='', help=_('URL')) @utils.arg('md5hash', metavar='', 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()) -- cgit v1.2.1