From: Kyr Shatskyy Date: Thu, 12 Dec 2019 22:48:43 +0000 (+0100) Subject: py3: cast dict_keys to list X-Git-Tag: 1.1.0~177^2~9 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=d853397a64ae25dd344192a4aa4d951a9238a21c;p=teuthology.git py3: cast dict_keys to list Addresses: TypeError: 'dict_keys' object does not support indexing and: RuntimeError: dictionary changed size during iteration Signed-off-by: Kyr Shatskyy --- diff --git a/teuthology/misc.py b/teuthology/misc.py index 16aeb0d373..4c9dab01c3 100644 --- a/teuthology/misc.py +++ b/teuthology/misc.py @@ -944,7 +944,7 @@ def reconnect(ctx, timeout, remotes=None): if remotes: need_reconnect = remotes else: - need_reconnect = ctx.cluster.remotes.keys() + need_reconnect = list(ctx.cluster.remotes.keys()) while need_reconnect: for remote in need_reconnect: diff --git a/teuthology/nuke/__init__.py b/teuthology/nuke/__init__.py index 5c105ef3df..8370e4d94f 100644 --- a/teuthology/nuke/__init__.py +++ b/teuthology/nuke/__init__.py @@ -296,7 +296,7 @@ def nuke_one(ctx, target, should_unlock, synch_clocks, reboot_all, ret = target else: if should_unlock: - unlock_one(ctx, target.keys()[0], ctx.owner) + unlock_one(ctx, list(target.keys())[0], ctx.owner) return ret diff --git a/teuthology/task/internal/__init__.py b/teuthology/task/internal/__init__.py index 5f00653b44..a539923039 100644 --- a/teuthology/task/internal/__init__.py +++ b/teuthology/task/internal/__init__.py @@ -68,7 +68,7 @@ def check_packages(ctx, config): If there are missing packages, fail the job. """ for task in ctx.config['tasks']: - if task.keys()[0] == 'buildpackages': + if list(task.keys())[0] == 'buildpackages': log.info("Checking packages skipped because " "the task buildpackages was found.") return @@ -227,7 +227,7 @@ def buildpackages_prep(ctx, config): return BUILDPACKAGES_OK elif buildpackages_index is not None and install_index is None: ctx.config['tasks'].pop(buildpackages_index) - all_tasks = [x.keys()[0] for x in ctx.config['tasks']] + all_tasks = [list(x.keys())[0] for x in ctx.config['tasks']] log.info('buildpackages removed because no install task found in ' + str(all_tasks)) return BUILDPACKAGES_REMOVED diff --git a/teuthology/task/internal/vm_setup.py b/teuthology/task/internal/vm_setup.py index 27ecd8b7e6..828eff1843 100644 --- a/teuthology/task/internal/vm_setup.py +++ b/teuthology/task/internal/vm_setup.py @@ -14,7 +14,7 @@ def vm_setup(ctx, config): """ Look for virtual machines and handle their initialization """ - all_tasks = [x.keys()[0] for x in ctx.config['tasks']] + all_tasks = [list(x.keys())[0] for x in ctx.config['tasks']] need_ansible = False if 'kernel' in all_tasks and 'ansible.cephlab' not in all_tasks: need_ansible = True diff --git a/teuthology/task/kernel.py b/teuthology/task/kernel.py index 5bc5042058..2af798111b 100644 --- a/teuthology/task/kernel.py +++ b/teuthology/task/kernel.py @@ -682,7 +682,7 @@ def wait_for_reboot(ctx, need_install, timeout, distro=False): starttime = time.time() while need_install: teuthology.reconnect(ctx, timeout) - for client in need_install.keys(): + for client in list(need_install.keys()): if 'distro' in str(need_install[client]): distro = True log.info('Checking client {client} for new kernel version...'.format(client=client))