Skip to content

Commit

Permalink
Closes #11675: Add support for specifying import/export route targets…
Browse files Browse the repository at this point in the history
… during VRF bulk import
  • Loading branch information
jeremystretch committed Aug 4, 2023
1 parent 88562d7 commit 0dd319d
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions netbox/ipam/forms/bulk_import.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from django import forms
from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import ValidationError
from django.db.models import Q
from django.utils.translation import gettext as _

from dcim.models import Device, Interface, Site
Expand All @@ -10,7 +9,9 @@
from ipam.models import *
from netbox.forms import NetBoxModelImportForm
from tenancy.models import Tenant
from utilities.forms.fields import CSVChoiceField, CSVContentTypeField, CSVModelChoiceField, SlugField
from utilities.forms.fields import (
CSVChoiceField, CSVContentTypeField, CSVModelChoiceField, CSVModelMultipleChoiceField, SlugField
)
from virtualization.models import VirtualMachine, VMInterface

__all__ = (
Expand Down Expand Up @@ -41,10 +42,25 @@ class VRFImportForm(NetBoxModelImportForm):
to_field_name='name',
help_text=_('Assigned tenant')
)
import_targets = CSVModelMultipleChoiceField(
queryset=RouteTarget.objects.all(),
required=False,
to_field_name='name',
help_text=_('Import route targets')
)
export_targets = CSVModelMultipleChoiceField(
queryset=RouteTarget.objects.all(),
required=False,
to_field_name='name',
help_text=_('Export route targets')
)

class Meta:
model = VRF
fields = ('name', 'rd', 'tenant', 'enforce_unique', 'description', 'comments', 'tags')
fields = (
'name', 'rd', 'tenant', 'enforce_unique', 'description', 'import_targets', 'export_targets', 'comments',
'tags',
)


class RouteTargetImportForm(NetBoxModelImportForm):
Expand Down

0 comments on commit 0dd319d

Please sign in to comment.