Unix socket workaround
This commit is contained in:
parent
6bd9731844
commit
fe8f9be567
|
@ -82,11 +82,6 @@ from xml.etree.ElementTree import parse
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.urls import fetch_url, url_argument_spec
|
from ansible.module_utils.urls import fetch_url, url_argument_spec
|
||||||
|
|
||||||
try:
|
|
||||||
import requests_unixsocket
|
|
||||||
except ImportError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
SYNCTHING_API_URI = "/rest/config/devices"
|
SYNCTHING_API_URI = "/rest/config/devices"
|
||||||
if platform.system() == 'Windows':
|
if platform.system() == 'Windows':
|
||||||
DEFAULT_ST_CONFIG_LOCATION = '%localappdata%/Syncthing/config.xml'
|
DEFAULT_ST_CONFIG_LOCATION = '%localappdata%/Syncthing/config.xml'
|
||||||
|
@ -121,6 +116,10 @@ def get_key_from_filesystem(module):
|
||||||
|
|
||||||
# Fetch Syncthing configuration
|
# Fetch Syncthing configuration
|
||||||
def remote_config(module, method='GET', config=None, result=None, device=None):
|
def remote_config(module, method='GET', config=None, result=None, device=None):
|
||||||
|
if 'unix_socket' in module.params:
|
||||||
|
url, headers = make_headers(module.params['unix_socket'], module.params['api_key'],
|
||||||
|
device)
|
||||||
|
else:
|
||||||
url, headers = make_headers(module.params['host'], module.params['api_key'],
|
url, headers = make_headers(module.params['host'], module.params['api_key'],
|
||||||
device)
|
device)
|
||||||
data = config
|
data = config
|
||||||
|
@ -130,6 +129,11 @@ def remote_config(module, method='GET', config=None, result=None, device=None):
|
||||||
if not result:
|
if not result:
|
||||||
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(
|
resp, info = fetch_url(
|
||||||
module, url, data=data, headers=headers,
|
module, url, data=data, headers=headers,
|
||||||
method=method, timeout=module.params['timeout'])
|
method=method, timeout=module.params['timeout'])
|
||||||
|
|
Loading…
Reference in New Issue
Block a user