diff --git a/code/ddns-lambda.py b/code/ddns-lambda.py index ed5f84b..091d639 100755 --- a/code/ddns-lambda.py +++ b/code/ddns-lambda.py @@ -73,7 +73,7 @@ LOGGER = logging.getLogger() ACCOUNT = None REGION = None -VERSION = '0.1.17' +VERSION = '0.1.18' # Adjust the logging level [logging.INFO, logging.DEBUG, logging.WARNING, etc] LOGGER.setLevel(logging.DEBUG) @@ -1470,6 +1470,38 @@ def get_dhcp_configurations(client, dhcp_options_id): LOGGER.info("unexpected error. %s\n", str(sys.exc_info()[0]) + lineno()) +def new_reverse_list(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 + """ + try: + ip = ipaddress.ip_address(ip_list) + reversed_list = ip.reverse_pointer + LOGGER.debug("returning: %s", str(reversed_list) + lineno()) + except: + LOGGER.info("unexpected error. %s\n", str(sys.exc_info()[0]) + lineno()) + return None + + np = '.'.join(p.split('.')[1:]) + + +def new_reverse_domain(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 of the subnet (/24 boundary) + """ + try: + ip = ipaddress.ip_address(ip_list) + reversed_list = '.'.join(ip.reverse_pointer.split('.')[1:]) + LOGGER.debug("returning: %s", str(reversed_list) + lineno()) + except: + LOGGER.info("unexpected error. %s\n", str(sys.exc_info()[0]) + lineno()) + return None + + def reverse_list(ip_list): """ Reverses the order of the instance's IP address and @@ -1730,17 +1762,3 @@ def parse_heritage(info): return kv_results except: return {} - -# heritage examples to incorporate -# h=initialize_heritage('dynr53','0.0.9') -# pprint(h) -# add_heritage_item(h,'instance_id','i-123123123123') -# add_heritage_item(h,'account_id','123123123123') -# add_heritage_item(h,'region','west') -# add_heritage_item_timestamp(h,'create_time') -# txt=format_heritage(h) -# print(txt) -# nh=parse_heritage(txt) -# print(dump_heritage(nh)) -# nh=parse_heritage('bob'+txt) -# print(dump_heritage(nh))