Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
badra001 committed Apr 24, 2023
1 parent f35b48f commit acf7bb8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions code/ddns-lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
LOGGER = logging.getLogger()
account_id = None
region = None
VERSION = '1.2.0b35'
VERSION = '1.2.0b36'

# Read Env variables
DEBUG_LOG_LEVEL = os.environ.get('DebugLogLevel', 'INFO')
Expand Down Expand Up @@ -1565,7 +1565,7 @@ def new_change_resource_recordset(oclient, instance_id, zone_id, host_name, host
{
"Action": "UPSERT",
"ResourceRecordSet": {
"Name": host_name,
"Name": create_fqdn(host_name, hosted_zone_name),
"Type": record_type,
"TTL": DNS_RR_TTL,
"ResourceRecords": [
Expand Down Expand Up @@ -1953,7 +1953,7 @@ def new_delete_resource_record(oclient, instance_id, zone_id, host_name, hosted_
{
"Action": "DELETE",
"ResourceRecordSet": {
"Name": host_name,
"Name": create_fqdn(host_name, hosted_zone_name),
"Type": record_type,
"TTL": DNS_RR_TTL,
"ResourceRecords": [
Expand Down Expand Up @@ -2209,7 +2209,7 @@ def new_reverse_entry(ip_list):
"""
Reverses the order of the instance's IP address and helps construct the reverse lookup zone name.
:param str ip_list: IPv4 address to reverse
:return str: Returns a string in the PTR format
:return str: Returns a string in the PTR format (with trailing dot)
"""
try:
ip = ipaddress.ip_address(ip_list)
Expand Down Expand Up @@ -3117,3 +3117,19 @@ def parse_hostname_to_components(name):
# noforward
# noreverse
# noheritage

def create_fqdn(host, zone):
"""
This takes a hostname (may or nay not be FQDN) and a zone, and returns the proper concatenation of the two, with a trailing dot.
:param str host: hostname (short or FQDN)
:param str zone: zone name
:return (str,str): Tuple containing hostname components (may include dot) and domain name for which a PHZ exists. None is returned if not found.
"""

hh = parse_hostname_to_components(name)
if hh[1] == '':
hh[1] = zone
fqdn = hh[0] + '.' + hh[1]
fqdn += '.' if fqdn[-1] != '.' else ''
return fqdn
Binary file modified code/ddns-lambda.zip
Binary file not shown.

0 comments on commit acf7bb8

Please sign in to comment.