1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Add VMInterface CSV import view

This commit is contained in:
Jeremy Stretch
2020-06-23 17:01:57 -04:00
parent fce19a363d
commit 603c804535
7 changed files with 45 additions and 21 deletions

View File

@ -715,6 +715,29 @@ class VMInterfaceCreateForm(BootstrapMixin, forms.Form):
self.fields['tagged_vlans'].widget.add_additional_query_param('site_id', site.pk)
class VMInterfaceCSVForm(CSVModelForm):
virtual_machine = CSVModelChoiceField(
queryset=VirtualMachine.objects.all(),
to_field_name='name'
)
mode = CSVChoiceField(
choices=InterfaceModeChoices,
required=False,
help_text='IEEE 802.1Q operational mode (for L2 interfaces)'
)
class Meta:
model = VMInterface
fields = VMInterface.csv_headers
def clean_enabled(self):
# Make sure enabled is True when it's not included in the uploaded data
if 'enabled' not in self.data:
return True
else:
return self.cleaned_data['enabled']
class VMInterfaceBulkEditForm(BootstrapMixin, BulkEditForm):
pk = forms.ModelMultipleChoiceField(
queryset=VMInterface.objects.all(),