mirror of
https://github.com/netbox-community/netbox.git
synced 2026-01-23 20:12:42 -06:00
Compare commits
1 Commits
21176-remo
...
15801-vlan
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
af8e53d8fb |
43
.github/ISSUE_TEMPLATE/03-performance.yaml
vendored
43
.github/ISSUE_TEMPLATE/03-performance.yaml
vendored
@@ -1,43 +0,0 @@
|
|||||||
---
|
|
||||||
name: 🏁 Performance
|
|
||||||
type: Performance
|
|
||||||
description: An opportunity to improve application performance
|
|
||||||
labels: ["netbox", "type: performance", "status: needs triage"]
|
|
||||||
body:
|
|
||||||
- type: input
|
|
||||||
attributes:
|
|
||||||
label: NetBox Version
|
|
||||||
description: What version of NetBox are you currently running?
|
|
||||||
placeholder: v4.5.1
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: dropdown
|
|
||||||
attributes:
|
|
||||||
label: Python Version
|
|
||||||
description: What version of Python are you currently running?
|
|
||||||
options:
|
|
||||||
- "3.12"
|
|
||||||
- "3.13"
|
|
||||||
- "3.14"
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: checkboxes
|
|
||||||
attributes:
|
|
||||||
label: Area(s) of Concern
|
|
||||||
description: Which application interface(s) are affected?
|
|
||||||
options:
|
|
||||||
- label: User Interface
|
|
||||||
- label: REST API
|
|
||||||
- label: GraphQL API
|
|
||||||
- label: Python ORM
|
|
||||||
- label: Other
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: textarea
|
|
||||||
attributes:
|
|
||||||
label: Details
|
|
||||||
description: >
|
|
||||||
Describe in detail the operations being performed and the indications of a performance issue.
|
|
||||||
Include any relevant testing parameters, benchmarks, and expected results.
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
@@ -6,7 +6,7 @@ from django.core.files.uploadedfile import SimpleUploadedFile
|
|||||||
from django.forms import ValidationError
|
from django.forms import ValidationError
|
||||||
from django.test import tag, TestCase
|
from django.test import tag, TestCase
|
||||||
|
|
||||||
from core.models import AutoSyncRecord, DataSource, ObjectType
|
from core.models import DataSource, ObjectType
|
||||||
from dcim.models import Device, DeviceRole, DeviceType, Location, Manufacturer, Platform, Region, Site, SiteGroup
|
from dcim.models import Device, DeviceRole, DeviceType, Location, Manufacturer, Platform, Region, Site, SiteGroup
|
||||||
from extras.models import ConfigContext, ConfigContextProfile, ConfigTemplate, ImageAttachment, Tag, TaggedItem
|
from extras.models import ConfigContext, ConfigContextProfile, ConfigTemplate, ImageAttachment, Tag, TaggedItem
|
||||||
from tenancy.models import Tenant, TenantGroup
|
from tenancy.models import Tenant, TenantGroup
|
||||||
@@ -754,53 +754,3 @@ class ConfigTemplateTest(TestCase):
|
|||||||
@tag('regression')
|
@tag('regression')
|
||||||
def test_config_template_with_data_source_nested_templates(self):
|
def test_config_template_with_data_source_nested_templates(self):
|
||||||
self.assertEqual(self.BASE_TEMPLATE, self.main_config_template.render({}))
|
self.assertEqual(self.BASE_TEMPLATE, self.main_config_template.render({}))
|
||||||
|
|
||||||
@tag('regression')
|
|
||||||
def test_autosyncrecord_cleanup_on_detach(self):
|
|
||||||
"""Test that AutoSyncRecord is deleted when detaching from DataSource."""
|
|
||||||
with tempfile.TemporaryDirectory() as temp_dir:
|
|
||||||
templates_dir = Path(temp_dir) / "templates"
|
|
||||||
templates_dir.mkdir(parents=True, exist_ok=True)
|
|
||||||
|
|
||||||
self._create_template_file(templates_dir, 'test.j2', 'Test content')
|
|
||||||
|
|
||||||
data_source = DataSource(
|
|
||||||
name="Test DataSource for Detach",
|
|
||||||
type="local",
|
|
||||||
source_url=str(templates_dir),
|
|
||||||
)
|
|
||||||
data_source.save()
|
|
||||||
data_source.sync()
|
|
||||||
|
|
||||||
data_file = data_source.datafiles.filter(path__endswith='test.j2').first()
|
|
||||||
|
|
||||||
# Create a ConfigTemplate with data_file and auto_sync_enabled
|
|
||||||
config_template = ConfigTemplate(
|
|
||||||
name="TestTemplateForDetach",
|
|
||||||
data_file=data_file,
|
|
||||||
auto_sync_enabled=True
|
|
||||||
)
|
|
||||||
config_template.clean()
|
|
||||||
config_template.save()
|
|
||||||
|
|
||||||
# Verify AutoSyncRecord was created
|
|
||||||
object_type = ObjectType.objects.get_for_model(ConfigTemplate)
|
|
||||||
autosync_records = AutoSyncRecord.objects.filter(
|
|
||||||
object_type=object_type,
|
|
||||||
object_id=config_template.pk
|
|
||||||
)
|
|
||||||
self.assertEqual(autosync_records.count(), 1, "AutoSyncRecord should be created")
|
|
||||||
|
|
||||||
# Detach from DataSource
|
|
||||||
config_template.data_file = None
|
|
||||||
config_template.data_source = None
|
|
||||||
config_template.auto_sync_enabled = False
|
|
||||||
config_template.clean()
|
|
||||||
config_template.save()
|
|
||||||
|
|
||||||
# Verify AutoSyncRecord was deleted
|
|
||||||
autosync_records = AutoSyncRecord.objects.filter(
|
|
||||||
object_type=object_type,
|
|
||||||
object_id=config_template.pk
|
|
||||||
)
|
|
||||||
self.assertEqual(autosync_records.count(), 0, "AutoSyncRecord should be deleted after detaching")
|
|
||||||
|
|||||||
@@ -370,11 +370,6 @@ class AnnotatedIPAddressTable(IPAddressTable):
|
|||||||
verbose_name=_('IP Address')
|
verbose_name=_('IP Address')
|
||||||
)
|
)
|
||||||
|
|
||||||
def render_pk(self, value, record, bound_column):
|
|
||||||
if type(record) is not self._meta.model:
|
|
||||||
return ''
|
|
||||||
return bound_column.column.render(value, bound_column, record)
|
|
||||||
|
|
||||||
class Meta(IPAddressTable.Meta):
|
class Meta(IPAddressTable.Meta):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ from django.utils.translation import gettext_lazy as _
|
|||||||
from django_tables2.utils import Accessor
|
from django_tables2.utils import Accessor
|
||||||
|
|
||||||
from dcim.models import Interface
|
from dcim.models import Interface
|
||||||
|
from dcim.tables.template_code import INTERFACE_LINKTERMINATION, LINKTERMINATION
|
||||||
from ipam.models import *
|
from ipam.models import *
|
||||||
from netbox.tables import NetBoxTable, OrganizationalModelTable, PrimaryModelTable, columns
|
from netbox.tables import NetBoxTable, OrganizationalModelTable, PrimaryModelTable, columns
|
||||||
from tenancy.tables import TenancyColumnsMixin, TenantColumn
|
from tenancy.tables import TenancyColumnsMixin, TenantColumn
|
||||||
@@ -159,11 +160,26 @@ class VLANDevicesTable(VLANMembersTable):
|
|||||||
actions = columns.ActionsColumn(
|
actions = columns.ActionsColumn(
|
||||||
actions=('edit',)
|
actions=('edit',)
|
||||||
)
|
)
|
||||||
|
link_peer = columns.TemplateColumn(
|
||||||
|
accessor='link_peers',
|
||||||
|
template_code=LINKTERMINATION,
|
||||||
|
orderable=False,
|
||||||
|
verbose_name=_('Link Peers'),
|
||||||
|
)
|
||||||
|
|
||||||
|
# Override PathEndpointTable.connection to accommodate virtual circuits
|
||||||
|
connection = columns.TemplateColumn(
|
||||||
|
accessor='_path__destinations',
|
||||||
|
template_code=INTERFACE_LINKTERMINATION,
|
||||||
|
orderable=False,
|
||||||
|
verbose_name=_('Connection'),
|
||||||
|
)
|
||||||
|
|
||||||
class Meta(NetBoxTable.Meta):
|
class Meta(NetBoxTable.Meta):
|
||||||
model = Interface
|
model = Interface
|
||||||
fields = ('device', 'name', 'tagged', 'actions')
|
fields = ('device', 'name', 'link_peer', 'connection', 'tagged', 'actions')
|
||||||
exclude = ('id', )
|
default_columns = ('device', 'name', 'connection', 'tagged', 'actions')
|
||||||
|
exclude = ('id',)
|
||||||
|
|
||||||
|
|
||||||
class VLANVirtualMachinesTable(VLANMembersTable):
|
class VLANVirtualMachinesTable(VLANMembersTable):
|
||||||
|
|||||||
@@ -1,41 +0,0 @@
|
|||||||
from django.test import RequestFactory, TestCase
|
|
||||||
from netaddr import IPNetwork
|
|
||||||
|
|
||||||
from ipam.models import IPAddress, IPRange, Prefix
|
|
||||||
from ipam.tables import AnnotatedIPAddressTable
|
|
||||||
from ipam.utils import annotate_ip_space
|
|
||||||
|
|
||||||
|
|
||||||
class AnnotatedIPAddressTableTest(TestCase):
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def setUpTestData(cls):
|
|
||||||
cls.prefix = Prefix.objects.create(
|
|
||||||
prefix=IPNetwork('10.1.1.0/24'),
|
|
||||||
status='active'
|
|
||||||
)
|
|
||||||
|
|
||||||
cls.ip_address = IPAddress.objects.create(
|
|
||||||
address='10.1.1.1/24',
|
|
||||||
status='active'
|
|
||||||
)
|
|
||||||
|
|
||||||
cls.ip_range = IPRange.objects.create(
|
|
||||||
start_address=IPNetwork('10.1.1.2/24'),
|
|
||||||
end_address=IPNetwork('10.1.1.10/24'),
|
|
||||||
status='active'
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_ipaddress_has_checkbox_iprange_does_not(self):
|
|
||||||
data = annotate_ip_space(self.prefix)
|
|
||||||
table = AnnotatedIPAddressTable(data, orderable=False)
|
|
||||||
table.columns.show('pk')
|
|
||||||
|
|
||||||
request = RequestFactory().get('/')
|
|
||||||
html = table.as_html(request)
|
|
||||||
|
|
||||||
ipaddress_checkbox_count = html.count(f'name="pk" value="{self.ip_address.pk}"')
|
|
||||||
self.assertEqual(ipaddress_checkbox_count, 1)
|
|
||||||
|
|
||||||
iprange_checkbox_count = html.count(f'name="pk" value="{self.ip_range.pk}"')
|
|
||||||
self.assertEqual(iprange_checkbox_count, 0)
|
|
||||||
@@ -49,9 +49,6 @@ def add_requested_prefixes(parent, prefix_list, show_available=True, show_assign
|
|||||||
if prefix_list and show_available:
|
if prefix_list and show_available:
|
||||||
|
|
||||||
# Find all unallocated space, add fake Prefix objects to child_prefixes.
|
# Find all unallocated space, add fake Prefix objects to child_prefixes.
|
||||||
# IMPORTANT: These are unsaved Prefix instances (pk=None). If this is ever changed to use
|
|
||||||
# saved Prefix instances with real pks, bulk delete will fail for mixed-type selections
|
|
||||||
# due to single-model form validation. See: https://github.com/netbox-community/netbox/issues/21176
|
|
||||||
available_prefixes = netaddr.IPSet(parent) ^ netaddr.IPSet([p.prefix for p in prefix_list])
|
available_prefixes = netaddr.IPSet(parent) ^ netaddr.IPSet([p.prefix for p in prefix_list])
|
||||||
available_prefixes = [Prefix(prefix=p, status=None) for p in available_prefixes.iter_cidrs()]
|
available_prefixes = [Prefix(prefix=p, status=None) for p in available_prefixes.iter_cidrs()]
|
||||||
child_prefixes = child_prefixes + available_prefixes
|
child_prefixes = child_prefixes + available_prefixes
|
||||||
|
|||||||
@@ -569,6 +569,7 @@ class SyncedDataMixin(models.Model):
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
AutoSyncRecord.objects.filter(
|
AutoSyncRecord.objects.filter(
|
||||||
|
datafile=self.data_file,
|
||||||
object_type=object_type,
|
object_type=object_type,
|
||||||
object_id=self.pk
|
object_id=self.pk
|
||||||
).delete()
|
).delete()
|
||||||
@@ -581,6 +582,7 @@ class SyncedDataMixin(models.Model):
|
|||||||
# Delete AutoSyncRecord
|
# Delete AutoSyncRecord
|
||||||
object_type = ObjectType.objects.get_for_model(self)
|
object_type = ObjectType.objects.get_for_model(self)
|
||||||
AutoSyncRecord.objects.filter(
|
AutoSyncRecord.objects.filter(
|
||||||
|
datafile=self.data_file,
|
||||||
object_type=object_type,
|
object_type=object_type,
|
||||||
object_id=self.pk
|
object_id=self.pk
|
||||||
).delete()
|
).delete()
|
||||||
|
|||||||
@@ -3,8 +3,6 @@
|
|||||||
|
|
||||||
{% block extra_controls %}
|
{% block extra_controls %}
|
||||||
{% include 'ipam/inc/toggle_available.html' %}
|
{% include 'ipam/inc/toggle_available.html' %}
|
||||||
{% include 'ipam/inc/max_depth.html' %}
|
|
||||||
{% include 'ipam/inc/max_length.html' %}
|
|
||||||
{% if perms.ipam.add_prefix and first_available_prefix %}
|
{% if perms.ipam.add_prefix and first_available_prefix %}
|
||||||
<a href="{% url 'ipam:prefix_add' %}?prefix={{ first_available_prefix }}" class="btn btn-primary">
|
<a href="{% url 'ipam:prefix_add' %}?prefix={{ first_available_prefix }}" class="btn btn-primary">
|
||||||
<i class="mdi mdi-plus-thick" aria-hidden="true"></i> {% trans "Add Prefix" %}
|
<i class="mdi mdi-plus-thick" aria-hidden="true"></i> {% trans "Add Prefix" %}
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
{% load i18n %}
|
|
||||||
{% load helpers %}
|
|
||||||
|
|
||||||
<div class="dropdown">
|
|
||||||
<button class="btn btn-outline-secondary dropdown-toggle" type="button" id="max_depth" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
|
|
||||||
{% trans "Max Depth" %}{% if "depth__lte" in request.GET %}: {{ request.GET.depth__lte }}{% endif %}
|
|
||||||
</button>
|
|
||||||
<ul class="dropdown-menu" aria-labelledby="max_depth">
|
|
||||||
{% if request.GET.depth__lte %}
|
|
||||||
<li>
|
|
||||||
<a class="dropdown-item" href="{{ request.path }}{% querystring request depth__lte=None page=1 %}">{% trans "Clear" %}</a>
|
|
||||||
</li>
|
|
||||||
{% endif %}
|
|
||||||
{% for i in 16|as_range %}
|
|
||||||
<li><a class="dropdown-item" href="{{ request.path }}{% querystring request depth__lte=i page=1 %}">
|
|
||||||
{{ i }} {% if request.GET.depth__lte == i %}<i class="mdi mdi-check-bold"></i>{% endif %}
|
|
||||||
</a></li>
|
|
||||||
{% endfor %}
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
{% load i18n %}
|
|
||||||
{% load helpers %}
|
|
||||||
|
|
||||||
<div class="dropdown">
|
|
||||||
<button class="btn btn-outline-secondary dropdown-toggle" type="button" id="max_length" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
|
|
||||||
{% trans "Max Length" %}{% if "mask_length__lte" in request.GET %}: {{ request.GET.mask_length__lte }}{% endif %}
|
|
||||||
</button>
|
|
||||||
<ul class="dropdown-menu" aria-labelledby="max_length">
|
|
||||||
{% if request.GET.mask_length__lte %}
|
|
||||||
<li>
|
|
||||||
<a class="dropdown-item" href="{{ request.path }}{% querystring request mask_length__lte=None page=1 %}">{% trans "Clear" %}</a>
|
|
||||||
</li>
|
|
||||||
{% endif %}
|
|
||||||
{% for i in "4,8,12,16,20,24,28,32,40,48,56,64"|split %}
|
|
||||||
<li><a class="dropdown-item" href="{{ request.path }}{% querystring request mask_length__lte=i page=1 %}">
|
|
||||||
{{ i }} {% if request.GET.mask_length__lte == i %}<i class="mdi mdi-check-bold"></i>{% endif %}
|
|
||||||
</a></li>
|
|
||||||
{% endfor %}
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
@@ -3,8 +3,6 @@
|
|||||||
|
|
||||||
{% block extra_controls %}
|
{% block extra_controls %}
|
||||||
{% include 'ipam/inc/toggle_available.html' %}
|
{% include 'ipam/inc/toggle_available.html' %}
|
||||||
{% include 'ipam/inc/max_depth.html' %}
|
|
||||||
{% include 'ipam/inc/max_length.html' %}
|
|
||||||
{% if perms.ipam.add_prefix and first_available_prefix %}
|
{% if perms.ipam.add_prefix and first_available_prefix %}
|
||||||
<a href="{% url 'ipam:prefix_add' %}?prefix={{ first_available_prefix }}&vrf={{ object.vrf.pk }}&site={{ object.site.pk }}&tenant_group={{ object.tenant.group.pk }}&tenant={{ object.tenant.pk }}" class="btn btn-primary">
|
<a href="{% url 'ipam:prefix_add' %}?prefix={{ first_available_prefix }}&vrf={{ object.vrf.pk }}&site={{ object.site.pk }}&tenant_group={{ object.tenant.group.pk }}&tenant={{ object.tenant.pk }}" class="btn btn-primary">
|
||||||
<i class="mdi mdi-plus-thick" aria-hidden="true"></i> {% trans "Add Prefix" %}
|
<i class="mdi mdi-plus-thick" aria-hidden="true"></i> {% trans "Add Prefix" %}
|
||||||
|
|||||||
@@ -6,6 +6,38 @@
|
|||||||
<button class="btn btn-outline-secondary toggle-depth" type="button">
|
<button class="btn btn-outline-secondary toggle-depth" type="button">
|
||||||
{% trans "Hide Depth Indicators" %}
|
{% trans "Hide Depth Indicators" %}
|
||||||
</button>
|
</button>
|
||||||
{% include 'ipam/inc/max_depth.html' %}
|
<div class="dropdown">
|
||||||
{% include 'ipam/inc/max_length.html' %}
|
<button class="btn btn-outline-secondary dropdown-toggle" type="button" id="max_depth" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
|
||||||
|
{% trans "Max Depth" %}{% if "depth__lte" in request.GET %}: {{ request.GET.depth__lte }}{% endif %}
|
||||||
|
</button>
|
||||||
|
<ul class="dropdown-menu" aria-labelledby="max_depth">
|
||||||
|
{% if request.GET.depth__lte %}
|
||||||
|
<li>
|
||||||
|
<a class="dropdown-item" href="{% url 'ipam:prefix_list' %}{% querystring request depth__lte=None page=1 %}">{% trans "Clear" %}</a>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
{% for i in 16|as_range %}
|
||||||
|
<li><a class="dropdown-item" href="{% url 'ipam:prefix_list' %}{% querystring request depth__lte=i page=1 %}">
|
||||||
|
{{ i }} {% if request.GET.depth__lte == i %}<i class="mdi mdi-check-bold"></i>{% endif %}
|
||||||
|
</a></li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div class="dropdown">
|
||||||
|
<button class="btn btn-outline-secondary dropdown-toggle" type="button" id="max_length" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
|
||||||
|
{% trans "Max Length" %}{% if "mask_length__lte" in request.GET %}: {{ request.GET.mask_length__lte }}{% endif %}
|
||||||
|
</button>
|
||||||
|
<ul class="dropdown-menu" aria-labelledby="max_length">
|
||||||
|
{% if request.GET.mask_length__lte %}
|
||||||
|
<li>
|
||||||
|
<a class="dropdown-item" href="{% url 'ipam:prefix_list' %}{% querystring request mask_length__lte=None page=1 %}">{% trans "Clear" %}</a>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
{% for i in "4,8,12,16,20,24,28,32,40,48,56,64"|split %}
|
||||||
|
<li><a class="dropdown-item" href="{% url 'ipam:prefix_list' %}{% querystring request mask_length__lte=i page=1 %}">
|
||||||
|
{{ i }} {% if request.GET.mask_length__lte == i %}<i class="mdi mdi-check-bold"></i>{% endif %}
|
||||||
|
</a></li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
Reference in New Issue
Block a user