#1425 add --show-channels listing to list-hosts
Merged 3 years ago by mikem. Opened 3 years ago by tkopecek.
tkopecek/koji issue1424  into  master

file modified
+18 -2
@@ -2771,6 +2771,7 @@ 

      parser.add_option("--not-enabled", action="store_false", dest="enabled", help=_("Limit to not enabled hosts"))

      parser.add_option("--quiet", action="store_true", default=goptions.quiet,

                  help=_("Do not print header information"))

+     parser.add_option("--show-channels", action="store_true", help=_("Show host's channels"))

      (options, args) = parser.parse_args(args)

      opts = {}

      activate_session(session, goptions)
@@ -2809,10 +2810,25 @@ 

          host['ready'] = yesno(host['ready'])

          host['arches'] = ','.join(host['arches'].split())

  

+     # pull hosts' channels

+     if options.show_channels:

+         session.multicall = True

+         for host in hosts:

+             session.listChannels(host['id'])

+         for host, [channels] in zip(hosts, session.multiCall()):

+             host['channels'] = ','.join(sorted([c['name'] for c in channels]))

+ 

+     longest_host = max([len(h['name']) for h in hosts])

      if not options.quiet:

-         print("Hostname                     Enb Rdy Load/Cap  Arches           Last Update")

+         hdr = "{hostname:<{longest_host}} Enb Rdy Load/Cap  Arches           Last Update".format(longest_host=longest_host, hostname='Hostname')

+         if options.show_channels:

+             hdr += "         Channels"

+         print(hdr)

+     mask = "%%(name)-%ss %%(enabled)-3s %%(ready)-3s %%(task_load)4.1f/%%(capacity)-4.1f %%(arches)-16s %%(update)-19s" % longest_host

+     if options.show_channels:

+         mask += " %(channels)s"

      for host in hosts:

-         print("%(name)-28s %(enabled)-3s %(ready)-3s %(task_load)4.1f/%(capacity)-4.1f %(arches)-16s %(update)s" % host)

+         print(mask % host)

  

  

  def anon_handle_list_pkgs(goptions, session, args):

I wonder if ', ' is the right separator. For the arch column we simply have ',', which makes the output easier to split. Otoh, if we used '|' or ':', then it would be easier to word select a channel name with a mouse

1 new commit added

  • fix alignment
3 years ago

1 new commit added

  • fix channel separator
3 years ago

I've changed ', ' to ',' - for mouse selection, doubleclick works for me.

Commit 6421617 fixes this pull-request

Pull-Request has been merged by mikem

3 years ago