From fb178b36cd88be0534a24540e32fb53b1f75bf07 Mon Sep 17 00:00:00 2001 From: Peter Surda Date: Mon, 22 Apr 2024 15:26:49 +0800 Subject: [PATCH] Refactoring - unix_socket still wasn't used correctly --- collection/plugins/modules/device.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/collection/plugins/modules/device.py b/collection/plugins/modules/device.py index 241f7bc..865fd44 100644 --- a/collection/plugins/modules/device.py +++ b/collection/plugins/modules/device.py @@ -121,11 +121,12 @@ def get_key_from_filesystem(module): # Fetch Syncthing configuration def remote_config(module, method='GET', config=None, result=None, device=None): + unix_socket = None + if 'unix_socket' in module.params: + unix_socket = module.params['unix_socket'] url, headers = make_headers( host=module.params['host'], - unix_socket=module.params['unix_socket'] - if 'unix_socket' in module.params - else None, + unix_socket=unix_socket, api_key= module.params['api_key'], device=device) data = config @@ -135,14 +136,10 @@ def remote_config(module, method='GET', config=None, result=None, device=None): if not result: result = {} - if 'unix_socket' in module.params: - resp, info = fetch_url( - module, unix_socket=url, data=data, headers=headers, - method=method, timeout=module.params['timeout']) - else: - resp, info = fetch_url( - module, url, data=data, headers=headers, - method=method, timeout=module.params['timeout']) + resp, info = fetch_url( + module, url=url, unix_socket=unix_socket, + data=data, headers=headers, + method=method, timeout=module.params['timeout']) if not info or info['status'] != 200: result['response'] = info