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

Added CSV export for cables

This commit is contained in:
Jeremy Stretch
2018-11-01 13:39:39 -04:00
parent c3db7191d2
commit 1119209fa0

View File

@ -2407,6 +2407,11 @@ class Cable(ChangeLoggedModel):
objects = CableQuerySet.as_manager()
csv_headers = [
'termination_a_type', 'termination_a_id', 'termination_b_type', 'termination_b_id', 'type', 'status', 'label',
'color', 'length', 'length_unit',
]
class Meta:
unique_together = (
('termination_a_type', 'termination_a_id'),
@ -2461,6 +2466,20 @@ class Cable(ChangeLoggedModel):
super(Cable, self).save(*args, **kwargs)
def to_csv(self):
return (
'{}.{}'.format(self.termination_a_type.app_label, self.termination_a_type.model),
self.termination_a_id,
'{}.{}'.format(self.termination_b_type.app_label, self.termination_b_type.model),
self.termination_b_id,
self.get_type_display(),
self.get_status_display(),
self.label,
self.color,
self.length,
self.length_unit,
)
def get_path_endpoints(self):
"""
Traverse both ends of a cable path and return its connected endpoints. Note that one or both endpoints may be