Enabled export templates for secrets

This commit is contained in:
Jeremy Stretch 2018-07-17 10:34:50 -04:00
parent 6cc9ceb198
commit 5cf38b5ce9
3 changed files with 10 additions and 0 deletions

View File

@ -53,6 +53,7 @@ EXPORTTEMPLATE_MODELS = [
'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', 'service', # IPAM 'aggregate', 'prefix', 'ipaddress', 'vlan', 'vrf', 'service', # IPAM
'secret', # Secrets
'tenant', # Tenancy 'tenant', # Tenancy
'cluster', 'virtualmachine', # Virtualization 'cluster', 'virtualmachine', # Virtualization
] ]

View File

@ -376,6 +376,14 @@ class Secret(ChangeLoggedModel, CustomFieldModel):
def get_absolute_url(self): def get_absolute_url(self):
return reverse('secrets:secret', args=[self.pk]) return reverse('secrets:secret', args=[self.pk])
def to_csv(self):
return (
self.device,
self.role,
self.name,
self.plaintext or '',
)
def _pad(self, s): def _pad(self, s):
""" """
Prepend the length of the plaintext (2B) and pad with garbage to a multiple of 16B (minimum of 64B). Prepend the length of the plaintext (2B) and pad with garbage to a multiple of 16B (minimum of 64B).

View File

@ -6,6 +6,7 @@
{% if perms.secrets.add_secret %} {% if perms.secrets.add_secret %}
{% import_button 'secrets:secret_import' %} {% import_button 'secrets:secret_import' %}
{% endif %} {% endif %}
{% export_button content_type %}
</div> </div>
<h1>{% block title %}Secrets{% endblock %}</h1> <h1>{% block title %}Secrets{% endblock %}</h1>
<div class="row"> <div class="row">