Add group list command
group list is a commonly used command, add this command here. Change-Id: I024633b9ffcf20b5f9f30d4c6e8a3ac92d6d58b6
This commit is contained in:
parent
c099b2ea69
commit
165465da1e
|
@ -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."""
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue