From a65db027e81dce5e47ffd4746e37b5b51cba84d5 Mon Sep 17 00:00:00 2001 From: ftntcorecse <43451990+ftntcorecse@users.noreply.github.com> Date: Mon, 4 Mar 2019 00:26:06 -0500 Subject: [PATCH] Fortinet FortiManager Module_Utils MINOR Update (#52756) * PR for minor update to FortiManager.py. Now accepts entire module as input, so it can use those data points for decisions later. This update is entirely related to our debugging and should have zero impact on existing modules. * Minor change to documentation to kick off another shippable. Suspected error on last run. * Commented out reference to the import library for fortimanager debug (which is only used by us, internally). It needs to be moved outside of the Ansible namespace so we can call it with try/catch without any other issues. Right now /ansible/executor/module_common.py runs w/ recursive_finder, and throws errors because it can't find debug on other machines within the ansible namespace. We don't have this issue with pyFMG legacy usage. So, we're disabling the code until we have a better way of calling this debug module. It isn't required for production usage. --- .../network/fortimanager/fortimanager.py | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/lib/ansible/module_utils/network/fortimanager/fortimanager.py b/lib/ansible/module_utils/network/fortimanager/fortimanager.py index fa6c21e9330..5a3875c2365 100644 --- a/lib/ansible/module_utils/network/fortimanager/fortimanager.py +++ b/lib/ansible/module_utils/network/fortimanager/fortimanager.py @@ -39,19 +39,23 @@ try: except ImportError: HAS_PYFMGR = False -# check for debug lib -try: - from ansible.module_utils.network.fortimanager.fortimanager_debug import debug_dump - HAS_FMGR_DEBUG = True -except ImportError: - HAS_FMGR_DEBUG = False +# ACTIVE BUG WITH OUR DEBUG IMPORT CALL -- BECAUSE IT'S UNDER MODULE_UTILITIES +# WHEN module_common.recursive_finder() runs under the module loader, it looks for this namespace debug import +# and because it's not there, it always fails, regardless of it being under a try/catch here. +# we're going to move it to a different namespace. +# # check for debug lib +# try: +# from ansible.module_utils.network.fortimanager.fortimanager_debug import debug_dump +# HAS_FMGR_DEBUG = True +# except: +# HAS_FMGR_DEBUG = False # BEGIN HANDLER CLASSES class FortiManagerHandler(object): - def __init__(self, conn, check_mode=False): + def __init__(self, conn, module): self._conn = conn - self._check_mode = check_mode + self._module = module self._tools = FMGRCommon def process_request(self, url, datagram, method): @@ -70,11 +74,12 @@ class FortiManagerHandler(object): """ data = self._tools.format_request(method, url, **datagram) response = self._conn.send_request(method, data) - if HAS_FMGR_DEBUG: - try: - debug_dump(response, datagram, url, method) - except BaseException: - pass + + # if HAS_FMGR_DEBUG: + # try: + # debug_dump(response, datagram, self._module.paramgram, url, method) + # except BaseException: + # pass return response