Commit 4a06a6e4 authored by Alberts S's avatar Alberts S
Browse files

Add support for to disable DNS setup

parent ca80ea91
......@@ -69,7 +69,9 @@ class Controller(CapybaraNetty):
router_coroutines.append(router.add_default_dummy_interface_ip(ip=router_dummy_interface_ip))
await asyncio.gather(*router_coroutines)
await asyncio.gather(self.set_router_interface_tunnels())
await self.setup_router_dns()
if self.dns.enabled:
await self.setup_router_dns()
self.load_pingers()
concurrent_tasks = [
......
......@@ -9,19 +9,23 @@ from CapybaraNetty import CapybaraNetty
class Dns(CapybaraNetty):
def __init__(self):
super().__init__()
self.api = PDNSAPI(self.config["dns_pdns_api_endpoint"])
self.api.session.headers.update({"X-Api-Key": self.config["dns_pdns_api_key"]})
self.ptr_zone = self.api.server("localhost").zone(self.config["dns_ptr_zone"])
self.name_zone = self.api.server("localhost").zone(self.config["dns_name_zone"])
if self.config["dns_ptr_delete_existing"]:
rrsets = self.ptr_zone.rrsets
self.ptr_zone.update_rrsets([x for x in rrsets if x.type == "PTR"], delete=True)
if self.config["dns_name_delete_existing"]:
rrsets = self.name_zone.rrsets
self.name_zone.update_rrsets([x for x in rrsets if x.type == "A"], delete=True)
self.enabled = self.config["dns_enabled"]
if self.enabled:
self.api = PDNSAPI(self.config["dns_pdns_api_endpoint"])
self.api.session.headers.update({"X-Api-Key": self.config["dns_pdns_api_key"]})
self.ptr_zone = self.api.server("localhost").zone(self.config["dns_ptr_zone"])
self.name_zone = self.api.server("localhost").zone(self.config["dns_name_zone"])
if self.config["dns_ptr_delete_existing"]:
rrsets = self.ptr_zone.rrsets
self.ptr_zone.update_rrsets([x for x in rrsets if x.type == "PTR"], delete=True)
if self.config["dns_name_delete_existing"]:
rrsets = self.name_zone.rrsets
self.name_zone.update_rrsets([x for x in rrsets if x.type == "A"], delete=True)
else:
self.__logger.warn("DNS is disabled")
def create_ptr_records(self, records: list[dict[str, ipaddress.ip_address]]):
# expects records=[{'name': 'x' 'ip': IPv4Address('10.88.224.0/32')}]
......
......@@ -44,6 +44,8 @@ controller_static_improvement_stable_time: 20
per_host_ssh_log: false
# Output directory for all commands ran via SSH on servers
per_host_ssh_log_output_directory: "./out/"
# Whether DNS creation is enabled
dns_enabled: False
# PowerDNS API endpoint utilized to create PTR and A records
dns_pdns_api_endpoint: "https://username:password@my-powerdns-server.example.com/api/v1/"
# PowerDNS API key
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment