-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds config template to vm model (#13450)
* adds config template to vm model #12461 * Add translation tags; collapse config data * i18n cleanup * Establish parity with DeviceRenderConfigView * Move config_template field to RenderConfigMixin --------- Co-authored-by: Jeremy Stretch <[email protected]>
- Loading branch information
1 parent
8593715
commit 752e26c
Showing
15 changed files
with
232 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
netbox/templates/virtualization/virtualmachine/render_config.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
{% extends 'virtualization/virtualmachine/base.html' %} | ||
{% load static %} | ||
{% load i18n %} | ||
|
||
{% block title %}{{ object }} - {% trans "Config" %}{% endblock %} | ||
|
||
{% block content %} | ||
<div class="row mb-3"> | ||
<div class="col-5"> | ||
<div class="card"> | ||
<h5 class="card-header">{% trans "Config Template" %}</h5> | ||
<div class="card-body"> | ||
<table class="table table-hover attr-table"> | ||
<tr> | ||
<th scope="row">{% trans "Config Template" %}</th> | ||
<td>{{ config_template|linkify|placeholder }}</td> | ||
</tr> | ||
<tr> | ||
<th scope="row">{% trans "Data Source" %}</th> | ||
<td>{{ config_template.data_file.source|linkify|placeholder }}</td> | ||
</tr> | ||
<tr> | ||
<th scope="row">{% trans "Data File" %}</th> | ||
<td>{{ config_template.data_file|linkify|placeholder }}</td> | ||
</tr> | ||
</table> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="col-7"> | ||
<div class="card"> | ||
<div class="accordion accordion-flush" id="renderConfig"> | ||
<div class="card-body"> | ||
<div class="accordion-item"> | ||
<h2 class="accordion-header" id="renderConfigHeading"> | ||
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapsedRenderConfig" aria-expanded="false" aria-controls="collapsedRenderConfig"> | ||
{% trans "Context Data" %} | ||
</button> | ||
</h2> | ||
<div id="collapsedRenderConfig" class="accordion-collapse collapse" aria-labelledby="renderConfigHeading" data-bs-parent="#renderConfig"> | ||
<div class="accordion-body"> | ||
<pre class="card-body">{{ context_data|pprint }}</pre> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="row"> | ||
<div class="col"> | ||
<div class="card"> | ||
<div class="card-header"> | ||
<div class="float-end"> | ||
<a href="?export=True" class="btn btn-sm btn-primary" role="button"> | ||
<i class="mdi mdi-download" aria-hidden="true"></i> {% trans "Download" %} | ||
</a> | ||
</div> | ||
<h5>{% trans "Rendered Config" %}</h5> | ||
</div> | ||
{% if config_template %} | ||
<pre class="card-body">{{ rendered_config }}</pre> | ||
{% else %} | ||
<div class="card-body text-muted">{% trans "No configuration template found" %}</div> | ||
{% endif %} | ||
</div> | ||
</div> | ||
</div> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
netbox/virtualization/migrations/0036_virtualmachine_config_template.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Generated by Django 4.1.10 on 2023-08-11 17:16 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('extras', '0098_webhook_custom_field_data_webhook_tags'), | ||
('virtualization', '0035_virtualmachine_interface_count'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='virtualmachine', | ||
name='config_template', | ||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='%(class)ss', to='extras.configtemplate'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.