#3363 CLI: list-channels with specific arch
Merged 2 months ago by tkopecek. Opened 3 months ago by jcupova.
jcupova/koji issue-1877  into  master

CLI: list-channels with specific arch
Jana Cupova • 3 months ago  
file modified
+5 -1
@@ -3025,6 +3025,7 @@ 

                        help="Limit to not enabled channels")

      parser.add_option("--disabled", action="store_false", dest="enabled",

                        help="Alias for --not-enabled")

+     parser.add_option("--arch", help="Limit to channels with specific arch")

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

      ensure_connection(session, goptions)

      opts = {}
@@ -3040,7 +3041,10 @@ 

          first_item = {}

      session.multicall = True

      for channel in channels:

-         session.listHosts(channelID=channel['id'])

+         if options.arch is not None:

+             session.listHosts(channelID=channel['id'], arches=options.arch)

+         else:

+             session.listHosts(channelID=channel['id'])

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

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

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

@@ -34,14 +34,33 @@ 

  

          self.list_hosts_mc = [

              [[

-                 {'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},

+                 {'arch': 'x86_64', 'enabled': True, 'ready': True, 'capacity': 2.0,

+                  'task_load': 1.34},

+                 {'arch': 'ppc', 'enabled': True, 'ready': False, 'capacity': 2.0,

+                  'task_load': 0.0},

+                 {'arch': 'x86_64', 'enabled': True, 'ready': False, 'capacity': 2.0,

+                  'task_load': 0.0},

              ]],

              [[

-                 {'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},

+                 {'arch': 'ppc', 'enabled': True, 'ready': True, 'capacity': 2.0,

+                  'task_load': 1.34},

+                 {'arch': 'x86_64', 'enabled': False, 'ready': True, 'capacity': 2.0,

+                  'task_load': 0.34},

+                 {'arch': 'ppc', 'enabled': True, 'ready': False, 'capacity': 2.0,

+                  'task_load': 0.0},

+             ]]

+         ]

+ 

+         self.list_hosts_mc_arch = [

+             [[

+                 {'arch': 'x86_64', 'enabled': True, 'ready': True, 'capacity': 2.0,

+                  'task_load': 1.34},

+                 {'arch': 'x86_64', 'enabled': True, 'ready': False, 'capacity': 2.0,

+                  'task_load': 0.0},

+             ]],

+             [[

+                 {'arch': 'x86_64', 'enabled': False, 'ready': True, 'capacity': 2.0,

+                  'task_load': 0.34},

              ]]

          ]

  
@@ -225,6 +244,24 @@ 

          self.assertMultiLineEqual(actual, expected)

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

  

+     @mock.patch('sys.stdout', new_callable=StringIO)

+     def test_list_channels_with_arch(self, stdout):

+         self.session.listChannels.return_value = self.list_channels

+         self.session.multiCall.return_value = self.list_hosts_mc_arch

+         args = []

+         self.options.quiet = False

+ 

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

+ 

+         actual = stdout.getvalue()

+         expected = "Channel        Enabled  Ready Disbld   Load    Cap   Perc    \n" \

+                    "-------------------------------------------------------------\n" \

+                    "default              2      1      0      1      4     33%\n" \

+                    "test [disabled]      0      1      1      0      2     17%\n"

+ 

+         self.assertMultiLineEqual(actual, expected)

+         self.ensure_connection_mock.assert_called_once_with(self.session, self.options)

+ 

      def test_list_channels_help(self):

          self.assert_help(

              anon_handle_list_channels,
@@ -240,6 +277,7 @@ 

    --enabled      Limit to enabled channels

    --not-enabled  Limit to not enabled channels

    --disabled     Alias for --not-enabled

+   --arch=ARCH    Limit to channels with specific arch

  """ % self.progname)

  

  

Metadata Update from @tkopecek:
- Pull-request tagged with: testing-ready

3 months ago

Metadata Update from @jobrauer:
- Pull-request tagged with: testing-done

2 months ago

Commit 3482582 fixes this pull-request

Pull-Request has been merged by tkopecek

2 months ago