updated modules

This commit is contained in:
Paul 2021-01-24 19:01:14 +01:00
parent 4560f9d1fe
commit 8170ebddd1
2 changed files with 14 additions and 9 deletions

View File

@ -145,7 +145,7 @@ def domain_put_record(zone="",
subDomain=subDomain) subDomain=subDomain)
if len(records) > 0: if len(records) > 0:
record = client.get(f'/domain/zone/{zone}/record/{records[0]}') record = client.get(f'/domain/zone/{zone}/record/{records[0]}')
req = client.put(f'/domain/zone/{zone}/record/{records[0]["id"]}', req = client.put(f'/domain/zone/{zone}/record/{record["id"]}',
subDomain=subDomain, subDomain=subDomain,
target=target, target=target,
ttl=ttl) ttl=ttl)

View File

@ -53,24 +53,29 @@ def domain_record_present(name,
res = __salt__['ovhapi.domain_put_record'](zone=zone, res = __salt__['ovhapi.domain_put_record'](zone=zone,
fieldType=recordtype, fieldType=recordtype,
subDomain=recordname) subDomain=recordname)
res_output = f"Updated record {recordname}, output: {res_output}" new_zone_state = __salt__['ovhapi.domain_get_zone'](zone=zone)
ret['changes'] = {
"diff": salt.utils.stringutils.get_diff(_str_split(cur_zone_state),
_str_split(new_zone_state))
}
res_output = f"Updated record {recordname}"
else: else:
res = __salt__['ovhapi.domain_post_record'](zone=zone, res = __salt__['ovhapi.domain_post_record'](zone=zone,
subDomain=recordname, subDomain=recordname,
fieldType=recordtype, fieldType=recordtype,
target=target, target=target,
ttl=ttl) ttl=ttl)
res_output = f"Updated record {recordname}, output: {res_output}"
new_zone_state = __salt__['ovhapi.domain_get_zone'](zone=zone) new_zone_state = __salt__['ovhapi.domain_get_zone'](zone=zone)
cur_zone_refresh = __salt__['ovhapi.domain_refresh_zone'](zone=zone)
ret['changes'] = { ret['changes'] = {
"diff": salt.utils.stringutils.get_diff(_str_split(cur_zone_state), "diff": salt.utils.stringutils.get_diff(_str_split(cur_zone_state),
_str_split(new_zone_state)) _str_split(new_zone_state))
} }
ret['comment'] = f'Result is {res_output}, refresh {cur_zone_refresh}' res_output = f"Created record {recordname}"
cur_zone_refresh = __salt__['ovhapi.domain_refresh_zone'](zone=zone)
ret['comment'] = f'Result is {res_output}'
return ret return ret