This commit is contained in:
+6
-1
@@ -45,14 +45,18 @@ def _get_current_record(hosted_zone_id: str, record: str, record_type: str) -> s
|
|||||||
if rrset["Name"].rstrip(".") == record_normalized and rrset["Type"] == record_type:
|
if rrset["Name"].rstrip(".") == record_normalized and rrset["Type"] == record_type:
|
||||||
records = rrset.get("ResourceRecords", [])
|
records = rrset.get("ResourceRecords", [])
|
||||||
if records:
|
if records:
|
||||||
return records[0]["Value"].rstrip(".")
|
value = records[0]["Value"].rstrip(".")
|
||||||
|
logger.debug("Found %s record %s: value='%s' (len=%d)", record_type, record, value, len(value))
|
||||||
|
return value
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning("Failed to get current %s record for %s: %s", record_type, record, e)
|
logger.warning("Failed to get current %s record for %s: %s", record_type, record, e)
|
||||||
|
logger.debug("No %s record found for %s", record_type, record)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def update_ipv4(hosted_zone_id: str, record: str, public_ipv4: str) -> bool:
|
def update_ipv4(hosted_zone_id: str, record: str, public_ipv4: str) -> bool:
|
||||||
current = _get_current_record(hosted_zone_id, record, "A")
|
current = _get_current_record(hosted_zone_id, record, "A")
|
||||||
|
logger.debug("IPv4 comparison for %s: current='%s' (len=%d) vs desired='%s' (len=%d)", record, current, len(current or ""), public_ipv4, len(public_ipv4))
|
||||||
if current == public_ipv4:
|
if current == public_ipv4:
|
||||||
logger.info("IPv4 for %s is already %s, no update needed", record, public_ipv4)
|
logger.info("IPv4 for %s is already %s, no update needed", record, public_ipv4)
|
||||||
return False
|
return False
|
||||||
@@ -87,6 +91,7 @@ def update_ipv4(hosted_zone_id: str, record: str, public_ipv4: str) -> bool:
|
|||||||
|
|
||||||
def update_ipv6(hosted_zone_id: str, record: str, public_ipv6: str) -> bool:
|
def update_ipv6(hosted_zone_id: str, record: str, public_ipv6: str) -> bool:
|
||||||
current = _get_current_record(hosted_zone_id, record, "AAAA")
|
current = _get_current_record(hosted_zone_id, record, "AAAA")
|
||||||
|
logger.debug("IPv6 comparison for %s: current='%s' (len=%d) vs desired='%s' (len=%d)", record, current, len(current or ""), public_ipv6, len(public_ipv6))
|
||||||
if current == public_ipv6:
|
if current == public_ipv6:
|
||||||
logger.info("IPv6 for %s is already %s, no update needed", record, public_ipv6)
|
logger.info("IPv6 for %s is already %s, no update needed", record, public_ipv6)
|
||||||
return False
|
return False
|
||||||
|
|||||||
Reference in New Issue
Block a user