コード例 #1
0
ファイル: reload_all_dns.py プロジェクト: simhaonline/pcp
 def handle(self, *args, **options):
     domains = Domain.objects.all()
     for domain in domains:
         if domain.dns:
             pri_br = BindRequest(domain.owner, "master")
             pri_br.mod_zone(domain)
             pri_br.mod_config()
             pri_br.reload()
             sec_br = BindRequest(domain.owner, "slave")
             sec_br.mod_config()
             sec_br.reload()
コード例 #2
0
ファイル: reload_all_dns.py プロジェクト: a740122/pcp
 def handle(self, *args, **options):
     domains = Domain.objects.all()
     for domain in domains:
         if domain.dns:
             pri_br = BindRequest(domain.owner, "master")
             pri_br.mod_zone(domain)
             pri_br.mod_config()
             pri_br.reload()
             sec_br = BindRequest(domain.owner, "slave")
             sec_br.mod_config()
             sec_br.reload()
コード例 #3
0
ファイル: views.py プロジェクト: simhaonline/pcp
def add(request):
    """
    Add domain of customer
    """
    u = request.session.get('switched_user', request.user)
    superuser = request.user

    if request.method == 'POST':
        form = FormDomain(request.POST)
        if form.is_valid():
            name = form.cleaned_data["name"]

            object = form.save(commit=False)
            object.owner = u
            object.save()

            if config.handle_dns and object.dns:
                pri_br = BindRequest(u, "master")
                pri_br.mod_zone(object)
                pri_br.mod_config()
                pri_br.reload()
                if config.handle_dns_secondary:
                    sec_br = BindRequest(u, "slave")
                    sec_br.mod_config()
                    sec_br.reload()

            logging.info(_("Added domain %s ") % name)
            message = _("Domain %s has been successfuly added") % name
            send_mail(_('Added new domain: %s') % name,
                      message,
                      settings.EMAIL_FROM,
                      [mail for (name, mail) in settings.ADMINS if mail],
                      fail_silently=True)

            messages.add_message(request, messages.SUCCESS,
                                 _('Domain has been added'))
            return HttpResponseRedirect(
                reverse("subdomains", args=(object.id, )))
    else:
        form = FormDomain()

    return render_to_response('universal.html', {
        "form": form,
        'form_helper': RostiFormHelper(),
        "title": _("Add domain"),
        "u": u,
        "superuser": superuser,
        "menu_active": "domains",
    },
                              context_instance=RequestContext(request))
コード例 #4
0
ファイル: views.py プロジェクト: a740122/pcp
def add(request):
    """
    Add domain of customer
    """
    u = request.session.get('switched_user', request.user)
    superuser = request.user

    if request.method == 'POST':
        form = FormDomain(request.POST)
        if form.is_valid():
            name = form.cleaned_data["name"]

            object = form.save(commit=False)
            object.owner = u
            object.save()

            if config.handle_dns and object.dns:
                pri_br = BindRequest(u, "master")
                pri_br.mod_zone(object)
                pri_br.mod_config()
                pri_br.reload()
                if config.handle_dns_secondary:
                    sec_br = BindRequest(u, "slave")
                    sec_br.mod_config()
                    sec_br.reload()

            logging.info(_("Added domain %s ") % name)
            message = _("Domain %s has been successfuly added") % name
            send_mail(_('Added new domain: %s') % name, message, settings.EMAIL_FROM, [mail for (name, mail) in settings.ADMINS if mail], fail_silently=True)

            messages.add_message(request, messages.SUCCESS, _('Domain has been added'))
            return HttpResponseRedirect(reverse("subdomains", args=(object.id, )))
    else:
        form = FormDomain()

    return render_to_response('universal.html',
            {
            "form": form,
            'form_helper': RostiFormHelper(),
            "title": _("Add domain"),
            "u": u,
            "superuser": superuser,
            "menu_active": "domains",
            },
        context_instance=RequestContext(request)
    )