list-channels CLI command

Related: https://pagure.io/koji/issue/437
This commit is contained in:
Tomas Kopecek 2017-05-31 13:35:43 +02:00 committed by Mike McLean
parent 6165d5dda3
commit c5f910ffd9
3 changed files with 62 additions and 1 deletions

View file

@ -709,7 +709,7 @@ def handle_add_host_to_channel(options, session, args):
usage = _("usage: %prog add-host-to-channel [options] hostname channel")
usage += _("\n(Specify the --help global option for a list of other help options)")
parser = OptionParser(usage=usage)
parser.add_option("--list", action="store_true", help=_("List possible channels"))
parser.add_option("--list", action="store_true", help=optparse.SUPPRESS_HELP)
parser.add_option("--new", action="store_true", help=_("Create channel if needed"))
(options, args) = parser.parse_args(args)
if not options.list and len(args) != 2:
@ -3189,6 +3189,25 @@ def handle_unblock_group_req(options, session, args):
activate_session(session)
session.groupReqListUnblock(tag, group, req)
def anon_handle_list_channels(options, session, args):
"[info] Print channels listing"
usage = _("usage: %prog list-channels")
usage += _("\n(Specify the --help global option for a list of other help options)")
parser = OptionParser(usage=usage)
parser.add_option("--quiet", action="store_true", help=_("Do not print header information"), default=options.quiet)
(options, args) = parser.parse_args(args)
activate_session(session)
channels = session.listChannels()
session.multicall = True
for channel in channels:
session.listHosts(channelID=channel['id'])
for channel, hosts in zip(channels, session.multiCall()):
channel['hosts'] = len(hosts[0])
if not options.quiet:
print('Channel Hosts')
for channel in channels:
print("%(name)-15s %(hosts) 5d" % channel)
def anon_handle_list_hosts(options, session, args):
"[info] Print the host listing"
usage = _("usage: %prog list-hosts [options]")