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
|
'provider', 'circuit', # Circuits
|
||||||
'site', 'region', 'rack', 'rackgroup', 'manufacturer', 'devicetype', 'device', # DCIM
|
'site', 'region', 'rack', 'rackgroup', 'manufacturer', 'devicetype', 'device', # DCIM
|
||||||
'consoleport', 'powerport', 'interfaceconnection', 'virtualchassis', # DCIM
|
'consoleport', 'powerport', 'interfaceconnection', 'virtualchassis', # DCIM
|
||||||
'aggregate', 'prefix', 'ipaddress', 'vlan', 'vrf', # IPAM
|
'aggregate', 'prefix', 'ipaddress', 'vlan', 'vrf', 'service', # IPAM
|
||||||
'tenant', # Tenancy
|
'tenant', # Tenancy
|
||||||
'cluster', 'virtualmachine', # Virtualization
|
'cluster', 'virtualmachine', # Virtualization
|
||||||
]
|
]
|
||||||
|
@ -880,6 +880,7 @@ class Service(ChangeLoggedModel, CustomFieldModel):
|
|||||||
tags = TaggableManager()
|
tags = TaggableManager()
|
||||||
|
|
||||||
serializer = 'ipam.api.serializers.ServiceSerializer'
|
serializer = 'ipam.api.serializers.ServiceSerializer'
|
||||||
|
csv_headers = ['device', 'virtual_machine', 'name', 'protocol', 'description']
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = ['protocol', 'port']
|
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.")
|
raise ValidationError("A service cannot be associated with both a device and a virtual machine.")
|
||||||
if not self.device and not self.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.")
|
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' %}
|
{% extends '_base.html' %}
|
||||||
|
{% load buttons %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
<div class="pull-right">
|
||||||
|
{% export_button content_type %}
|
||||||
|
</div>
|
||||||
<h1>{% block title %}Services{% endblock %}</h1>
|
<h1>{% block title %}Services{% endblock %}</h1>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
|
Reference in New Issue
Block a user