From 3a6a663280f9f34470f8046eb7ce2537b42c3eb7 Mon Sep 17 00:00:00 2001 From: Trishna Guha Date: Mon, 29 Oct 2018 18:50:59 +0530 Subject: [PATCH] [2.6] Cherry pick bugfixes (#193) * Fix templating repeat_for (#190) Signed-off-by: Trishna Guha (cherry picked from commit e08ef8de726469c7f9823f586ca76e7bac1e5b93) * Fix validate_role_spec typo Signed-off-by: Trishna Guha (cherry picked from commit 91eddb5815f9ad5d6e2ccb3f7792ba8e7dc40089) * fix flake8 failure Signed-off-by: Trishna Guha (cherry picked from commit 86f3dc53b6c2c802bf4dd4650966d3a5cdb5025a) * Add missing boilerplate for net_facts module (#194) Signed-off-by: Trishna Guha (cherry picked from commit 906553570284655e950d0d7c3e40a28fd76e7978) --- action_plugins/validate_role_spec.py | 2 +- lib/network_engine/plugins/template/json_template.py | 5 ++++- library/net_facts.py | 4 ++++ lookup_plugins/network_template.py | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/action_plugins/validate_role_spec.py b/action_plugins/validate_role_spec.py index e35457d..151280e 100644 --- a/action_plugins/validate_role_spec.py +++ b/action_plugins/validate_role_spec.py @@ -58,7 +58,7 @@ class ActionModule(ActionBase): VALID_MODULE_KWARGS = ( 'argument_spec', 'mutually_exclusive', 'required_if', - 'required_one_of', 'requred_together' + 'required_one_of', 'required_together' ) def run(self, tmp=None, task_vars=None): diff --git a/lib/network_engine/plugins/template/json_template.py b/lib/network_engine/plugins/template/json_template.py index d14f8a8..fcdb736 100644 --- a/lib/network_engine/plugins/template/json_template.py +++ b/lib/network_engine/plugins/template/json_template.py @@ -53,7 +53,10 @@ def run(self, template, variables=None): for loop_item in loop_data: variables[loop_var] = loop_item - templated_value.append(self.template(items, variables)) + if isinstance(items, string_types): + templated_value.append(self.template(items, variables)) + else: + templated_value.append(self.run(items, variables)) if item_type == 'list': templated_items[key] = templated_value diff --git a/library/net_facts.py b/library/net_facts.py index 78c8326..e28a42f 100644 --- a/library/net_facts.py +++ b/library/net_facts.py @@ -4,6 +4,10 @@ # (c) 2018, Red Hat, Inc. # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +from __future__ import absolute_import, division, print_function +__metaclass__ = type + + ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'network'} diff --git a/lookup_plugins/network_template.py b/lookup_plugins/network_template.py index 6453ab5..aca6c00 100644 --- a/lookup_plugins/network_template.py +++ b/lookup_plugins/network_template.py @@ -243,7 +243,7 @@ def _coerce_to_native(self, value): if not isinstance(value, bool): try: value = int(value) - except Exception as exc: + except Exception: if value is None or len(value) == 0: return None return value