modified: netbox_dns_bridge/catalog_zone_manager.py
modified: netbox_dns_bridge/dns_server.py modified: netbox_dns_bridge/management/commands/dns-export-zone.py modified: netbox_dns_bridge/management/commands/dns-export-zones.py modified: netbox_dns_bridge/management/commands/dns-settings.py modified: netbox_dns_bridge/management/commands/dns-transfer-endpoint.py modified: netbox_dns_bridge/migrations/0001_initial.py modified: netbox_dns_bridge/models.py modified: netbox_dns_bridge/request_handler.py modified: netbox_dns_bridge/signals.py modified: netbox_dns_bridge/utils.py Black code formating corrected
This commit is contained in:
1 parent
165a0faa67
commit
c32161b8a2
11 files changed
+114
-89
No files matched your search
@@ -7,11 +7,14 @@ import netbox_dns.models
|
||||
from netbox_dns_bridge.utils import export_bind_zone_file
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
"--view", type=str, help="The name of the view the Zone to be exported is in"
|
||||
"--view",
|
||||
type=str,
|
||||
help="The name of the view the Zone to be exported is in",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--zone", type=str, help="The FQDN of the Zone to be exported"
|
||||
@@ -20,16 +23,15 @@ class Command(BaseCommand):
|
||||
"--file", type=str, help="Path of the zone file to be written"
|
||||
)
|
||||
|
||||
|
||||
def handle(self, *args, **options):
|
||||
#if len(options) < 2:
|
||||
# if len(options) < 2:
|
||||
# print("export-zone <zone name> <file path>")
|
||||
# sys.exit(1)
|
||||
|
||||
# Load parameters
|
||||
view_name = options['view']
|
||||
zone_name = options['zone']
|
||||
file_path = options['file']
|
||||
view_name = options["view"]
|
||||
zone_name = options["zone"]
|
||||
file_path = options["file"]
|
||||
|
||||
if not view_name:
|
||||
raise CommandError("No --view parameter given")
|
||||
@@ -40,7 +42,9 @@ class Command(BaseCommand):
|
||||
|
||||
try:
|
||||
# Load the zone from NetBox DNS
|
||||
nb_zone = netbox_dns.models.Zone.objects.get(view__name=view_name, name=zone_name)
|
||||
nb_zone = netbox_dns.models.Zone.objects.get(
|
||||
view__name=view_name, name=zone_name
|
||||
)
|
||||
|
||||
if nb_zone:
|
||||
export_bind_zone_file(nb_zone, file_path=file_path)
|
||||
@@ -51,6 +55,6 @@ class Command(BaseCommand):
|
||||
except Exception as e:
|
||||
raise CommandError(f"Failed to export zone: {e}")
|
||||
|
||||
self.stdout.write(self.style.SUCCESS(f"Zone '{zone_name}' exported to '{file_path}'"))
|
||||
|
||||
|
||||
self.stdout.write(
|
||||
self.style.SUCCESS(f"Zone '{zone_name}' exported to '{file_path}'")
|
||||
)
|
||||
@@ -7,16 +7,19 @@ import netbox_dns.models
|
||||
from netbox_dns_bridge.utils import export_bind_zone_file
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
"--path", type=str, help="Path to the directory where zone files are to be written"
|
||||
"--path",
|
||||
type=str,
|
||||
help="Path to the directory where zone files are to be written",
|
||||
)
|
||||
|
||||
def handle(self, *args, **options):
|
||||
# Load parameters
|
||||
base_path = options['path']
|
||||
base_path = options["path"]
|
||||
|
||||
if not base_path:
|
||||
raise CommandError("No --path parameter given")
|
||||
@@ -42,6 +45,8 @@ class Command(BaseCommand):
|
||||
try:
|
||||
# Call existing export function
|
||||
export_bind_zone_file(zone, file_path=file_path)
|
||||
self.stdout.write(self.style.SUCCESS(f"Exported zone '{zone.name}' to '{file_path}'"))
|
||||
self.stdout.write(
|
||||
self.style.SUCCESS(f"Exported zone '{zone.name}' to '{file_path}'")
|
||||
)
|
||||
except Exception as e:
|
||||
self.stderr.write(f"Failed to export zone '{zone.name}': {e}")
|
||||
@@ -6,9 +6,13 @@ class Command(BaseCommand):
|
||||
help = "Get or set integer key-value settings"
|
||||
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument("action", choices=["get", "set", "list"], help="Action to perform")
|
||||
parser.add_argument(
|
||||
"action", choices=["get", "set", "list"], help="Action to perform"
|
||||
)
|
||||
parser.add_argument("key", nargs="?", help="Setting key")
|
||||
parser.add_argument("value", nargs="?", type=int, help="Value to set (required for 'set')")
|
||||
parser.add_argument(
|
||||
"value", nargs="?", type=int, help="Value to set (required for 'set')"
|
||||
)
|
||||
|
||||
def handle(self, *args, **options):
|
||||
action = options["action"]
|
||||
|
||||
@@ -21,13 +21,12 @@ from netbox_dns_bridge.models import IntegerKeyValueSetting
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = "Run a minimal AXFR DNS server using data from NetBox DNS plugin"
|
||||
|
||||
def load_settings(self):
|
||||
self.settings = settings.PLUGINS_CONFIG.get(
|
||||
"netbox_dns_bridge", None
|
||||
)
|
||||
self.settings = settings.PLUGINS_CONFIG.get("netbox_dns_bridge", None)
|
||||
if not self.settings:
|
||||
raise RuntimeError(
|
||||
"Command failed to initialize due to missing settings. Terminating Netbox."
|
||||
|
||||
Reference in new issue
Block a user