summaryrefslogtreecommitdiff
path: root/openstackclient/common
diff options
context:
space:
mode:
Diffstat (limited to 'openstackclient/common')
-rw-r--r--openstackclient/common/commandmanager.py2
-rw-r--r--openstackclient/common/exceptions.py2
-rw-r--r--openstackclient/common/module.py20
-rw-r--r--openstackclient/common/utils.py2
4 files changed, 21 insertions, 5 deletions
diff --git a/openstackclient/common/commandmanager.py b/openstackclient/common/commandmanager.py
index b809d63a..c190e33e 100644
--- a/openstackclient/common/commandmanager.py
+++ b/openstackclient/common/commandmanager.py
@@ -56,4 +56,4 @@ class CommandManager(cliff.commandmanager.CommandManager):
)
group_list.append(cmd_name)
return group_list
- return self.commands.keys()
+ return list(self.commands.keys())
diff --git a/openstackclient/common/exceptions.py b/openstackclient/common/exceptions.py
index 5f5f5ab1..ee0f7a11 100644
--- a/openstackclient/common/exceptions.py
+++ b/openstackclient/common/exceptions.py
@@ -122,7 +122,7 @@ def from_response(response, body):
cls = _code_map.get(response.status, ClientException)
if body:
if hasattr(body, 'keys'):
- error = body[body.keys()[0]]
+ error = body[list(body.keys())[0]]
message = error.get('message')
details = error.get('details')
else:
diff --git a/openstackclient/common/module.py b/openstackclient/common/module.py
index a3dea5da..30c67c68 100644
--- a/openstackclient/common/module.py
+++ b/openstackclient/common/module.py
@@ -19,6 +19,7 @@ import six
import sys
from openstackclient.common import command
+from openstackclient.common import utils
class ListCommand(command.Lister):
@@ -29,9 +30,24 @@ class ListCommand(command.Lister):
def take_action(self, parsed_args):
cm = self.app.command_manager
groups = cm.get_command_groups()
-
+ groups = sorted(groups)
columns = ('Command Group', 'Commands')
- return (columns, ((c, cm.get_command_names(group=c)) for c in groups))
+
+ commands = []
+ for group in groups:
+ command_names = cm.get_command_names(group)
+ command_names = sorted(command_names)
+
+ if command_names != []:
+
+ # TODO(bapalm): Fix this when cliff properly supports
+ # handling the detection rather than using the hard-code below.
+ if parsed_args.formatter == 'table':
+ command_names = utils.format_list(command_names, "\n")
+
+ commands.append((group, command_names))
+
+ return (columns, commands)
class ListModule(command.ShowOne):
diff --git a/openstackclient/common/utils.py b/openstackclient/common/utils.py
index 840da402..c6ed6a71 100644
--- a/openstackclient/common/utils.py
+++ b/openstackclient/common/utils.py
@@ -281,7 +281,7 @@ def get_client_class(api_name, version, version_map):
client_path = version_map[str(version)]
except (KeyError, ValueError):
msg = "Invalid %s client version '%s'. must be one of: %s" % (
- (api_name, version, ', '.join(version_map.keys())))
+ (api_name, version, ', '.join(list(version_map.keys()))))
raise exceptions.UnsupportedVersion(msg)
return importutils.import_class(client_path)