Initial commit

This commit is contained in:
sven committed 2026-08-16 13:10:26 +02:00
commit 4ff9eac274
45 files changed
+2911

No files matched your search

@@ -0,0 +1,29 @@
{% load helpers %}
{% load i18n %}
{% if nodes %}
<ul class="tree" style="list-style: none; padding-left: {{ depth|add:'20' }}px;">
{% for node in nodes %}
<li>
<strong>{{ node.name }}</strong>
— <code>{{ node.object_type }}</code>
<span class="badge bg-secondary">{{ node.quantity|default:1 }}×</span>
<span class="badge bg-info">{{ node.scope|default:'parent' }}</span>
{% if node.selector %}
<details class="d-inline">
<summary class="badge bg-primary">{% trans "selector" %}</summary>
<pre class="small mt-1">{{ node.selector|json }}</pre>
</details>
{% endif %}
{% if node.allocation %}
<details class="d-inline">
<summary class="badge bg-success">{% trans "allocation" %}</summary>
<pre class="small mt-1">{{ node.allocation|json }}</pre>
</details>
{% endif %}
{% if node.children %}
{% include 'netbox_services/_tree_node.html' with nodes=node.children depth=depth|add:'1' %}
{% endif %}
</li>
{% endfor %}
</ul>
{% endif %}
@@ -0,0 +1,80 @@
{% extends 'generic/object.html' %}
{% load helpers %}
{% load i18n %}
{% block content %}
<div class="row mb-3">
<div class="col col-md-7">
<div class="card">
<h5 class="card-header">{% trans "Service" %}</h5>
<div class="card-body">
<table class="table table-hover attr-table">
<tr>
<th scope="row">{% trans "Name" %}</th>
<td>{{ object.name }}</td>
</tr>
<tr>
<th scope="row">{% trans "Service Template" %}</th>
<td><a href="{{ object.service_template.get_absolute_url }}">{{ object.service_template }}</a></td>
</tr>
<tr>
<th scope="row">{% trans "Tenant" %}</th>
<td>{{ object.tenant|default:'—' }}</td>
</tr>
<tr>
<th scope="row">{% trans "Status" %}</th>
<td>{{ object.get_status_display }}</td>
</tr>
<tr>
<th scope="row">{% trans "Description" %}</th>
<td>{{ object.description|placeholder }}</td>
</tr>
</table>
</div>
</div>
</div>
<div class="col col-md-5">
<div class="card">
<h5 class="card-header">{% trans "Actions" %}</h5>
<div class="card-body">
<a href="{% url 'plugins:netbox_services:service_resolve' pk=object.pk %}" class="btn btn-primary mb-2">
<i class="mdi mdi-play"></i> {% trans "Resolve" %}
</a>
<p class="text-muted small mb-0">
{% trans "Run the resolver to preview and/or reconcile the service's resource bindings." %}
</p>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col col-md-12">
<div class="card">
<h5 class="card-header">{% trans "Resource Bindings" %}</h5>
<div class="card-body">
{% if bindings %}
<table class="table table-sm table-hover">
<thead>
<tr>
<th>{% trans "Object Type" %}</th>
<th>{% trans "Object" %}</th>
</tr>
</thead>
<tbody>
{% for binding in bindings %}
<tr>
<td>{{ binding.content_type }}</td>
<td>{{ binding.content_object|default:'—' }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<span class="text-muted">{% trans "No bindings. Resolve the service to create bindings." %}</span>
{% endif %}
</div>
</div>
</div>
</div>
{% endblock %}
@@ -0,0 +1,119 @@
{% extends 'base/layout.html' %}
{% load helpers %}
{% load i18n %}
{% block title %}{{ service }} — {% trans "Resolve" %}{% endblock %}
{% block content %}
<div class="row mb-3">
<div class="col col-md-12">
<div class="card">
<h5 class="card-header">
{% trans "Resolution Preview" %} — {{ service }}
</h5>
<div class="card-body">
{% if result.errors %}
<div class="alert alert-danger">
<h6>{% trans "Errors" %}</h6>
<ul>
{% for error in result.errors %}
<li>{{ error }}</li>
{% endfor %}
</ul>
</div>
{% endif %}
{% if result.warnings %}
<div class="alert alert-warning">
<h6>{% trans "Warnings" %}</h6>
<ul>
{% for warning in result.warnings %}
<li>{{ warning }}</li>
{% endfor %}
</ul>
</div>
{% endif %}
<div class="row mb-3">
<div class="col col-md-4">
<div class="card border-success">
<div class="card-body text-center">
<h3 class="text-success">{{ result.to_add|length }}</h3>
<p class="mb-0">{% trans "to add" %}</p>
</div>
</div>
</div>
<div class="col col-md-4">
<div class="card border-danger">
<div class="card-body text-center">
<h3 class="text-danger">{{ result.to_remove|length }}</h3>
<p class="mb-0">{% trans "to remove" %}</p>
</div>
</div>
</div>
<div class="col col-md-4">
<div class="card border-secondary">
<div class="card-body text-center">
<h3 class="text-secondary">{{ result.total_planned|add:'0' }}</h3>
<p class="mb-0">{% trans "total planned" %}</p>
</div>
</div>
</div>
</div>
{% if planned_preview %}
<table class="table table-sm table-hover">
<thead>
<tr>
<th>{% trans "Node" %}</th>
<th>{% trans "Object" %}</th>
<th>{% trans "Action" %}</th>
</tr>
</thead>
<tbody>
{% for item in planned_preview %}
<tr>
<td>{{ item.node }}</td>
<td>{{ item.object }}</td>
<td>
{% if item.action == "add" %}
<span class="badge bg-success">{% trans "add" %}</span>
{% else %}
<span class="badge bg-secondary">{% trans "keep" %}</span>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p class="text-muted">{% trans "No objects would be bound." %}</p>
{% endif %}
</div>
</div>
</div>
</div>
<div class="row mb-3">
<div class="col col-md-6">
<div class="card">
<h5 class="card-header">{% trans "Commit" %}</h5>
<div class="card-body">
<p class="text-muted">
{% trans "Committing will add/remove bindings. Allocated objects (e.g. IP addresses) are not deleted on removal — only the binding is removed." %}
</p>
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<button type="submit" class="btn btn-success">
<i class="mdi mdi-check"></i> {% trans "Commit" %}
</button>
<a href="{% url 'plugins:netbox_services:service' pk=service.pk %}" class="btn btn-secondary">
{% trans "Cancel" %}
</a>
</form>
</div>
</div>
</div>
</div>
{% endblock %}
@@ -0,0 +1,67 @@
{% extends 'generic/object.html' %}
{% load helpers %}
{% load i18n %}
{% block content %}
<div class="row mb-3">
<div class="col col-md-7">
<div class="card">
<h5 class="card-header">{% trans "Service Template" %}</h5>
<div class="card-body">
<table class="table table-hover attr-table">
<tr>
<th scope="row">{% trans "Name" %}</th>
<td>{{ object.name }}</td>
</tr>
<tr>
<th scope="row">{% trans "Status" %}</th>
<td>{{ object.get_status_display }}</td>
</tr>
<tr>
<th scope="row">{% trans "Description" %}</th>
<td>{{ object.description|placeholder }}</td>
</tr>
<tr>
<th scope="row">{% trans "Locked" %}</th>
<td>
{% if is_locked %}
<span class="text-warning">{% trans "Yes — services have been spawned" %}</span>
{% else %}
<span class="text-success">{% trans "No — editable" %}</span>
{% endif %}
</td>
</tr>
</table>
</div>
</div>
</div>
<div class="col col-md-5">
<div class="card">
<h5 class="card-header">{% trans "Stats" %}</h5>
<div class="card-body">
<table class="table table-hover attr-table">
<tr>
<th scope="row">{% trans "Services" %}</th>
<td><a href="{% url 'plugins:netbox_services:service_list' %}?service_template={{ object.pk }}">{{ object.services.count }}</a></td>
</tr>
</table>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col col-md-12">
<div class="card">
<h5 class="card-header">{% trans "Requirement Tree" %}</h5>
<div class="card-body">
{% if object.tree %}
{% include 'netbox_services/_tree_node.html' with nodes=object.tree depth=0 %}
{% else %}
<span class="text-muted">{% trans "No requirements defined." %}</span>
{% endif %}
</div>
</div>
</div>
</div>
{% endblock %}