mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Enabled export templates for services
This commit is contained in:
@ -51,7 +51,7 @@ EXPORTTEMPLATE_MODELS = [
|
||||
'provider', 'circuit', # Circuits
|
||||
'site', 'region', 'rack', 'rackgroup', 'manufacturer', 'devicetype', 'device', # DCIM
|
||||
'consoleport', 'powerport', 'interfaceconnection', 'virtualchassis', # DCIM
|
||||
'aggregate', 'prefix', 'ipaddress', 'vlan', 'vrf', # IPAM
|
||||
'aggregate', 'prefix', 'ipaddress', 'vlan', 'vrf', 'service', # IPAM
|
||||
'tenant', # Tenancy
|
||||
'cluster', 'virtualmachine', # Virtualization
|
||||
]
|
||||
|
@ -880,6 +880,7 @@ class Service(ChangeLoggedModel, CustomFieldModel):
|
||||
tags = TaggableManager()
|
||||
|
||||
serializer = 'ipam.api.serializers.ServiceSerializer'
|
||||
csv_headers = ['device', 'virtual_machine', 'name', 'protocol', 'description']
|
||||
|
||||
class Meta:
|
||||
ordering = ['protocol', 'port']
|
||||
@ -901,3 +902,13 @@ class Service(ChangeLoggedModel, CustomFieldModel):
|
||||
raise ValidationError("A service cannot be associated with both a device and a virtual machine.")
|
||||
if not self.device and not self.virtual_machine:
|
||||
raise ValidationError("A service must be associated with either a device or a virtual machine.")
|
||||
|
||||
def to_csv(self):
|
||||
return (
|
||||
self.device.name if self.device else None,
|
||||
self.virtual_machine.name if self.virtual_machine else None,
|
||||
self.name,
|
||||
self.get_protocol_display(),
|
||||
self.port,
|
||||
self.description,
|
||||
)
|
||||
|
@ -1,6 +1,10 @@
|
||||
{% extends '_base.html' %}
|
||||
{% load buttons %}
|
||||
|
||||
{% block content %}
|
||||
<div class="pull-right">
|
||||
{% export_button content_type %}
|
||||
</div>
|
||||
<h1>{% block title %}Services{% endblock %}</h1>
|
||||
<div class="row">
|
||||
<div class="col-md-9">
|
||||
|
Reference in New Issue
Block a user