From 3bf6f8fe99a988ef508edbac429b122f84bf1768 Mon Sep 17 00:00:00 2001 From: James Penick Date: Wed, 22 Jul 2015 16:23:31 +0000 Subject: [PATCH] rename root-password to set-password all references to `root password` have been changed to `admin password` but the `root-password` command remained. This changes it to `set-password` which is less ambiguous and consistent with existing commands `clear-password` and `get-password` Change-Id: I8683e4ecd4d9294989eb3d8d27d1fb75c16b261b --- novaclient/tests/unit/test_shell.py | 8 ++++---- novaclient/tests/unit/v2/test_shell.py | 8 ++++++++ novaclient/v2/shell.py | 6 ++++++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/novaclient/tests/unit/test_shell.py b/novaclient/tests/unit/test_shell.py index 4958023d7..d1f80c5a2 100644 --- a/novaclient/tests/unit/test_shell.py +++ b/novaclient/tests/unit/test_shell.py @@ -146,7 +146,7 @@ class ShellTest(utils.TestCase): def test_help(self): required = [ '.*?^usage: ', - '.*?^\s+root-password\s+Change the admin password', + '.*?^\s+set-password\s+Change the admin password', '.*?^See "nova help COMMAND" for help on a specific command', ] stdout, stderr = self.shell('help') @@ -156,11 +156,11 @@ class ShellTest(utils.TestCase): def test_help_on_subcommand(self): required = [ - '.*?^usage: nova root-password', + '.*?^usage: nova set-password', '.*?^Change the admin password', '.*?^Positional arguments:', ] - stdout, stderr = self.shell('help root-password') + stdout, stderr = self.shell('help set-password') for r in required: self.assertThat((stdout + stderr), matchers.MatchesRegex(r, re.DOTALL | re.MULTILINE)) @@ -168,7 +168,7 @@ class ShellTest(utils.TestCase): def test_help_no_options(self): required = [ '.*?^usage: ', - '.*?^\s+root-password\s+Change the admin password', + '.*?^\s+set-password\s+Change the admin password', '.*?^See "nova help COMMAND" for help on a specific command', ] stdout, stderr = self.shell('') diff --git a/novaclient/tests/unit/v2/test_shell.py b/novaclient/tests/unit/v2/test_shell.py index e5d8914a5..287e87873 100644 --- a/novaclient/tests/unit/v2/test_shell.py +++ b/novaclient/tests/unit/v2/test_shell.py @@ -1061,6 +1061,14 @@ class ShellTest(utils.TestCase): self.assert_called('POST', '/servers/1234/action', {'revertResize': None}) + @mock.patch('getpass.getpass', mock.Mock(return_value='p')) + def test_set_password(self): + self.run_command('set-password sample-server') + self.assert_called('POST', '/servers/1234/action', + {'changePassword': {'adminPass': 'p'}}) + + # root-password is deprecated, keeping this arond until it's removed + # entirely - penick @mock.patch('getpass.getpass', mock.Mock(return_value='p')) def test_root_password(self): self.run_command('root-password sample-server') diff --git a/novaclient/v2/shell.py b/novaclient/v2/shell.py index 32ba61164..36b0ce0c0 100644 --- a/novaclient/v2/shell.py +++ b/novaclient/v2/shell.py @@ -1730,6 +1730,12 @@ def do_refresh_network(cs, args): @cliutils.arg('server', metavar='', help=_('Name or ID of server.')) def do_root_password(cs, args): + """DEPRECATED, use set-password instead.""" + do_set_password(cs, args) + + +@cliutils.arg('server', metavar='', help=_('Name or ID of server.')) +def do_set_password(cs, args): """ Change the admin password for a server. """