Exemple #1
0
class RoutingPolicyForm(BootstrapMixin, forms.ModelForm):
    slug = SlugField(max_length=255)
    type = forms.ChoiceField(choices=ROUTING_POLICY_TYPE_CHOICES,
                             widget=StaticSelect)
    address_family = forms.ChoiceField(choices=IP_FAMILY_CHOICES,
                                       widget=StaticSelect)
    comments = CommentField()
    tags = TagField(required=False)

    class Meta:
        model = RoutingPolicy

        fields = (
            "name",
            "slug",
            "type",
            "weight",
            "address_family",
            "comments",
            "tags",
        )
Exemple #2
0
class InternetExchangePeeringDBForm(BootstrapMixin, forms.ModelForm):
    slug = SlugField(max_length=255)

    def __init__(self, *args, **kwargs):
        kwargs.setdefault("label_suffix", "")
        super().__init__(*args, **kwargs)
        self.fields["peeringdb_id"].widget = forms.HiddenInput()

    class Meta:
        model = InternetExchange
        fields = ("peeringdb_id", "name", "slug", "ipv6_address",
                  "ipv4_address")
        labels = {
            "ipv6_address": "IPv6 Address",
            "ipv4_address": "IPv4 Address"
        }
        help_texts = {
            "name": "Full name of the Internet Exchange point",
            "ipv6_address": "IPv6 Address used to peer",
            "ipv4_address": "IPv4 Address used to peer",
        }
Exemple #3
0
class BGPGroupForm(BootstrapMixin, forms.ModelForm):
    slug = SlugField(
        max_length=255,
        help_text=
        "Friendly unique shorthand used for URL and config. Warning: may result in change of operational state on a router if being used in the configuration.",
    )
    comments = CommentField()
    import_routing_policies = DynamicModelMultipleChoiceField(
        required=False,
        queryset=RoutingPolicy.objects.all(),
        query_params={"type": "import-policy"},
    )
    export_routing_policies = DynamicModelMultipleChoiceField(
        required=False,
        queryset=RoutingPolicy.objects.all(),
        query_params={"type": "export-policy"},
    )
    communities = DynamicModelMultipleChoiceField(
        required=False, queryset=Community.objects.all())
    tags = TagField(required=False)

    class Meta:
        model = BGPGroup
        fields = (
            "name",
            "slug",
            "comments",
            "import_routing_policies",
            "export_routing_policies",
            "communities",
            "check_bgp_session_states",
            "tags",
        )
        labels = {"check_bgp_session_states": "Poll peering session states"}
        help_texts = {
            "name":
            "Full name of the BGP group",
            "check_bgp_session_states":
            "If enabled, the state of peering sessions will be polled.",
        }
class BGPGroupForm(BootstrapMixin, forms.ModelForm):
    slug = SlugField(max_length=255)
    comments = CommentField()
    import_routing_policies = DynamicModelMultipleChoiceField(
        required=False,
        queryset=RoutingPolicy.objects.all(),
        widget=APISelectMultiple(
            additional_query_params={"type": "import-policy"}),
    )
    export_routing_policies = DynamicModelMultipleChoiceField(
        required=False,
        queryset=RoutingPolicy.objects.all(),
        widget=APISelectMultiple(
            additional_query_params={"type": "export-policy"}),
    )
    communities = DynamicModelMultipleChoiceField(
        required=False, queryset=Community.objects.all())
    tags = TagField(required=False)

    class Meta:
        model = BGPGroup
        fields = (
            "name",
            "slug",
            "comments",
            "import_routing_policies",
            "export_routing_policies",
            "communities",
            "check_bgp_session_states",
            "tags",
        )
        labels = {"check_bgp_session_states": "Poll Peering Session States"}
        help_texts = {
            "name":
            "Full name of the BGP group",
            "check_bgp_session_states":
            "If enabled, the state of peering sessions will be polled.",
        }
Exemple #5
0
class RoutingPolicyForm(BootstrapMixin, forms.ModelForm):
    slug = SlugField(max_length=255)
    type = forms.ChoiceField(choices=RoutingPolicyType.choices, widget=StaticSelect)
    address_family = forms.ChoiceField(choices=IPFamily.choices, widget=StaticSelect)
    config_context = JSONField(
        required=False, label="Config context", widget=SmallTextarea
    )
    comments = CommentField()
    tags = TagField(required=False)

    class Meta:
        model = RoutingPolicy

        fields = (
            "name",
            "slug",
            "type",
            "weight",
            "address_family",
            "config_context",
            "comments",
            "tags",
        )
Exemple #6
0
class InternetExchangeForm(BootstrapMixin, forms.ModelForm):
    slug = SlugField(max_length=255)
    import_routing_policies = FilterChoiceField(
        required=False,
        queryset=RoutingPolicy.objects.all(),
        widget=APISelectMultiple(
            api_url="/api/peering/routing-policies/",
            query_filters={"type": "import-policy"},
        ),
    )
    export_routing_policies = FilterChoiceField(
        required=False,
        queryset=RoutingPolicy.objects.all(),
        widget=APISelectMultiple(
            api_url="/api/peering/routing-policies/",
            query_filters={"type": "export-policy"},
        ),
    )
    communities = FilterChoiceField(
        required=False,
        queryset=Community.objects.all(),
        widget=APISelectMultiple(api_url="/api/peering/communities/"),
    )
    comments = CommentField()
    tags = TagField(required=False)

    class Meta:
        model = InternetExchange
        fields = (
            "peeringdb_id",
            "name",
            "slug",
            "ipv6_address",
            "ipv4_address",
            "communities",
            "import_routing_policies",
            "export_routing_policies",
            "router",
            "check_bgp_session_states",
            "comments",
            "tags",
        )
        labels = {
            "peeringdb_id": "PeeringDB ID",
            "ipv6_address": "IPv6 Address",
            "ipv4_address": "IPv4 Address",
            "check_bgp_session_states": "Poll Peering Session States",
        }
        help_texts = {
            "peeringdb_id":
            "The PeeringDB ID for the IX connection (can be left empty)",
            "name":
            "Full name of the Internet Exchange point",
            "ipv6_address":
            "IPv6 Address used to peer",
            "ipv4_address":
            "IPv4 Address used to peer",
            "router":
            "Router connected to the Internet Exchange point",
            "check_bgp_session_states":
            "If enabled, with a usable router, the state of peering sessions will be polled.",
        }
        widgets = {"router": APISelect(api_url="/api/peering/routers/")}
Exemple #7
0
class InternetExchangeForm(BootstrapMixin, forms.ModelForm):
    slug = SlugField(
        max_length=255,
        help_text=
        "Friendly unique shorthand used for URL and config. Change Warning: May result in change of Operational State on a Router if being used in config generation",
    )
    local_autonomous_system = DynamicModelChoiceField(
        queryset=AutonomousSystem.objects.all(),
        query_params={"affiliated": True},
        label="Local Autonomous System",
    )
    import_routing_policies = DynamicModelMultipleChoiceField(
        required=False,
        queryset=RoutingPolicy.objects.all(),
        query_params={"type": "import-policy"},
    )
    export_routing_policies = DynamicModelMultipleChoiceField(
        required=False,
        queryset=RoutingPolicy.objects.all(),
        query_params={"type": "export-policy"},
    )
    communities = DynamicModelMultipleChoiceField(
        required=False, queryset=Community.objects.all())
    router = DynamicModelChoiceField(
        required=False,
        queryset=Router.objects.all(),
        help_text="Router connected to the Internet Exchange point",
    )
    comments = CommentField()
    tags = TagField(required=False)

    class Meta:
        model = InternetExchange
        fields = (
            "name",
            "slug",
            "local_autonomous_system",
            "ipv6_address",
            "ipv4_address",
            "communities",
            "import_routing_policies",
            "export_routing_policies",
            "router",
            "check_bgp_session_states",
            "comments",
            "tags",
        )
        labels = {
            "ipv6_address": "IPv6 Address",
            "ipv4_address": "IPv4 Address",
            "check_bgp_session_states": "Poll Peering Session States",
        }
        help_texts = {
            "name":
            "Full name of the Internet Exchange point",
            "ipv6_address":
            "IPv6 Address used to peer",
            "ipv4_address":
            "IPv4 Address used to peer",
            "check_bgp_session_states":
            "If enabled, with a usable router, the state of peering sessions will be polled.",
        }