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