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

#9888 - Add filter and columns for device and site

This commit is contained in:
Daniel Sheppard
2022-08-02 12:38:16 -05:00
parent 29a611c729
commit 5b3ef04550
4 changed files with 136 additions and 17 deletions

View File

@@ -113,3 +113,18 @@ class L2VPNTermination(NetBoxModel):
f'{l2vpn_type} L2VPNs cannot have more than two terminations; found {terminations_count} already '
f'defined.'
)
@property
def assigned_object_parent(self):
obj_type = ContentType.objects.get_for_model(self.assigned_object)
if obj_type.model == 'vminterface':
return self.assigned_object.virtual_machine
elif obj_type.model == 'interface':
return self.assigned_object.device
elif obj_type.model == 'vminterface':
return self.assigned_object.virtual_machine
return None
@property
def assigned_object_site(self):
return self.assigned_object_parent.site