updated ovh api scripts

This commit is contained in:
Paul 2021-02-07 16:18:16 +01:00
parent bde78d1c43
commit e133fc3f5f
2 changed files with 12 additions and 6 deletions

View File

@ -53,7 +53,7 @@ def domain_get_zone(zone=""):
return results
def domain_get_record(zone="", fieldType="", subDomain=""):
def domain_get_record(zone="", fieldType="", subDomain="", target=""):
'''
Record of the zone
@ -63,6 +63,8 @@ def domain_get_record(zone="", fieldType="", subDomain=""):
Filter the value of fieldType property (like)
subDomain
Filter the value of subDomain property (like)
target
Resource record target
'''
if zone == "":
@ -70,12 +72,15 @@ def domain_get_record(zone="", fieldType="", subDomain=""):
res = None
client = _auth()
try:
record = client.get(f'/domain/zone/{zone}/record',
records = client.get(f'/domain/zone/{zone}/record',
fieldType=fieldType,
subDomain=subDomain)
if len(record) > 0:
req = client.get(f'/domain/zone/{zone}/record/{record}')
return req
if len(records) > 0:
for rec in records:
res = client.get(f'/domain/zone/{zone}/record/{rec}')
if res['target'] == target:
return res
return None
except APIError:
return "Query failed in OVH API"
return None

View File

@ -48,7 +48,8 @@ def domain_record_present(name,
# check if record exists
cur_record = __salt__['ovhapi.domain_get_record'](zone=zone,
fieldType=recordtype,
subDomain=recordname)
subDomain=recordname,
target=target)
if cur_record is not None:
res = __salt__['ovhapi.domain_put_record'](zone=zone,
fieldType=recordtype,