mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-23 07:56:44 -06:00
validation of ip address for device and virtual machine
This commit is contained in:
parent
650783b085
commit
518ee85d9e
@ -516,7 +516,21 @@ class ServiceImportForm(NetBoxModelImportForm):
|
||||
|
||||
class Meta:
|
||||
model = Service
|
||||
fields = ('device', 'virtual_machine', 'ipaddresses', 'name', 'protocol', 'ports', 'description', 'comments', 'tags')
|
||||
fields = (
|
||||
'device', 'virtual_machine', 'ipaddresses', 'name', 'protocol', 'ports', 'description', 'comments', 'tags')
|
||||
|
||||
def clean_ipaddresses(self):
|
||||
|
||||
device = self.cleaned_data.get('device')
|
||||
virtual_machine = self.cleaned_data.get('virtual_machine')
|
||||
|
||||
for ip_address in self.cleaned_data.get('ipaddresses'):
|
||||
if device and ip_address != device.primary_ip4:
|
||||
raise forms.ValidationError("Device should assign to be an ip address")
|
||||
if virtual_machine and ip_address != virtual_machine.primary_ip4:
|
||||
raise forms.ValidationError("Virtual Machine should assign to be an ip address")
|
||||
|
||||
return self.cleaned_data
|
||||
|
||||
|
||||
class L2VPNImportForm(NetBoxModelImportForm):
|
||||
|
Loading…
Reference in New Issue
Block a user