diff --git a/states/_modules/bl.py b/states/_modules/bl.py index d700f74..86ae916 100644 --- a/states/_modules/bl.py +++ b/states/_modules/bl.py @@ -3,9 +3,9 @@ import json from urllib.request import urlopen, Request - def get_ips(url="https://ipbl.paulbsd.com"): """get_ips fetch ips blacklists from ipbl""" + fullurl = f"{url}/ips/last?interval=3%20h" req = Request(method="GET", url=fullurl) res = urlopen(req) @@ -13,4 +13,5 @@ def get_ips(url="https://ipbl.paulbsd.com"): ips = [i["ip"] for i in results] if res.status == 200: return ips + return None diff --git a/states/_modules/custom.py b/states/_modules/custom.py index d231a50..db9af76 100644 --- a/states/_modules/custom.py +++ b/states/_modules/custom.py @@ -2,7 +2,6 @@ import salt.exceptions - def current_state(name): ret = dict() @@ -11,7 +10,6 @@ def current_state(name): return ret - def change_state(name, foo): ret = dict() diff --git a/states/_modules/dkron.py b/states/_modules/dkron.py index 2c44174..0b8b8a6 100644 --- a/states/_modules/dkron.py +++ b/states/_modules/dkron.py @@ -3,20 +3,21 @@ import json from urllib.request import urlopen, Request - def get_job(url="http://localhost:8898"): """get_job fetchs jobs from dkron""" + fullurl = f"{url}/v1/jobs" req = Request(method="GET", url=fullurl) res = urlopen(req) dkron_ret = json.loads(res.read()) if res.status == 200: return dkron_ret - return None + return None def set_job(url="http://localhost:8898", job=None): """set_job sets job in dkron""" + fullurl = f"{url}/v1/jobs" data = json.dumps(job).encode('utf-8') req = Request(method="POST", url=fullurl, data=data) @@ -25,4 +26,5 @@ def set_job(url="http://localhost:8898", job=None): dkron_ret = json.loads(res.read()) if res.status == 201: return dkron_ret + return None diff --git a/states/_modules/net.py b/states/_modules/net.py index fd6beab..a9acfc7 100644 --- a/states/_modules/net.py +++ b/states/_modules/net.py @@ -31,7 +31,6 @@ def get_public_ip(url="https://4.ident.me/json"): return None - def get_internal_networks(tgt="*", fmt="std"): res = [] res.extend([net for k, net in __salt__["mine.get"](tgt=tgt, fun='public_ip', tgt_type='compound').items()]) @@ -42,6 +41,7 @@ def get_internal_networks(tgt="*", fmt="std"): res.extend([POSTFIX_FORMAT(net) for k, nets in __salt__["mine.get"](tgt=tgt, fun='ip_networks6', tgt_type='compound').items() for net in nets]) res = list(set(res)) res.sort() + return res def get_nat_networks(tgt="*"): @@ -49,4 +49,5 @@ def get_nat_networks(tgt="*"): res.extend([net for k, nets in __salt__["mine.get"](tgt=tgt, fun='ip_networks', tgt_type='compound').items() for net in nets if __salt__['network.is_private'](net.split("/")[0])]) res = list(set(res)) res.sort() + return res diff --git a/states/_modules/ovhapi.py b/states/_modules/ovhapi.py index 9f23566..0f18731 100644 --- a/states/_modules/ovhapi.py +++ b/states/_modules/ovhapi.py @@ -6,11 +6,9 @@ import ovh from salt.exceptions import CommandExecutionError, ArgumentValueError from ovh.exceptions import ResourceNotFoundError, APIError - def __virtual__(): return True - def _config(): config = __salt__['config.get']('ovh') if not config: @@ -20,7 +18,6 @@ def _config(): return config - def authenticate(): cfg = _config() client = ovh.Client( @@ -32,7 +29,6 @@ def authenticate(): return client - def domain_get_zone(zone="", client=None): ''' @@ -53,7 +49,6 @@ def domain_get_zone(zone="", return results - def domain_get_record(zone="", fieldType="", subDomain="", @@ -89,7 +84,6 @@ def domain_get_record(zone="", return "Query failed in OVH API" return None - def domain_post_record(zone="", fieldType="", subDomain="", @@ -126,7 +120,6 @@ def domain_post_record(zone="", return req - def domain_put_record(zone="", fieldType="", subDomain="", @@ -163,8 +156,8 @@ def domain_put_record(zone="", changed = client.get(f'/domain/zone/{zone}/record/{current["id"]}') except APIError: return "Query failed in OVH API" - return changed + return changed def domain_delete_record(zone="", fieldType="", @@ -201,7 +194,6 @@ def domain_delete_record(zone="", return results - def domain_refresh_zone(zone="", client=None): ''' diff --git a/states/_modules/pki.py b/states/_modules/pki.py index e9b20e8..93607c5 100644 --- a/states/_modules/pki.py +++ b/states/_modules/pki.py @@ -6,7 +6,6 @@ import base64 from urllib.request import urlopen from urllib.request import Request - def get_file_content(checkfile=None): try: with open(checkfile, "r") as f: @@ -16,7 +15,6 @@ def get_file_content(checkfile=None): return ret - def write_file_content(content=None, filename=None): try: @@ -27,7 +25,6 @@ def write_file_content(content=None, return ret - def get_pki_cert(url="http://pki", username=None, password=None, diff --git a/states/_modules/syncthing.py b/states/_modules/syncthing.py index 2769406..414a8c0 100644 --- a/states/_modules/syncthing.py +++ b/states/_modules/syncthing.py @@ -8,7 +8,6 @@ from urllib.request import urlopen, Request from urllib.parse import urljoin from urllib.error import HTTPError - def get_context(verify): ctx = None if not verify: @@ -17,7 +16,6 @@ def get_context(verify): ctx.verify_mode = ssl.CERT_NONE return ctx - def get_apikey(configfile="/root/.config/syncthing/config.xml"): try: tree = ET.parse(configfile) @@ -29,7 +27,6 @@ def get_apikey(configfile="/root/.config/syncthing/config.xml"): return None - def get_config(url="http://localhost:8384", verify=False, apikey=""): try: apikey=get_apikey() @@ -50,7 +47,6 @@ def get_config(url="http://localhost:8384", verify=False, apikey=""): return None - def set_config_options(url="http://localhost:8384", verify=False, apikey=get_apikey(), options={}): fullurl = f"{url}/rest/config/options" req = Request(method="PUT", @@ -117,7 +113,6 @@ def _set_config(url="http://localhost:8384", verify=False, apikey=get_apikey(), return None - def insync(url="http://localhost:8384", verify=False, apikey=get_apikey()): fullurl = f"{url}/rest/config/restart-required" req = Request(method="GET", @@ -133,7 +128,6 @@ def insync(url="http://localhost:8384", verify=False, apikey=get_apikey()): return None - def restart(url="http://localhost:8384", verify=False, apikey=get_apikey()): fullurl = f"{url}/rest/system/restart" req = Request(method="POST",