Skip to content

Commit

Permalink
Fixes #1717: Fixed inteface validation for virtual machines
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremystretch committed Nov 15, 2017
1 parent 8ff10d5 commit 0cb3e17
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions netbox/dcim/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1120,6 +1120,8 @@ def __str__(self):
def clean(self):

# Check that the parent device's DeviceType is a console server
if self.device is None:
raise ValidationError("Console server ports must be assigned to devices.")
device_type = self.device.device_type
if not device_type.is_console_server:
raise ValidationError("The {} {} device type not support assignment of console server ports.".format(
Expand Down Expand Up @@ -1194,6 +1196,8 @@ def __str__(self):
def clean(self):

# Check that the parent device's DeviceType is a PDU
if self.device is None:
raise ValidationError("Power outlets must be assigned to devices.")
device_type = self.device.device_type
if not device_type.is_pdu:
raise ValidationError("The {} {} device type not support assignment of power outlets.".format(
Expand Down Expand Up @@ -1257,11 +1261,12 @@ def __str__(self):
def clean(self):

# Check that the parent device's DeviceType is a network device
device_type = self.device.device_type
if not device_type.is_network_device:
raise ValidationError("The {} {} device type not support assignment of network interfaces.".format(
device_type.manufacturer, device_type
))
if self.device is not None:
device_type = self.device.device_type
if not device_type.is_network_device:
raise ValidationError("The {} {} device type not support assignment of network interfaces.".format(
device_type.manufacturer, device_type
))

# An Interface must belong to a Device *or* to a VirtualMachine
if self.device and self.virtual_machine:
Expand Down

0 comments on commit 0cb3e17

Please sign in to comment.