fixed variable names to follow snake_case naming

This commit is contained in:
Louis Lacoste 2022-09-10 10:25:32 +02:00
parent cb39d99618
commit 241b8f5736

View file

@ -78,28 +78,30 @@ def retrieve_dns_ip(api_url, headers):
def update_dns_ip(api_url, headers): def update_dns_ip(api_url, headers):
"""Updates the IP in the DNS record using the IP provided (acquired by retrieve_public_ip) if it is different from the DNS IP""" """Updates the IP in the DNS record using the IP provided (acquired by retrieve_public_ip) if it is different from the DNS IP"""
if destination == "public_ip": if destination == "public_ip":
publicIP = retrieve_public_ip() public_ip = retrieve_public_ip()
else: else:
publicIP = destination public_ip = destination
dnsIP, dns_ttl = retrieve_dns_ip(api_url, headers) dns_ip, dns_ttl = retrieve_dns_ip(api_url, headers)
if verbose: if verbose:
print(f"Public IP is : {publicIP}") print(f"Public IP is : {public_ip}")
if dnsIP: if dns_ip:
print(f"DNS IP is : {dnsIP}") print(f"DNS IP is : {dns_ip}")
else: else:
print("The subdomain doesn't exist, no DNS IP associated") print("The subdomain doesn't exist, no DNS IP associated")
print(f"DNS TTL is {dns_ttl}") print(f"DNS TTL is {dns_ttl}")
if publicIP != dnsIP or dns_ttl != ttl: if public_ip != dns_ip or dns_ttl != ttl:
data = dict() data = dict()
data["rrset_values"] = [publicIP] data["rrset_values"] = [public_ip]
print(f"{domain_record_string : <{domain_record_string_lenght}} | Old IP : {dnsIP} replaced -> by New IP : {publicIP}") print(f"{domain_record_string : <{domain_record_string_lenght}} | Old IP : {dns_ip} replaced -> by New IP : {public_ip}")
print(f"{domain_record_string : <{domain_record_string_lenght}} | Old TTL : {dns_ttl} replaced -> by New IP : {ttl}")
if dns_ttl != ttl: if dns_ttl != ttl:
data["rrset_ttl"] = ttl data["rrset_ttl"] = ttl
if verbose: if verbose:
print(f"TTL are differents. DNS TTL {dns_ttl} where wanted TTL is {ttl}") print(
f"TTL are differents. DNS TTL {dns_ttl} where wanted TTL is {ttl}")
if verbose: if verbose:
print(f"The data to be sent is : {data}") print(f"The data to be sent is : {data}")
@ -107,7 +109,7 @@ def update_dns_ip(api_url, headers):
if verbose: if verbose:
print(f"Request exited with status code : {response.status_code}") print(f"Request exited with status code : {response.status_code}")
else: else:
if publicIP == dnsIP: if public_ip == dns_ip:
print( print(
f"{domain_record_string : <{domain_record_string_lenght}} | {'IPs are the same.':<17}") f"{domain_record_string : <{domain_record_string_lenght}} | {'IPs are the same.':<17}")
if dns_ttl == ttl: if dns_ttl == ttl: