Exemple #1
0
    def get_form(self, *args, **kwargs):
        initial = self.get_form_kwargs()
        if 'ip_type' in self.request.GET and 'ip_str' in self.request.GET:
            ip_str = self.request.GET['ip_str']
            ip_type = self.request.GET['ip_type']
            network = calc_parent_str(ip_str, ip_type)
            if network and network.vlan and network.site:
                expected_name = "{0}.{1}.mozilla.com".format(network.vlan.name,
                                                             network.site.get_site_path())
                try:
                    domain = Domain.objects.get(name=expected_name)
                except ObjectDoesNotExist, e:
                    domain = None

            if domain:
                initial['initial'] = {'ip_str': ip_str,
                                      'name': "." + domain.name, 'ip_type': ip_type}
            else:
                initial['initial'] = {'ip_str': ip_str, 'ip_type': ip_type}
Exemple #2
0
    def get_form(self, *args, **kwargs):
        initial = self.get_form_kwargs()
        if 'ip_type' in self.request.GET and 'ip_str' in self.request.GET:
            ip_str = self.request.GET['ip_str']
            ip_type = self.request.GET['ip_type']
            network = calc_parent_str(ip_str, ip_type)
            if network and network.vlan and network.site:
                expected_name = "{0}.{1}.mozilla.com".format(
                    network.vlan.name, network.site.get_site_path())
                try:
                    domain = Domain.objects.get(name=expected_name)
                except ObjectDoesNotExist, e:
                    domain = None

            if domain:
                initial['initial'] = {
                    'ip_str': ip_str,
                    'domain': domain,
                    'ip_type': ip_type
                }
            else:
                initial['initial'] = {'ip_str': ip_str, 'ip_type': ip_type}
Exemple #3
0
            intr = interface_form.save()
        except ValidationError, e:
            interface_form._errors['__all__'] = ErrorList(e.messages)
            return render(request, 'cydhcp/cydhcp_form.html', {
                'form': interface_form,
            })

        return redirect(intr.system.get_detail_url())

    else:
        initial = {}
        if 'ip_type' in request.GET and 'ip_str' in request.GET:
            ip_str = request.GET['ip_str']
            ip_type = request.GET['ip_type']
            network = calc_parent_str(ip_str, ip_type)
            if network and network.vlan and network.site:
                expected_name = "{0}.{1}.mozilla.com".format(network.vlan.name,
                                                             network.site.get_site_path())
                try:
                    domain = Domain.objects.get(name=expected_name)
                except ObjectDoesNotExist, e:
                    domain = None

            if domain:
                initial['initial'] = {'ip_str': ip_str, 'domain': domain,
                                      'ip_type': ip_type}
            else:
                initial['initial'] = {'ip_str': ip_str, 'ip_type': ip_type}

        interface_form = FullStaticInterfaceForm(**initial)
Exemple #4
0
                                           ip_lower=ip_lower).exists()):
                    raise ValidationError("This network has already been "
                                          "allocated.")
            except ValidationError, e:
                form = NetworkForm_network(request.POST)
                if form._errors is None:
                    form._errors = ErrorDict()
                form._errors['__all__'] = ErrorList(e.messages)
                return render(request, 'network/wizard_form.html', {
                    'form': form,
                    'action': 'network'
                })

            request.session['net_wiz_vars'] = {'ip_type': ip_type,
                                               'network_str': str(network)}
            parent = calc_parent_str(network_str, ip_type=ip_type)

            # Now build the form with the correct site.
            form = NetworkForm_site()
            if parent:
                form.fields['site'].initial = parent.site
            else:
                form = NetworkForm_site()

            return render(request, 'network/wizard_form.html', {
                'form': form,
                'action': 'site'
            })
        elif action == "site":
            # We are looking for the user to choose a site.
            form = NetworkForm_site(request.POST)