From 82637528a01cb71e3dc481472f2bb50601359ac4 Mon Sep 17 00:00:00 2001 From: Mike McLean Date: Jun 27 2017 16:50:53 +0000 Subject: restart-hosts: check for existing tasks first --- diff --git a/cli/koji b/cli/koji index c6c0a6d..2d1b2ce 100755 --- a/cli/koji +++ b/cli/koji @@ -1563,9 +1563,26 @@ def handle_restart_hosts(options, session, args): help=_("Don't wait on task")) parser.add_option("--quiet", action="store_true", help=_("Do not print the task information"), default=options.quiet) + parser.add_option("--force", action="store_true", + help=_("Ignore checks and force operation")) (my_opts, args) = parser.parse_args(args) activate_session(session) + + # check for existing restart tasks + if not my_opts.force: + query = { + 'method': 'restartHosts', + 'state': + [koji.TASK_STATES[s] for s in ('FREE', 'OPEN', 'ASSIGNED')], + } + others = session.listTasks(query) + if others: + print('Found other restartHosts tasks running.') + print('Task ids: %r' % [t['id'] for t in others]) + print('Use --force to run anyway') + return 1 + task_id = session.restartHosts() if my_opts.wait or (my_opts.wait is None and not _running_in_bg()): session.logout()