From 444ffbeaa9c110b2bd79b93800bd9a24b38bb725 Mon Sep 17 00:00:00 2001
From: zwei <leidong@unitedstack.com>
Date: Thu, 17 Mar 2016 18:35:08 +0800
Subject: [PATCH] Fix v2 so that you can see the default help info

you can see the default help informatiion is v2
subcommand information if input glance command

Co-Authored-By: Stuart McLaren <stuart.mclaren@hp.com>

Closes-bug: #1563649
Change-Id: I7d227f3e68aa555b2e25848618f76df4872af35d
---
 glanceclient/shell.py                 |  1 +
 glanceclient/tests/unit/test_shell.py | 11 ++++++++---
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/glanceclient/shell.py b/glanceclient/shell.py
index 86e61077..10b22def 100755
--- a/glanceclient/shell.py
+++ b/glanceclient/shell.py
@@ -535,6 +535,7 @@ class OpenStackImagesShell(object):
         # Handle top-level --help/-h before attempting to parse
         # a command off the command line
         if options.help or not argv:
+            parser = _get_subparser(api_version)
             self.do_help(options, parser=parser)
             return 0
 
diff --git a/glanceclient/tests/unit/test_shell.py b/glanceclient/tests/unit/test_shell.py
index 2a33dc00..fb2ca9b3 100644
--- a/glanceclient/tests/unit/test_shell.py
+++ b/glanceclient/tests/unit/test_shell.py
@@ -523,9 +523,14 @@ class ShellTest(testutils.TestCase):
         except SystemExit:
             self.fail('Unexpected SystemExit')
 
-        # We expect the normal usage as a result
-        self.assertIn('Command-line interface to the OpenStack Images API',
-                      sys.stdout.getvalue())
+        # We expect the normal v2 usage as a result
+        expected = ['Command-line interface to the OpenStack Images API',
+                    'image-list',
+                    'image-deactivate',
+                    'location-add']
+        for output in expected:
+            self.assertIn(output,
+                          sys.stdout.getvalue())
 
 
 class ShellTestWithKeystoneV3Auth(ShellTest):