diff --git a/code/ddns-lambda.py b/code/ddns-lambda.py index 23112e3..1845793 100755 --- a/code/ddns-lambda.py +++ b/code/ddns-lambda.py @@ -73,7 +73,7 @@ LOGGER = logging.getLogger() account_id = None region = None -VERSION = '1.2.0b78' +VERSION = '1.2.0b80' # Read Env variables DEBUG_LOG_LEVEL = os.environ.get('DebugLogLevel', 'INFO') @@ -689,6 +689,8 @@ def lambda_handler( f_hostname = tag_data['option_name'].hostname f_zonename = tag_data['option_name'].zonename elif not tag_data['option_name'].valid and tag_data['option_name'].hostname and tag_data['dhcp_options'].valid: + LOGGER.info( + f"2.2 instance: {instance_id}, using tag_option.name hostname {tag_data['option_name'].hostname} and and tag_option.name zone {tag_data['option_name'].zonename}") f_hostname = tag_data['option_name'].hostname f_zonename = tag_data['dhcp_options'].zonename elif tag_data['name'].valid: @@ -3069,11 +3071,11 @@ def process_tags_flags(tags): """ Process the DNS flags tags into for tags[key]=='boc:dns:flags' - :param list(dict(string)) tags: tags from instance, list of dict of string + :param list(dict(string)) tags: tags from instance, list of dict of string. Keys and values turned to lowercase. :return dict(string): flag settings in defaultdict for controlling which names are registered and when """ - tag_dict = {tag['Key'].lstrip().lower(): tag['Value'] for tag in tags} + tag_dict = {tag['Key'].lstrip().lower(): tag['Value'].lower() for tag in tags} flags_dict = defaultdict(lambda: False) flags = tag_dict.get(TAGKEY_FLAGS.lower(), '').split(',') for flag in flags: @@ -3093,9 +3095,10 @@ def process_tags_value(name): """ if name != '': - components = parse_hostname_to_components(name) - if components: - return (True, components[0], components[1]) + return parse_hostname_to_components(name) +# components = parse_hostname_to_components(name) +# if components: +# return (True, components[0], components[1]) return (False, name, None) @@ -3200,10 +3203,10 @@ def parse_hostname_to_components(name): the Name, boc:dns:cname or boc:dns:name tags contain myhost.db.common.edl.census.gov, and the zone is common.edl.census.gov, simply checking at the first dot (host==myhost, domain==db.common.edl.census.gov) will fail. This will go through the list of PHZs found for the VPC for each of the possible domains, and return the name components if a match is found. - That returned name/zone shoudl be used for all settings. + That returned name/zone shoudl be used for all settings. If the zone is not found it will parse into first part before dot, remainder. :param str name: FQDN to parse and find existing defined PHZ - :return (str,str): Tuple containing hostname components (may include dot) and domain name for which a PHZ exists. None is returned if not found. + :return (bool,str,str): Tuple containing found-PHZ (True|False), hostname components (may include dot) and domain name for which a PHZ exists. None is returned if not found. """ global phz_collection_by_vpc @@ -3212,10 +3215,12 @@ def parse_hostname_to_components(name): host = '.'.join(names[0:i]) domain = '.'.join(names[i:]) + '.' if phz_collection_by_vpc.get(domain): - return (host, domain) - LOGGER.error( - f"No PHZ found for any domain components of {name} associated with this vpc: {lineno()}") - return None + return (True, host, domain) + host = name[0] + domain = '.'.join(names[1:]) + '.' + LOGGER.info( + f"No PHZ found for any domain components of {name} associated with this vpc, returing host {host} domain {domain}: {lineno()}") + return (False, host, domain) # noforward diff --git a/code/ddns-lambda.zip b/code/ddns-lambda.zip index 20d55fd..2b6b2d5 100644 Binary files a/code/ddns-lambda.zip and b/code/ddns-lambda.zip differ