updated ovh api scripts
This commit is contained in:
parent
bde78d1c43
commit
e133fc3f5f
@ -53,7 +53,7 @@ def domain_get_zone(zone=""):
|
|||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
||||||
def domain_get_record(zone="", fieldType="", subDomain=""):
|
def domain_get_record(zone="", fieldType="", subDomain="", target=""):
|
||||||
'''
|
'''
|
||||||
Record of the zone
|
Record of the zone
|
||||||
|
|
||||||
@ -63,6 +63,8 @@ def domain_get_record(zone="", fieldType="", subDomain=""):
|
|||||||
Filter the value of fieldType property (like)
|
Filter the value of fieldType property (like)
|
||||||
subDomain
|
subDomain
|
||||||
Filter the value of subDomain property (like)
|
Filter the value of subDomain property (like)
|
||||||
|
target
|
||||||
|
Resource record target
|
||||||
'''
|
'''
|
||||||
|
|
||||||
if zone == "":
|
if zone == "":
|
||||||
@ -70,12 +72,15 @@ def domain_get_record(zone="", fieldType="", subDomain=""):
|
|||||||
res = None
|
res = None
|
||||||
client = _auth()
|
client = _auth()
|
||||||
try:
|
try:
|
||||||
record = client.get(f'/domain/zone/{zone}/record',
|
records = client.get(f'/domain/zone/{zone}/record',
|
||||||
fieldType=fieldType,
|
fieldType=fieldType,
|
||||||
subDomain=subDomain)
|
subDomain=subDomain)
|
||||||
if len(record) > 0:
|
if len(records) > 0:
|
||||||
req = client.get(f'/domain/zone/{zone}/record/{record}')
|
for rec in records:
|
||||||
return req
|
res = client.get(f'/domain/zone/{zone}/record/{rec}')
|
||||||
|
if res['target'] == target:
|
||||||
|
return res
|
||||||
|
return None
|
||||||
except APIError:
|
except APIError:
|
||||||
return "Query failed in OVH API"
|
return "Query failed in OVH API"
|
||||||
return None
|
return None
|
||||||
|
@ -48,7 +48,8 @@ def domain_record_present(name,
|
|||||||
# check if record exists
|
# check if record exists
|
||||||
cur_record = __salt__['ovhapi.domain_get_record'](zone=zone,
|
cur_record = __salt__['ovhapi.domain_get_record'](zone=zone,
|
||||||
fieldType=recordtype,
|
fieldType=recordtype,
|
||||||
subDomain=recordname)
|
subDomain=recordname,
|
||||||
|
target=target)
|
||||||
if cur_record is not None:
|
if cur_record is not None:
|
||||||
res = __salt__['ovhapi.domain_put_record'](zone=zone,
|
res = __salt__['ovhapi.domain_put_record'](zone=zone,
|
||||||
fieldType=recordtype,
|
fieldType=recordtype,
|
||||||
|
Loading…
Reference in New Issue
Block a user