#1449 show load/capacity in list-channels
Merged 4 years ago by mikem. Opened 4 years ago by tkopecek.
tkopecek/koji issue1448  into  master

file modified
+18 -4
@@ -2739,6 +2739,8 @@ 

      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("--simple", action="store_true", default=False,

+                 help=_("Print just list of channels without additional info"))

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

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

      (options, args) = parser.parse_args(args)
@@ -2752,10 +2754,22 @@ 

          channel['enabled'] = len([x for x in hosts if x['enabled']])

          channel['disabled'] = len(hosts) - channel['enabled']

          channel['ready'] = len([x for x in hosts if x['ready']])

-     if not options.quiet:

-         print('Channel           Enb   Rdy   Dis')

-     for channel in channels:

-         print("%(name)-15s %(enabled)5d %(ready)5d %(disabled)5d" % channel)

+         channel['capacity'] = sum([x['capacity'] for x in hosts])

+         channel['load'] = sum([x['task_load'] for x in hosts])

+         if channel['capacity']:

+             channel['perc_load'] = channel['load'] / channel['capacity'] * 100.0

+         else:

+             channel['perc_load'] = 0.0

+     if options.simple:

+         if not options.quiet:

+             print('Channel')

+         for channel in channels:

+             print(channel['name'])

+     else:

+         if not options.quiet:

+             print('Channel        Enabled  Ready Disbld   Load    Cap    Perc')

+         for channel in channels:

+             print("%(name)-15s %(enabled)6d %(ready)6d %(disabled)6d %(load)6d %(capacity)6d %(perc_load)6d%%" % channel)

  

  

  def anon_handle_list_hosts(goptions, session, args):

@@ -27,20 +27,24 @@ 

          ]

          self.session.multiCall.return_value = [

              [[

-                 {'enabled': True, 'ready': True},

-                 {'enabled': True, 'ready': False},

-                 {'enabled': True, 'ready': False},

+                 {'enabled': True, 'ready': True, 'capacity': 2.0, 'task_load': 1.34},

+                 {'enabled': True, 'ready': False, 'capacity': 2.0, 'task_load': 0.0},

+                 {'enabled': True, 'ready': False, 'capacity': 2.0, 'task_load': 0.0},

              ]],

              [[

-                 {'enabled': True, 'ready': True},

-                 {'enabled': False, 'ready': True},

-                 {'enabled': True, 'ready': False},

+                 {'enabled': True, 'ready': True, 'capacity': 2.0, 'task_load': 1.34},

+                 {'enabled': False, 'ready': True, 'capacity': 2.0, 'task_load': 0.34},

+                 {'enabled': True, 'ready': False, 'capacity': 2.0, 'task_load': 0.0},

              ]],

          ]

  

          anon_handle_list_channels(self.options, self.session, self.args)

  

          actual = stdout.getvalue()

-         expected = 'default             3     1     0\ntest                2     2     1\n'

+         print(actual)

+         expected = """\

+ default              3      1      0      1      6     22%

+ test                 2      2      1      1      6     28%

+ """

          self.assertMultiLineEqual(actual, expected)

          activate_session_mock.assert_called_once_with(self.session, self.options)

1 new commit added

  • fix test
4 years ago

This is the output I'm seeing:

Channel           Enb   Rdy   Dis Loa/Cap/Perc
appliance           1     0     0   0/  8/  0%
createrepo          1     0     0   0/  8/  0%
default             3     0     2   0/ 24/  0%
image               1     0     0   0/  8/  0%
livecd              0     0     0   0/  0/  0%
livemedia           1     0     0   0/  8/  0%
maven               1     0     0   0/  8/  0%
runroot             1     0     0   0/  8/  0%
vm                  0     0     0   0/  0/  0%

The output is very busy and the layout seems unbalanced.

The abbreviations in the headers are very terse. I realize we're just following the existing short Enb/Rdy/Dis, but altogether it starts to look like a jumble of letters.

The slashes in the L/C/P portion end up being distracting when combined with whitespace.

1 new commit added

  • more readable layout
4 years ago

Changed to this:

Channel        Enabled  Ready Disbld   Load    Cap    Perc
appliance            1      0      0      0      5      0%
createrepo           1      0      0      0      5      0%
default              1      0      1      0      7      0%
image                1      0      1      0      7      0%
livecd               0      0      0      0      0      0%
livemedia            1      0      0      0      5      0%
maven                1      0      0      0      5      0%
runroot              1      0      0      0      5      0%
vm                   0      0      0      0      0      0%

1 new commit added

  • fix test
4 years ago

Thanks, looks much better

Commit 3674e70 fixes this pull-request

Pull-Request has been merged by mikem

4 years ago