diff --git a/cinderclient/shell.py b/cinderclient/shell.py index b648fbce0..ecc586298 100644 --- a/cinderclient/shell.py +++ b/cinderclient/shell.py @@ -46,6 +46,7 @@ from cinderclient import exceptions as exc from cinderclient import utils +DEFAULT_MAJOR_OS_VOLUME_API_VERSION = "3" DEFAULT_CINDER_ENDPOINT_TYPE = 'publicURL' V1_SHELL = 'cinderclient.v1.shell' V2_SHELL = 'cinderclient.v2.shell' @@ -527,8 +528,10 @@ class OpenStackCinderShell(object): '--help' in argv) or ('-h' in argv) or not argv if not options.os_volume_api_version: - api_version = api_versions.get_api_version( - api_versions.MAX_VERSION) + use_version = DEFAULT_MAJOR_OS_VOLUME_API_VERSION + if do_help: + use_version = api_versions.MAX_VERSION + api_version = api_versions.get_api_version(use_version) else: api_version = api_versions.get_api_version( options.os_volume_api_version) diff --git a/cinderclient/tests/unit/test_shell.py b/cinderclient/tests/unit/test_shell.py index 6156f36e5..e611ace7a 100644 --- a/cinderclient/tests/unit/test_shell.py +++ b/cinderclient/tests/unit/test_shell.py @@ -114,9 +114,11 @@ class ShellTest(utils.TestCase): self.assertRaises(exceptions.CommandError, self.shell, 'help foofoo') def test_help(self): + # Some expected help output, including microversioned commands required = [ '.*?^usage: ', '.*?(?m)^\s+create\s+Creates a volume.', + '.*?(?m)^\s+summary\s+Get volumes summary.', '.*?(?m)^Run "cinder help SUBCOMMAND" for help on a subcommand.', ] help_text = self.shell('help') @@ -134,6 +136,16 @@ class ShellTest(utils.TestCase): self.assertThat(help_text, matchers.MatchesRegex(r, re.DOTALL | re.MULTILINE)) + def test_help_on_subcommand_mv(self): + required = [ + '.*?^usage: cinder summary', + '.*?(?m)^Get volumes summary.', + ] + help_text = self.shell('help summary') + for r in required: + self.assertThat(help_text, + matchers.MatchesRegex(r, re.DOTALL | re.MULTILINE)) + @ddt.data('backup-create --help', '--help backup-create') def test_dash_dash_help_on_subcommand(self, cmd): required = ['.*?^Creates a volume backup.']