From 40f9445aeaace2def038b539fe0b9a8e33fd6875 Mon Sep 17 00:00:00 2001 From: Boris Date: Sun, 20 Feb 2022 10:40:56 +0200 Subject: [PATCH] Fix module failure due to itertools.izip_longest (#4211) * Fix module failure due to itertools.izip_longest * Add changelog fragment. Remove itertools import * Update changelogs/fragments/4206-imc-rest-module.yaml Co-authored-by: Felix Fontein Co-authored-by: Boris Vasilev Co-authored-by: Felix Fontein --- changelogs/fragments/4206-imc-rest-module.yaml | 2 ++ plugins/modules/remote_management/imc/imc_rest.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/4206-imc-rest-module.yaml diff --git a/changelogs/fragments/4206-imc-rest-module.yaml b/changelogs/fragments/4206-imc-rest-module.yaml new file mode 100644 index 0000000000..e36305e31b --- /dev/null +++ b/changelogs/fragments/4206-imc-rest-module.yaml @@ -0,0 +1,2 @@ +bugfixes: + - imc_rest - fixes the module failure due to the usage of ``itertools.izip_longest`` which is not available in Python 3 (https://github.com/ansible-collections/community.general/issues/4206). diff --git a/plugins/modules/remote_management/imc/imc_rest.py b/plugins/modules/remote_management/imc/imc_rest.py index 239c76fab3..b685e96b82 100644 --- a/plugins/modules/remote_management/imc/imc_rest.py +++ b/plugins/modules/remote_management/imc/imc_rest.py @@ -261,7 +261,6 @@ output: ''' import datetime -import itertools import os import traceback from functools import partial @@ -283,6 +282,7 @@ except ImportError: HAS_XMLJSON_COBRA = False from ansible.module_utils.basic import AnsibleModule, missing_required_lib +from ansible.module_utils.six.moves import zip_longest from ansible.module_utils.urls import fetch_url @@ -318,7 +318,7 @@ def merge(one, two): return copy elif isinstance(one, list) and isinstance(two, list): - return [merge(alpha, beta) for (alpha, beta) in itertools.izip_longest(one, two)] + return [merge(alpha, beta) for (alpha, beta) in zip_longest(one, two)] return one if two is None else two