Fix style

This commit is contained in:
Antonio J. Delgado 2024-12-09 13:50:29 +02:00
parent 10421cc86a
commit a5d4abfe95

View file

@ -42,14 +42,19 @@ class odi6:
)
ipv4, ipv6 = self._determine_ip()
self._log.debug(
f"IPv4: {ipv4}. IPv6: {ipv6}"
"IPv4: %s. IPv6: %s",
ipv4,
ipv6
)
try:
self._update_a_record(ipv4)
if ipv6:
self._update_aaaa_record(ipv6)
result = self.ovh.post(f"/domain/zone/{self.config['domain']}/refresh")
self._log.debug(f"Zone refresh result: {result}")
self._log.debug(
"Zone refresh result: %s",
result
)
except Exception as error:
self._log.error(
"Error updating records. %s", error
@ -68,8 +73,8 @@ class odi6:
if data['subDomain'] == self.config['hostname']:
record_exists = data
self._log.debug(
f"""Found a record that match the 'subDomain' with
the hostname: {data}"""
"Found a record that match the 'subDomain' with the hostname: %s",
data
)
params = {
'fieldType': "A",
@ -80,8 +85,8 @@ the hostname: {data}"""
if record_exists:
if record_exists['target'] != ipv4:
self._log.debug(
f"""An A record ({record_exists}) exists for this
hostname, updating it."""
"An A record (%s) exists for this hostname, updating it.",
record_exists
)
uri = f"/domain/zone/{self.config['domain']}/record/{record_exists['id']}"
try:
@ -91,7 +96,9 @@ hostname, updating it."""
)
except Exception as error:
self._log.error(
f"Error updating record with URI {uri}. {error}"
"Error updating record with URI %s. %s",
uri,
error
)
sys.exit(1)
else:
@ -105,7 +112,10 @@ target, doing nothing."
f"/domain/zone/{self.config['domain']}/record",
**params,
)
self._log.debug(f"Result: {result}")
self._log.debug(
"Result: %s",
result
)
def _update_aaaa_record(self, ipv6):
aaaa_records = self.ovh.get(
@ -120,8 +130,8 @@ target, doing nothing."
if data['subDomain'] == self.config['hostname']:
record_exists = data
self._log.debug(
f"Found a record that match the 'subDomain' with\
the hostname: {data}"
"Found a record that match the 'subDomain' with the hostname: %s",
data
)
params = {
'fieldType': "AAAA",
@ -132,8 +142,9 @@ the hostname: {data}"
if record_exists:
if record_exists['target'] != ipv6:
self._log.debug(
f"""A AAAA record ({record_exists}) exists for this
hostname, updating it with '{params}'."""
"A AAAA record (%s) exists for this hostname, updating it with '%s'.",
record_exists,
params
)
result = self.ovh.put(
f"""/domain/zone/{self.config['domain']}/record/{record_exists['id']}""",
@ -199,16 +210,20 @@ same target, doing nothing."""
if match:
ipv6 = match.group(0).decode()
except Exception as error:
self._log.debug(f"Exception reaching IPv6 URL. {error}")
self._log.debug(
"Exception reaching IPv6 URL. %s",
error
)
return ipv4, ipv6
self._log.error(
f"""Unable to determine the IP using
'{self.config['web_service_url']}'. Returned data: {result.content}"""
"Unable to determine the IP using '%s'. Returned data: %s",
self.config['web_service_url'],
result.content
)
else:
self._log.error(
f"""Selected method '{self.config['ip_method']}'
has not been implemented."""
"Selected method '%s' has not been implemented.",
self.config['ip_method']
)
return False