From 165465da1e8203964089399b8133c57de4808a13 Mon Sep 17 00:00:00 2001 From: "wu.chunyang" Date: Tue, 13 Aug 2019 22:07:16 +0800 Subject: [PATCH] Add group list command group list is a commonly used command, add this command here. Change-Id: I024633b9ffcf20b5f9f30d4c6e8a3ac92d6d58b6 --- kolla_cli/commands/group.py | 19 +++++++++++++++++++ setup.cfg | 1 + 2 files changed, 20 insertions(+) diff --git a/kolla_cli/commands/group.py b/kolla_cli/commands/group.py index fc272ee..120118e 100644 --- a/kolla_cli/commands/group.py +++ b/kolla_cli/commands/group.py @@ -114,6 +114,25 @@ class GroupRemovehost(Command): raise Exception(traceback.format_exc()) +class GroupList(Lister): + """Only list all groups """ + + def take_action(self, parsed_args): + try: + data = [('',)] + groups = CLIENT.group_get_all() + if groups: + data = [] + for group in groups: + data.append((group.get_name(),)) + data = convert_lists_to_string(data, parsed_args) + return ((u._('Group'), ), sorted(data)) + except ClientException as e: + raise CommandError(str(e)) + except Exception as e: + raise Exception(traceback.format_exc()) + + class GroupListhosts(Lister): """List all groups and their hosts.""" diff --git a/setup.cfg b/setup.cfg index 90cbb3b..a1335d9 100644 --- a/setup.cfg +++ b/setup.cfg @@ -45,6 +45,7 @@ kolla.cli = getdeploy = kolla_cli.commands.mode:Getdeploy group_add = kolla_cli.commands.group:GroupAdd group_addhost = kolla_cli.commands.group:GroupAddhost + group_list = kolla_cli.commands.group:GroupList group_listhosts = kolla_cli.commands.group:GroupListhosts group_listservices = kolla_cli.commands.group:GroupListservices group_remove = kolla_cli.commands.group:GroupRemove