updated state modules
This commit is contained in:
parent
4ed76b8dbb
commit
5d8819eca7
@ -4,8 +4,8 @@ import json
|
||||
from urllib.request import urlopen, Request
|
||||
|
||||
|
||||
def get_jobs(url="http://localhost:8898"):
|
||||
"""get_jobs fetch jobs from dkron"""
|
||||
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)
|
||||
@ -15,8 +15,8 @@ def get_jobs(url="http://localhost:8898"):
|
||||
return None
|
||||
|
||||
|
||||
def set_jobs(url="http://localhost:8898", job=None):
|
||||
"""set_jobs set jobs on dkron"""
|
||||
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)
|
||||
|
@ -3,6 +3,7 @@
|
||||
import ssl
|
||||
import json
|
||||
import xml.etree.ElementTree as ET
|
||||
import http.client
|
||||
from urllib.request import urlopen, Request
|
||||
from urllib.parse import urljoin
|
||||
from urllib.error import HTTPError
|
||||
|
@ -4,15 +4,17 @@ import salt.utils.dictupdate
|
||||
import salt.utils.dictdiffer
|
||||
|
||||
|
||||
def jobs(name, url="http://localhost:8080", verify=False, jobs={}):
|
||||
def jobs(name, url="http://localhost:8080", verify=False, jobs={}, default_job={}):
|
||||
ret = {'name': name,
|
||||
'changes': {},
|
||||
'result': True,
|
||||
'comment': 'Config is up to date'}
|
||||
|
||||
for name, job in jobs.items():
|
||||
job['name'] = name
|
||||
res = __salt__['dkron.set_jobs'](url, job)
|
||||
for name, j in jobs.items():
|
||||
j['name'] = name
|
||||
job = default_job.copy()
|
||||
job.update(j)
|
||||
res = __salt__['dkron.set_job'](url, job)
|
||||
if res is not None:
|
||||
ret['changes'][job['name']] = res
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user