mirror of
https://github.com/netbox-community/netbox.git
synced 2026-01-24 20:39:59 -06:00
Merge branch 'develop' into feature
This commit is contained in:
@@ -686,6 +686,7 @@ class ModuleForm(NetBoxModelForm):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
if self.instance.pk:
|
||||
self.fields['device'].disabled = True
|
||||
self.fields['replicate_components'].initial = False
|
||||
self.fields['replicate_components'].disabled = True
|
||||
self.fields['adopt_components'].initial = False
|
||||
|
||||
@@ -1009,6 +1009,14 @@ class Module(NetBoxModel, ConfigContextModel):
|
||||
def get_absolute_url(self):
|
||||
return reverse('dcim:module', args=[self.pk])
|
||||
|
||||
def clean(self):
|
||||
super().clean()
|
||||
|
||||
if self.module_bay.device != self.device:
|
||||
raise ValidationError(
|
||||
f"Module must be installed within a module bay belonging to the assigned device ({self.device})."
|
||||
)
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
is_new = self.pk is None
|
||||
|
||||
|
||||
@@ -1778,10 +1778,12 @@ class ModuleTestCase(
|
||||
ModuleBay(device=devices[0], name='Module Bay 2'),
|
||||
ModuleBay(device=devices[0], name='Module Bay 3'),
|
||||
ModuleBay(device=devices[0], name='Module Bay 4'),
|
||||
ModuleBay(device=devices[0], name='Module Bay 5'),
|
||||
ModuleBay(device=devices[1], name='Module Bay 1'),
|
||||
ModuleBay(device=devices[1], name='Module Bay 2'),
|
||||
ModuleBay(device=devices[1], name='Module Bay 3'),
|
||||
ModuleBay(device=devices[1], name='Module Bay 4'),
|
||||
ModuleBay(device=devices[1], name='Module Bay 5'),
|
||||
)
|
||||
ModuleBay.objects.bulk_create(module_bays)
|
||||
|
||||
@@ -1795,7 +1797,7 @@ class ModuleTestCase(
|
||||
tags = create_tags('Alpha', 'Bravo', 'Charlie')
|
||||
|
||||
cls.form_data = {
|
||||
'device': devices[1].pk,
|
||||
'device': devices[0].pk,
|
||||
'module_bay': module_bays[3].pk,
|
||||
'module_type': module_types[0].pk,
|
||||
'serial': 'A',
|
||||
@@ -1867,7 +1869,6 @@ class ModuleTestCase(
|
||||
self.assertIsNone(interface.module)
|
||||
|
||||
# Create a module with adopted components
|
||||
form_data['module_bay'] = ModuleBay.objects.filter(device=device).first()
|
||||
form_data['module_type'] = module_type
|
||||
form_data['replicate_components'] = False
|
||||
form_data['adopt_components'] = True
|
||||
|
||||
@@ -1616,6 +1616,7 @@ class DeviceView(generic.ObjectView):
|
||||
return {
|
||||
'services': services,
|
||||
'vc_members': vc_members,
|
||||
'svg_extra': f'highlight=id:{instance.pk}'
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -471,6 +471,14 @@ class JournalEntry(CustomFieldsMixin, CustomLinksMixin, TagsMixin, WebhooksMixin
|
||||
def get_absolute_url(self):
|
||||
return reverse('extras:journalentry', args=[self.pk])
|
||||
|
||||
def clean(self):
|
||||
super().clean()
|
||||
|
||||
# Prevent the creation of journal entries on unsupported models
|
||||
permitted_types = ContentType.objects.filter(FeatureQuery('journaling').get_query())
|
||||
if self.assigned_object_type not in permitted_types:
|
||||
raise ValidationError(f"Journaling is not supported for this object type ({self.assigned_object_type}).")
|
||||
|
||||
def get_kind_color(self):
|
||||
return JournalEntryKindChoices.colors.get(self.kind)
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ class NetBoxFeatureSet(
|
||||
CustomLinksMixin,
|
||||
CustomValidationMixin,
|
||||
ExportTemplatesMixin,
|
||||
JournalingMixin,
|
||||
TagsMixin,
|
||||
WebhooksMixin
|
||||
):
|
||||
@@ -51,7 +50,7 @@ class ChangeLoggedModel(ChangeLoggingMixin, CustomValidationMixin, models.Model)
|
||||
abstract = True
|
||||
|
||||
|
||||
class NetBoxModel(CloningMixin, NetBoxFeatureSet, models.Model):
|
||||
class NetBoxModel(CloningMixin, JournalingMixin, NetBoxFeatureSet, models.Model):
|
||||
"""
|
||||
Primary models represent real objects within the infrastructure being modeled.
|
||||
"""
|
||||
|
||||
@@ -28,7 +28,7 @@ django.utils.encoding.force_text = force_str # type: ignore
|
||||
# Environment setup
|
||||
#
|
||||
|
||||
VERSION = '3.3.5-dev'
|
||||
VERSION = '3.4-beta1'
|
||||
|
||||
# Hostname
|
||||
HOSTNAME = platform.node()
|
||||
|
||||
2
netbox/project-static/dist/netbox.js
vendored
2
netbox/project-static/dist/netbox.js
vendored
File diff suppressed because one or more lines are too long
2
netbox/project-static/dist/netbox.js.map
vendored
2
netbox/project-static/dist/netbox.js.map
vendored
File diff suppressed because one or more lines are too long
@@ -37,6 +37,20 @@ function initDocument(): void {
|
||||
}
|
||||
|
||||
function initWindow(): void {
|
||||
|
||||
const documentForms = document.forms
|
||||
for (var documentForm of documentForms) {
|
||||
if (documentForm.method.toUpperCase() == 'GET') {
|
||||
// @ts-ignore: Our version of typescript seems to be too old for FormDataEvent
|
||||
documentForm.addEventListener('formdata', function(event: FormDataEvent) {
|
||||
let formData: FormData = event.formData;
|
||||
for (let [name, value] of Array.from(formData.entries())) {
|
||||
if (value === '') formData.delete(name);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const contentContainer = document.querySelector<HTMLElement>('.content-container');
|
||||
if (contentContainer !== null) {
|
||||
// Focus the content container for accessible navigation.
|
||||
|
||||
@@ -54,80 +54,40 @@
|
||||
{% plugin_left_page object %}
|
||||
</div>
|
||||
<div class="col col-md-6">
|
||||
<div class="card">
|
||||
<h5 class="card-header">
|
||||
Connection
|
||||
</h5>
|
||||
<div class="card-body">
|
||||
{% if object.mark_connected %}
|
||||
<span class="text-success"><i class="mdi mdi-check-bold"></i></span> Marked as connected
|
||||
{% elif object.cable %}
|
||||
<table class="table table-hover attr-table">
|
||||
<tr>
|
||||
<th scope="row">Cable</th>
|
||||
<td>
|
||||
{{ object.cable|linkify }}
|
||||
<a href="{% url 'dcim:consoleport_trace' pk=object.pk %}" class="btn btn-primary btn-sm lh-1" title="Trace">
|
||||
<i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% if object.connected_endpoint %}
|
||||
<tr>
|
||||
<th scope="row">Device</th>
|
||||
<td>{{ object.connected_endpoint.device|linkify }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Name</th>
|
||||
<td>{{ object.connected_endpoint|linkify:"name" }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Type</th>
|
||||
<td>{{ object.connected_endpoint.get_type_display|placeholder }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Description</th>
|
||||
<td>{{ object.connected_endpoint.description|placeholder }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Path Status</th>
|
||||
<td>
|
||||
{% if object.path.is_active %}
|
||||
<span class="badge bg-success">Reachable</span>
|
||||
{% else %}
|
||||
<span class="badge bg-danger">Not Reachable</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
</table>
|
||||
{% else %}
|
||||
<div class="text-muted">
|
||||
Not Connected
|
||||
{% if perms.dcim.add_cable %}
|
||||
<div class="dropdown float-end">
|
||||
<button type="button" class="btn btn-primary btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
<span class="mdi mdi-ethernet-cable" aria-hidden="true"></span> Connect
|
||||
</button>
|
||||
<ul class="dropdown-menu dropdown-menu-end">
|
||||
<li>
|
||||
<a href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.consoleport&a_terminations={{ object.pk }}&b_terminations_type=dcim.consoleserverport&termination_b_site={{ object.device.site.pk }}&termination_b_rack={{ object.device.rack.pk }}&return_url={{ object.get_absolute_url }}" class="dropdown-item">Console Server Port</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.consoleport&a_terminations={{ object.pk }}&b_terminations_type=dcim.frontport&termination_b_site={{ object.device.site.pk }}&termination_b_rack={{ object.device.rack.pk }}&return_url={{ object.get_absolute_url }}" class="dropdown-item">Front Port</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.consoleport&a_terminations={{ object.pk }}&b_terminations_type=dcim.rearport&termination_b_site={{ object.device.site.pk }}&termination_b_rack={{ object.device.rack.pk }}&return_url={{ object.get_absolute_url }}" class="dropdown-item">Rear Port</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="card">
|
||||
<h5 class="card-header">Connection</h5>
|
||||
<div class="card-body">
|
||||
{% if object.mark_connected %}
|
||||
<span class="text-success"><i class="mdi mdi-check-bold"></i></span> Marked as connected
|
||||
{% elif object.cable %}
|
||||
{% include 'dcim/inc/connection_endpoints.html' %}
|
||||
{% else %}
|
||||
<div class="text-muted">
|
||||
Not Connected
|
||||
{% if perms.dcim.add_cable %}
|
||||
<div class="dropdown float-end">
|
||||
<button type="button" class="btn btn-primary btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
<span class="mdi mdi-ethernet-cable" aria-hidden="true"></span> Connect
|
||||
</button>
|
||||
<ul class="dropdown-menu dropdown-menu-end">
|
||||
<li>
|
||||
<a href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.consoleport&a_terminations={{ object.pk }}&b_terminations_type=dcim.consoleserverport&termination_b_site={{ object.device.site.pk }}&termination_b_rack={{ object.device.rack.pk }}&return_url={{ object.get_absolute_url }}" class="dropdown-item">Console Server Port</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.consoleport&a_terminations={{ object.pk }}&b_terminations_type=dcim.frontport&termination_b_site={{ object.device.site.pk }}&termination_b_rack={{ object.device.rack.pk }}&return_url={{ object.get_absolute_url }}" class="dropdown-item">Front Port</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.consoleport&a_terminations={{ object.pk }}&b_terminations_type=dcim.rearport&termination_b_site={{ object.device.site.pk }}&termination_b_rack={{ object.device.rack.pk }}&return_url={{ object.get_absolute_url }}" class="dropdown-item">Rear Port</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% include 'dcim/inc/panels/inventory_items.html' %}
|
||||
{% plugin_right_page object %}
|
||||
</div>
|
||||
{% include 'dcim/inc/panels/inventory_items.html' %}
|
||||
{% plugin_right_page object %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
||||
@@ -54,82 +54,40 @@
|
||||
{% plugin_left_page object %}
|
||||
</div>
|
||||
<div class="col col-md-6">
|
||||
<div class="card">
|
||||
<h5 class="card-header">
|
||||
Connection
|
||||
</h5>
|
||||
<div class="card-body">
|
||||
{% if object.mark_connected %}
|
||||
<span class="text-success"><i class="mdi mdi-check-bold"></i></span> Marked as connected
|
||||
{% elif object.cable %}
|
||||
<table class="table table-hover attr-table">
|
||||
<tr>
|
||||
<th scope="row">Cable</th>
|
||||
<td>
|
||||
{{ object.cable|linkify }}
|
||||
<a href="{% url 'dcim:consoleserverport_trace' pk=object.pk %}" class="btn btn-primary btn-sm lh-1" title="Trace">
|
||||
<i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% if object.connected_endpoint %}
|
||||
<tr>
|
||||
<th scope="row">Device</th>
|
||||
<td>
|
||||
{{ object.connected_endpoint.device|linkify }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Name</th>
|
||||
<td>{{ object.connected_endpoint|linkify:"name" }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Type</th>
|
||||
<td>{{ object.connected_endpoint.get_type_display|placeholder }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Description</th>
|
||||
<td>{{ object.connected_endpoint.description|placeholder }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Path Status</th>
|
||||
<td>
|
||||
{% if object.path.is_active %}
|
||||
<span class="badge bg-success">Reachable</span>
|
||||
{% else %}
|
||||
<span class="badge bg-danger">Not Reachable</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
</table>
|
||||
{% else %}
|
||||
<div class="text-muted">
|
||||
Not Connected
|
||||
{% if perms.dcim.add_cable %}
|
||||
<div class="dropdown float-end">
|
||||
<button type="button" class="btn btn-primary btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
<span class="mdi mdi-ethernet-cable" aria-hidden="true"></span> Connect
|
||||
</button>
|
||||
<ul class="dropdown-menu dropdown-menu-end">
|
||||
<li>
|
||||
<a href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.consoleserverport&a_terminations={{ object.pk }}&b_terminations_type=dcim.consoleport&termination_b_site={{ object.device.site.pk }}&termination_b_rack={{ object.device.rack.pk }}&return_url={{ object.get_absolute_url }}" class="dropdown-item">Console Port</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.consoleserverport&a_terminations={{ object.pk }}&b_terminations_type=dcim.frontport&termination_b_site={{ object.device.site.pk }}&termination_b_rack={{ object.device.rack.pk }}&return_url={{ object.get_absolute_url }}" class="dropdown-item">Front Port</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.consoleserverport&a_terminations={{ object.pk }}&b_terminations_type=dcim.rearport&termination_b_site={{ object.device.site.pk }}&termination_b_rack={{ object.device.rack.pk }}&return_url={{ object.get_absolute_url }}" class="dropdown-item">Rear Port</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="card">
|
||||
<h5 class="card-header">Connection</h5>
|
||||
<div class="card-body">
|
||||
{% if object.mark_connected %}
|
||||
<span class="text-success"><i class="mdi mdi-check-bold"></i></span> Marked as connected
|
||||
{% elif object.cable %}
|
||||
{% include 'dcim/inc/connection_endpoints.html' %}
|
||||
{% else %}
|
||||
<div class="text-muted">
|
||||
Not Connected
|
||||
{% if perms.dcim.add_cable %}
|
||||
<div class="dropdown float-end">
|
||||
<button type="button" class="btn btn-primary btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
<span class="mdi mdi-ethernet-cable" aria-hidden="true"></span> Connect
|
||||
</button>
|
||||
<ul class="dropdown-menu dropdown-menu-end">
|
||||
<li>
|
||||
<a href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.consoleserverport&a_terminations={{ object.pk }}&b_terminations_type=dcim.consoleport&termination_b_site={{ object.device.site.pk }}&termination_b_rack={{ object.device.rack.pk }}&return_url={{ object.get_absolute_url }}" class="dropdown-item">Console Port</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.consoleserverport&a_terminations={{ object.pk }}&b_terminations_type=dcim.frontport&termination_b_site={{ object.device.site.pk }}&termination_b_rack={{ object.device.rack.pk }}&return_url={{ object.get_absolute_url }}" class="dropdown-item">Front Port</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.consoleserverport&a_terminations={{ object.pk }}&b_terminations_type=dcim.rearport&termination_b_site={{ object.device.site.pk }}&termination_b_rack={{ object.device.rack.pk }}&return_url={{ object.get_absolute_url }}" class="dropdown-item">Rear Port</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% include 'dcim/inc/panels/inventory_items.html' %}
|
||||
{% plugin_right_page object %}
|
||||
</div>
|
||||
{% include 'dcim/inc/panels/inventory_items.html' %}
|
||||
{% plugin_right_page object %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<div class="col col-md-6">
|
||||
<div class="col col-12 col-xl-6">
|
||||
<div class="card">
|
||||
<h5 class="card-header">
|
||||
Device
|
||||
@@ -153,7 +153,7 @@
|
||||
{% include 'inc/panels/comments.html' %}
|
||||
{% plugin_left_page object %}
|
||||
</div>
|
||||
<div class="col col-md-6">
|
||||
<div class="col col-12 col-xl-6">
|
||||
<div class="card">
|
||||
<h5 class="card-header">Management</h5>
|
||||
<div class="card-body">
|
||||
@@ -286,6 +286,22 @@
|
||||
</div>
|
||||
{% include 'inc/panels/contacts.html' %}
|
||||
{% include 'inc/panels/image_attachments.html' %}
|
||||
{% if object.rack and object.position %}
|
||||
<div class="row" style="margin-bottom: 20px">
|
||||
<div class="col col-md-6 col-sm-6 col-xs-12 text-center">
|
||||
<div style="margin-left: 30px">
|
||||
<h4>Front</h4>
|
||||
{% include 'dcim/inc/rack_elevation.html' with object=object.rack face='front' extra_params=svg_extra %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col col-md-6 col-sm-6 col-xs-12 text-center">
|
||||
<div style="margin-left: 30px">
|
||||
<h4>Rear</h4>
|
||||
{% include 'dcim/inc/rack_elevation.html' with object=object.rack face='rear' extra_params=svg_extra %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% plugin_right_page object %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
<td>
|
||||
{% if termination.parent_object.provider %}
|
||||
<i class="mdi mdi-lightning-bolt" title="Circuit"></i>
|
||||
<a href="{{ termination.parent_object.get_absolute_url }}">
|
||||
{{ termination.parent_object.provider }}
|
||||
{{ termination.parent_object }}
|
||||
</a>
|
||||
{% else %}
|
||||
{{ termination.parent_object|linkify }}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{{ termination|linkify }}
|
||||
</td>
|
||||
36
netbox/templates/dcim/inc/connection_endpoints.html
Normal file
36
netbox/templates/dcim/inc/connection_endpoints.html
Normal file
@@ -0,0 +1,36 @@
|
||||
<table class="table table-hover">
|
||||
<tr>
|
||||
<th scope="row">Cable</th>
|
||||
<td>
|
||||
{{ object.cable|linkify }}
|
||||
<a href="{% url 'dcim:interface_trace' pk=object.pk %}" class="btn btn-primary btn-sm lh-1" title="Trace">
|
||||
<i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Path Status</th>
|
||||
<td>
|
||||
{% if object.path.is_complete and object.path.is_active %}
|
||||
<span class="badge bg-success">Reachable</span>
|
||||
{% else %}
|
||||
<span class="badge bg-danger">Not Reachable</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Path Endpoints</th>
|
||||
<td>
|
||||
{% for endpoint in object.connected_endpoints %}
|
||||
{% if endpoint.parent_object %}
|
||||
{{ endpoint.parent_object|linkify }}
|
||||
<i class="mdi mdi-chevron-right"></i>
|
||||
{% endif %}
|
||||
{{ endpoint|linkify }}
|
||||
{% if not forloop.last %}<br />{% endif %}
|
||||
{% empty %}
|
||||
{{ ''|placeholder }}
|
||||
{% endfor %}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@@ -144,89 +144,7 @@
|
||||
<span class="text-success"><i class="mdi mdi-check-bold"></i></span> Marked as Connected
|
||||
</div>
|
||||
{% elif object.cable %}
|
||||
<table class="table table-hover">
|
||||
{% if object.connected_endpoint.device %}
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
{% if object.connected_endpoint.enabled %}
|
||||
<span class="badge bg-success">Enabled</span>
|
||||
{% else %}
|
||||
<span class="badge bg-danger">Disabled</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
<tr>
|
||||
<th scope="row">Cable</th>
|
||||
<td>
|
||||
{{ object.cable|linkify }}
|
||||
<a href="{% url 'dcim:interface_trace' pk=object.pk %}" class="btn btn-primary btn-sm lh-1" title="Trace">
|
||||
<i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% if object.connected_endpoint.device %}
|
||||
{% with iface=object.connected_endpoint %}
|
||||
<tr>
|
||||
<th scope="row">Device</th>
|
||||
<td>{{ iface.device|linkify }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Name</th>
|
||||
<td>{{ iface|linkify:"name" }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Type</th>
|
||||
<td>{{ iface.get_type_display }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">LAG</th>
|
||||
<td>{{ iface.lag|linkify|placeholder }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Description</th>
|
||||
<td>{{ iface.description|placeholder }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">MTU</th>
|
||||
<td>{{ iface.mtu|placeholder }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">MAC Address</th>
|
||||
<td>{{ iface.mac_address|placeholder }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">802.1Q Mode</th>
|
||||
<td>{{ iface.get_mode_display }}</td>
|
||||
</tr>
|
||||
{% endwith %}
|
||||
{% elif object.connected_endpoint.circuit %}
|
||||
{% with ct=object.connected_endpoint %}
|
||||
<tr>
|
||||
<th scope="row">Provider</th>
|
||||
<td>{{ ct.circuit.provider|linkify }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Circuit</th>
|
||||
<td>{{ ct.circuit|linkify }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Side</th>
|
||||
<td>{{ ct.term_side }}</td>
|
||||
</tr>
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
<tr>
|
||||
<th scope="row">Path Status</th>
|
||||
<td>
|
||||
{% if object.path.is_complete and object.path.is_active %}
|
||||
<span class="badge bg-success">Reachable</span>
|
||||
{% else %}
|
||||
<span class="badge bg-danger">Not Reachable</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
{% include 'dcim/inc/connection_endpoints.html' %}
|
||||
{% elif object.wireless_link %}
|
||||
<table class="table table-hover">
|
||||
<tr>
|
||||
@@ -238,7 +156,7 @@
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% with peer_interface=object.connected_endpoint %}
|
||||
{% with peer_interface=object.link_peers.0 %}
|
||||
<tr>
|
||||
<th scope="row">Device</th>
|
||||
<td>{{ peer_interface.device|linkify }}</td>
|
||||
|
||||
@@ -41,8 +41,8 @@
|
||||
<tr>
|
||||
<th scope="row">Connected Device</th>
|
||||
<td>
|
||||
{% if object.connected_endpoint %}
|
||||
{{ object.connected_endpoint.device|linkify }} ({{ object.connected_endpoint }})
|
||||
{% if object.connected_endpoints %}
|
||||
{{ object.connected_endpoints.0.device|linkify }} ({{ object.connected_endpoints.0|linkify:"name" }})
|
||||
{% else %}
|
||||
{{ ''|placeholder }}
|
||||
{% endif %}
|
||||
@@ -50,7 +50,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Utilization (Allocated)</th>
|
||||
{% with utilization=object.connected_endpoint.get_power_draw %}
|
||||
{% with utilization=object.connected_endpoints.0.get_power_draw %}
|
||||
{% if utilization %}
|
||||
<td>
|
||||
{{ utilization.allocated }}VA / {{ object.available_power }}VA
|
||||
@@ -100,73 +100,33 @@
|
||||
{% plugin_left_page object %}
|
||||
</div>
|
||||
<div class="col col-md-6">
|
||||
<div class="card">
|
||||
<h5 class="card-header">
|
||||
Connection
|
||||
</h5>
|
||||
<div class="card-body">
|
||||
{% if object.mark_connected %}
|
||||
<div class="text-muted">
|
||||
<span class="text-success"><i class="mdi mdi-check-bold"></i></span> Marked as connected
|
||||
</div>
|
||||
{% elif object.cable %}
|
||||
<table class="table table-hover attr-table">
|
||||
<tr>
|
||||
<th scope="row">Cable</th>
|
||||
<td>
|
||||
{{ object.cable|linkify }}
|
||||
<a href="{% url 'dcim:powerfeed_trace' pk=object.pk %}" class="btn btn-primary btn-sm lh-1" title="Trace">
|
||||
<i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% if object.connected_endpoint %}
|
||||
<tr>
|
||||
<th scope="row">Device</th>
|
||||
<td>{{ object.connected_endpoint.device|linkify }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Name</th>
|
||||
<td>{{ object.connected_endpoint|linkify:"name" }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Type</th>
|
||||
<td>{{ object.connected_endpoint.get_type_display|placeholder }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Description</th>
|
||||
<td>{{ object.connected_endpoint.description|placeholder }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Path Status</th>
|
||||
<td>
|
||||
{% if object.path.is_active %}
|
||||
<span class="badge bg-success">Reachable</span>
|
||||
{% else %}
|
||||
<span class="badge bg-danger">Not Reachable</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
</table>
|
||||
{% else %}
|
||||
<div class="text-muted">
|
||||
Not connected
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="card">
|
||||
<h5 class="card-header">Connection</h5>
|
||||
<div class="card-body">
|
||||
{% if object.mark_connected %}
|
||||
<div class="text-muted">
|
||||
<span class="text-success"><i class="mdi mdi-check-bold"></i></span> Marked as connected
|
||||
</div>
|
||||
{% if not object.mark_connected and not object.cable %}
|
||||
<div class="card-footer">
|
||||
{% if perms.dcim.add_cable %}
|
||||
<a href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.powerfeed&a_terminations={{ object.pk }}&b_terminations_type=dcim.powerport&termination_b_site={{ object.device.site.pk }}&termination_b_rack={{ object.device.rack.pk }}&return_url={{ object.get_absolute_url }}" class="btn btn-primary btn-sm float-end">
|
||||
<i class="mdi mdi-ethernet-cable" aria-hidden="true"></i> Connect
|
||||
</a>
|
||||
{% endif %}
|
||||
{% elif object.cable %}
|
||||
{% include 'dcim/inc/connection_endpoints.html' %}
|
||||
{% else %}
|
||||
<div class="text-muted">
|
||||
Not connected
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% include 'inc/panels/comments.html' %}
|
||||
{% plugin_right_page object %}
|
||||
{% if not object.mark_connected and not object.cable %}
|
||||
<div class="card-footer">
|
||||
{% if perms.dcim.add_cable %}
|
||||
<a href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.powerfeed&a_terminations={{ object.pk }}&b_terminations_type=dcim.powerport&termination_b_site={{ object.device.site.pk }}&termination_b_rack={{ object.device.rack.pk }}&return_url={{ object.get_absolute_url }}" class="btn btn-primary btn-sm float-end">
|
||||
<i class="mdi mdi-ethernet-cable" aria-hidden="true"></i> Connect
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% include 'inc/panels/comments.html' %}
|
||||
{% plugin_right_page object %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
||||
@@ -58,69 +58,29 @@
|
||||
{% plugin_left_page object %}
|
||||
</div>
|
||||
<div class="col col-md-6">
|
||||
<div class="card">
|
||||
<h5 class="card-header">
|
||||
Connection
|
||||
</h5>
|
||||
<div class="card-body">
|
||||
{% if object.mark_connected %}
|
||||
<div class="text-muted">
|
||||
<span class="text-success"><i class="mdi mdi-check-bold"></i></span> Marked as Connected
|
||||
</div>
|
||||
{% elif object.cable %}
|
||||
<table class="table table-hover attr-table">
|
||||
<tr>
|
||||
<th scope="row">Cable</th>
|
||||
<td>
|
||||
{{ object.cable|linkify }}
|
||||
<a href="{% url 'dcim:poweroutlet_trace' pk=object.pk %}" class="btn btn-primary btn-sm lh-1" title="Trace">
|
||||
<i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% if object.connected_endpoint %}
|
||||
<tr>
|
||||
<th scope="row">Device</th>
|
||||
<td>{{ object.connected_endpoint.device|linkify }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Name</th>
|
||||
<td>{{ object.connected_endpoint|linkify:"name" }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Type</th>
|
||||
<td>{{ object.connected_endpoint.get_type_display|placeholder }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Description</th>
|
||||
<td>{{ object.connected_endpoint.description|placeholder }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Path Status</th>
|
||||
<td>
|
||||
{% if object.path.is_active %}
|
||||
<span class="badge bg-success">Reachable</span>
|
||||
{% else %}
|
||||
<span class="badge bg-danger">Not Reachable</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
</table>
|
||||
{% else %}
|
||||
<div class="text-muted">
|
||||
Not Connected
|
||||
{% if perms.dcim.add_cable %}
|
||||
<a href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.poweroutlet&a_terminations={{ object.pk }}&b_terminations_type=dcim.powerport&termination_b_site={{ object.device.site.pk }}&termination_b_rack={{ object.device.rack.pk }}&return_url={{ object.get_absolute_url }}" title="Connect" class="btn btn-primary btn-sm float-end">
|
||||
<i class="mdi mdi-ethernet-cable" aria-hidden="true"></i> Connect
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="card">
|
||||
<h5 class="card-header">Connection</h5>
|
||||
<div class="card-body">
|
||||
{% if object.mark_connected %}
|
||||
<div class="text-muted">
|
||||
<span class="text-success"><i class="mdi mdi-check-bold"></i></span> Marked as Connected
|
||||
</div>
|
||||
{% elif object.cable %}
|
||||
{% include 'dcim/inc/connection_endpoints.html' %}
|
||||
{% else %}
|
||||
<div class="text-muted">
|
||||
Not Connected
|
||||
{% if perms.dcim.add_cable %}
|
||||
<a href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.poweroutlet&a_terminations={{ object.pk }}&b_terminations_type=dcim.powerport&termination_b_site={{ object.device.site.pk }}&termination_b_rack={{ object.device.rack.pk }}&return_url={{ object.get_absolute_url }}" title="Connect" class="btn btn-primary btn-sm float-end">
|
||||
<i class="mdi mdi-ethernet-cable" aria-hidden="true"></i> Connect
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% include 'dcim/inc/panels/inventory_items.html' %}
|
||||
{% plugin_right_page object %}
|
||||
</div>
|
||||
{% include 'dcim/inc/panels/inventory_items.html' %}
|
||||
{% plugin_right_page object %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
|
||||
@@ -58,79 +58,39 @@
|
||||
{% plugin_left_page object %}
|
||||
</div>
|
||||
<div class="col col-md-6">
|
||||
<div class="card">
|
||||
<h5 class="card-header">
|
||||
Connection
|
||||
</h5>
|
||||
<div class="card-body">
|
||||
{% if object.mark_connected %}
|
||||
<div class="text-muted">
|
||||
<span class="text-success"><i class="mdi mdi-check-bold"></i></span> Marked as Connected
|
||||
</div>
|
||||
{% elif object.cable %}
|
||||
<table class="table table-hover attr-table">
|
||||
<tr>
|
||||
<th scope="row">Cable</th>
|
||||
<td>
|
||||
{{ object.cable|linkify }}
|
||||
<a href="{% url 'dcim:powerport_trace' pk=object.pk %}" class="btn btn-primary btn-sm lh-1" title="Trace">
|
||||
<i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% if object.connected_endpoint %}
|
||||
<tr>
|
||||
<th scope="row">Device</th>
|
||||
<td>{{ object.connected_endpoint.device|linkify }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Name</th>
|
||||
<td>{{ object.connected_endpoint|linkify:"name" }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Type</th>
|
||||
<td>{{ object.connected_endpoint.get_type_display|placeholder }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Description</th>
|
||||
<td>{{ object.connected_endpoint.description|placeholder }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Path Status</th>
|
||||
<td>
|
||||
{% if object.path.is_active %}
|
||||
<span class="badge bg-success">Reachable</span>
|
||||
{% else %}
|
||||
<span class="badge bg-danger">Not Reachable</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
</table>
|
||||
{% else %}
|
||||
<div class="text-muted">
|
||||
Not Connected
|
||||
{% if perms.dcim.add_cable %}
|
||||
<span class="dropdown float-end">
|
||||
<button type="button" class="btn btn-primary btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<span class="mdi mdi-ethernet-cable" aria-hidden="true"></span> Connect
|
||||
</button>
|
||||
<ul class="dropdown-menu dropdown-menu-end">
|
||||
<li>
|
||||
<a href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.powerportport&a_terminations={{ object.pk }}&termination_b_type=dcim.poweroutlet&termination_b_site={{ object.device.site.pk }}&termination_b_rack={{ object.device.rack.pk }}&return_url={{ object.get_absolute_url }}" class="dropdown-link">Power Outlet</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.powerportport&a_terminations={{ object.pk }}&termination_b_type=dcim.powerfeed&termination_b_site={{ object.device.site.pk }}&termination_b_rack={{ object.device.rack.pk }}&return_url={{ object.get_absolute_url }}" class="dropdown-link">Power Feed</a>
|
||||
</li>
|
||||
</ul>
|
||||
</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="card">
|
||||
<h5 class="card-header">Connection</h5>
|
||||
<div class="card-body">
|
||||
{% if object.mark_connected %}
|
||||
<div class="text-muted">
|
||||
<span class="text-success"><i class="mdi mdi-check-bold"></i></span> Marked as Connected
|
||||
</div>
|
||||
{% elif object.cable %}
|
||||
{% include 'dcim/inc/connection_endpoints.html' %}
|
||||
{% else %}
|
||||
<div class="text-muted">
|
||||
Not Connected
|
||||
{% if perms.dcim.add_cable %}
|
||||
<span class="dropdown float-end">
|
||||
<button type="button" class="btn btn-primary btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<span class="mdi mdi-ethernet-cable" aria-hidden="true"></span> Connect
|
||||
</button>
|
||||
<ul class="dropdown-menu dropdown-menu-end">
|
||||
<li>
|
||||
<a href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.powerportport&a_terminations={{ object.pk }}&termination_b_type=dcim.poweroutlet&termination_b_site={{ object.device.site.pk }}&termination_b_rack={{ object.device.rack.pk }}&return_url={{ object.get_absolute_url }}" class="dropdown-link">Power Outlet</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.powerportport&a_terminations={{ object.pk }}&termination_b_type=dcim.powerfeed&termination_b_site={{ object.device.site.pk }}&termination_b_rack={{ object.device.rack.pk }}&return_url={{ object.get_absolute_url }}" class="dropdown-link">Power Feed</a>
|
||||
</li>
|
||||
</ul>
|
||||
</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% include 'dcim/inc/panels/inventory_items.html' %}
|
||||
{% plugin_right_page object %}
|
||||
</div>
|
||||
{% include 'dcim/inc/panels/inventory_items.html' %}
|
||||
{% plugin_right_page object %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Group</th>
|
||||
<td>{{ object.group|linkify }}</td>
|
||||
<td>{{ object.group|linkify|placeholder }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Tenant</th>
|
||||
@@ -34,7 +34,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Site</th>
|
||||
<td>{{ object.site|linkify }}</td>
|
||||
<td>{{ object.site|linkify|placeholder }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Virtual Machines</th>
|
||||
|
||||
@@ -174,8 +174,8 @@ class ContactAssignment(WebhooksMixin, ChangeLoggedModel):
|
||||
|
||||
def __str__(self):
|
||||
if self.priority:
|
||||
return f"{self.contact} ({self.get_priority_display()})"
|
||||
return str(self.contact)
|
||||
return f"{self.contact} ({self.get_priority_display()}) -> {self.object}"
|
||||
return str(f"{self.contact} -> {self.object}")
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse('tenancy:contact', args=[self.contact.pk])
|
||||
|
||||
@@ -42,7 +42,7 @@ class TenantTable(NetBoxTable):
|
||||
linkify_item=True
|
||||
)
|
||||
tags = columns.TagColumn(
|
||||
url_name='tenancy:tenant_list'
|
||||
url_name='tenancy:contact_list'
|
||||
)
|
||||
|
||||
class Meta(NetBoxTable.Meta):
|
||||
|
||||
@@ -350,14 +350,12 @@ class VirtualMachine(NetBoxModel, ConfigContextModel):
|
||||
})
|
||||
|
||||
# Validate site for cluster & device
|
||||
if self.cluster and self.cluster.site != self.site:
|
||||
if self.cluster and self.site and self.cluster.site != self.site:
|
||||
raise ValidationError({
|
||||
'cluster': f'The selected cluster ({self.cluster} is not assigned to this site ({self.site}).'
|
||||
})
|
||||
if self.device and self.device.site != self.site:
|
||||
raise ValidationError({
|
||||
'device': f'The selected device ({self.device} is not assigned to this site ({self.site}).'
|
||||
'cluster': f'The selected cluster ({self.cluster}) is not assigned to this site ({self.site}).'
|
||||
})
|
||||
elif self.cluster:
|
||||
self.site = self.cluster.site
|
||||
|
||||
# Validate assigned cluster device
|
||||
if self.device and not self.cluster:
|
||||
@@ -366,7 +364,7 @@ class VirtualMachine(NetBoxModel, ConfigContextModel):
|
||||
})
|
||||
if self.device and self.device not in self.cluster.devices.all():
|
||||
raise ValidationError({
|
||||
'device': f'The selected device ({self.device} is not assigned to this cluster ({self.cluster}).'
|
||||
'device': f'The selected device ({self.device}) is not assigned to this cluster ({self.cluster}).'
|
||||
})
|
||||
|
||||
# Validate primary IP addresses
|
||||
|
||||
@@ -70,9 +70,10 @@ class VirtualMachineTestCase(TestCase):
|
||||
with self.assertRaises(ValidationError):
|
||||
VirtualMachine(name='vm1', site=sites[0], cluster=clusters[1]).full_clean()
|
||||
|
||||
# VM with cluster site but no direct site should fail
|
||||
with self.assertRaises(ValidationError):
|
||||
VirtualMachine(name='vm1', site=None, cluster=clusters[0]).full_clean()
|
||||
# VM with cluster site but no direct site should have its site set automatically
|
||||
vm = VirtualMachine(name='vm1', site=None, cluster=clusters[0])
|
||||
vm.full_clean()
|
||||
self.assertEqual(vm.site, sites[0])
|
||||
|
||||
def test_vm_name_case_sensitivity(self):
|
||||
vm1 = VirtualMachine(
|
||||
|
||||
Reference in New Issue
Block a user