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}'")
|
||||
)
|
||||
Reference in new issue
Block a user