Example #1
0
def import_axfr_view(request):
    if request.method == 'POST':
        form = AxfrImportForm(request.POST)
        if form.is_valid():
            origin = form.cleaned_data['origin']
            nameserver = form.cleaned_data['nameserver']
            overwrite = form.cleaned_data['overwrite']

            try:
                process_axfr_response(origin, nameserver, overwrite)
            except Exception as e:
                info_dict = {
                    'strerror': mark_safe(str(e)),
                }
                return render_to_response('powerdns_manager/import/error.html',
                                          {},
                                          mimetype='text/html')
            info_dict = {'is_axfr': True}
            return render_to_response('powerdns_manager/import/success.html',
                                      info_dict,
                                      mimetype='text/html')

    else:
        form = AxfrImportForm()  # An unbound form

    info_dict = {
        'form': form,
    }
    return render_to_response('powerdns_manager/import/axfr.html',
                              info_dict,
                              context_instance=RequestContext(request),
                              mimetype='text/html')
Example #2
0
def import_axfr_view(request):
    if request.method == 'POST':
        form = AxfrImportForm(request.POST)
        if form.is_valid():
            origin = form.cleaned_data['origin']
            nameserver = form.cleaned_data['nameserver']
            overwrite = form.cleaned_data['overwrite']
            
            try:
                process_axfr_response(origin, nameserver, request.user, overwrite)
            except Exception as e:
                info_dict = {
                    'strerror': mark_safe(str(e)),
                }
                return render_to_response('powerdns_manager/zone/import/error.html', {})
            info_dict = {'is_axfr': True}
            return render_to_response('powerdns_manager/zone/import/success.html', info_dict)
            
    else:
        form = AxfrImportForm() # An unbound form

    info_dict = {
        'form': form,
    }
    return render_to_response(
        'powerdns_manager/zone/import/axfr.html', info_dict, context_instance=RequestContext(request))
 def handle(self, *arg_domains, **options):
     nameserver = options.get('nameserver')
     domainfile = options.get('domainfile')
     overwrite = options.get('overwrite')
     verbosity = int(options.get('verbosity', 1))
     
     if not nameserver:
         raise CommandError('error: nameserver is required')
     elif domainfile and not os.path.isfile(domainfile):
         raise CommandError('error: Expected path to file')
     elif not arg_domains and not domainfile:
         raise CommandError('error: Missing domain')
     
     # Domains may exist as args (arg_domains) or contained in the domainfile.
     # Create a list containing all domains.
     domains = []
     for d in arg_domains:
         domains.append(d)
     if domainfile:
         f = open(domainfile, 'rb')
         domains.extend( [line.strip() for line in f.readlines() if line.strip()] )
         f.close()
     
     for domain in domains:
         try:
             process_axfr_response(domain, nameserver, overwrite=overwrite)
         except Exception, e:
             sys.stderr.write('error: %s: %s\n' % (str(e), domain))
             sys.stderr.flush()
         else:
             if verbosity:
                 sys.stdout.write('success: %s\n' % domain)
                 sys.stdout.flush()
Example #4
0
def import_axfr_view(request):
    if request.method == 'POST':
        form = AxfrImportForm(request.POST)
        if form.is_valid():
            origin = form.cleaned_data['origin']
            nameserver = form.cleaned_data['nameserver']
            overwrite = form.cleaned_data['overwrite']
            
            try:
                process_axfr_response(origin, nameserver, overwrite)
            except Exception, e:
                info_dict = {
                    'strerror': mark_safe(str(e)),
                }
                return render_to_response('powerdns_manager/import/error.html', {}, mimetype='text/html')
            info_dict = {'is_axfr': True}
            return render_to_response('powerdns_manager/import/success.html', info_dict, mimetype='text/html')
Example #5
0
def import_axfr_view(request):
    if request.method == 'POST':
        form = AxfrImportForm(request.POST)
        if form.is_valid():
            origin = form.cleaned_data['origin']
            nameserver = form.cleaned_data['nameserver']
            overwrite = form.cleaned_data['overwrite']

            try:
                process_axfr_response(origin, nameserver, request.user,
                                      overwrite)
            except Exception, e:
                info_dict = {
                    'strerror': mark_safe(str(e)),
                }
                return render_to_response(
                    'powerdns_manager/zone/import/error.html', {})
            info_dict = {'is_axfr': True}
            return render_to_response(
                'powerdns_manager/zone/import/success.html', info_dict)