Browse Source

Added support for group assignment during VLAN import

Jeremy Stretch 8 years ago
parent
commit
cb4643d810
2 changed files with 9 additions and 2 deletions
  1. 3 1
      netbox/ipam/forms.py
  2. 6 1
      netbox/templates/ipam/vlan_import.html

+ 3 - 1
netbox/ipam/forms.py

@@ -503,13 +503,15 @@ class VLANForm(forms.ModelForm, BootstrapMixin):
 class VLANFromCSVForm(forms.ModelForm):
     site = forms.ModelChoiceField(queryset=Site.objects.all(), to_field_name='name',
                                   error_messages={'invalid_choice': 'Device not found.'})
+    group = forms.ModelChoiceField(queryset=VLANGroup.objects.all(), required=False, to_field_name='name',
+                                   error_messages={'invalid_choice': 'VLAN group not found.'})
     status_name = forms.ChoiceField(choices=[(s[1], s[0]) for s in VLAN_STATUS_CHOICES])
     role = forms.ModelChoiceField(queryset=Role.objects.all(), required=False, to_field_name='name',
                                   error_messages={'invalid_choice': 'Invalid role.'})
 
     class Meta:
         model = VLAN
-        fields = ['site', 'vid', 'name', 'status_name', 'role']
+        fields = ['site', 'group', 'vid', 'name', 'status_name', 'role']
 
     def save(self, *args, **kwargs):
         m = super(VLANFromCSVForm, self).save(commit=False)

+ 6 - 1
netbox/templates/ipam/vlan_import.html

@@ -34,6 +34,11 @@
 					<td>LAS2</td>
 				</tr>
 				<tr>
+					<td>Group</td>
+					<td>Name of VLAN group (optional)</td>
+					<td>Backend Network</td>
+				</tr>
+				<tr>
 					<td>ID</td>
 					<td>Configured VLAN ID</td>
 					<td>1400</td>
@@ -56,7 +61,7 @@
 			</tbody>
 		</table>
 		<h4>Example</h4>
-		<pre>LAS2,1400,Cameras,Active,Security</pre>
+		<pre>LAS2,Backend Network,1400,Cameras,Active,Security</pre>
 	</div>
 </div>
 {% endblock %}