From a061470a8edf282ab24911c20e6e033c97541cc5 Mon Sep 17 00:00:00 2001
From: rsritesh <rsritesh@rediff.com>
Date: Thu, 18 Jun 2015 13:08:34 +0200
Subject: [PATCH] Improve hypervisor-show print list

Current hypervisor-show <hostname> command does not properly list
when there is a long list of cpu info feature. The long list of
cpu info feature has comma-separated values.
Because of this user is not able to read the print out properly.

print_dict() has been changed to show a list with comma-separated
values properly.

Change-Id: Icc53439cecd3b5eee2340267a0447ce209d7b653
Closes-Bug: #1466435
---
 novaclient/tests/unit/test_utils.py | 14 ++++++++++++++
 novaclient/v2/shell.py              |  6 +++++-
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/novaclient/tests/unit/test_utils.py b/novaclient/tests/unit/test_utils.py
index 8bcb2bfcd..d4eff35c2 100644
--- a/novaclient/tests/unit/test_utils.py
+++ b/novaclient/tests/unit/test_utils.py
@@ -266,6 +266,20 @@ class PrintResultTestCase(test_utils.TestCase):
                          '+----------+----------------+\n',
                          sys.stdout.getvalue())
 
+    @mock.patch('sys.stdout', six.StringIO())
+    def test_print_large_dict_list(self):
+        dict = {'k': ['foo1', 'bar1', 'foo2', 'bar2',
+                      'foo3', 'bar3', 'foo4', 'bar4']}
+        utils.print_dict(dict, wrap=40)
+        self.assertEqual(
+            '+----------+------------------------------------------+\n'
+            '| Property | Value                                    |\n'
+            '+----------+------------------------------------------+\n'
+            '| k        | ["foo1", "bar1", "foo2", "bar2", "foo3", |\n'
+            '|          | "bar3", "foo4", "bar4"]                  |\n'
+            '+----------+------------------------------------------+\n',
+            sys.stdout.getvalue())
+
 
 class FlattenTestCase(test_utils.TestCase):
     def test_flattening(self):
diff --git a/novaclient/v2/shell.py b/novaclient/v2/shell.py
index 7af3fa8ab..c38d6081c 100644
--- a/novaclient/v2/shell.py
+++ b/novaclient/v2/shell.py
@@ -3667,10 +3667,14 @@ def do_hypervisor_servers(cs, args):
     'hypervisor',
     metavar='<hypervisor>',
     help=_('Name or ID of the hypervisor to show the details of.'))
+@cliutils.arg(
+    '--wrap', dest='wrap', metavar='<integer>', default=40,
+    help=_('Wrap the output to a specified length. '
+           'Default is 40 or 0 to disable'))
 def do_hypervisor_show(cs, args):
     """Display the details of the specified hypervisor."""
     hyper = _find_hypervisor(cs, args.hypervisor)
-    utils.print_dict(utils.flatten_dict(hyper._info))
+    utils.print_dict(utils.flatten_dict(hyper._info), wrap=int(args.wrap))
 
 
 @cliutils.arg(