diff --git a/novaclient/tests/functional/v2/legacy/test_readonly_nova.py b/novaclient/tests/functional/v2/legacy/test_readonly_nova.py index a91188b87..57d4107a1 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 aeb8a5601..fd9cbfac7 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 0a6c223e5..d71bf1943 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 753dd127f..23f5486f6 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()) diff --git a/releasenotes/notes/deprecate-agent-d0f58718ad1782f6.yaml b/releasenotes/notes/deprecate-agent-d0f58718ad1782f6.yaml new file mode 100644 index 000000000..c43d92cec --- /dev/null +++ b/releasenotes/notes/deprecate-agent-d0f58718ad1782f6.yaml @@ -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.