Bugfix: wrong rrid
This commit is contained in:
parent
8db62e081f
commit
abc91bd616
10
update.py
10
update.py
@ -30,6 +30,7 @@ def get_public_ip():
|
|||||||
return None
|
return None
|
||||||
return res.text.strip()
|
return res.text.strip()
|
||||||
|
|
||||||
|
|
||||||
def get_namesilo_dns(key, domain, target_host):
|
def get_namesilo_dns(key, domain, target_host):
|
||||||
res = get(LIST_URL.format(base=BASE_URL, key=key, domain=domain))
|
res = get(LIST_URL.format(base=BASE_URL, key=key, domain=domain))
|
||||||
if res.status_code != 200:
|
if res.status_code != 200:
|
||||||
@ -39,7 +40,7 @@ def get_namesilo_dns(key, domain, target_host):
|
|||||||
host = i.find('./host').text
|
host = i.find('./host').text
|
||||||
if host == target_host:
|
if host == target_host:
|
||||||
return {
|
return {
|
||||||
'rrid': i.find('./host').text,
|
'rrid': i.find('./record_id').text,
|
||||||
'value': i.find('./value').text,
|
'value': i.find('./value').text,
|
||||||
'host': host,
|
'host': host,
|
||||||
}
|
}
|
||||||
@ -79,7 +80,8 @@ def main():
|
|||||||
print('NAMESILO API service is down or target not found')
|
print('NAMESILO API service is down or target not found')
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
if namesilo_data['value'] == public_ip:
|
curr_ip = namesilo_data['value']
|
||||||
|
if curr_ip == public_ip:
|
||||||
print('Current value is okay. No need to do anything')
|
print('Current value is okay. No need to do anything')
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
@ -88,7 +90,9 @@ def main():
|
|||||||
if not result:
|
if not result:
|
||||||
print('Updating process failed.')
|
print('Updating process failed.')
|
||||||
sys.exit()
|
sys.exit()
|
||||||
print('Updated to a new IP: {}'.format(public_ip))
|
|
||||||
|
print('Updated to a new IP: {} from {}'.format(public_ip, curr_ip))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user