updated modules
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Paul 2025-09-06 07:56:50 +02:00
parent cef1853601
commit 9bb1b3205e
7 changed files with 9 additions and 24 deletions

View File

@ -3,9 +3,9 @@
import json import json
from urllib.request import urlopen, Request from urllib.request import urlopen, Request
def get_ips(url="https://ipbl.paulbsd.com"): def get_ips(url="https://ipbl.paulbsd.com"):
"""get_ips fetch ips blacklists from ipbl""" """get_ips fetch ips blacklists from ipbl"""
fullurl = f"{url}/ips/last?interval=3%20h" fullurl = f"{url}/ips/last?interval=3%20h"
req = Request(method="GET", url=fullurl) req = Request(method="GET", url=fullurl)
res = urlopen(req) res = urlopen(req)
@ -13,4 +13,5 @@ def get_ips(url="https://ipbl.paulbsd.com"):
ips = [i["ip"] for i in results] ips = [i["ip"] for i in results]
if res.status == 200: if res.status == 200:
return ips return ips
return None return None

View File

@ -2,7 +2,6 @@
import salt.exceptions import salt.exceptions
def current_state(name): def current_state(name):
ret = dict() ret = dict()
@ -11,7 +10,6 @@ def current_state(name):
return ret return ret
def change_state(name, foo): def change_state(name, foo):
ret = dict() ret = dict()

View File

@ -3,20 +3,21 @@
import json import json
from urllib.request import urlopen, Request from urllib.request import urlopen, Request
def get_job(url="http://localhost:8898"): def get_job(url="http://localhost:8898"):
"""get_job fetchs jobs from dkron""" """get_job fetchs jobs from dkron"""
fullurl = f"{url}/v1/jobs" fullurl = f"{url}/v1/jobs"
req = Request(method="GET", url=fullurl) req = Request(method="GET", url=fullurl)
res = urlopen(req) res = urlopen(req)
dkron_ret = json.loads(res.read()) dkron_ret = json.loads(res.read())
if res.status == 200: if res.status == 200:
return dkron_ret return dkron_ret
return None
return None
def set_job(url="http://localhost:8898", job=None): def set_job(url="http://localhost:8898", job=None):
"""set_job sets job in dkron""" """set_job sets job in dkron"""
fullurl = f"{url}/v1/jobs" fullurl = f"{url}/v1/jobs"
data = json.dumps(job).encode('utf-8') data = json.dumps(job).encode('utf-8')
req = Request(method="POST", url=fullurl, data=data) 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()) dkron_ret = json.loads(res.read())
if res.status == 201: if res.status == 201:
return dkron_ret return dkron_ret
return None return None

View File

@ -31,7 +31,6 @@ def get_public_ip(url="https://4.ident.me/json"):
return None return None
def get_internal_networks(tgt="*", fmt="std"): def get_internal_networks(tgt="*", fmt="std"):
res = [] res = []
res.extend([net for k, net in __salt__["mine.get"](tgt=tgt, fun='public_ip', tgt_type='compound').items()]) 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.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 = list(set(res))
res.sort() res.sort()
return res return res
def get_nat_networks(tgt="*"): 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.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 = list(set(res))
res.sort() res.sort()
return res return res

View File

@ -6,11 +6,9 @@ import ovh
from salt.exceptions import CommandExecutionError, ArgumentValueError from salt.exceptions import CommandExecutionError, ArgumentValueError
from ovh.exceptions import ResourceNotFoundError, APIError from ovh.exceptions import ResourceNotFoundError, APIError
def __virtual__(): def __virtual__():
return True return True
def _config(): def _config():
config = __salt__['config.get']('ovh') config = __salt__['config.get']('ovh')
if not config: if not config:
@ -20,7 +18,6 @@ def _config():
return config return config
def authenticate(): def authenticate():
cfg = _config() cfg = _config()
client = ovh.Client( client = ovh.Client(
@ -32,7 +29,6 @@ def authenticate():
return client return client
def domain_get_zone(zone="", def domain_get_zone(zone="",
client=None): client=None):
''' '''
@ -53,7 +49,6 @@ def domain_get_zone(zone="",
return results return results
def domain_get_record(zone="", def domain_get_record(zone="",
fieldType="", fieldType="",
subDomain="", subDomain="",
@ -89,7 +84,6 @@ def domain_get_record(zone="",
return "Query failed in OVH API" return "Query failed in OVH API"
return None return None
def domain_post_record(zone="", def domain_post_record(zone="",
fieldType="", fieldType="",
subDomain="", subDomain="",
@ -126,7 +120,6 @@ def domain_post_record(zone="",
return req return req
def domain_put_record(zone="", def domain_put_record(zone="",
fieldType="", fieldType="",
subDomain="", subDomain="",
@ -163,8 +156,8 @@ def domain_put_record(zone="",
changed = client.get(f'/domain/zone/{zone}/record/{current["id"]}') changed = client.get(f'/domain/zone/{zone}/record/{current["id"]}')
except APIError: except APIError:
return "Query failed in OVH API" return "Query failed in OVH API"
return changed
return changed
def domain_delete_record(zone="", def domain_delete_record(zone="",
fieldType="", fieldType="",
@ -201,7 +194,6 @@ def domain_delete_record(zone="",
return results return results
def domain_refresh_zone(zone="", def domain_refresh_zone(zone="",
client=None): client=None):
''' '''

View File

@ -6,7 +6,6 @@ import base64
from urllib.request import urlopen from urllib.request import urlopen
from urllib.request import Request from urllib.request import Request
def get_file_content(checkfile=None): def get_file_content(checkfile=None):
try: try:
with open(checkfile, "r") as f: with open(checkfile, "r") as f:
@ -16,7 +15,6 @@ def get_file_content(checkfile=None):
return ret return ret
def write_file_content(content=None, def write_file_content(content=None,
filename=None): filename=None):
try: try:
@ -27,7 +25,6 @@ def write_file_content(content=None,
return ret return ret
def get_pki_cert(url="http://pki", def get_pki_cert(url="http://pki",
username=None, username=None,
password=None, password=None,

View File

@ -8,7 +8,6 @@ from urllib.request import urlopen, Request
from urllib.parse import urljoin from urllib.parse import urljoin
from urllib.error import HTTPError from urllib.error import HTTPError
def get_context(verify): def get_context(verify):
ctx = None ctx = None
if not verify: if not verify:
@ -17,7 +16,6 @@ def get_context(verify):
ctx.verify_mode = ssl.CERT_NONE ctx.verify_mode = ssl.CERT_NONE
return ctx return ctx
def get_apikey(configfile="/root/.config/syncthing/config.xml"): def get_apikey(configfile="/root/.config/syncthing/config.xml"):
try: try:
tree = ET.parse(configfile) tree = ET.parse(configfile)
@ -29,7 +27,6 @@ def get_apikey(configfile="/root/.config/syncthing/config.xml"):
return None return None
def get_config(url="http://localhost:8384", verify=False, apikey=""): def get_config(url="http://localhost:8384", verify=False, apikey=""):
try: try:
apikey=get_apikey() apikey=get_apikey()
@ -50,7 +47,6 @@ def get_config(url="http://localhost:8384", verify=False, apikey=""):
return None return None
def set_config_options(url="http://localhost:8384", verify=False, apikey=get_apikey(), options={}): def set_config_options(url="http://localhost:8384", verify=False, apikey=get_apikey(), options={}):
fullurl = f"{url}/rest/config/options" fullurl = f"{url}/rest/config/options"
req = Request(method="PUT", req = Request(method="PUT",
@ -117,7 +113,6 @@ def _set_config(url="http://localhost:8384", verify=False, apikey=get_apikey(),
return None return None
def insync(url="http://localhost:8384", verify=False, apikey=get_apikey()): def insync(url="http://localhost:8384", verify=False, apikey=get_apikey()):
fullurl = f"{url}/rest/config/restart-required" fullurl = f"{url}/rest/config/restart-required"
req = Request(method="GET", req = Request(method="GET",
@ -133,7 +128,6 @@ def insync(url="http://localhost:8384", verify=False, apikey=get_apikey()):
return None return None
def restart(url="http://localhost:8384", verify=False, apikey=get_apikey()): def restart(url="http://localhost:8384", verify=False, apikey=get_apikey()):
fullurl = f"{url}/rest/system/restart" fullurl = f"{url}/rest/system/restart"
req = Request(method="POST", req = Request(method="POST",