mirror of
https://github.com/netbox-community/netbox.git
synced 2026-03-07 15:00:04 +01:00
Compare commits
21 Commits
21357-regi
...
feature
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6659bb3abe | ||
|
|
0a5f40338d | ||
|
|
fd6e0e9784 | ||
|
|
2a176df28a | ||
|
|
cd5d88ff8a | ||
|
|
6e3fd9d4b2 | ||
|
|
53ae164c75 | ||
|
|
fa5f9430fc | ||
|
|
351066c73f | ||
|
|
e6db3f75ea | ||
|
|
04244e188f | ||
|
|
eaad5cc26f | ||
|
|
c40640af81 | ||
|
|
3c6596de8f | ||
|
|
b3de0b9bee | ||
|
|
ec0fe62df5 | ||
|
|
d3a0566ee3 | ||
|
|
a1d82e45a0 | ||
|
|
694e3765dd | ||
|
|
303199dc8f | ||
|
|
e4f7f080b3 |
19
.github/workflows/claude-code-review.yml
vendored
19
.github/workflows/claude-code-review.yml
vendored
@@ -3,20 +3,14 @@ name: Claude Code Review
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, synchronize, ready_for_review, reopened]
|
||||
# Optional: Only run on specific file changes
|
||||
# paths:
|
||||
# - "src/**/*.ts"
|
||||
# - "src/**/*.tsx"
|
||||
# - "src/**/*.js"
|
||||
# - "src/**/*.jsx"
|
||||
|
||||
jobs:
|
||||
claude-review:
|
||||
# Optional: Filter by PR author
|
||||
# if: |
|
||||
# github.event.pull_request.user.login == 'external-contributor' ||
|
||||
# github.event.pull_request.user.login == 'new-developer' ||
|
||||
# github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR'
|
||||
# Only run for PRs submitted by organization members or owners
|
||||
if: |
|
||||
github.repository == 'netbox-community/netbox' &&
|
||||
(github.event.pull_request.author_association == 'MEMBER' ||
|
||||
github.event.pull_request.author_association == 'OWNER')
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
@@ -33,7 +27,7 @@ jobs:
|
||||
|
||||
- name: Run Claude Code Review
|
||||
id: claude-review
|
||||
uses: anthropics/claude-code-action@v1
|
||||
uses: anthropics/claude-code-action@e763fe78de2db7389e04818a00b5ff8ba13d1360 # v1
|
||||
with:
|
||||
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
|
||||
plugin_marketplaces: 'https://github.com/anthropics/claude-code.git'
|
||||
@@ -41,4 +35,3 @@ jobs:
|
||||
prompt: '/code-review:code-review ${{ github.repository }}/pull/${{ github.event.pull_request.number }}'
|
||||
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
|
||||
# or https://code.claude.com/docs/en/cli-reference for available options
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ colorama
|
||||
|
||||
# The Python web framework on which NetBox is built
|
||||
# https://docs.djangoproject.com/en/stable/releases/
|
||||
Django==5.2.*
|
||||
Django==6.0.*
|
||||
|
||||
# Django middleware which permits cross-domain API requests
|
||||
# https://github.com/adamchainz/django-cors-headers/blob/main/CHANGELOG.rst
|
||||
@@ -35,7 +35,9 @@ django-pglocks
|
||||
|
||||
# Prometheus metrics library for Django
|
||||
# https://github.com/korfuri/django-prometheus/blob/master/CHANGELOG.md
|
||||
django-prometheus
|
||||
# TODO: 2.4.1 is incompatible with Django>=6.0, but a fixed release is expected
|
||||
# https://github.com/django-commons/django-prometheus/issues/494
|
||||
django-prometheus>=2.4.0,<2.5.0,!=2.4.1
|
||||
|
||||
# Django caching backend using Redis
|
||||
# https://github.com/jazzband/django-redis/blob/master/CHANGELOG.rst
|
||||
|
||||
@@ -20,9 +20,7 @@ There are four core actions that can be permitted for each type of object within
|
||||
* **Change** - Modify an existing object
|
||||
* **Delete** - Delete an existing object
|
||||
|
||||
In addition to these, permissions can also grant custom actions that may be required by a specific model or plugin. For example, the `sync` action for data sources allows a user to synchronize data from a remote source, and the `render_config` action for devices and virtual machines allows rendering configuration templates.
|
||||
|
||||
Some models have registered custom actions that appear as checkboxes when creating or editing a permission. These are grouped by model under "Custom actions" in the permission form. Additional custom actions (such as those not yet registered or for backwards compatibility) can be entered manually in the "Additional actions" field.
|
||||
In addition to these, permissions can also grant custom actions that may be required by a specific model or plugin. For example, the `run` permission for scripts allows a user to execute custom scripts. These can be specified when granting a permission in the "additional actions" field.
|
||||
|
||||
!!! note
|
||||
Internally, all actions granted by a permission (both built-in and custom) are stored as strings in an array field named `actions`.
|
||||
|
||||
@@ -21,6 +21,7 @@ Some configuration parameters are primarily controlled via NetBox's admin interf
|
||||
* [`BANNER_BOTTOM`](./miscellaneous.md#banner_bottom)
|
||||
* [`BANNER_LOGIN`](./miscellaneous.md#banner_login)
|
||||
* [`BANNER_TOP`](./miscellaneous.md#banner_top)
|
||||
* [`CHANGELOG_RETAIN_CREATE_LAST_UPDATE`](./miscellaneous.md#changelog_retain_create_last_update)
|
||||
* [`CHANGELOG_RETENTION`](./miscellaneous.md#changelog_retention)
|
||||
* [`CUSTOM_VALIDATORS`](./data-validation.md#custom_validators)
|
||||
* [`DEFAULT_USER_PREFERENCES`](./default-values.md#default_user_preferences)
|
||||
|
||||
@@ -73,6 +73,27 @@ This data enables the project maintainers to estimate how many NetBox deployment
|
||||
|
||||
---
|
||||
|
||||
## CHANGELOG_RETAIN_CREATE_LAST_UPDATE
|
||||
|
||||
!!! tip "Dynamic Configuration Parameter"
|
||||
|
||||
Default: `True`
|
||||
|
||||
When pruning expired changelog entries (per `CHANGELOG_RETENTION`), retain each non-deleted object's original `create`
|
||||
change record and its most recent `update` change record. If an object has a `delete` change record, its changelog
|
||||
entries are pruned normally according to `CHANGELOG_RETENTION`.
|
||||
|
||||
!!! note
|
||||
For objects without a `delete` change record, the original `create` record and most recent `update` record are
|
||||
exempt from pruning. All other changelog records (including intermediate `update` records and all `delete` records)
|
||||
remain subject to pruning per `CHANGELOG_RETENTION`.
|
||||
|
||||
!!! warning
|
||||
This setting is enabled by default. Upgrading deployments that rely on complete pruning of expired changelog entries
|
||||
should explicitly set `CHANGELOG_RETAIN_CREATE_LAST_UPDATE = False` to preserve the previous behavior.
|
||||
|
||||
---
|
||||
|
||||
## CHANGELOG_RETENTION
|
||||
|
||||
!!! tip "Dynamic Configuration Parameter"
|
||||
|
||||
@@ -341,7 +341,7 @@ When retrieving devices and virtual machines via the REST API, each will include
|
||||
|
||||
## Pagination
|
||||
|
||||
API responses which contain a list of many objects will be paginated for efficiency. The root JSON object returned by a list endpoint contains the following attributes:
|
||||
API responses which contain a list of many objects will be paginated for efficiency. NetBox employs offset-based pagination by default, which forms a page by skipping the number of objects indicated by the `offset` URL parameter. The root JSON object returned by a list endpoint contains the following attributes:
|
||||
|
||||
* `count`: The total number of all objects matching the query
|
||||
* `next`: A hyperlink to the next page of results (if applicable)
|
||||
@@ -398,6 +398,49 @@ The maximum number of objects that can be returned is limited by the [`MAX_PAGE_
|
||||
!!! warning
|
||||
Disabling the page size limit introduces a potential for very resource-intensive requests, since one API request can effectively retrieve an entire table from the database.
|
||||
|
||||
### Cursor-Based Pagination
|
||||
|
||||
For large datasets, offset-based pagination can become inefficient because the database must scan all rows up to the offset. As an alternative, cursor-based pagination uses the `start` query parameter to filter results by primary key (PK), enabling efficient keyset pagination.
|
||||
|
||||
To use cursor-based pagination, pass `start` (the minimum PK value) and `limit` (the page size):
|
||||
|
||||
```
|
||||
http://netbox/api/dcim/devices/?start=0&limit=100
|
||||
```
|
||||
|
||||
This returns objects with an `id` greater than or equal to zero, ordered by PK, limited to 100 results. Below is an example showing an arbitrary `start` value.
|
||||
|
||||
```json
|
||||
{
|
||||
"count": null,
|
||||
"next": "http://netbox/api/dcim/devices/?start=356&limit=100",
|
||||
"previous": null,
|
||||
"results": [
|
||||
{
|
||||
"id": 109,
|
||||
"name": "dist-router07",
|
||||
...
|
||||
},
|
||||
...
|
||||
{
|
||||
"id": 356,
|
||||
"name": "acc-switch492",
|
||||
...
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
To iterate through all results, use the `id` of the last object in each response plus one as the `start` value for the next request. Continue until `next` is null.
|
||||
|
||||
!!! info
|
||||
Some important differences from offset-based pagination:
|
||||
|
||||
* `start` and `offset` are **mutually exclusive**; specifying both will result in a 400 error.
|
||||
* Results are always ordered by primary key when using `start`. This is required to ensure deterministic behavior.
|
||||
* `count` is always `null` in cursor mode, as counting all matching rows would partially negate its performance benefit.
|
||||
* `previous` is always `null`: cursor-based pagination supports only forward navigation.
|
||||
|
||||
## Interacting with Objects
|
||||
|
||||
### Retrieving Multiple Objects
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
# Custom Model Actions
|
||||
|
||||
Plugins can register custom permission actions for their models. These actions appear as checkboxes in the ObjectPermission form, making it easy for administrators to grant or restrict access to plugin-specific functionality without manually entering action names.
|
||||
|
||||
For example, a plugin might define a "sync" action for a model that syncs data from an external source, or a "bypass" action that allows users to bypass certain restrictions.
|
||||
|
||||
## Registering Model Actions
|
||||
|
||||
To register custom actions for a model, call `register_model_actions()` in your plugin's `ready()` method:
|
||||
|
||||
```python
|
||||
# __init__.py
|
||||
from netbox.plugins import PluginConfig
|
||||
|
||||
class MyPluginConfig(PluginConfig):
|
||||
name = 'my_plugin'
|
||||
# ...
|
||||
|
||||
def ready(self):
|
||||
super().ready()
|
||||
from utilities.permissions import ModelAction, register_model_actions
|
||||
from .models import MyModel
|
||||
|
||||
register_model_actions(MyModel, [
|
||||
ModelAction('sync', help_text='Synchronize data from external source'),
|
||||
ModelAction('export', help_text='Export data to external system'),
|
||||
])
|
||||
|
||||
config = MyPluginConfig
|
||||
```
|
||||
|
||||
Once registered, these actions will appear grouped under your model's name when creating or editing an ObjectPermission that includes your model as an object type.
|
||||
|
||||
::: utilities.permissions.ModelAction
|
||||
|
||||
::: utilities.permissions.register_model_actions
|
||||
@@ -151,7 +151,6 @@ nav:
|
||||
- Filters & Filter Sets: 'plugins/development/filtersets.md'
|
||||
- Search: 'plugins/development/search.md'
|
||||
- Event Types: 'plugins/development/event-types.md'
|
||||
- Permissions: 'plugins/development/permissions.md'
|
||||
- Data Backends: 'plugins/development/data-backends.md'
|
||||
- Webhooks: 'plugins/development/webhooks.md'
|
||||
- User Interface: 'plugins/development/user-interface.md'
|
||||
|
||||
@@ -25,19 +25,12 @@ class CoreConfig(AppConfig):
|
||||
from core.checks import check_duplicate_indexes # noqa: F401
|
||||
from netbox import context_managers # noqa: F401
|
||||
from netbox.models.features import register_models
|
||||
from utilities.permissions import ModelAction, register_model_actions
|
||||
|
||||
from . import data_backends, events, search # noqa: F401
|
||||
from .models import DataSource
|
||||
|
||||
# Register models
|
||||
register_models(*self.get_models())
|
||||
|
||||
# Register custom permission actions
|
||||
register_model_actions(DataSource, [
|
||||
ModelAction('sync', help_text=_('Synchronize data from remote source')),
|
||||
])
|
||||
|
||||
# Register core events
|
||||
EventType(OBJECT_CREATED, _('Object created')).register()
|
||||
EventType(OBJECT_UPDATED, _('Object updated')).register()
|
||||
|
||||
@@ -165,9 +165,10 @@ class ConfigRevisionForm(forms.ModelForm, metaclass=ConfigFormMetaclass):
|
||||
FieldSet('PAGINATE_COUNT', 'MAX_PAGE_SIZE', name=_('Pagination')),
|
||||
FieldSet('CUSTOM_VALIDATORS', 'PROTECTION_RULES', name=_('Validation')),
|
||||
FieldSet('DEFAULT_USER_PREFERENCES', name=_('User Preferences')),
|
||||
FieldSet('CHANGELOG_RETENTION', 'CHANGELOG_RETAIN_CREATE_LAST_UPDATE', name=_('Change Log')),
|
||||
FieldSet(
|
||||
'MAINTENANCE_MODE', 'COPILOT_ENABLED', 'GRAPHQL_ENABLED', 'CHANGELOG_RETENTION', 'JOB_RETENTION',
|
||||
'MAPS_URL', name=_('Miscellaneous'),
|
||||
'MAINTENANCE_MODE', 'COPILOT_ENABLED', 'GRAPHQL_ENABLED', 'JOB_RETENTION', 'MAPS_URL',
|
||||
name=_('Miscellaneous'),
|
||||
),
|
||||
FieldSet('comment', name=_('Config Revision'))
|
||||
)
|
||||
|
||||
@@ -5,6 +5,7 @@ from importlib import import_module
|
||||
import requests
|
||||
from django.conf import settings
|
||||
from django.core.cache import cache
|
||||
from django.db.models import Exists, OuterRef, Subquery
|
||||
from django.utils import timezone
|
||||
from packaging import version
|
||||
|
||||
@@ -14,7 +15,7 @@ from netbox.jobs import JobRunner, system_job
|
||||
from netbox.search.backends import search_backend
|
||||
from utilities.proxy import resolve_proxies
|
||||
|
||||
from .choices import DataSourceStatusChoices, JobIntervalChoices
|
||||
from .choices import DataSourceStatusChoices, JobIntervalChoices, ObjectChangeActionChoices
|
||||
from .models import DataSource
|
||||
|
||||
|
||||
@@ -126,19 +127,51 @@ class SystemHousekeepingJob(JobRunner):
|
||||
"""
|
||||
Delete any ObjectChange records older than the configured changelog retention time (if any).
|
||||
"""
|
||||
self.logger.info("Pruning old changelog entries...")
|
||||
self.logger.info('Pruning old changelog entries...')
|
||||
config = Config()
|
||||
if not config.CHANGELOG_RETENTION:
|
||||
self.logger.info("No retention period specified; skipping.")
|
||||
self.logger.info('No retention period specified; skipping.')
|
||||
return
|
||||
|
||||
cutoff = timezone.now() - timedelta(days=config.CHANGELOG_RETENTION)
|
||||
self.logger.debug(
|
||||
f"Changelog retention period: {config.CHANGELOG_RETENTION} days ({cutoff:%Y-%m-%d %H:%M:%S})"
|
||||
)
|
||||
self.logger.debug(f'Changelog retention period: {config.CHANGELOG_RETENTION} days ({cutoff:%Y-%m-%d %H:%M:%S})')
|
||||
|
||||
count = ObjectChange.objects.filter(time__lt=cutoff).delete()[0]
|
||||
self.logger.info(f"Deleted {count} expired changelog records")
|
||||
expired_qs = ObjectChange.objects.filter(time__lt=cutoff)
|
||||
|
||||
# When enabled, retain each object's original create record and most recent update record while pruning expired
|
||||
# changelog entries. This applies only to objects without a delete record.
|
||||
if config.CHANGELOG_RETAIN_CREATE_LAST_UPDATE:
|
||||
self.logger.debug('Retaining changelog create records and last update records (excluding deleted objects)')
|
||||
|
||||
deleted_exists = ObjectChange.objects.filter(
|
||||
action=ObjectChangeActionChoices.ACTION_DELETE,
|
||||
changed_object_type_id=OuterRef('changed_object_type_id'),
|
||||
changed_object_id=OuterRef('changed_object_id'),
|
||||
)
|
||||
|
||||
# Keep create records only where no delete exists for that object
|
||||
create_pks_to_keep = (
|
||||
ObjectChange.objects.filter(action=ObjectChangeActionChoices.ACTION_CREATE)
|
||||
.annotate(has_delete=Exists(deleted_exists))
|
||||
.filter(has_delete=False)
|
||||
.values('pk')
|
||||
)
|
||||
|
||||
# Keep the most recent update per object only where no delete exists for the object
|
||||
latest_update_pks_to_keep = (
|
||||
ObjectChange.objects.filter(action=ObjectChangeActionChoices.ACTION_UPDATE)
|
||||
.annotate(has_delete=Exists(deleted_exists))
|
||||
.filter(has_delete=False)
|
||||
.order_by('changed_object_type_id', 'changed_object_id', '-time', '-pk')
|
||||
.distinct('changed_object_type_id', 'changed_object_id')
|
||||
.values('pk')
|
||||
)
|
||||
|
||||
expired_qs = expired_qs.exclude(pk__in=Subquery(create_pks_to_keep))
|
||||
expired_qs = expired_qs.exclude(pk__in=Subquery(latest_update_pks_to_keep))
|
||||
|
||||
count = expired_qs.delete()[0]
|
||||
self.logger.info(f'Deleted {count} expired changelog records')
|
||||
|
||||
def delete_expired_jobs(self):
|
||||
"""
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import django_tables2 as tables
|
||||
from django.utils.html import conditional_escape
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from core.constants import JOB_LOG_ENTRY_LEVELS
|
||||
@@ -82,3 +84,9 @@ class JobLogEntryTable(BaseTable):
|
||||
class Meta(BaseTable.Meta):
|
||||
empty_text = _('No log entries')
|
||||
fields = ('timestamp', 'level', 'message')
|
||||
|
||||
def render_message(self, record, value):
|
||||
if record.get('level') == 'error' and '\n' in value:
|
||||
value = conditional_escape(value)
|
||||
return mark_safe(f'<pre class="p-0">{value}</pre>')
|
||||
return value
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
import logging
|
||||
import uuid
|
||||
from datetime import timedelta
|
||||
from unittest.mock import patch
|
||||
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.test import override_settings
|
||||
from django.test import TestCase, override_settings
|
||||
from django.urls import reverse
|
||||
from django.utils import timezone
|
||||
from rest_framework import status
|
||||
|
||||
from core.choices import ObjectChangeActionChoices
|
||||
from core.jobs import SystemHousekeepingJob
|
||||
from core.models import ObjectChange, ObjectType
|
||||
from dcim.choices import InterfaceTypeChoices, ModuleStatusChoices, SiteStatusChoices
|
||||
from dcim.models import (
|
||||
@@ -694,3 +701,99 @@ class ChangeLogAPITest(APITestCase):
|
||||
self.assertEqual(changes[3].changed_object_type, ContentType.objects.get_for_model(Module))
|
||||
self.assertEqual(changes[3].changed_object_id, module.pk)
|
||||
self.assertEqual(changes[3].action, ObjectChangeActionChoices.ACTION_DELETE)
|
||||
|
||||
|
||||
class ChangelogPruneRetentionTest(TestCase):
|
||||
"""Test suite for Changelog pruning retention settings."""
|
||||
|
||||
@staticmethod
|
||||
def _make_oc(*, ct, obj_id, action, ts):
|
||||
oc = ObjectChange.objects.create(
|
||||
changed_object_type=ct,
|
||||
changed_object_id=obj_id,
|
||||
action=action,
|
||||
user_name='test',
|
||||
request_id=uuid.uuid4(),
|
||||
object_repr=f'Object {obj_id}',
|
||||
)
|
||||
ObjectChange.objects.filter(pk=oc.pk).update(time=ts)
|
||||
return oc.pk
|
||||
|
||||
@staticmethod
|
||||
def _run_prune(*, retention_days, retain_create_last_update):
|
||||
job = SystemHousekeepingJob.__new__(SystemHousekeepingJob)
|
||||
job.logger = logging.getLogger('netbox.tests.changelog_prune')
|
||||
|
||||
with patch('core.jobs.Config') as MockConfig:
|
||||
cfg = MockConfig.return_value
|
||||
cfg.CHANGELOG_RETENTION = retention_days
|
||||
cfg.CHANGELOG_RETAIN_CREATE_LAST_UPDATE = retain_create_last_update
|
||||
job.prune_changelog()
|
||||
|
||||
def test_prune_retain_create_last_update_excludes_deleted_objects(self):
|
||||
ct = ContentType.objects.get_for_model(Site)
|
||||
|
||||
retention_days = 90
|
||||
now = timezone.now()
|
||||
cutoff = now - timedelta(days=retention_days)
|
||||
|
||||
expired_old = cutoff - timedelta(days=10)
|
||||
expired_newer = cutoff - timedelta(days=1)
|
||||
not_expired = cutoff + timedelta(days=1)
|
||||
|
||||
# A) Not deleted: should keep CREATE + latest UPDATE, prune intermediate UPDATEs
|
||||
a_create = self._make_oc(ct=ct, obj_id=1, action=ObjectChangeActionChoices.ACTION_CREATE, ts=expired_old)
|
||||
a_update1 = self._make_oc(ct=ct, obj_id=1, action=ObjectChangeActionChoices.ACTION_UPDATE, ts=expired_old)
|
||||
a_update2 = self._make_oc(ct=ct, obj_id=1, action=ObjectChangeActionChoices.ACTION_UPDATE, ts=expired_newer)
|
||||
|
||||
# B) Deleted (all expired): should keep NOTHING
|
||||
b_create = self._make_oc(ct=ct, obj_id=2, action=ObjectChangeActionChoices.ACTION_CREATE, ts=expired_old)
|
||||
b_update = self._make_oc(ct=ct, obj_id=2, action=ObjectChangeActionChoices.ACTION_UPDATE, ts=expired_newer)
|
||||
b_delete = self._make_oc(ct=ct, obj_id=2, action=ObjectChangeActionChoices.ACTION_DELETE, ts=expired_newer)
|
||||
|
||||
# C) Deleted but delete is not expired: create/update expired should be pruned; delete remains
|
||||
c_create = self._make_oc(ct=ct, obj_id=3, action=ObjectChangeActionChoices.ACTION_CREATE, ts=expired_old)
|
||||
c_update = self._make_oc(ct=ct, obj_id=3, action=ObjectChangeActionChoices.ACTION_UPDATE, ts=expired_newer)
|
||||
c_delete = self._make_oc(ct=ct, obj_id=3, action=ObjectChangeActionChoices.ACTION_DELETE, ts=not_expired)
|
||||
|
||||
self._run_prune(retention_days=retention_days, retain_create_last_update=True)
|
||||
|
||||
remaining = set(ObjectChange.objects.values_list('pk', flat=True))
|
||||
|
||||
# A) Not deleted -> create + latest update remain
|
||||
self.assertIn(a_create, remaining)
|
||||
self.assertIn(a_update2, remaining)
|
||||
self.assertNotIn(a_update1, remaining)
|
||||
|
||||
# B) Deleted (all expired) -> nothing remains
|
||||
self.assertNotIn(b_create, remaining)
|
||||
self.assertNotIn(b_update, remaining)
|
||||
self.assertNotIn(b_delete, remaining)
|
||||
|
||||
# C) Deleted, delete not expired -> delete remains, but create/update are pruned
|
||||
self.assertNotIn(c_create, remaining)
|
||||
self.assertNotIn(c_update, remaining)
|
||||
self.assertIn(c_delete, remaining)
|
||||
|
||||
def test_prune_disabled_deletes_all_expired(self):
|
||||
ct = ContentType.objects.get_for_model(Site)
|
||||
|
||||
retention_days = 90
|
||||
now = timezone.now()
|
||||
cutoff = now - timedelta(days=retention_days)
|
||||
expired = cutoff - timedelta(days=1)
|
||||
not_expired = cutoff + timedelta(days=1)
|
||||
|
||||
# expired create/update should be deleted when feature disabled
|
||||
x_create = self._make_oc(ct=ct, obj_id=10, action=ObjectChangeActionChoices.ACTION_CREATE, ts=expired)
|
||||
x_update = self._make_oc(ct=ct, obj_id=10, action=ObjectChangeActionChoices.ACTION_UPDATE, ts=expired)
|
||||
|
||||
# non-expired delete should remain regardless
|
||||
y_delete = self._make_oc(ct=ct, obj_id=11, action=ObjectChangeActionChoices.ACTION_DELETE, ts=not_expired)
|
||||
|
||||
self._run_prune(retention_days=retention_days, retain_create_last_update=False)
|
||||
|
||||
remaining = set(ObjectChange.objects.values_list('pk', flat=True))
|
||||
self.assertNotIn(x_create, remaining)
|
||||
self.assertNotIn(x_update, remaining)
|
||||
self.assertIn(y_delete, remaining)
|
||||
|
||||
@@ -8,11 +8,8 @@ class DCIMConfig(AppConfig):
|
||||
verbose_name = "DCIM"
|
||||
|
||||
def ready(self):
|
||||
from django.utils.translation import gettext as _
|
||||
|
||||
from netbox.models.features import register_models
|
||||
from utilities.counters import connect_counters
|
||||
from utilities.permissions import ModelAction, register_model_actions
|
||||
|
||||
from . import search, signals # noqa: F401
|
||||
from .models import CableTermination, Device, DeviceType, ModuleType, RackType, VirtualChassis
|
||||
@@ -20,11 +17,6 @@ class DCIMConfig(AppConfig):
|
||||
# Register models
|
||||
register_models(*self.get_models())
|
||||
|
||||
# Register custom permission actions
|
||||
register_model_actions(Device, [
|
||||
ModelAction('render_config', help_text=_('Render device configuration')),
|
||||
])
|
||||
|
||||
# Register denormalized fields
|
||||
denormalized.register(CableTermination, '_device', {
|
||||
'_rack': 'rack',
|
||||
|
||||
@@ -137,6 +137,12 @@ class DeviceDimensionsPanel(panels.ObjectAttributesPanel):
|
||||
total_weight = attrs.TemplatedAttr('total_weight', template_name='dcim/device/attrs/total_weight.html')
|
||||
|
||||
|
||||
class DeviceRolePanel(panels.NestedGroupObjectPanel):
|
||||
color = attrs.ColorAttr('color')
|
||||
vm_role = attrs.BooleanAttr('vm_role', label=_('VM role'))
|
||||
config_template = attrs.RelatedObjectAttr('config_template', linkify=True)
|
||||
|
||||
|
||||
class DeviceTypePanel(panels.ObjectAttributesPanel):
|
||||
manufacturer = attrs.RelatedObjectAttr('manufacturer', linkify=True)
|
||||
model = attrs.TextAttr('model')
|
||||
@@ -153,11 +159,36 @@ class DeviceTypePanel(panels.ObjectAttributesPanel):
|
||||
rear_image = attrs.ImageAttr('rear_image')
|
||||
|
||||
|
||||
class ModulePanel(panels.ObjectAttributesPanel):
|
||||
device = attrs.RelatedObjectAttr('device', linkify=True)
|
||||
device_type = attrs.RelatedObjectAttr('device.device_type', linkify=True, grouped_by='manufacturer')
|
||||
module_bay = attrs.NestedObjectAttr('module_bay', linkify=True)
|
||||
status = attrs.ChoiceAttr('status')
|
||||
description = attrs.TextAttr('description')
|
||||
serial = attrs.TextAttr('serial', label=_('Serial number'), style='font-monospace', copy_button=True)
|
||||
asset_tag = attrs.TextAttr('asset_tag', style='font-monospace', copy_button=True)
|
||||
|
||||
|
||||
class ModuleTypeProfilePanel(panels.ObjectAttributesPanel):
|
||||
name = attrs.TextAttr('name')
|
||||
description = attrs.TextAttr('description')
|
||||
|
||||
|
||||
class ModuleTypePanel(panels.ObjectAttributesPanel):
|
||||
profile = attrs.RelatedObjectAttr('profile', linkify=True)
|
||||
manufacturer = attrs.RelatedObjectAttr('manufacturer', linkify=True)
|
||||
model = attrs.TextAttr('model', label=_('Model name'))
|
||||
part_number = attrs.TextAttr('part_number')
|
||||
description = attrs.TextAttr('description')
|
||||
airflow = attrs.ChoiceAttr('airflow')
|
||||
weight = attrs.NumericAttr('weight', unit_accessor='get_weight_unit_display')
|
||||
|
||||
|
||||
class PlatformPanel(panels.NestedGroupObjectPanel):
|
||||
manufacturer = attrs.RelatedObjectAttr('manufacturer', linkify=True)
|
||||
config_template = attrs.RelatedObjectAttr('config_template', linkify=True)
|
||||
|
||||
|
||||
class VirtualChassisMembersPanel(panels.ObjectPanel):
|
||||
"""
|
||||
A panel which lists all members of a virtual chassis.
|
||||
|
||||
@@ -25,6 +25,7 @@ from netbox.ui.panels import (
|
||||
NestedGroupObjectPanel,
|
||||
ObjectsTablePanel,
|
||||
OrganizationalObjectPanel,
|
||||
Panel,
|
||||
RelatedObjectsPanel,
|
||||
TemplatePanel,
|
||||
)
|
||||
@@ -1667,6 +1668,22 @@ class ModuleTypeListView(generic.ObjectListView):
|
||||
@register_model_view(ModuleType)
|
||||
class ModuleTypeView(GetRelatedModelsMixin, generic.ObjectView):
|
||||
queryset = ModuleType.objects.all()
|
||||
layout = layout.SimpleLayout(
|
||||
left_panels=[
|
||||
panels.ModuleTypePanel(),
|
||||
TagsPanel(),
|
||||
CommentsPanel(),
|
||||
],
|
||||
right_panels=[
|
||||
Panel(
|
||||
title=_('Attributes'),
|
||||
template_name='dcim/panels/module_type_attributes.html',
|
||||
),
|
||||
RelatedObjectsPanel(),
|
||||
CustomFieldsPanel(),
|
||||
ImageAttachmentsPanel(),
|
||||
],
|
||||
)
|
||||
|
||||
def get_extra_context(self, request, instance):
|
||||
return {
|
||||
@@ -2306,6 +2323,27 @@ class DeviceRoleListView(generic.ObjectListView):
|
||||
@register_model_view(DeviceRole)
|
||||
class DeviceRoleView(GetRelatedModelsMixin, generic.ObjectView):
|
||||
queryset = DeviceRole.objects.all()
|
||||
layout = layout.SimpleLayout(
|
||||
left_panels=[
|
||||
panels.DeviceRolePanel(),
|
||||
TagsPanel(),
|
||||
],
|
||||
right_panels=[
|
||||
RelatedObjectsPanel(),
|
||||
CustomFieldsPanel(),
|
||||
CommentsPanel(),
|
||||
],
|
||||
bottom_panels=[
|
||||
ObjectsTablePanel(
|
||||
model='dcim.DeviceRole',
|
||||
title=_('Child Device Roles'),
|
||||
filters={'parent_id': lambda ctx: ctx['object'].pk},
|
||||
actions=[
|
||||
actions.AddObject('dcim.DeviceRole', url_params={'parent': lambda ctx: ctx['object'].pk}),
|
||||
],
|
||||
),
|
||||
]
|
||||
)
|
||||
|
||||
def get_extra_context(self, request, instance):
|
||||
return {
|
||||
@@ -2385,6 +2423,27 @@ class PlatformListView(generic.ObjectListView):
|
||||
@register_model_view(Platform)
|
||||
class PlatformView(GetRelatedModelsMixin, generic.ObjectView):
|
||||
queryset = Platform.objects.all()
|
||||
layout = layout.SimpleLayout(
|
||||
left_panels=[
|
||||
panels.PlatformPanel(),
|
||||
TagsPanel(),
|
||||
],
|
||||
right_panels=[
|
||||
RelatedObjectsPanel(),
|
||||
CustomFieldsPanel(),
|
||||
CommentsPanel(),
|
||||
],
|
||||
bottom_panels=[
|
||||
ObjectsTablePanel(
|
||||
model='dcim.Platform',
|
||||
title=_('Child Platforms'),
|
||||
filters={'parent_id': lambda ctx: ctx['object'].pk},
|
||||
actions=[
|
||||
actions.AddObject('dcim.Platform', url_params={'parent': lambda ctx: ctx['object'].pk}),
|
||||
],
|
||||
),
|
||||
]
|
||||
)
|
||||
|
||||
def get_extra_context(self, request, instance):
|
||||
return {
|
||||
@@ -2778,6 +2837,21 @@ class ModuleListView(generic.ObjectListView):
|
||||
@register_model_view(Module)
|
||||
class ModuleView(GetRelatedModelsMixin, generic.ObjectView):
|
||||
queryset = Module.objects.all()
|
||||
layout = layout.SimpleLayout(
|
||||
left_panels=[
|
||||
panels.ModulePanel(),
|
||||
TagsPanel(),
|
||||
CommentsPanel(),
|
||||
],
|
||||
right_panels=[
|
||||
Panel(
|
||||
title=_('Module Type'),
|
||||
template_name='dcim/panels/module_type.html',
|
||||
),
|
||||
RelatedObjectsPanel(),
|
||||
CustomFieldsPanel(),
|
||||
],
|
||||
)
|
||||
|
||||
def get_extra_context(self, request, instance):
|
||||
return {
|
||||
|
||||
@@ -6,9 +6,11 @@ import requests
|
||||
from django.conf import settings
|
||||
from django.core.cache import cache
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.db.models import Exists, OuterRef, Subquery
|
||||
from django.utils import timezone
|
||||
from packaging import version
|
||||
|
||||
from core.choices import ObjectChangeActionChoices
|
||||
from core.models import Job, ObjectChange
|
||||
from netbox.config import Config
|
||||
from utilities.proxy import resolve_proxies
|
||||
@@ -47,29 +49,63 @@ class Command(BaseCommand):
|
||||
|
||||
# Delete expired ObjectChanges
|
||||
if options['verbosity']:
|
||||
self.stdout.write("[*] Checking for expired changelog records")
|
||||
self.stdout.write('[*] Checking for expired changelog records')
|
||||
if config.CHANGELOG_RETENTION:
|
||||
cutoff = timezone.now() - timedelta(days=config.CHANGELOG_RETENTION)
|
||||
if options['verbosity'] >= 2:
|
||||
self.stdout.write(f"\tRetention period: {config.CHANGELOG_RETENTION} days")
|
||||
self.stdout.write(f"\tCut-off time: {cutoff}")
|
||||
expired_records = ObjectChange.objects.filter(time__lt=cutoff).count()
|
||||
self.stdout.write(f'\tRetention period: {config.CHANGELOG_RETENTION} days')
|
||||
self.stdout.write(f'\tCut-off time: {cutoff}')
|
||||
|
||||
expired_qs = ObjectChange.objects.filter(time__lt=cutoff)
|
||||
|
||||
# When enabled, retain each object's original create and most recent update record while pruning expired
|
||||
# changelog entries. This applies only to objects without a delete record.
|
||||
if config.CHANGELOG_RETAIN_CREATE_LAST_UPDATE:
|
||||
if options['verbosity'] >= 2:
|
||||
self.stdout.write('\tRetaining create & last update records for non-deleted objects')
|
||||
|
||||
deleted_exists = ObjectChange.objects.filter(
|
||||
action=ObjectChangeActionChoices.ACTION_DELETE,
|
||||
changed_object_type_id=OuterRef('changed_object_type_id'),
|
||||
changed_object_id=OuterRef('changed_object_id'),
|
||||
)
|
||||
|
||||
# Keep create records only where no delete exists for that object
|
||||
create_pks_to_keep = (
|
||||
ObjectChange.objects.filter(action=ObjectChangeActionChoices.ACTION_CREATE)
|
||||
.annotate(has_delete=Exists(deleted_exists))
|
||||
.filter(has_delete=False)
|
||||
.values('pk')
|
||||
)
|
||||
|
||||
# Keep the most recent update per object only where no delete exists for the object
|
||||
latest_update_pks_to_keep = (
|
||||
ObjectChange.objects.filter(action=ObjectChangeActionChoices.ACTION_UPDATE)
|
||||
.annotate(has_delete=Exists(deleted_exists))
|
||||
.filter(has_delete=False)
|
||||
.order_by('changed_object_type_id', 'changed_object_id', '-time', '-pk')
|
||||
.distinct('changed_object_type_id', 'changed_object_id')
|
||||
.values('pk')
|
||||
)
|
||||
|
||||
expired_qs = expired_qs.exclude(pk__in=Subquery(create_pks_to_keep))
|
||||
expired_qs = expired_qs.exclude(pk__in=Subquery(latest_update_pks_to_keep))
|
||||
|
||||
expired_records = expired_qs.count()
|
||||
if expired_records:
|
||||
if options['verbosity']:
|
||||
self.stdout.write(
|
||||
f"\tDeleting {expired_records} expired records... ",
|
||||
self.style.WARNING,
|
||||
ending=""
|
||||
f'\tDeleting {expired_records} expired records... ', self.style.WARNING, ending=''
|
||||
)
|
||||
self.stdout.flush()
|
||||
ObjectChange.objects.filter(time__lt=cutoff).delete()
|
||||
expired_qs.delete()
|
||||
if options['verbosity']:
|
||||
self.stdout.write("Done.", self.style.SUCCESS)
|
||||
self.stdout.write('Done.', self.style.SUCCESS)
|
||||
elif options['verbosity']:
|
||||
self.stdout.write("\tNo expired records found.", self.style.SUCCESS)
|
||||
self.stdout.write('\tNo expired records found.', self.style.SUCCESS)
|
||||
elif options['verbosity']:
|
||||
self.stdout.write(
|
||||
f"\tSkipping: No retention period specified (CHANGELOG_RETENTION = {config.CHANGELOG_RETENTION})"
|
||||
f'\tSkipping: No retention period specified (CHANGELOG_RETENTION = {config.CHANGELOG_RETENTION})'
|
||||
)
|
||||
|
||||
# Delete expired Jobs
|
||||
|
||||
@@ -677,15 +677,19 @@ class ConfigContextTest(TestCase):
|
||||
if hasattr(node, 'children'):
|
||||
for child in node.children:
|
||||
try:
|
||||
if child.rhs.query.model is TaggedItem:
|
||||
subqueries.append(child.rhs.query)
|
||||
# In Django 6.0+, rhs is a Query directly; older Django wraps it in Subquery
|
||||
rhs_query = getattr(child.rhs, 'query', child.rhs)
|
||||
if rhs_query.model is TaggedItem:
|
||||
subqueries.append(rhs_query)
|
||||
except AttributeError:
|
||||
traverse(child)
|
||||
traverse(where_node)
|
||||
return subqueries
|
||||
|
||||
# In Django 6.0+, the annotation is a Query directly; older Django wraps it in Subquery
|
||||
annotation_query = getattr(config_annotation, 'query', config_annotation)
|
||||
# Find subqueries in the WHERE clause that should have DISTINCT
|
||||
tag_subqueries = find_tag_subqueries(config_annotation.query.where)
|
||||
tag_subqueries = find_tag_subqueries(annotation_query.where)
|
||||
distinct_subqueries = [sq for sq in tag_subqueries if sq.distinct]
|
||||
|
||||
# Verify we found at least one DISTINCT subquery for tags
|
||||
|
||||
@@ -94,9 +94,11 @@ class NetHost(Lookup):
|
||||
rhs, rhs_params = self.process_rhs(qn, connection)
|
||||
# Query parameters are automatically converted to IPNetwork objects, which are then turned to strings. We need
|
||||
# to omit the mask portion of the object's string representation to match PostgreSQL's HOST() function.
|
||||
# Note: params may be tuples (Django 6.0+) or lists (older Django), so convert before mutating.
|
||||
rhs_params = list(rhs_params)
|
||||
if rhs_params:
|
||||
rhs_params[0] = rhs_params[0].split('/')[0]
|
||||
params = lhs_params + rhs_params
|
||||
params = list(lhs_params) + rhs_params
|
||||
return f'HOST({lhs}) = {rhs}', params
|
||||
|
||||
|
||||
|
||||
@@ -1,18 +1,40 @@
|
||||
from django.db.models import QuerySet
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from rest_framework.exceptions import ValidationError
|
||||
from rest_framework.pagination import LimitOffsetPagination
|
||||
from rest_framework.utils.urls import remove_query_param, replace_query_param
|
||||
|
||||
from netbox.api.exceptions import QuerySetNotOrdered
|
||||
from netbox.config import get_config
|
||||
|
||||
|
||||
class OptionalLimitOffsetPagination(LimitOffsetPagination):
|
||||
class NetBoxPagination(LimitOffsetPagination):
|
||||
"""
|
||||
Override the stock paginator to allow setting limit=0 to disable pagination for a request. This returns all objects
|
||||
matching a query, but retains the same format as a paginated request. The limit can only be disabled if
|
||||
MAX_PAGE_SIZE has been set to 0 or None.
|
||||
Provides two mutually exclusive pagination mechanisms: offset-based and cursor-based.
|
||||
|
||||
Offset-based pagination employs `offset` and (optionally) `limit` parameters to page through results following the
|
||||
model's natural order. `offset` indicates the number of results to skip. This provides very human-friendly behavior,
|
||||
but performance can suffer when querying very large data sets due the overhead required to determine the starting
|
||||
point in the database.
|
||||
|
||||
Cursor-based pagination employs `start` and (optionally) `limit` parameters to page through results as ordered by
|
||||
the model's primary key (i.e. `id`). `start` indicates the numeric ID of the first object to return; `limit`
|
||||
indicates the maximum number of objects to return beginning with the specified ID. Objects *must* be ordered by ID
|
||||
to ensure pagination is consistent. This approach is less human-friendly but offers superior performance to
|
||||
offset-based pagination. In cursor mode, `count` is omitted (null) for performance.
|
||||
|
||||
Offset- and cursor-based pagination are mutually exclusive: Only `offset` _or_ `start` is permitted for a request.
|
||||
|
||||
`limit` may be set to zero (`?limit=0`). This returns all objects matching a query, but retains the same format as
|
||||
a paginated request. The limit can only be disabled if `MAX_PAGE_SIZE` has been set to 0 or None.
|
||||
"""
|
||||
start_query_param = 'start'
|
||||
|
||||
def __init__(self):
|
||||
self.default_limit = get_config().PAGINATE_COUNT
|
||||
self.start = None
|
||||
self._page_length = 0
|
||||
self._last_pk = None
|
||||
|
||||
def paginate_queryset(self, queryset, request, view=None):
|
||||
|
||||
@@ -22,15 +44,42 @@ class OptionalLimitOffsetPagination(LimitOffsetPagination):
|
||||
"ordering has been applied to the queryset for this API endpoint."
|
||||
)
|
||||
|
||||
self.start = self.get_start(request)
|
||||
self.limit = self.get_limit(request)
|
||||
self.request = request
|
||||
|
||||
# Cursor-based pagination
|
||||
if self.start is not None:
|
||||
if self.offset_query_param in request.query_params:
|
||||
raise ValidationError(
|
||||
_("'{start_param}' and '{offset_param}' are mutually exclusive.").format(
|
||||
start_param=self.start_query_param,
|
||||
offset_param=self.offset_query_param,
|
||||
)
|
||||
)
|
||||
if 'ordering' in request.query_params:
|
||||
raise ValidationError(_("Ordering cannot be specified in conjunction with cursor-based pagination."))
|
||||
|
||||
self.count = None
|
||||
self.offset = 0
|
||||
|
||||
queryset = queryset.filter(pk__gte=self.start).order_by('pk')
|
||||
results = list(queryset[:self.limit]) if self.limit else list(queryset)
|
||||
|
||||
self._page_length = len(results)
|
||||
if results:
|
||||
self._last_pk = results[-1].pk if hasattr(results[-1], 'pk') else results[-1]['pk']
|
||||
|
||||
return results
|
||||
|
||||
# Offset-based pagination
|
||||
if isinstance(queryset, QuerySet):
|
||||
self.count = self.get_queryset_count(queryset)
|
||||
else:
|
||||
# We're dealing with an iterable, not a QuerySet
|
||||
self.count = len(queryset)
|
||||
|
||||
self.limit = self.get_limit(request)
|
||||
self.offset = self.get_offset(request)
|
||||
self.request = request
|
||||
|
||||
if self.limit and self.count > self.limit and self.template is not None:
|
||||
self.display_page_controls = True
|
||||
@@ -42,6 +91,25 @@ class OptionalLimitOffsetPagination(LimitOffsetPagination):
|
||||
return list(queryset[self.offset:self.offset + self.limit])
|
||||
return list(queryset[self.offset:])
|
||||
|
||||
def get_start(self, request):
|
||||
try:
|
||||
value = int(request.query_params[self.start_query_param])
|
||||
if value < 0:
|
||||
raise ValidationError(
|
||||
_("Invalid '{param}' parameter: must be a non-negative integer.").format(
|
||||
param=self.start_query_param,
|
||||
)
|
||||
)
|
||||
return value
|
||||
except KeyError:
|
||||
return None
|
||||
except (ValueError, TypeError):
|
||||
raise ValidationError(
|
||||
_("Invalid '{param}' parameter: must be a non-negative integer.").format(
|
||||
param=self.start_query_param,
|
||||
)
|
||||
)
|
||||
|
||||
def get_limit(self, request):
|
||||
max_limit = self.default_limit
|
||||
MAX_PAGE_SIZE = get_config().MAX_PAGE_SIZE
|
||||
@@ -75,6 +143,16 @@ class OptionalLimitOffsetPagination(LimitOffsetPagination):
|
||||
if not self.limit:
|
||||
return None
|
||||
|
||||
# Cursor mode
|
||||
if self.start is not None:
|
||||
if self._page_length < self.limit:
|
||||
return None
|
||||
url = self.request.build_absolute_uri()
|
||||
url = replace_query_param(url, self.start_query_param, self._last_pk + 1)
|
||||
url = replace_query_param(url, self.limit_query_param, self.limit)
|
||||
url = remove_query_param(url, self.offset_query_param)
|
||||
return url
|
||||
|
||||
return super().get_next_link()
|
||||
|
||||
def get_previous_link(self):
|
||||
@@ -83,10 +161,30 @@ class OptionalLimitOffsetPagination(LimitOffsetPagination):
|
||||
if not self.limit:
|
||||
return None
|
||||
|
||||
# Cursor mode: forward-only
|
||||
if self.start is not None:
|
||||
return None
|
||||
|
||||
return super().get_previous_link()
|
||||
|
||||
def get_schema_operation_parameters(self, view):
|
||||
parameters = super().get_schema_operation_parameters(view)
|
||||
parameters.append({
|
||||
'name': self.start_query_param,
|
||||
'required': False,
|
||||
'in': 'query',
|
||||
'description': (
|
||||
'Cursor-based pagination: return results with pk >= start, ordered by pk. '
|
||||
'Mutually exclusive with offset.'
|
||||
),
|
||||
'schema': {
|
||||
'type': 'integer',
|
||||
},
|
||||
})
|
||||
return parameters
|
||||
|
||||
class StripCountAnnotationsPaginator(OptionalLimitOffsetPagination):
|
||||
|
||||
class StripCountAnnotationsPaginator(NetBoxPagination):
|
||||
"""
|
||||
Strips the annotations on the queryset before getting the count
|
||||
to optimize pagination of complex queries.
|
||||
|
||||
@@ -13,7 +13,7 @@ from rest_framework.viewsets import GenericViewSet
|
||||
from netbox.api.serializers.features import ChangeLogMessageSerializer
|
||||
from netbox.constants import ADVISORY_LOCK_KEYS
|
||||
from utilities.api import get_annotations_for_serializer, get_prefetches_for_serializer
|
||||
from utilities.exceptions import AbortRequest
|
||||
from utilities.exceptions import AbortRequest, PreconditionFailed
|
||||
from utilities.query import reapply_model_ordering
|
||||
|
||||
from . import mixins
|
||||
@@ -34,6 +34,50 @@ HTTP_ACTIONS = {
|
||||
}
|
||||
|
||||
|
||||
class ETagMixin:
|
||||
"""
|
||||
Adds ETag header support to ViewSets. Generates weak ETags (W/ prefix per
|
||||
RFC 7232 §2.1) from `last_updated` (or `created` if unavailable). Weak ETags
|
||||
are appropriate here because the tag is derived from a modification timestamp
|
||||
rather than a hash of the serialized payload.
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def _get_etag(obj):
|
||||
"""Return a weak ETag string for the given object, or None."""
|
||||
if ts := getattr(obj, 'last_updated', None) or getattr(obj, 'created', None):
|
||||
return f'W/"{ts.isoformat()}"'
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def _get_if_match(request):
|
||||
"""Return the list of If-Match header values (if specified)."""
|
||||
if (if_match := request.META.get('HTTP_IF_MATCH')) and if_match != '*':
|
||||
return [e.strip() for e in if_match.split(',')]
|
||||
return []
|
||||
|
||||
def _validate_etag(self, request, instance):
|
||||
"""Validate the request's ETag"""
|
||||
if provided := self._get_if_match(request):
|
||||
current_etag = self._get_etag(instance)
|
||||
if current_etag and current_etag not in provided:
|
||||
raise PreconditionFailed(etag=current_etag)
|
||||
|
||||
def handle_exception(self, exc):
|
||||
response = super().handle_exception(exc)
|
||||
if isinstance(exc, PreconditionFailed) and exc.etag:
|
||||
response['ETag'] = exc.etag
|
||||
return response
|
||||
|
||||
def retrieve(self, request, *args, **kwargs):
|
||||
instance = self.get_object()
|
||||
serializer = self.get_serializer(instance)
|
||||
response = Response(serializer.data)
|
||||
if etag := self._get_etag(instance):
|
||||
response['ETag'] = etag
|
||||
return response
|
||||
|
||||
|
||||
class BaseViewSet(GenericViewSet):
|
||||
"""
|
||||
Base class for all API ViewSets. This is responsible for the enforcement of object-based permissions.
|
||||
@@ -95,6 +139,7 @@ class BaseViewSet(GenericViewSet):
|
||||
|
||||
|
||||
class NetBoxReadOnlyModelViewSet(
|
||||
ETagMixin,
|
||||
mixins.CustomFieldsMixin,
|
||||
mixins.ExportTemplatesMixin,
|
||||
drf_mixins.RetrieveModelMixin,
|
||||
@@ -105,6 +150,7 @@ class NetBoxReadOnlyModelViewSet(
|
||||
|
||||
|
||||
class NetBoxModelViewSet(
|
||||
ETagMixin,
|
||||
mixins.BulkUpdateModelMixin,
|
||||
mixins.BulkDestroyModelMixin,
|
||||
mixins.ObjectValidationMixin,
|
||||
@@ -191,7 +237,14 @@ class NetBoxModelViewSet(
|
||||
serializer = self.get_serializer(qs, many=bulk_create)
|
||||
|
||||
headers = self.get_success_headers(serializer.data)
|
||||
return Response(serializer.data, status=status.HTTP_201_CREATED, headers=headers)
|
||||
response = Response(serializer.data, status=status.HTTP_201_CREATED, headers=headers)
|
||||
|
||||
# Add ETag for single-object creation only (bulk returns a list, no single ETag)
|
||||
if not bulk_create:
|
||||
if etag := self._get_etag(qs):
|
||||
response['ETag'] = etag
|
||||
|
||||
return response
|
||||
|
||||
def perform_create(self, serializer):
|
||||
model = self.queryset.model
|
||||
@@ -211,6 +264,10 @@ class NetBoxModelViewSet(
|
||||
def update(self, request, *args, **kwargs):
|
||||
partial = kwargs.pop('partial', False)
|
||||
instance = self.get_object_with_snapshot()
|
||||
|
||||
# Enforce If-Match precondition (RFC 9110 §13.1.1)
|
||||
self._validate_etag(self.request, instance)
|
||||
|
||||
serializer = self.get_serializer(instance, data=request.data, partial=partial)
|
||||
serializer.is_valid(raise_exception=True)
|
||||
self.perform_update(serializer)
|
||||
@@ -221,8 +278,12 @@ class NetBoxModelViewSet(
|
||||
|
||||
# Re-serialize the instance(s) with prefetched data
|
||||
serializer = self.get_serializer(qs)
|
||||
response = Response(serializer.data)
|
||||
|
||||
return Response(serializer.data)
|
||||
if etag := self._get_etag(qs):
|
||||
response['ETag'] = etag
|
||||
|
||||
return response
|
||||
|
||||
def perform_update(self, serializer):
|
||||
model = self.queryset.model
|
||||
@@ -232,6 +293,11 @@ class NetBoxModelViewSet(
|
||||
# Enforce object-level permissions on save()
|
||||
try:
|
||||
with transaction.atomic(using=router.db_for_write(model)):
|
||||
# Re-check the If-Match ETag under a row-level lock to close the TOCTOU window
|
||||
# between the initial check in update() and the actual write.
|
||||
if self._get_if_match(self.request):
|
||||
locked = model.objects.select_for_update().get(pk=serializer.instance.pk)
|
||||
self._validate_etag(self.request, locked)
|
||||
instance = serializer.save()
|
||||
self._validate_objects(instance)
|
||||
except ObjectDoesNotExist:
|
||||
@@ -242,6 +308,9 @@ class NetBoxModelViewSet(
|
||||
def destroy(self, request, *args, **kwargs):
|
||||
instance = self.get_object_with_snapshot()
|
||||
|
||||
# Enforce If-Match precondition (RFC 9110 §13.1.1)
|
||||
self._validate_etag(request, instance)
|
||||
|
||||
# Attach changelog message (if any)
|
||||
serializer = ChangeLogMessageSerializer(data=request.data)
|
||||
serializer.is_valid(raise_exception=True)
|
||||
@@ -256,7 +325,16 @@ class NetBoxModelViewSet(
|
||||
logger = logging.getLogger(f'netbox.api.views.{self.__class__.__name__}')
|
||||
logger.info(f"Deleting {model._meta.verbose_name} {instance} (PK: {instance.pk})")
|
||||
|
||||
return super().perform_destroy(instance)
|
||||
try:
|
||||
with transaction.atomic(using=router.db_for_write(model)):
|
||||
# Re-check the If-Match ETag under a row-level lock to close the TOCTOU window
|
||||
# between the initial check in destroy() and the actual delete.
|
||||
if self._get_if_match(self.request):
|
||||
locked = model.objects.select_for_update().get(pk=instance.pk)
|
||||
self._validate_etag(self.request, locked)
|
||||
super().perform_destroy(instance)
|
||||
except ObjectDoesNotExist:
|
||||
raise PermissionDenied()
|
||||
|
||||
|
||||
class MPTTLockedMixin:
|
||||
|
||||
@@ -10,6 +10,7 @@ from .parameters import PARAMS
|
||||
|
||||
__all__ = (
|
||||
'PARAMS',
|
||||
'Config',
|
||||
'ConfigItem',
|
||||
'clear_config',
|
||||
'get_config',
|
||||
|
||||
@@ -175,6 +175,25 @@ PARAMS = (
|
||||
field=forms.JSONField
|
||||
),
|
||||
|
||||
# Change log
|
||||
ConfigParam(
|
||||
name='CHANGELOG_RETENTION',
|
||||
label=_('Changelog retention'),
|
||||
default=90,
|
||||
description=_("Days to retain changelog history (set to zero for unlimited)"),
|
||||
field=forms.IntegerField,
|
||||
),
|
||||
ConfigParam(
|
||||
name='CHANGELOG_RETAIN_CREATE_LAST_UPDATE',
|
||||
label=_('Retain create & last update changelog records'),
|
||||
default=True,
|
||||
description=_(
|
||||
"Retain each object's create record and most recent update record when pruning expired changelog entries "
|
||||
"(excluding objects with a delete record)."
|
||||
),
|
||||
field=forms.BooleanField,
|
||||
),
|
||||
|
||||
# Miscellaneous
|
||||
ConfigParam(
|
||||
name='MAINTENANCE_MODE',
|
||||
@@ -199,13 +218,6 @@ PARAMS = (
|
||||
description=_("Enable the GraphQL API"),
|
||||
field=forms.BooleanField
|
||||
),
|
||||
ConfigParam(
|
||||
name='CHANGELOG_RETENTION',
|
||||
label=_('Changelog retention'),
|
||||
default=90,
|
||||
description=_("Days to retain changelog history (set to zero for unlimited)"),
|
||||
field=forms.IntegerField
|
||||
),
|
||||
ConfigParam(
|
||||
name='JOB_RETENTION',
|
||||
label=_('Job result retention'),
|
||||
|
||||
@@ -79,6 +79,9 @@ class IntegerLookup:
|
||||
if not filters:
|
||||
return queryset, Q()
|
||||
|
||||
if isinstance(filters, RangeLookup):
|
||||
prefix = f'{prefix}range__'
|
||||
|
||||
return process_filters(filters=filters, queryset=queryset, info=info, prefix=prefix)
|
||||
|
||||
|
||||
@@ -102,6 +105,9 @@ class BigIntegerLookup:
|
||||
if not filters:
|
||||
return queryset, Q()
|
||||
|
||||
if isinstance(filters, RangeLookup):
|
||||
prefix = f'{prefix}range__'
|
||||
|
||||
return process_filters(filters=filters, queryset=queryset, info=info, prefix=prefix)
|
||||
|
||||
|
||||
@@ -125,6 +131,9 @@ class FloatLookup:
|
||||
if not filters:
|
||||
return queryset, Q()
|
||||
|
||||
if isinstance(filters, RangeLookup):
|
||||
prefix = f'{prefix}range__'
|
||||
|
||||
return process_filters(filters=filters, queryset=queryset, info=info, prefix=prefix)
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import logging
|
||||
import os
|
||||
import traceback
|
||||
from abc import ABC, abstractmethod
|
||||
from datetime import timedelta
|
||||
from pathlib import Path
|
||||
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.utils import timezone
|
||||
@@ -21,6 +24,11 @@ __all__ = (
|
||||
'system_job',
|
||||
)
|
||||
|
||||
# The installation root, e.g. "/opt/netbox/". Used to strip absolute path
|
||||
# prefixes from traceback file paths before recording them in the job log.
|
||||
# jobs.py lives at <root>/netbox/netbox/jobs.py, so parents[2] is the root.
|
||||
_INSTALL_ROOT = str(Path(__file__).resolve().parents[2]) + os.sep
|
||||
|
||||
|
||||
def system_job(interval):
|
||||
"""
|
||||
@@ -107,6 +115,13 @@ class JobRunner(ABC):
|
||||
job.terminate(status=JobStatusChoices.STATUS_FAILED)
|
||||
|
||||
except Exception as e:
|
||||
tb_str = traceback.format_exc().replace(_INSTALL_ROOT, '')
|
||||
tb_record = logging.makeLogRecord({
|
||||
'levelno': logging.ERROR,
|
||||
'levelname': 'ERROR',
|
||||
'msg': tb_str,
|
||||
})
|
||||
job.log(tb_record)
|
||||
job.terminate(status=JobStatusChoices.STATUS_ERRORED, error=repr(e))
|
||||
if type(e) is JobTimeoutException:
|
||||
logger.error(e)
|
||||
|
||||
@@ -28,7 +28,6 @@ registry = Registry({
|
||||
'denormalized_fields': collections.defaultdict(list),
|
||||
'event_types': dict(),
|
||||
'filtersets': dict(),
|
||||
'model_actions': collections.defaultdict(list),
|
||||
'model_features': dict(),
|
||||
'models': collections.defaultdict(set),
|
||||
'plugins': dict(),
|
||||
|
||||
@@ -435,6 +435,7 @@ INSTALLED_APPS = [
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'django.contrib.humanize',
|
||||
'django.contrib.postgres',
|
||||
'django.forms',
|
||||
'corsheaders',
|
||||
'debug_toolbar',
|
||||
@@ -723,7 +724,7 @@ REST_FRAMEWORK = {
|
||||
'rest_framework.filters.OrderingFilter',
|
||||
),
|
||||
'DEFAULT_METADATA_CLASS': 'netbox.api.metadata.BulkOperationMetadata',
|
||||
'DEFAULT_PAGINATION_CLASS': 'netbox.api.pagination.OptionalLimitOffsetPagination',
|
||||
'DEFAULT_PAGINATION_CLASS': 'netbox.api.pagination.NetBoxPagination',
|
||||
'DEFAULT_PARSER_CLASSES': (
|
||||
'rest_framework.parsers.JSONParser',
|
||||
'rest_framework.parsers.MultiPartParser',
|
||||
|
||||
@@ -2,10 +2,11 @@ import uuid
|
||||
|
||||
from django.test import RequestFactory, TestCase
|
||||
from django.urls import reverse
|
||||
from rest_framework.exceptions import ValidationError
|
||||
from rest_framework.request import Request
|
||||
|
||||
from netbox.api.exceptions import QuerySetNotOrdered
|
||||
from netbox.api.pagination import OptionalLimitOffsetPagination
|
||||
from netbox.api.pagination import NetBoxPagination
|
||||
from users.models import Token
|
||||
from utilities.testing import APITestCase
|
||||
|
||||
@@ -48,7 +49,7 @@ class AppTest(APITestCase):
|
||||
class OptionalLimitOffsetPaginationTest(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.paginator = OptionalLimitOffsetPagination()
|
||||
self.paginator = NetBoxPagination()
|
||||
self.factory = RequestFactory()
|
||||
|
||||
def _make_drf_request(self, path='/', query_params=None):
|
||||
@@ -80,3 +81,33 @@ class OptionalLimitOffsetPaginationTest(TestCase):
|
||||
request = self._make_drf_request()
|
||||
|
||||
self.paginator.paginate_queryset(iterable, request) # Should not raise exception
|
||||
|
||||
def test_get_start_returns_none_when_absent(self):
|
||||
"""get_start() returns None when start param is not in the request"""
|
||||
request = self._make_drf_request()
|
||||
self.assertIsNone(self.paginator.get_start(request))
|
||||
|
||||
def test_get_start_returns_integer(self):
|
||||
"""get_start() returns an integer when start param is present"""
|
||||
request = self._make_drf_request(query_params={'start': '42'})
|
||||
self.assertEqual(self.paginator.get_start(request), 42)
|
||||
|
||||
def test_get_start_raises_for_negative(self):
|
||||
"""get_start() raises ValidationError for negative values"""
|
||||
request = self._make_drf_request(query_params={'start': '-1'})
|
||||
with self.assertRaises(ValidationError):
|
||||
self.paginator.get_start(request)
|
||||
|
||||
def test_cursor_and_offset_conflict_raises_validation_error(self):
|
||||
"""paginate_queryset() raises ValidationError when both start and offset are specified"""
|
||||
queryset = Token.objects.all().order_by('created')
|
||||
request = self._make_drf_request(query_params={'start': '1', 'offset': '10'})
|
||||
with self.assertRaises(ValidationError):
|
||||
self.paginator.paginate_queryset(queryset, request)
|
||||
|
||||
def test_cursor_and_ordering_conflict_raises_validation_error(self):
|
||||
"""paginate_queryset() raises ValidationError when both start and ordering are specified"""
|
||||
queryset = Token.objects.all().order_by('created')
|
||||
request = self._make_drf_request(query_params={'start': '1', 'ordering': 'created'})
|
||||
with self.assertRaises(ValidationError):
|
||||
self.paginator.paginate_queryset(queryset, request)
|
||||
|
||||
@@ -5,7 +5,7 @@ from django.urls import reverse
|
||||
from rest_framework import status
|
||||
|
||||
from dcim.choices import LocationStatusChoices
|
||||
from dcim.models import Location, Site
|
||||
from dcim.models import Device, DeviceRole, DeviceType, Location, Manufacturer, Site, VirtualChassis
|
||||
from utilities.testing import APITestCase, TestCase, disable_warnings
|
||||
|
||||
|
||||
@@ -138,6 +138,40 @@ class GraphQLAPITestCase(APITestCase):
|
||||
self.assertNotIn('errors', data)
|
||||
self.assertEqual(len(data['data']['site']['locations']), 0)
|
||||
|
||||
def test_graphql_integer_range_lookup(self):
|
||||
"""
|
||||
Test that range_lookup works for integer fields (e.g. vc_position). Regression test for #20468.
|
||||
"""
|
||||
self.add_permissions('dcim.view_device')
|
||||
url = reverse('graphql')
|
||||
|
||||
manufacturer = Manufacturer.objects.create(name='Test Manufacturer', slug='test-manufacturer')
|
||||
device_type = DeviceType.objects.create(manufacturer=manufacturer, model='Test Device', slug='test-device')
|
||||
device_role = DeviceRole.objects.create(name='Test Role', slug='test-role')
|
||||
site = Site.objects.first()
|
||||
vc = VirtualChassis.objects.create(name='Test VC')
|
||||
|
||||
devices = [
|
||||
Device(name=f'Device {i}', device_type=device_type, role=device_role, site=site,
|
||||
virtual_chassis=vc, vc_position=i)
|
||||
for i in range(1, 6)
|
||||
]
|
||||
Device.objects.bulk_create(devices)
|
||||
|
||||
# range_lookup should return devices with vc_position between 2 and 4 inclusive
|
||||
query = """
|
||||
{
|
||||
device_list(filters: {vc_position: {range_lookup: {start: 2, end: 4}}}) {
|
||||
id name
|
||||
}
|
||||
}
|
||||
"""
|
||||
response = self.client.post(url, data={'query': query}, format="json", **self.header)
|
||||
self.assertHttpStatus(response, status.HTTP_200_OK)
|
||||
data = json.loads(response.content)
|
||||
self.assertNotIn('errors', data)
|
||||
self.assertEqual(len(data['data']['device_list']), 3)
|
||||
|
||||
def test_offset_pagination(self):
|
||||
self.add_permissions('dcim.view_site')
|
||||
url = reverse('graphql')
|
||||
|
||||
@@ -10,6 +10,7 @@ from core.models import DataSource, Job
|
||||
from utilities.testing import disable_warnings
|
||||
|
||||
from ..jobs import *
|
||||
from ..jobs import _INSTALL_ROOT
|
||||
|
||||
|
||||
class TestJobRunner(JobRunner):
|
||||
@@ -83,6 +84,12 @@ class JobRunnerTest(JobRunnerTestCase):
|
||||
|
||||
self.assertEqual(job.status, JobStatusChoices.STATUS_ERRORED)
|
||||
self.assertEqual(job.error, repr(ErroredJobRunner.EXP))
|
||||
self.assertEqual(len(job.log_entries), 1)
|
||||
self.assertEqual(job.log_entries[0]['level'], 'error')
|
||||
tb_message = job.log_entries[0]['message']
|
||||
self.assertIn('Traceback', tb_message)
|
||||
self.assertIn('Test error', tb_message)
|
||||
self.assertNotIn(_INSTALL_ROOT, tb_message)
|
||||
|
||||
|
||||
class EnqueueTest(JobRunnerTestCase):
|
||||
|
||||
@@ -44,15 +44,18 @@ class Panel:
|
||||
Parameters:
|
||||
title (str): The human-friendly title of the panel
|
||||
actions (list): An iterable of PanelActions to include in the panel header
|
||||
template_name (str): Overrides the default template name, if defined
|
||||
"""
|
||||
template_name = None
|
||||
title = None
|
||||
actions = None
|
||||
|
||||
def __init__(self, title=None, actions=None):
|
||||
def __init__(self, title=None, actions=None, template_name=None):
|
||||
if title is not None:
|
||||
self.title = title
|
||||
self.actions = actions or self.actions or []
|
||||
if template_name is not None:
|
||||
self.template_name = template_name
|
||||
|
||||
def get_context(self, context):
|
||||
"""
|
||||
@@ -317,9 +320,8 @@ class TemplatePanel(Panel):
|
||||
Parameters:
|
||||
template_name (str): The name of the template to render
|
||||
"""
|
||||
def __init__(self, template_name, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
self.template_name = template_name
|
||||
def __init__(self, template_name):
|
||||
super().__init__(template_name=template_name)
|
||||
|
||||
def render(self, context):
|
||||
# Pass the entire context to the template
|
||||
|
||||
8
netbox/project-static/dist/netbox.js
vendored
8
netbox/project-static/dist/netbox.js
vendored
File diff suppressed because one or more lines are too long
8
netbox/project-static/dist/netbox.js.map
vendored
8
netbox/project-static/dist/netbox.js.map
vendored
File diff suppressed because one or more lines are too long
@@ -57,7 +57,10 @@
|
||||
"typescript": "^5.9.3"
|
||||
},
|
||||
"resolutions": {
|
||||
"@types/bootstrap/**/@popperjs/core": "^2.11.6"
|
||||
"@types/bootstrap/**/@popperjs/core": "^2.11.6",
|
||||
"eslint/**/minimatch": "^3.1.3",
|
||||
"eslint-plugin-import/**/minimatch": "^3.1.3",
|
||||
"**/markdown-it": "^14.1.1"
|
||||
},
|
||||
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
|
||||
}
|
||||
|
||||
@@ -1,17 +1,10 @@
|
||||
import { initClearField } from './clearField';
|
||||
import { initFormElements } from './elements';
|
||||
import { initFilterModifiers } from './filterModifiers';
|
||||
import { initRegisteredActions } from './registeredActions';
|
||||
import { initSpeedSelector } from './speedSelector';
|
||||
|
||||
export function initForms(): void {
|
||||
for (const func of [
|
||||
initFormElements,
|
||||
initSpeedSelector,
|
||||
initFilterModifiers,
|
||||
initClearField,
|
||||
initRegisteredActions,
|
||||
]) {
|
||||
for (const func of [initFormElements, initSpeedSelector, initFilterModifiers, initClearField]) {
|
||||
func();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
import { getElements } from '../util';
|
||||
|
||||
/**
|
||||
* Show/hide registered action checkboxes based on selected object_types.
|
||||
*/
|
||||
export function initRegisteredActions(): void {
|
||||
const actionsContainer = document.getElementById('id_registered_actions_container');
|
||||
const selectedList = document.getElementById('id_object_types_1') as HTMLSelectElement;
|
||||
|
||||
if (!actionsContainer || !selectedList) {
|
||||
return;
|
||||
}
|
||||
|
||||
function updateVisibility(): void {
|
||||
const selectedModels = new Set<string>();
|
||||
|
||||
// Get model keys from selected options
|
||||
for (const option of Array.from(selectedList.options)) {
|
||||
const modelKey = option.dataset.modelKey;
|
||||
if (modelKey) {
|
||||
selectedModels.add(modelKey);
|
||||
}
|
||||
}
|
||||
|
||||
// Show/hide action groups
|
||||
const groups = actionsContainer!.querySelectorAll('.model-actions');
|
||||
let anyVisible = false;
|
||||
|
||||
groups.forEach(group => {
|
||||
const modelKey = group.getAttribute('data-model');
|
||||
const visible = modelKey !== null && selectedModels.has(modelKey);
|
||||
(group as HTMLElement).style.display = visible ? 'block' : 'none';
|
||||
if (visible) {
|
||||
anyVisible = true;
|
||||
}
|
||||
});
|
||||
|
||||
// Show/hide "no actions" message
|
||||
const noActionsMsg = document.getElementById('no-custom-actions-message');
|
||||
if (noActionsMsg) {
|
||||
noActionsMsg.style.display = anyVisible ? 'none' : 'block';
|
||||
}
|
||||
|
||||
// Hide the entire field row when no actions are visible
|
||||
const fieldRow = actionsContainer!.closest('.field-row, .mb-3');
|
||||
if (fieldRow) {
|
||||
(fieldRow as HTMLElement).style.display = anyVisible ? '' : 'none';
|
||||
}
|
||||
}
|
||||
|
||||
// Initial update
|
||||
updateVisibility();
|
||||
|
||||
// Listen to move button clicks
|
||||
for (const btn of getElements<HTMLButtonElement>('.move-option')) {
|
||||
btn.addEventListener('click', () => {
|
||||
// Wait for DOM update
|
||||
setTimeout(updateVisibility, 50);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -2779,10 +2779,10 @@ loose-envify@^1.1.0:
|
||||
dependencies:
|
||||
js-tokens "^3.0.0 || ^4.0.0"
|
||||
|
||||
markdown-it@^14.1.0:
|
||||
version "14.1.0"
|
||||
resolved "https://registry.npmjs.org/markdown-it/-/markdown-it-14.1.0.tgz"
|
||||
integrity sha512-a54IwgWPaeBCAAsv13YgmALOF1elABB08FxO9i+r4VFk5Vl4pKokRPeX8u5TCgSsPi6ec1otfLjdOpVcgbpshg==
|
||||
markdown-it@^14.1.0, markdown-it@^14.1.1:
|
||||
version "14.1.1"
|
||||
resolved "https://registry.yarnpkg.com/markdown-it/-/markdown-it-14.1.1.tgz#856f90b66fc39ae70affd25c1b18b581d7deee1f"
|
||||
integrity sha512-BuU2qnTti9YKgK5N+IeMubp14ZUKUUw7yeJbkjtosvHiP0AZ5c8IAgEMk79D0eC8F23r4Ac/q8cAIFdm2FtyoA==
|
||||
dependencies:
|
||||
argparse "^2.0.1"
|
||||
entities "^4.4.0"
|
||||
@@ -2821,14 +2821,7 @@ minimatch@^10.2.2:
|
||||
dependencies:
|
||||
brace-expansion "^5.0.2"
|
||||
|
||||
minimatch@^3.1.2:
|
||||
version "3.1.2"
|
||||
resolved "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz"
|
||||
integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==
|
||||
dependencies:
|
||||
brace-expansion "^1.1.7"
|
||||
|
||||
minimatch@^3.1.3:
|
||||
minimatch@^3.1.2, minimatch@^3.1.3:
|
||||
version "3.1.5"
|
||||
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.5.tgz#580c88f8d5445f2bd6aa8f3cadefa0de79fbd69e"
|
||||
integrity sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==
|
||||
|
||||
@@ -122,6 +122,19 @@
|
||||
{% endif %}
|
||||
</tr>
|
||||
|
||||
{# Changelog #}
|
||||
<tr>
|
||||
<td colspan="2" class="bg-secondary-subtle fs-5 fw-bold border-0 py-1">{% trans "Change log" %}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row" class="ps-3">{% trans "Changelog retention" %}</th>
|
||||
<td>{{ config.CHANGELOG_RETENTION }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row" class="ps-3">{% trans "Changelog retain create & last update records" %}</th>
|
||||
<td>{% checkmark config.CHANGELOG_RETAIN_CREATE_LAST_UPDATE %}</td>
|
||||
</tr>
|
||||
|
||||
{# Miscellaneous #}
|
||||
<tr>
|
||||
<td colspan="2" class="bg-secondary-subtle fs-5 fw-bold border-0 py-1">{% trans "Miscellaneous" %}</td>
|
||||
@@ -137,10 +150,6 @@
|
||||
<th scope="row" class="ps-3">{% trans "GraphQL enabled" %}</th>
|
||||
<td>{% checkmark config.GRAPHQL_ENABLED %}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row" class="ps-3">{% trans "Changelog retention" %}</th>
|
||||
<td>{{ config.CHANGELOG_RETENTION }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row" class="ps-3">{% trans "Job retention" %}</th>
|
||||
<td>{{ config.JOB_RETENTION }}</td>
|
||||
|
||||
@@ -6,6 +6,6 @@
|
||||
{% block content %}
|
||||
{{ block.super }}
|
||||
<div class="text-muted px-3">
|
||||
{% trans "Change log retention" %}: {% if config.CHANGELOG_RETENTION %}{{ config.CHANGELOG_RETENTION }} {% trans "days" %}{% else %}{% trans "Indefinite" %}{% endif %}
|
||||
{% trans "Change log retention" %}: {% if config.CHANGELOG_RETENTION %}{{ config.CHANGELOG_RETENTION }} {% trans "days" %}{% if config.CHANGELOG_RETAIN_CREATE_LAST_UPDATE %} ({% trans "retaining create & last update records for non-deleted objects" %}){% endif %}{% else %}{% trans "Indefinite" %}{% endif %}
|
||||
</div>
|
||||
{% endblock content %}
|
||||
|
||||
@@ -15,67 +15,3 @@
|
||||
</a>
|
||||
{% endif %}
|
||||
{% endblock extra_controls %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row mb-3">
|
||||
<div class="col col-12 col-md-6">
|
||||
<div class="card">
|
||||
<h2 class="card-header">{% trans "Device Role" %}</h2>
|
||||
<table class="table table-hover attr-table">
|
||||
<tr>
|
||||
<th scope="row">{% trans "Name" %}</th>
|
||||
<td>{{ object.name }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Description" %}</th>
|
||||
<td>{{ object.description|placeholder }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Parent" %}</th>
|
||||
<td>{{ object.parent|linkify|placeholder }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Color" %}</th>
|
||||
<td>
|
||||
<span class="badge color-label" style="background-color: #{{ object.color }}"> </span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "VM Role" %}</th>
|
||||
<td>{% checkmark object.vm_role %}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Config Template" %}</th>
|
||||
<td>{{ object.config_template|linkify|placeholder }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
{% include 'inc/panels/tags.html' %}
|
||||
{% plugin_left_page object %}
|
||||
</div>
|
||||
<div class="col col-12 col-md-6">
|
||||
{% include 'inc/panels/related_objects.html' %}
|
||||
{% include 'inc/panels/custom_fields.html' %}
|
||||
{% include 'inc/panels/comments.html' %}
|
||||
{% plugin_right_page object %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<div class="col col-md-12">
|
||||
<div class="card">
|
||||
<h2 class="card-header">
|
||||
{% trans "Child Device Roles" %}
|
||||
{% if perms.dcim.add_devicerole %}
|
||||
<div class="card-actions">
|
||||
<a href="{% url 'dcim:devicerole_add' %}?parent={{ object.pk }}&return_url={{ object.get_absolute_url }}" class="btn btn-ghost-primary btn-sm">
|
||||
<i class="mdi mdi-plus-thick" aria-hidden="true"></i> {% trans "Add a Device Role" %}
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</h2>
|
||||
{% htmx_table 'dcim:devicerole_list' parent_id=object.pk %}
|
||||
</div>
|
||||
{% plugin_full_width_page object %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
@@ -46,75 +46,3 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<div class="col col-12 col-md-6">
|
||||
<div class="card">
|
||||
<h2 class="card-header">{% trans "Module" %}</h2>
|
||||
<table class="table table-hover attr-table">
|
||||
<tr>
|
||||
<th scope="row">{% trans "Device" %}</th>
|
||||
<td>{{ object.device|linkify }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Device Type" %}</th>
|
||||
<td>{{ object.device.device_type|linkify }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Module Bay" %}</th>
|
||||
<td>{% nested_tree object.module_bay %}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Status" %}</th>
|
||||
<td>{% badge object.get_status_display bg_color=object.get_status_color %}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Description" %}</th>
|
||||
<td>{{ object.description|placeholder }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Serial Number" %}</th>
|
||||
<td class="font-monospace">{{ object.serial|placeholder }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Asset Tag" %}</th>
|
||||
<td class="font-monospace">{{ object.asset_tag|placeholder }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
{% include 'inc/panels/tags.html' %}
|
||||
{% include 'inc/panels/comments.html' %}
|
||||
{% plugin_left_page object %}
|
||||
</div>
|
||||
<div class="col col-12 col-md-6">
|
||||
<div class="card">
|
||||
<h2 class="card-header">{% trans "Module Type" %}</h2>
|
||||
<table class="table table-hover attr-table">
|
||||
<tr>
|
||||
<th scope="row">{% trans "Manufacturer" %}</th>
|
||||
<td>{{ object.module_type.manufacturer|linkify }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Model" %}</th>
|
||||
<td>{{ object.module_type|linkify }}</td>
|
||||
</tr>
|
||||
{% for k, v in object.module_type.attributes.items %}
|
||||
<tr>
|
||||
<th scope="row">{{ k }}</th>
|
||||
<td>{{ v|placeholder }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
</div>
|
||||
{% include 'inc/panels/related_objects.html' %}
|
||||
{% include 'inc/panels/custom_fields.html' %}
|
||||
{% plugin_right_page object %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col col-md-12">
|
||||
{% plugin_full_width_page object %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
{% extends 'generic/object.html' %}
|
||||
{% load buttons %}
|
||||
{% load helpers %}
|
||||
{% load plugins %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block title %}{{ object.manufacturer }} {{ object.model }}{% endblock %}
|
||||
@@ -14,92 +11,5 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_controls %}
|
||||
{% include 'dcim/inc/moduletype_buttons.html' %}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<div class="col col-12 col-md-6">
|
||||
<div class="card">
|
||||
<h2 class="card-header">{% trans "Module Type" %}</h2>
|
||||
<table class="table table-hover attr-table">
|
||||
<tr>
|
||||
<th scope="row">{% trans "Profile" %}</th>
|
||||
<td>{{ object.profile|linkify|placeholder }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Manufacturer" %}</th>
|
||||
<td>{{ object.manufacturer|linkify }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Model Name" %}</th>
|
||||
<td>{{ object.model }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Part Number" %}</th>
|
||||
<td>{{ object.part_number|placeholder }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Description" %}</th>
|
||||
<td>{{ object.description|placeholder }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Airflow" %}</th>
|
||||
<td>{{ object.get_airflow_display|placeholder }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Weight" %}</th>
|
||||
<td>
|
||||
{% if object.weight %}
|
||||
{{ object.weight|floatformat }} {{ object.get_weight_unit_display }}
|
||||
{% else %}
|
||||
{{ ''|placeholder }}
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
{% include 'inc/panels/tags.html' %}
|
||||
{% include 'inc/panels/comments.html' %}
|
||||
{% plugin_left_page object %}
|
||||
</div>
|
||||
<div class="col col-12 col-md-6">
|
||||
<div class="card">
|
||||
<h2 class="card-header">{% trans "Attributes" %}</h2>
|
||||
{% if not object.profile %}
|
||||
<div class="card-body text-muted">
|
||||
{% trans "No profile assigned" %}
|
||||
</div>
|
||||
{% elif object.attributes %}
|
||||
<table class="table table-hover attr-table">
|
||||
{% for k, v in object.attributes.items %}
|
||||
<tr>
|
||||
<th scope="row">{{ k }}</th>
|
||||
<td>
|
||||
{% if v is True or v is False %}
|
||||
{% checkmark v %}
|
||||
{% else %}
|
||||
{{ v|placeholder }}
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% else %}
|
||||
<div class="card-body text-muted">
|
||||
{% trans "None" %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% include 'inc/panels/related_objects.html' %}
|
||||
{% include 'inc/panels/custom_fields.html' %}
|
||||
{% include 'inc/panels/image_attachments.html' %}
|
||||
{% plugin_right_page object %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col col-md-12">
|
||||
{% plugin_full_width_page object %}
|
||||
</div>
|
||||
</div>
|
||||
{% include 'dcim/inc/moduletype_buttons.html' %}
|
||||
{% endblock %}
|
||||
|
||||
27
netbox/templates/dcim/panels/module_type.html
Normal file
27
netbox/templates/dcim/panels/module_type.html
Normal file
@@ -0,0 +1,27 @@
|
||||
{% extends "ui/panels/_base.html" %}
|
||||
{% load helpers i18n %}
|
||||
|
||||
{% block panel_content %}
|
||||
<table class="table table-hover attr-table">
|
||||
<tr>
|
||||
<th scope="row">{% trans "Manufacturer" %}</th>
|
||||
<td>{{ object.module_type.manufacturer|linkify }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Model" %}</th>
|
||||
<td>{{ object.module_type|linkify }}</td>
|
||||
</tr>
|
||||
{% for k, v in object.module_type.attributes.items %}
|
||||
<tr>
|
||||
<th scope="row">{{ k }}</th>
|
||||
<td>
|
||||
{% if v is True or v is False %}
|
||||
{% checkmark v %}
|
||||
{% else %}
|
||||
{{ v|placeholder }}
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% endblock panel_content %}
|
||||
29
netbox/templates/dcim/panels/module_type_attributes.html
Normal file
29
netbox/templates/dcim/panels/module_type_attributes.html
Normal file
@@ -0,0 +1,29 @@
|
||||
{% extends "ui/panels/_base.html" %}
|
||||
{% load helpers i18n %}
|
||||
|
||||
{% block panel_content %}
|
||||
{% if not object.profile %}
|
||||
<div class="card-body text-muted">
|
||||
{% trans "No profile assigned" %}
|
||||
</div>
|
||||
{% elif object.attributes %}
|
||||
<table class="table table-hover attr-table">
|
||||
{% for k, v in object.attributes.items %}
|
||||
<tr>
|
||||
<th scope="row">{{ k }}</th>
|
||||
<td>
|
||||
{% if v is True or v is False %}
|
||||
{% checkmark v %}
|
||||
{% else %}
|
||||
{{ v|placeholder }}
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% else %}
|
||||
<div class="card-body text-muted">
|
||||
{% trans "None" %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endblock panel_content %}
|
||||
@@ -18,61 +18,3 @@
|
||||
</a>
|
||||
{% endif %}
|
||||
{% endblock extra_controls %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row mb-3">
|
||||
<div class="col col-12 col-md-6">
|
||||
<div class="card">
|
||||
<h2 class="card-header">{% trans "Platform" %}</h2>
|
||||
<table class="table table-hover attr-table">
|
||||
<tr>
|
||||
<th scope="row">{% trans "Name" %}</th>
|
||||
<td>{{ object.name }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Description" %}</th>
|
||||
<td>{{ object.description|placeholder }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Parent" %}</th>
|
||||
<td>{{ object.parent|linkify|placeholder }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Manufacturer" %}</th>
|
||||
<td>{{ object.manufacturer|linkify|placeholder }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Config Template" %}</th>
|
||||
<td>{{ object.config_template|linkify|placeholder }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
{% include 'inc/panels/tags.html' %}
|
||||
{% plugin_left_page object %}
|
||||
</div>
|
||||
<div class="col col-12 col-md-6">
|
||||
{% include 'inc/panels/related_objects.html' %}
|
||||
{% include 'inc/panels/custom_fields.html' %}
|
||||
{% include 'inc/panels/comments.html' %}
|
||||
{% plugin_right_page object %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<div class="col col-md-12">
|
||||
<div class="card">
|
||||
<h2 class="card-header">
|
||||
{% trans "Child Platforms" %}
|
||||
{% if perms.dcim.add_platform %}
|
||||
<div class="card-actions">
|
||||
<a href="{% url 'dcim:platform_add' %}?parent={{ object.pk }}&return_url={{ object.get_absolute_url }}" class="btn btn-ghost-primary btn-sm">
|
||||
<i class="mdi mdi-plus-thick" aria-hidden="true"></i> {% trans "Add a Platform" %}
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</h2>
|
||||
{% htmx_table 'dcim:platform_list' parent_id=object.pk %}
|
||||
</div>
|
||||
{% plugin_full_width_page object %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-muted">
|
||||
{% trans "Change log retention" %}: {% if config.CHANGELOG_RETENTION %}{{ config.CHANGELOG_RETENTION }} {% trans "days" %}{% else %}{% trans "Indefinite" %}{% endif %}
|
||||
{% trans "Change log retention" %}: {% if config.CHANGELOG_RETENTION %}{{ config.CHANGELOG_RETENTION }} {% trans "days" %}{% if config.CHANGELOG_RETAIN_CREATE_LAST_UPDATE %} ({% trans "retaining create & last update records for non-deleted objects" %}){% endif %}{% else %}{% trans "Indefinite" %}{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -92,7 +92,7 @@ Context:
|
||||
|
||||
<div class="form form-horizontal">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="return_url" value="{% if return_url %}{{ return_url }}{% else %}{{ request.path }}{% if request.GET %}?{{ request.GET.urlencode }}{% endif %}{% endif %}" />
|
||||
<input type="hidden" id="object-list-return-url" name="return_url" value="{% if return_url %}{{ return_url }}{% else %}{{ request.path }}{% if request.GET %}?{{ request.GET.urlencode }}{% endif %}{% endif %}" />
|
||||
|
||||
{# Warn of any missing prerequisite objects #}
|
||||
{% if prerequisite_model %}
|
||||
|
||||
@@ -32,4 +32,9 @@
|
||||
{% action_buttons actions model multi=True %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{# Update the return_url to reflect any changed query parameters (e.g. per_page) #}
|
||||
{% if not table.embedded %}
|
||||
<input type="hidden" id="object-list-return-url" name="return_url" value="{{ request.get_full_path }}" hx-swap-oob="outerHTML:#object-list-return-url" />
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
@@ -46,14 +46,6 @@
|
||||
<th scope="row">{% trans "Delete" %}</th>
|
||||
<td>{% checkmark object.can_delete %}</td>
|
||||
</tr>
|
||||
{% for action in object.actions %}
|
||||
{% if action not in reserved_actions %}
|
||||
<tr>
|
||||
<th scope="row">{{ action }}</th>
|
||||
<td>{% checkmark True %}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</table>
|
||||
</div>
|
||||
<div class="card">
|
||||
|
||||
@@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2026-03-03 05:20+0000\n"
|
||||
"POT-Creation-Date: 2026-03-04 05:17+0000\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@@ -172,8 +172,8 @@ msgstr ""
|
||||
#: netbox/dcim/forms/bulk_edit.py:323 netbox/dcim/forms/bulk_edit.py:673
|
||||
#: netbox/dcim/forms/bulk_edit.py:860 netbox/dcim/forms/bulk_import.py:146
|
||||
#: netbox/dcim/forms/bulk_import.py:247 netbox/dcim/forms/bulk_import.py:349
|
||||
#: netbox/dcim/forms/bulk_import.py:640 netbox/dcim/forms/bulk_import.py:1608
|
||||
#: netbox/dcim/forms/bulk_import.py:1636 netbox/dcim/forms/filtersets.py:106
|
||||
#: netbox/dcim/forms/bulk_import.py:640 netbox/dcim/forms/bulk_import.py:1609
|
||||
#: netbox/dcim/forms/bulk_import.py:1637 netbox/dcim/forms/filtersets.py:106
|
||||
#: netbox/dcim/forms/filtersets.py:256 netbox/dcim/forms/filtersets.py:379
|
||||
#: netbox/dcim/forms/filtersets.py:483 netbox/dcim/forms/filtersets.py:855
|
||||
#: netbox/dcim/forms/filtersets.py:1073 netbox/dcim/forms/filtersets.py:1147
|
||||
@@ -187,7 +187,7 @@ msgstr ""
|
||||
#: netbox/dcim/tables/power.py:90 netbox/dcim/tables/racks.py:111
|
||||
#: netbox/dcim/tables/racks.py:194 netbox/dcim/tables/sites.py:102
|
||||
#: netbox/extras/filtersets.py:707 netbox/ipam/forms/bulk_edit.py:414
|
||||
#: netbox/ipam/forms/bulk_import.py:487 netbox/ipam/forms/filtersets.py:171
|
||||
#: netbox/ipam/forms/bulk_import.py:489 netbox/ipam/forms/filtersets.py:171
|
||||
#: netbox/ipam/forms/filtersets.py:251 netbox/ipam/forms/filtersets.py:476
|
||||
#: netbox/ipam/forms/filtersets.py:573 netbox/ipam/forms/model_forms.py:663
|
||||
#: netbox/ipam/tables/vlans.py:92 netbox/ipam/tables/vlans.py:214
|
||||
@@ -326,7 +326,7 @@ msgstr ""
|
||||
#: netbox/circuits/forms/model_forms.py:162
|
||||
#: netbox/circuits/forms/model_forms.py:260
|
||||
#: netbox/circuits/tables/circuits.py:103
|
||||
#: netbox/circuits/tables/circuits.py:199 netbox/dcim/forms/connections.py:79
|
||||
#: netbox/circuits/tables/circuits.py:199 netbox/dcim/forms/connections.py:83
|
||||
#: netbox/templates/circuits/circuit.html:15
|
||||
#: netbox/templates/circuits/circuitgroupassignment.html:30
|
||||
#: netbox/templates/circuits/circuittermination.html:19
|
||||
@@ -463,7 +463,7 @@ msgstr ""
|
||||
#: netbox/dcim/forms/bulk_edit.py:605 netbox/dcim/forms/bulk_edit.py:803
|
||||
#: netbox/dcim/forms/bulk_edit.py:1057 netbox/dcim/forms/bulk_edit.py:1156
|
||||
#: netbox/dcim/forms/bulk_edit.py:1183 netbox/dcim/forms/bulk_edit.py:1717
|
||||
#: netbox/dcim/forms/bulk_import.py:1483 netbox/dcim/forms/filtersets.py:1220
|
||||
#: netbox/dcim/forms/bulk_import.py:1484 netbox/dcim/forms/filtersets.py:1220
|
||||
#: netbox/dcim/forms/filtersets.py:1545 netbox/dcim/forms/filtersets.py:1761
|
||||
#: netbox/dcim/forms/filtersets.py:1780 netbox/dcim/forms/filtersets.py:1804
|
||||
#: netbox/dcim/forms/filtersets.py:1823 netbox/dcim/tables/devices.py:786
|
||||
@@ -500,8 +500,8 @@ msgstr ""
|
||||
#: netbox/dcim/forms/bulk_import.py:813 netbox/dcim/forms/bulk_import.py:839
|
||||
#: netbox/dcim/forms/bulk_import.py:865 netbox/dcim/forms/bulk_import.py:886
|
||||
#: netbox/dcim/forms/bulk_import.py:972 netbox/dcim/forms/bulk_import.py:1101
|
||||
#: netbox/dcim/forms/bulk_import.py:1120 netbox/dcim/forms/bulk_import.py:1464
|
||||
#: netbox/dcim/forms/bulk_import.py:1673 netbox/dcim/forms/filtersets.py:1104
|
||||
#: netbox/dcim/forms/bulk_import.py:1120 netbox/dcim/forms/bulk_import.py:1465
|
||||
#: netbox/dcim/forms/bulk_import.py:1674 netbox/dcim/forms/filtersets.py:1104
|
||||
#: netbox/dcim/forms/filtersets.py:1205 netbox/dcim/forms/filtersets.py:1333
|
||||
#: netbox/dcim/forms/filtersets.py:1424 netbox/dcim/forms/filtersets.py:1444
|
||||
#: netbox/dcim/forms/filtersets.py:1464 netbox/dcim/forms/filtersets.py:1484
|
||||
@@ -572,8 +572,8 @@ msgstr ""
|
||||
#: netbox/dcim/forms/bulk_import.py:103 netbox/dcim/forms/bulk_import.py:162
|
||||
#: netbox/dcim/forms/bulk_import.py:265 netbox/dcim/forms/bulk_import.py:374
|
||||
#: netbox/dcim/forms/bulk_import.py:605 netbox/dcim/forms/bulk_import.py:765
|
||||
#: netbox/dcim/forms/bulk_import.py:1230 netbox/dcim/forms/bulk_import.py:1452
|
||||
#: netbox/dcim/forms/bulk_import.py:1668 netbox/dcim/forms/bulk_import.py:1731
|
||||
#: netbox/dcim/forms/bulk_import.py:1230 netbox/dcim/forms/bulk_import.py:1453
|
||||
#: netbox/dcim/forms/bulk_import.py:1669 netbox/dcim/forms/bulk_import.py:1732
|
||||
#: netbox/dcim/forms/filtersets.py:208 netbox/dcim/forms/filtersets.py:268
|
||||
#: netbox/dcim/forms/filtersets.py:396 netbox/dcim/forms/filtersets.py:504
|
||||
#: netbox/dcim/forms/filtersets.py:901 netbox/dcim/forms/filtersets.py:1024
|
||||
@@ -588,7 +588,7 @@ msgstr ""
|
||||
#: netbox/ipam/forms/bulk_edit.py:204 netbox/ipam/forms/bulk_edit.py:248
|
||||
#: netbox/ipam/forms/bulk_edit.py:295 netbox/ipam/forms/bulk_edit.py:436
|
||||
#: netbox/ipam/forms/bulk_import.py:198 netbox/ipam/forms/bulk_import.py:262
|
||||
#: netbox/ipam/forms/bulk_import.py:298 netbox/ipam/forms/bulk_import.py:508
|
||||
#: netbox/ipam/forms/bulk_import.py:298 netbox/ipam/forms/bulk_import.py:510
|
||||
#: netbox/ipam/forms/filtersets.py:234 netbox/ipam/forms/filtersets.py:313
|
||||
#: netbox/ipam/forms/filtersets.py:396 netbox/ipam/forms/filtersets.py:585
|
||||
#: netbox/ipam/forms/model_forms.py:503 netbox/ipam/tables/ip.py:182
|
||||
@@ -647,8 +647,8 @@ msgstr ""
|
||||
#: netbox/dcim/forms/bulk_edit.py:793 netbox/dcim/forms/bulk_edit.py:1740
|
||||
#: netbox/dcim/forms/bulk_import.py:122 netbox/dcim/forms/bulk_import.py:167
|
||||
#: netbox/dcim/forms/bulk_import.py:258 netbox/dcim/forms/bulk_import.py:379
|
||||
#: netbox/dcim/forms/bulk_import.py:579 netbox/dcim/forms/bulk_import.py:1470
|
||||
#: netbox/dcim/forms/bulk_import.py:1724 netbox/dcim/forms/filtersets.py:143
|
||||
#: netbox/dcim/forms/bulk_import.py:579 netbox/dcim/forms/bulk_import.py:1471
|
||||
#: netbox/dcim/forms/bulk_import.py:1725 netbox/dcim/forms/filtersets.py:143
|
||||
#: netbox/dcim/forms/filtersets.py:202 netbox/dcim/forms/filtersets.py:235
|
||||
#: netbox/dcim/forms/filtersets.py:363 netbox/dcim/forms/filtersets.py:442
|
||||
#: netbox/dcim/forms/filtersets.py:463 netbox/dcim/forms/filtersets.py:823
|
||||
@@ -665,7 +665,7 @@ msgstr ""
|
||||
#: netbox/ipam/forms/bulk_import.py:102 netbox/ipam/forms/bulk_import.py:122
|
||||
#: netbox/ipam/forms/bulk_import.py:142 netbox/ipam/forms/bulk_import.py:170
|
||||
#: netbox/ipam/forms/bulk_import.py:255 netbox/ipam/forms/bulk_import.py:291
|
||||
#: netbox/ipam/forms/bulk_import.py:468 netbox/ipam/forms/bulk_import.py:501
|
||||
#: netbox/ipam/forms/bulk_import.py:470 netbox/ipam/forms/bulk_import.py:503
|
||||
#: netbox/ipam/forms/filtersets.py:50 netbox/ipam/forms/filtersets.py:71
|
||||
#: netbox/ipam/forms/filtersets.py:109 netbox/ipam/forms/filtersets.py:131
|
||||
#: netbox/ipam/forms/filtersets.py:155 netbox/ipam/forms/filtersets.py:196
|
||||
@@ -922,7 +922,7 @@ msgstr ""
|
||||
|
||||
#: netbox/circuits/forms/bulk_edit.py:192
|
||||
#: netbox/circuits/forms/model_forms.py:170
|
||||
#: netbox/dcim/forms/bulk_import.py:1418 netbox/dcim/forms/bulk_import.py:1443
|
||||
#: netbox/dcim/forms/bulk_import.py:1419 netbox/dcim/forms/bulk_import.py:1444
|
||||
msgid "Termination type"
|
||||
msgstr ""
|
||||
|
||||
@@ -1008,7 +1008,7 @@ msgstr ""
|
||||
#: netbox/ipam/forms/bulk_edit.py:253 netbox/ipam/forms/bulk_edit.py:300
|
||||
#: netbox/ipam/forms/bulk_edit.py:441 netbox/ipam/forms/bulk_import.py:203
|
||||
#: netbox/ipam/forms/bulk_import.py:267 netbox/ipam/forms/bulk_import.py:303
|
||||
#: netbox/ipam/forms/bulk_import.py:513 netbox/ipam/forms/filtersets.py:262
|
||||
#: netbox/ipam/forms/bulk_import.py:515 netbox/ipam/forms/filtersets.py:262
|
||||
#: netbox/ipam/forms/filtersets.py:321 netbox/ipam/forms/filtersets.py:401
|
||||
#: netbox/ipam/forms/filtersets.py:593 netbox/ipam/forms/model_forms.py:189
|
||||
#: netbox/ipam/forms/model_forms.py:215 netbox/ipam/forms/model_forms.py:253
|
||||
@@ -1057,10 +1057,10 @@ msgstr ""
|
||||
#: netbox/dcim/forms/bulk_import.py:105 netbox/dcim/forms/bulk_import.py:164
|
||||
#: netbox/dcim/forms/bulk_import.py:267 netbox/dcim/forms/bulk_import.py:376
|
||||
#: netbox/dcim/forms/bulk_import.py:607 netbox/dcim/forms/bulk_import.py:767
|
||||
#: netbox/dcim/forms/bulk_import.py:1232 netbox/dcim/forms/bulk_import.py:1670
|
||||
#: netbox/dcim/forms/bulk_import.py:1232 netbox/dcim/forms/bulk_import.py:1671
|
||||
#: netbox/ipam/forms/bulk_import.py:200 netbox/ipam/forms/bulk_import.py:264
|
||||
#: netbox/ipam/forms/bulk_import.py:300 netbox/ipam/forms/bulk_import.py:510
|
||||
#: netbox/ipam/forms/bulk_import.py:523
|
||||
#: netbox/ipam/forms/bulk_import.py:300 netbox/ipam/forms/bulk_import.py:512
|
||||
#: netbox/ipam/forms/bulk_import.py:525
|
||||
#: netbox/virtualization/forms/bulk_import.py:57
|
||||
#: netbox/virtualization/forms/bulk_import.py:89
|
||||
#: netbox/vpn/forms/bulk_import.py:38 netbox/vpn/forms/bulk_import.py:265
|
||||
@@ -1073,13 +1073,13 @@ msgstr ""
|
||||
#: netbox/circuits/forms/bulk_import.py:235
|
||||
#: netbox/dcim/forms/bulk_import.py:126 netbox/dcim/forms/bulk_import.py:171
|
||||
#: netbox/dcim/forms/bulk_import.py:383 netbox/dcim/forms/bulk_import.py:583
|
||||
#: netbox/dcim/forms/bulk_import.py:1474 netbox/dcim/forms/bulk_import.py:1665
|
||||
#: netbox/dcim/forms/bulk_import.py:1728 netbox/ipam/forms/bulk_import.py:49
|
||||
#: netbox/dcim/forms/bulk_import.py:1475 netbox/dcim/forms/bulk_import.py:1666
|
||||
#: netbox/dcim/forms/bulk_import.py:1729 netbox/ipam/forms/bulk_import.py:49
|
||||
#: netbox/ipam/forms/bulk_import.py:78 netbox/ipam/forms/bulk_import.py:106
|
||||
#: netbox/ipam/forms/bulk_import.py:126 netbox/ipam/forms/bulk_import.py:146
|
||||
#: netbox/ipam/forms/bulk_import.py:174 netbox/ipam/forms/bulk_import.py:259
|
||||
#: netbox/ipam/forms/bulk_import.py:295 netbox/ipam/forms/bulk_import.py:472
|
||||
#: netbox/ipam/forms/bulk_import.py:505
|
||||
#: netbox/ipam/forms/bulk_import.py:295 netbox/ipam/forms/bulk_import.py:474
|
||||
#: netbox/ipam/forms/bulk_import.py:507
|
||||
#: netbox/virtualization/forms/bulk_import.py:71
|
||||
#: netbox/virtualization/forms/bulk_import.py:132
|
||||
#: netbox/vpn/forms/bulk_import.py:62 netbox/wireless/forms/bulk_import.py:60
|
||||
@@ -1152,8 +1152,8 @@ msgstr ""
|
||||
#: netbox/dcim/forms/bulk_edit.py:439 netbox/dcim/forms/bulk_edit.py:678
|
||||
#: netbox/dcim/forms/bulk_edit.py:727 netbox/dcim/forms/bulk_edit.py:869
|
||||
#: netbox/dcim/forms/bulk_import.py:252 netbox/dcim/forms/bulk_import.py:355
|
||||
#: netbox/dcim/forms/bulk_import.py:646 netbox/dcim/forms/bulk_import.py:1614
|
||||
#: netbox/dcim/forms/bulk_import.py:1648 netbox/dcim/forms/filtersets.py:114
|
||||
#: netbox/dcim/forms/bulk_import.py:646 netbox/dcim/forms/bulk_import.py:1615
|
||||
#: netbox/dcim/forms/bulk_import.py:1649 netbox/dcim/forms/filtersets.py:114
|
||||
#: netbox/dcim/forms/filtersets.py:358 netbox/dcim/forms/filtersets.py:393
|
||||
#: netbox/dcim/forms/filtersets.py:438 netbox/dcim/forms/filtersets.py:491
|
||||
#: netbox/dcim/forms/filtersets.py:820 netbox/dcim/forms/filtersets.py:864
|
||||
@@ -1343,7 +1343,7 @@ msgstr ""
|
||||
#: netbox/dcim/forms/bulk_import.py:115 netbox/dcim/forms/model_forms.py:135
|
||||
#: netbox/dcim/tables/sites.py:69 netbox/extras/forms/filtersets.py:600
|
||||
#: netbox/ipam/filtersets.py:1034 netbox/ipam/forms/bulk_edit.py:423
|
||||
#: netbox/ipam/forms/bulk_import.py:494 netbox/ipam/forms/model_forms.py:561
|
||||
#: netbox/ipam/forms/bulk_import.py:496 netbox/ipam/forms/model_forms.py:561
|
||||
#: netbox/ipam/tables/fhrp.py:64 netbox/ipam/tables/vlans.py:96
|
||||
#: netbox/ipam/tables/vlans.py:219
|
||||
#: netbox/templates/circuits/circuitgroupassignment.html:22
|
||||
@@ -1433,8 +1433,8 @@ msgstr ""
|
||||
#: netbox/dcim/models/modules.py:219 netbox/dcim/models/power.py:95
|
||||
#: netbox/dcim/models/racks.py:301 netbox/dcim/models/racks.py:685
|
||||
#: netbox/dcim/models/sites.py:163 netbox/dcim/models/sites.py:287
|
||||
#: netbox/ipam/models/ip.py:244 netbox/ipam/models/ip.py:526
|
||||
#: netbox/ipam/models/ip.py:755 netbox/ipam/models/vlans.py:228
|
||||
#: netbox/ipam/models/ip.py:244 netbox/ipam/models/ip.py:528
|
||||
#: netbox/ipam/models/ip.py:757 netbox/ipam/models/vlans.py:228
|
||||
#: netbox/virtualization/models/clusters.py:70
|
||||
#: netbox/virtualization/models/virtualmachines.py:80
|
||||
#: netbox/vpn/models/l2vpn.py:36 netbox/vpn/models/tunnels.py:38
|
||||
@@ -1656,7 +1656,7 @@ msgid "virtual circuits"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/circuits/models/virtual_circuits.py:135 netbox/ipam/models/ip.py:201
|
||||
#: netbox/ipam/models/ip.py:762 netbox/vpn/models/tunnels.py:109
|
||||
#: netbox/ipam/models/ip.py:764 netbox/vpn/models/tunnels.py:109
|
||||
msgid "role"
|
||||
msgstr ""
|
||||
|
||||
@@ -1826,7 +1826,7 @@ msgstr ""
|
||||
msgid "Assignments"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/circuits/tables/circuits.py:112 netbox/dcim/forms/connections.py:87
|
||||
#: netbox/circuits/tables/circuits.py:112 netbox/dcim/forms/connections.py:91
|
||||
msgid "Side"
|
||||
msgstr ""
|
||||
|
||||
@@ -1879,7 +1879,7 @@ msgstr ""
|
||||
#: netbox/dcim/forms/bulk_import.py:1096 netbox/dcim/forms/bulk_import.py:1115
|
||||
#: netbox/dcim/forms/bulk_import.py:1134 netbox/dcim/forms/bulk_import.py:1146
|
||||
#: netbox/dcim/forms/bulk_import.py:1194 netbox/dcim/forms/bulk_import.py:1316
|
||||
#: netbox/dcim/forms/bulk_import.py:1718 netbox/dcim/forms/connections.py:30
|
||||
#: netbox/dcim/forms/bulk_import.py:1719 netbox/dcim/forms/connections.py:34
|
||||
#: netbox/dcim/forms/filtersets.py:156 netbox/dcim/forms/filtersets.py:1021
|
||||
#: netbox/dcim/forms/filtersets.py:1054 netbox/dcim/forms/filtersets.py:1202
|
||||
#: netbox/dcim/forms/filtersets.py:1418 netbox/dcim/forms/filtersets.py:1441
|
||||
@@ -2606,7 +2606,7 @@ msgstr ""
|
||||
msgid "last updated"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/core/models/data.py:300 netbox/dcim/models/cables.py:623
|
||||
#: netbox/core/models/data.py:300 netbox/dcim/models/cables.py:667
|
||||
msgid "path"
|
||||
msgstr ""
|
||||
|
||||
@@ -2614,7 +2614,7 @@ msgstr ""
|
||||
msgid "File path relative to the data source's root"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/core/models/data.py:307 netbox/ipam/models/ip.py:507
|
||||
#: netbox/core/models/data.py:307 netbox/ipam/models/ip.py:509
|
||||
msgid "size"
|
||||
msgstr ""
|
||||
|
||||
@@ -3141,7 +3141,7 @@ msgstr ""
|
||||
#: netbox/dcim/forms/model_forms.py:1709 netbox/dcim/forms/object_import.py:177
|
||||
#: netbox/dcim/tables/devices.py:702 netbox/dcim/tables/devices.py:737
|
||||
#: netbox/dcim/tables/devices.py:965 netbox/dcim/tables/devices.py:1052
|
||||
#: netbox/dcim/tables/devices.py:1205 netbox/ipam/forms/bulk_import.py:580
|
||||
#: netbox/dcim/tables/devices.py:1205 netbox/ipam/forms/bulk_import.py:582
|
||||
#: netbox/ipam/forms/model_forms.py:758 netbox/ipam/tables/fhrp.py:56
|
||||
#: netbox/ipam/tables/ip.py:329 netbox/ipam/tables/services.py:42
|
||||
#: netbox/netbox/tables/tables.py:329 netbox/netbox/ui/panels.py:203
|
||||
@@ -4065,8 +4065,8 @@ msgstr ""
|
||||
#: netbox/ipam/forms/model_forms.py:203 netbox/ipam/forms/model_forms.py:250
|
||||
#: netbox/ipam/forms/model_forms.py:303 netbox/ipam/forms/model_forms.py:466
|
||||
#: netbox/ipam/forms/model_forms.py:480 netbox/ipam/forms/model_forms.py:494
|
||||
#: netbox/ipam/models/ip.py:224 netbox/ipam/models/ip.py:516
|
||||
#: netbox/ipam/models/ip.py:745 netbox/ipam/models/vrfs.py:61
|
||||
#: netbox/ipam/models/ip.py:224 netbox/ipam/models/ip.py:518
|
||||
#: netbox/ipam/models/ip.py:747 netbox/ipam/models/vrfs.py:61
|
||||
#: netbox/ipam/tables/ip.py:187 netbox/ipam/tables/ip.py:258
|
||||
#: netbox/ipam/tables/ip.py:311 netbox/ipam/tables/ip.py:413
|
||||
#: netbox/templates/dcim/interface.html:165
|
||||
@@ -4447,8 +4447,8 @@ msgstr ""
|
||||
|
||||
#: netbox/dcim/forms/bulk_edit.py:438 netbox/dcim/forms/bulk_edit.py:891
|
||||
#: netbox/dcim/forms/bulk_import.py:362 netbox/dcim/forms/bulk_import.py:365
|
||||
#: netbox/dcim/forms/bulk_import.py:653 netbox/dcim/forms/bulk_import.py:1655
|
||||
#: netbox/dcim/forms/bulk_import.py:1659 netbox/dcim/forms/filtersets.py:123
|
||||
#: netbox/dcim/forms/bulk_import.py:653 netbox/dcim/forms/bulk_import.py:1656
|
||||
#: netbox/dcim/forms/bulk_import.py:1660 netbox/dcim/forms/filtersets.py:123
|
||||
#: netbox/dcim/forms/filtersets.py:359 netbox/dcim/forms/filtersets.py:448
|
||||
#: netbox/dcim/forms/filtersets.py:462 netbox/dcim/forms/filtersets.py:501
|
||||
#: netbox/dcim/forms/filtersets.py:874 netbox/dcim/forms/filtersets.py:1086
|
||||
@@ -4510,7 +4510,7 @@ msgstr ""
|
||||
|
||||
#: netbox/dcim/forms/bulk_edit.py:549 netbox/dcim/forms/bulk_edit.py:556
|
||||
#: netbox/dcim/forms/bulk_edit.py:787 netbox/dcim/forms/bulk_import.py:460
|
||||
#: netbox/dcim/forms/bulk_import.py:1458 netbox/dcim/forms/filtersets.py:690
|
||||
#: netbox/dcim/forms/bulk_import.py:1459 netbox/dcim/forms/filtersets.py:690
|
||||
#: netbox/dcim/forms/filtersets.py:1215 netbox/dcim/forms/model_forms.py:418
|
||||
#: netbox/dcim/forms/model_forms.py:431 netbox/dcim/tables/modules.py:43
|
||||
#: netbox/extras/forms/filtersets.py:413 netbox/extras/forms/model_forms.py:626
|
||||
@@ -4647,8 +4647,8 @@ msgstr ""
|
||||
msgid "Length"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/forms/bulk_edit.py:812 netbox/dcim/forms/bulk_import.py:1477
|
||||
#: netbox/dcim/forms/bulk_import.py:1480 netbox/dcim/forms/filtersets.py:1228
|
||||
#: netbox/dcim/forms/bulk_edit.py:812 netbox/dcim/forms/bulk_import.py:1478
|
||||
#: netbox/dcim/forms/bulk_import.py:1481 netbox/dcim/forms/filtersets.py:1228
|
||||
msgid "Length unit"
|
||||
msgstr ""
|
||||
|
||||
@@ -4657,17 +4657,17 @@ msgstr ""
|
||||
msgid "Domain"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/forms/bulk_edit.py:886 netbox/dcim/forms/bulk_import.py:1642
|
||||
#: netbox/dcim/forms/bulk_edit.py:886 netbox/dcim/forms/bulk_import.py:1643
|
||||
#: netbox/dcim/forms/filtersets.py:1316 netbox/dcim/forms/model_forms.py:865
|
||||
msgid "Power panel"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/forms/bulk_edit.py:908 netbox/dcim/forms/bulk_import.py:1678
|
||||
#: netbox/dcim/forms/bulk_edit.py:908 netbox/dcim/forms/bulk_import.py:1679
|
||||
#: netbox/dcim/forms/filtersets.py:1338 netbox/templates/dcim/powerfeed.html:83
|
||||
msgid "Supply"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/forms/bulk_edit.py:914 netbox/dcim/forms/bulk_import.py:1683
|
||||
#: netbox/dcim/forms/bulk_edit.py:914 netbox/dcim/forms/bulk_import.py:1684
|
||||
#: netbox/dcim/forms/filtersets.py:1343 netbox/templates/dcim/powerfeed.html:95
|
||||
msgid "Phase"
|
||||
msgstr ""
|
||||
@@ -4914,7 +4914,7 @@ msgid "available options"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/forms/bulk_import.py:149 netbox/dcim/forms/bulk_import.py:643
|
||||
#: netbox/dcim/forms/bulk_import.py:1639 netbox/ipam/forms/bulk_import.py:491
|
||||
#: netbox/dcim/forms/bulk_import.py:1640 netbox/ipam/forms/bulk_import.py:493
|
||||
#: netbox/virtualization/forms/bulk_import.py:64
|
||||
#: netbox/virtualization/forms/bulk_import.py:102
|
||||
msgid "Assigned site"
|
||||
@@ -4977,7 +4977,7 @@ msgstr ""
|
||||
msgid "Parent site"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/forms/bulk_import.py:359 netbox/dcim/forms/bulk_import.py:1652
|
||||
#: netbox/dcim/forms/bulk_import.py:359 netbox/dcim/forms/bulk_import.py:1653
|
||||
msgid "Rack's location (if any)"
|
||||
msgstr ""
|
||||
|
||||
@@ -5042,7 +5042,7 @@ msgstr ""
|
||||
msgid "Limit platform assignments to this manufacturer"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/forms/bulk_import.py:576 netbox/dcim/forms/bulk_import.py:1721
|
||||
#: netbox/dcim/forms/bulk_import.py:576 netbox/dcim/forms/bulk_import.py:1722
|
||||
#: netbox/tenancy/forms/bulk_import.py:116
|
||||
msgid "Assigned role"
|
||||
msgstr ""
|
||||
@@ -5245,7 +5245,7 @@ msgid "VDC {vdc} is not assigned to device {device}"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/forms/bulk_import.py:1103 netbox/dcim/forms/bulk_import.py:1121
|
||||
#: netbox/dcim/forms/bulk_import.py:1467
|
||||
#: netbox/dcim/forms/bulk_import.py:1468
|
||||
msgid "Physical medium classification"
|
||||
msgstr ""
|
||||
|
||||
@@ -5329,87 +5329,87 @@ msgstr ""
|
||||
msgid "Must specify the parent device or VM when assigning an interface"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/forms/bulk_import.py:1402
|
||||
#: netbox/dcim/forms/bulk_import.py:1403
|
||||
msgid "Side A site"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/forms/bulk_import.py:1406
|
||||
#: netbox/dcim/forms/bulk_import.py:1407
|
||||
#: netbox/wireless/forms/bulk_import.py:93
|
||||
msgid "Site of parent device A (if any)"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/forms/bulk_import.py:1409
|
||||
#: netbox/dcim/forms/bulk_import.py:1410
|
||||
msgid "Side A device"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/forms/bulk_import.py:1412 netbox/dcim/forms/bulk_import.py:1437
|
||||
#: netbox/dcim/forms/bulk_import.py:1413 netbox/dcim/forms/bulk_import.py:1438
|
||||
msgid "Device name"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/forms/bulk_import.py:1415
|
||||
#: netbox/dcim/forms/bulk_import.py:1416
|
||||
msgid "Side A type"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/forms/bulk_import.py:1421
|
||||
#: netbox/dcim/forms/bulk_import.py:1422
|
||||
msgid "Side A name"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/forms/bulk_import.py:1422 netbox/dcim/forms/bulk_import.py:1447
|
||||
#: netbox/dcim/forms/bulk_import.py:1423 netbox/dcim/forms/bulk_import.py:1448
|
||||
msgid "Termination name"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/forms/bulk_import.py:1427
|
||||
#: netbox/dcim/forms/bulk_import.py:1428
|
||||
msgid "Side B site"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/forms/bulk_import.py:1431
|
||||
#: netbox/dcim/forms/bulk_import.py:1432
|
||||
#: netbox/wireless/forms/bulk_import.py:114
|
||||
msgid "Site of parent device B (if any)"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/forms/bulk_import.py:1434
|
||||
#: netbox/dcim/forms/bulk_import.py:1435
|
||||
msgid "Side B device"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/forms/bulk_import.py:1440
|
||||
#: netbox/dcim/forms/bulk_import.py:1441
|
||||
msgid "Side B type"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/forms/bulk_import.py:1446
|
||||
#: netbox/dcim/forms/bulk_import.py:1447
|
||||
msgid "Side B name"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/forms/bulk_import.py:1455
|
||||
#: netbox/dcim/forms/bulk_import.py:1456
|
||||
#: netbox/wireless/forms/bulk_import.py:133
|
||||
msgid "Connection status"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/forms/bulk_import.py:1461
|
||||
#: netbox/dcim/forms/bulk_import.py:1462
|
||||
msgid "Cable connection profile"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/forms/bulk_import.py:1486
|
||||
#: netbox/dcim/forms/bulk_import.py:1487
|
||||
msgid "Color name (e.g. \"Red\") or hex code (e.g. \"f44336\")"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/forms/bulk_import.py:1538
|
||||
#: netbox/dcim/forms/bulk_import.py:1539
|
||||
#, python-brace-format
|
||||
msgid "Side {side_upper}: {device} {termination_object} is already connected"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/forms/bulk_import.py:1544
|
||||
#: netbox/dcim/forms/bulk_import.py:1545
|
||||
#, python-brace-format
|
||||
msgid "{side_upper} side termination not found: {device} {name}"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/forms/bulk_import.py:1565
|
||||
#: netbox/dcim/forms/bulk_import.py:1566
|
||||
#, python-brace-format
|
||||
msgid ""
|
||||
"{color} did not match any used color name and was longer than six "
|
||||
"characters: invalid hex."
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/forms/bulk_import.py:1590 netbox/dcim/forms/model_forms.py:900
|
||||
#: netbox/dcim/forms/bulk_import.py:1591 netbox/dcim/forms/model_forms.py:900
|
||||
#: netbox/dcim/tables/devices.py:1124
|
||||
#: netbox/templates/dcim/panels/virtual_chassis_members.html:10
|
||||
#: netbox/templates/dcim/virtualchassis.html:17
|
||||
@@ -5417,49 +5417,49 @@ msgstr ""
|
||||
msgid "Master"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/forms/bulk_import.py:1594
|
||||
#: netbox/dcim/forms/bulk_import.py:1595
|
||||
msgid "Master device"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/forms/bulk_import.py:1611
|
||||
#: netbox/dcim/forms/bulk_import.py:1612
|
||||
msgid "Name of parent site"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/forms/bulk_import.py:1645
|
||||
#: netbox/dcim/forms/bulk_import.py:1646
|
||||
msgid "Upstream power panel"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/forms/bulk_import.py:1675
|
||||
#: netbox/dcim/forms/bulk_import.py:1676
|
||||
msgid "Primary or redundant"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/forms/bulk_import.py:1680
|
||||
#: netbox/dcim/forms/bulk_import.py:1681
|
||||
msgid "Supply type (AC/DC)"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/forms/bulk_import.py:1685
|
||||
#: netbox/dcim/forms/bulk_import.py:1686
|
||||
msgid "Single or three-phase"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/forms/bulk_import.py:1735 netbox/dcim/forms/model_forms.py:1875
|
||||
#: netbox/dcim/forms/bulk_import.py:1736 netbox/dcim/forms/model_forms.py:1875
|
||||
#: netbox/dcim/ui/panels.py:108
|
||||
#: netbox/templates/dcim/virtualdevicecontext.html:30
|
||||
#: netbox/virtualization/ui/panels.py:28
|
||||
msgid "Primary IPv4"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/forms/bulk_import.py:1739
|
||||
#: netbox/dcim/forms/bulk_import.py:1740
|
||||
msgid "IPv4 address with mask, e.g. 1.2.3.4/24"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/forms/bulk_import.py:1742 netbox/dcim/forms/model_forms.py:1884
|
||||
#: netbox/dcim/forms/bulk_import.py:1743 netbox/dcim/forms/model_forms.py:1884
|
||||
#: netbox/dcim/ui/panels.py:113
|
||||
#: netbox/templates/dcim/virtualdevicecontext.html:41
|
||||
#: netbox/virtualization/ui/panels.py:33
|
||||
msgid "Primary IPv6"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/forms/bulk_import.py:1746
|
||||
#: netbox/dcim/forms/bulk_import.py:1747
|
||||
msgid "IPv6 address with prefix length, e.g. 2001:db8::1/64"
|
||||
msgstr ""
|
||||
|
||||
@@ -5500,7 +5500,7 @@ msgstr ""
|
||||
msgid "A {model} named {name} already exists"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/forms/connections.py:55 netbox/dcim/forms/model_forms.py:853
|
||||
#: netbox/dcim/forms/connections.py:59 netbox/dcim/forms/model_forms.py:853
|
||||
#: netbox/dcim/tables/power.py:63
|
||||
#: netbox/templates/dcim/inc/cable_termination.html:40
|
||||
#: netbox/templates/dcim/powerfeed.html:24
|
||||
@@ -5509,7 +5509,7 @@ msgstr ""
|
||||
msgid "Power Panel"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/forms/connections.py:64 netbox/dcim/forms/model_forms.py:880
|
||||
#: netbox/dcim/forms/connections.py:68 netbox/dcim/forms/model_forms.py:880
|
||||
#: netbox/templates/dcim/powerfeed.html:21
|
||||
#: netbox/templates/dcim/powerport.html:80
|
||||
msgid "Power Feed"
|
||||
@@ -5722,7 +5722,7 @@ msgstr ""
|
||||
msgid "Please select a {scope_type}."
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/forms/mixins.py:122 netbox/ipam/forms/bulk_import.py:462
|
||||
#: netbox/dcim/forms/mixins.py:122 netbox/ipam/forms/bulk_import.py:464
|
||||
msgid "Scope type (app & model)"
|
||||
msgstr ""
|
||||
|
||||
@@ -6056,78 +6056,78 @@ msgstr ""
|
||||
msgid "A and B terminations cannot connect to the same object."
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/models/cables.py:412 netbox/ipam/models/asns.py:38
|
||||
#: netbox/dcim/models/cables.py:456 netbox/ipam/models/asns.py:38
|
||||
msgid "end"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/models/cables.py:483
|
||||
#: netbox/dcim/models/cables.py:527
|
||||
msgid "cable termination"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/models/cables.py:484
|
||||
#: netbox/dcim/models/cables.py:528
|
||||
msgid "cable terminations"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/models/cables.py:497
|
||||
#: netbox/dcim/models/cables.py:541
|
||||
#, python-brace-format
|
||||
msgid ""
|
||||
"Cannot connect a cable to {obj_parent} > {obj} because it is marked as "
|
||||
"connected."
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/models/cables.py:514
|
||||
#: netbox/dcim/models/cables.py:558
|
||||
#, python-brace-format
|
||||
msgid ""
|
||||
"Duplicate termination found for {app_label}.{model} {termination_id}: cable "
|
||||
"{cable_pk}"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/models/cables.py:524
|
||||
#: netbox/dcim/models/cables.py:568
|
||||
#, python-brace-format
|
||||
msgid "Cables cannot be terminated to {type_display} interfaces"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/models/cables.py:531
|
||||
#: netbox/dcim/models/cables.py:575
|
||||
msgid "Circuit terminations attached to a provider network may not be cabled."
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/models/cables.py:627 netbox/extras/models/configs.py:100
|
||||
#: netbox/dcim/models/cables.py:671 netbox/extras/models/configs.py:100
|
||||
msgid "is active"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/models/cables.py:631
|
||||
#: netbox/dcim/models/cables.py:675
|
||||
msgid "is complete"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/models/cables.py:635
|
||||
#: netbox/dcim/models/cables.py:679
|
||||
msgid "is split"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/models/cables.py:643
|
||||
#: netbox/dcim/models/cables.py:687
|
||||
msgid "cable path"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/models/cables.py:644
|
||||
#: netbox/dcim/models/cables.py:688
|
||||
msgid "cable paths"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/models/cables.py:731
|
||||
#: netbox/dcim/models/cables.py:775
|
||||
msgid "All originating terminations must be attached to the same link"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/models/cables.py:749
|
||||
#: netbox/dcim/models/cables.py:793
|
||||
msgid "All mid-span terminations must have the same termination type"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/models/cables.py:757
|
||||
#: netbox/dcim/models/cables.py:801
|
||||
msgid "All mid-span terminations must have the same parent object"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/models/cables.py:787
|
||||
#: netbox/dcim/models/cables.py:831
|
||||
msgid "All links must be cable or wireless"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/models/cables.py:789
|
||||
#: netbox/dcim/models/cables.py:833
|
||||
msgid "All links must match first link type"
|
||||
msgstr ""
|
||||
|
||||
@@ -6479,7 +6479,7 @@ msgstr ""
|
||||
|
||||
#: netbox/dcim/models/device_components.py:661
|
||||
#: netbox/dcim/tables/devices.py:625 netbox/ipam/forms/bulk_edit.py:451
|
||||
#: netbox/ipam/forms/bulk_import.py:526 netbox/ipam/forms/filtersets.py:608
|
||||
#: netbox/ipam/forms/bulk_import.py:528 netbox/ipam/forms/filtersets.py:608
|
||||
#: netbox/ipam/forms/model_forms.py:684 netbox/ipam/tables/vlans.py:111
|
||||
#: netbox/templates/dcim/interface.html:86 netbox/templates/ipam/vlan.html:77
|
||||
#: netbox/virtualization/ui/panels.py:63
|
||||
@@ -7393,7 +7393,7 @@ msgstr ""
|
||||
|
||||
#: netbox/dcim/models/racks.py:312 netbox/ipam/forms/bulk_import.py:207
|
||||
#: netbox/ipam/forms/bulk_import.py:271 netbox/ipam/forms/bulk_import.py:306
|
||||
#: netbox/ipam/forms/bulk_import.py:517
|
||||
#: netbox/ipam/forms/bulk_import.py:519
|
||||
#: netbox/virtualization/forms/bulk_import.py:125
|
||||
msgid "Functional role"
|
||||
msgstr ""
|
||||
@@ -7643,7 +7643,7 @@ msgid "U Height"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/tables/devices.py:196 netbox/dcim/tables/devices.py:1161
|
||||
#: netbox/ipam/forms/bulk_import.py:599 netbox/ipam/forms/model_forms.py:309
|
||||
#: netbox/ipam/forms/bulk_import.py:601 netbox/ipam/forms/model_forms.py:309
|
||||
#: netbox/ipam/forms/model_forms.py:321 netbox/ipam/tables/ip.py:307
|
||||
#: netbox/ipam/tables/ip.py:371 netbox/ipam/tables/ip.py:386
|
||||
#: netbox/ipam/tables/ip.py:409 netbox/templates/ipam/ipaddress.html:11
|
||||
@@ -8148,31 +8148,31 @@ msgstr ""
|
||||
msgid "Virtual Machines"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/views.py:3531
|
||||
#: netbox/dcim/views.py:3532
|
||||
#, python-brace-format
|
||||
msgid "Installed device {device} in bay {device_bay}."
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/views.py:3572
|
||||
#: netbox/dcim/views.py:3573
|
||||
#, python-brace-format
|
||||
msgid "Removed device {device} from bay {device_bay}."
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/views.py:3685 netbox/ipam/tables/ip.py:179
|
||||
#: netbox/dcim/views.py:3686 netbox/ipam/tables/ip.py:179
|
||||
msgid "Children"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/views.py:4158
|
||||
#: netbox/dcim/views.py:4147
|
||||
#, python-brace-format
|
||||
msgid "Added member <a href=\"{url}\">{device}</a>"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/views.py:4203
|
||||
#: netbox/dcim/views.py:4192
|
||||
#, python-brace-format
|
||||
msgid "Unable to remove master device {device} from the virtual chassis."
|
||||
msgstr ""
|
||||
|
||||
#: netbox/dcim/views.py:4214
|
||||
#: netbox/dcim/views.py:4203
|
||||
#, python-brace-format
|
||||
msgid "Removed {device} from virtual chassis {chassis}"
|
||||
msgstr ""
|
||||
@@ -10494,7 +10494,7 @@ msgstr ""
|
||||
msgid "IP address (ID)"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/ipam/filtersets.py:1259 netbox/ipam/models/ip.py:813
|
||||
#: netbox/ipam/filtersets.py:1259 netbox/ipam/models/ip.py:815
|
||||
msgid "IP address"
|
||||
msgstr ""
|
||||
|
||||
@@ -10616,13 +10616,13 @@ msgstr ""
|
||||
msgid "Treat as populated"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/ipam/forms/bulk_edit.py:307 netbox/ipam/models/ip.py:797
|
||||
#: netbox/ipam/forms/bulk_edit.py:307 netbox/ipam/models/ip.py:799
|
||||
msgid "DNS name"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/ipam/forms/bulk_edit.py:322 netbox/ipam/forms/bulk_edit.py:496
|
||||
#: netbox/ipam/forms/bulk_import.py:444 netbox/ipam/forms/bulk_import.py:563
|
||||
#: netbox/ipam/forms/bulk_import.py:591 netbox/ipam/forms/filtersets.py:432
|
||||
#: netbox/ipam/forms/bulk_import.py:446 netbox/ipam/forms/bulk_import.py:565
|
||||
#: netbox/ipam/forms/bulk_import.py:593 netbox/ipam/forms/filtersets.py:432
|
||||
#: netbox/ipam/forms/filtersets.py:626 netbox/templates/ipam/fhrpgroup.html:22
|
||||
#: netbox/templates/ipam/inc/panels/fhrp_groups.html:24
|
||||
#: netbox/templates/ipam/panels/fhrp_groups.html:10
|
||||
@@ -10667,7 +10667,7 @@ msgstr ""
|
||||
msgid "VLAN ID ranges"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/ipam/forms/bulk_edit.py:446 netbox/ipam/forms/bulk_import.py:520
|
||||
#: netbox/ipam/forms/bulk_edit.py:446 netbox/ipam/forms/bulk_import.py:522
|
||||
#: netbox/ipam/forms/filtersets.py:600 netbox/ipam/models/vlans.py:250
|
||||
#: netbox/ipam/tables/vlans.py:108
|
||||
msgid "Q-in-Q role"
|
||||
@@ -10681,7 +10681,7 @@ msgstr ""
|
||||
msgid "Site & Group"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/ipam/forms/bulk_edit.py:480 netbox/ipam/forms/bulk_import.py:550
|
||||
#: netbox/ipam/forms/bulk_edit.py:480 netbox/ipam/forms/bulk_import.py:552
|
||||
#: netbox/ipam/forms/model_forms.py:715 netbox/ipam/tables/vlans.py:273
|
||||
#: netbox/templates/ipam/vlantranslationrule.html:14
|
||||
#: netbox/vpn/forms/model_forms.py:319 netbox/vpn/forms/model_forms.py:356
|
||||
@@ -10768,44 +10768,44 @@ msgstr ""
|
||||
msgid "No interface specified; cannot set as out-of-band IP"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/ipam/forms/bulk_import.py:448
|
||||
#: netbox/ipam/forms/bulk_import.py:450
|
||||
msgid "Auth type"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/ipam/forms/bulk_import.py:498
|
||||
#: netbox/ipam/forms/bulk_import.py:500
|
||||
msgid "Assigned VLAN group"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/ipam/forms/bulk_import.py:530
|
||||
#: netbox/ipam/forms/bulk_import.py:532
|
||||
msgid "Service VLAN (for Q-in-Q/802.1ad customer VLANs)"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/ipam/forms/bulk_import.py:553 netbox/ipam/models/vlans.py:369
|
||||
#: netbox/ipam/forms/bulk_import.py:555 netbox/ipam/models/vlans.py:369
|
||||
msgid "VLAN translation policy"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/ipam/forms/bulk_import.py:565 netbox/ipam/forms/bulk_import.py:593
|
||||
#: netbox/ipam/forms/bulk_import.py:567 netbox/ipam/forms/bulk_import.py:595
|
||||
msgid "IP protocol"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/ipam/forms/bulk_import.py:577
|
||||
#: netbox/ipam/forms/bulk_import.py:579
|
||||
msgid "Parent type (app & model)"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/ipam/forms/bulk_import.py:584
|
||||
#: netbox/ipam/forms/bulk_import.py:586
|
||||
msgid "Parent object name"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/ipam/forms/bulk_import.py:588
|
||||
#: netbox/ipam/forms/bulk_import.py:590
|
||||
msgid "Parent object ID"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/ipam/forms/bulk_import.py:640
|
||||
#: netbox/ipam/forms/bulk_import.py:642
|
||||
msgid ""
|
||||
"One of parent or parent_object_id must be included with parent_object_type"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/ipam/forms/bulk_import.py:653
|
||||
#: netbox/ipam/forms/bulk_import.py:655
|
||||
#, python-brace-format
|
||||
msgid "{ip} is not assigned to this parent."
|
||||
msgstr ""
|
||||
@@ -11160,7 +11160,7 @@ msgstr ""
|
||||
msgid "All IP addresses within this prefix are considered usable"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/ipam/models/ip.py:261 netbox/ipam/models/ip.py:546
|
||||
#: netbox/ipam/models/ip.py:261 netbox/ipam/models/ip.py:548
|
||||
msgid "mark utilized"
|
||||
msgstr ""
|
||||
|
||||
@@ -11172,12 +11172,12 @@ msgstr ""
|
||||
msgid "Cannot create prefix with /0 mask."
|
||||
msgstr ""
|
||||
|
||||
#: netbox/ipam/models/ip.py:316 netbox/ipam/models/ip.py:903
|
||||
#: netbox/ipam/models/ip.py:316 netbox/ipam/models/ip.py:905
|
||||
#, python-brace-format
|
||||
msgid "VRF {vrf}"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/ipam/models/ip.py:316 netbox/ipam/models/ip.py:903
|
||||
#: netbox/ipam/models/ip.py:316 netbox/ipam/models/ip.py:905
|
||||
msgid "global table"
|
||||
msgstr ""
|
||||
|
||||
@@ -11186,136 +11186,136 @@ msgstr ""
|
||||
msgid "Duplicate prefix found in {table}: {prefix}"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/ipam/models/ip.py:499
|
||||
#: netbox/ipam/models/ip.py:501
|
||||
msgid "start address"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/ipam/models/ip.py:500 netbox/ipam/models/ip.py:504
|
||||
#: netbox/ipam/models/ip.py:737
|
||||
#: netbox/ipam/models/ip.py:502 netbox/ipam/models/ip.py:506
|
||||
#: netbox/ipam/models/ip.py:739
|
||||
msgid "IPv4 or IPv6 address (with mask)"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/ipam/models/ip.py:503
|
||||
#: netbox/ipam/models/ip.py:505
|
||||
msgid "end address"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/ipam/models/ip.py:530
|
||||
#: netbox/ipam/models/ip.py:532
|
||||
msgid "Operational status of this range"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/ipam/models/ip.py:538
|
||||
#: netbox/ipam/models/ip.py:540
|
||||
msgid "The primary function of this range"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/ipam/models/ip.py:541
|
||||
#: netbox/ipam/models/ip.py:543
|
||||
msgid "mark populated"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/ipam/models/ip.py:543
|
||||
#: netbox/ipam/models/ip.py:545
|
||||
msgid "Prevent the creation of IP addresses within this range"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/ipam/models/ip.py:548
|
||||
#: netbox/ipam/models/ip.py:550
|
||||
msgid "Report space as fully utilized"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/ipam/models/ip.py:557
|
||||
#: netbox/ipam/models/ip.py:559
|
||||
msgid "IP range"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/ipam/models/ip.py:558
|
||||
#: netbox/ipam/models/ip.py:560
|
||||
msgid "IP ranges"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/ipam/models/ip.py:571
|
||||
#: netbox/ipam/models/ip.py:573
|
||||
msgid "Starting and ending IP address versions must match"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/ipam/models/ip.py:577
|
||||
#: netbox/ipam/models/ip.py:579
|
||||
msgid "Starting and ending IP address masks must match"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/ipam/models/ip.py:584
|
||||
#: netbox/ipam/models/ip.py:586
|
||||
#, python-brace-format
|
||||
msgid ""
|
||||
"Ending address must be greater than the starting address ({start_address})"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/ipam/models/ip.py:612
|
||||
#: netbox/ipam/models/ip.py:614
|
||||
#, python-brace-format
|
||||
msgid "Defined addresses overlap with range {overlapping_range} in VRF {vrf}"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/ipam/models/ip.py:621
|
||||
#: netbox/ipam/models/ip.py:623
|
||||
#, python-brace-format
|
||||
msgid "Defined range exceeds maximum supported size ({max_size})"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/ipam/models/ip.py:736 netbox/tenancy/models/contacts.py:78
|
||||
#: netbox/ipam/models/ip.py:738 netbox/tenancy/models/contacts.py:78
|
||||
msgid "address"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/ipam/models/ip.py:759
|
||||
#: netbox/ipam/models/ip.py:761
|
||||
msgid "The operational status of this IP"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/ipam/models/ip.py:767
|
||||
#: netbox/ipam/models/ip.py:769
|
||||
msgid "The functional role of this IP"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/ipam/models/ip.py:790 netbox/templates/ipam/ipaddress.html:72
|
||||
#: netbox/ipam/models/ip.py:792 netbox/templates/ipam/ipaddress.html:72
|
||||
msgid "NAT (inside)"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/ipam/models/ip.py:791
|
||||
#: netbox/ipam/models/ip.py:793
|
||||
msgid "The IP for which this address is the \"outside\" IP"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/ipam/models/ip.py:798
|
||||
#: netbox/ipam/models/ip.py:800
|
||||
msgid "Hostname or FQDN (not case-sensitive)"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/ipam/models/ip.py:814 netbox/ipam/models/services.py:86
|
||||
#: netbox/ipam/models/ip.py:816 netbox/ipam/models/services.py:86
|
||||
msgid "IP addresses"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/ipam/models/ip.py:874
|
||||
#: netbox/ipam/models/ip.py:876
|
||||
msgid "Cannot create IP address with /0 mask."
|
||||
msgstr ""
|
||||
|
||||
#: netbox/ipam/models/ip.py:880
|
||||
#: netbox/ipam/models/ip.py:882
|
||||
#, python-brace-format
|
||||
msgid "{ip} is a network ID, which may not be assigned to an interface."
|
||||
msgstr ""
|
||||
|
||||
#: netbox/ipam/models/ip.py:891
|
||||
#: netbox/ipam/models/ip.py:893
|
||||
#, python-brace-format
|
||||
msgid "{ip} is a broadcast address, which may not be assigned to an interface."
|
||||
msgstr ""
|
||||
|
||||
#: netbox/ipam/models/ip.py:905
|
||||
#: netbox/ipam/models/ip.py:907
|
||||
#, python-brace-format
|
||||
msgid "Duplicate IP address found in {table}: {ipaddress}"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/ipam/models/ip.py:921
|
||||
#: netbox/ipam/models/ip.py:923
|
||||
#, python-brace-format
|
||||
msgid "Cannot create IP address {ip} inside range {range}."
|
||||
msgstr ""
|
||||
|
||||
#: netbox/ipam/models/ip.py:942
|
||||
#: netbox/ipam/models/ip.py:944
|
||||
msgid ""
|
||||
"Cannot reassign IP address while it is designated as the primary IP for the "
|
||||
"parent object"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/ipam/models/ip.py:949
|
||||
#: netbox/ipam/models/ip.py:951
|
||||
msgid ""
|
||||
"Cannot reassign IP address while it is designated as the OOB IP for the "
|
||||
"parent object"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/ipam/models/ip.py:955
|
||||
#: netbox/ipam/models/ip.py:957
|
||||
msgid "Only IPv6 addresses can be assigned SLAAC status"
|
||||
msgstr ""
|
||||
|
||||
|
||||
@@ -10,10 +10,6 @@ OBJECTPERMISSION_OBJECT_TYPES = (
|
||||
|
||||
CONSTRAINT_TOKEN_USER = '$user'
|
||||
|
||||
# Built-in actions that receive special handling (dedicated checkboxes, model properties)
|
||||
# and should not be registered as custom model actions.
|
||||
RESERVED_ACTIONS = ('view', 'add', 'change', 'delete')
|
||||
|
||||
# API tokens
|
||||
TOKEN_PREFIX = 'nbt_' # Used for v2 tokens only
|
||||
TOKEN_KEY_LENGTH = 12
|
||||
|
||||
@@ -14,7 +14,6 @@ from ipam.formfields import IPNetworkFormField
|
||||
from ipam.validators import prefix_validator
|
||||
from netbox.config import get_config
|
||||
from netbox.preferences import PREFERENCES
|
||||
from netbox.registry import registry
|
||||
from users.choices import TokenVersionChoices
|
||||
from users.constants import *
|
||||
from users.models import *
|
||||
@@ -26,7 +25,7 @@ from utilities.forms.fields import (
|
||||
JSONField,
|
||||
)
|
||||
from utilities.forms.rendering import FieldSet
|
||||
from utilities.forms.widgets import DateTimePicker, ObjectTypeSplitMultiSelectWidget, RegisteredActionsWidget
|
||||
from utilities.forms.widgets import DateTimePicker, SplitMultiSelectWidget
|
||||
from utilities.permissions import qs_filter_from_constraints
|
||||
from utilities.string import title
|
||||
|
||||
@@ -326,7 +325,7 @@ class ObjectPermissionForm(forms.ModelForm):
|
||||
object_types = ContentTypeMultipleChoiceField(
|
||||
label=_('Object types'),
|
||||
queryset=ObjectType.objects.all(),
|
||||
widget=ObjectTypeSplitMultiSelectWidget(
|
||||
widget=SplitMultiSelectWidget(
|
||||
choices=get_object_types_choices
|
||||
),
|
||||
help_text=_('Select the types of objects to which the permission will apply.')
|
||||
@@ -343,11 +342,6 @@ class ObjectPermissionForm(forms.ModelForm):
|
||||
can_delete = forms.BooleanField(
|
||||
required=False
|
||||
)
|
||||
registered_actions = forms.MultipleChoiceField(
|
||||
required=False,
|
||||
widget=RegisteredActionsWidget(),
|
||||
label=_('Custom actions'),
|
||||
)
|
||||
actions = SimpleArrayField(
|
||||
label=_('Additional actions'),
|
||||
base_field=forms.CharField(),
|
||||
@@ -376,11 +370,8 @@ class ObjectPermissionForm(forms.ModelForm):
|
||||
|
||||
fieldsets = (
|
||||
FieldSet('name', 'description', 'enabled'),
|
||||
FieldSet('can_view', 'can_add', 'can_change', 'can_delete', 'actions', name=_('Actions')),
|
||||
FieldSet('object_types', name=_('Objects')),
|
||||
FieldSet(
|
||||
'can_view', 'can_add', 'can_change', 'can_delete', 'registered_actions', 'actions',
|
||||
name=_('Actions')
|
||||
),
|
||||
FieldSet('groups', 'users', name=_('Assignment')),
|
||||
FieldSet('constraints', name=_('Constraints')),
|
||||
)
|
||||
@@ -394,22 +385,6 @@ class ObjectPermissionForm(forms.ModelForm):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
# Build PK to model key mapping for object_types widget
|
||||
pk_to_model_key = {
|
||||
ot.pk: f'{ot.app_label}.{ot.model}'
|
||||
for ot in ObjectType.objects.filter(OBJECTPERMISSION_OBJECT_TYPES)
|
||||
}
|
||||
self.fields['object_types'].widget.set_model_key_map(pk_to_model_key)
|
||||
|
||||
# Configure registered_actions widget and field choices
|
||||
model_actions = dict(registry['model_actions'])
|
||||
self.fields['registered_actions'].widget.model_actions = model_actions
|
||||
choices = []
|
||||
for model_key, actions in model_actions.items():
|
||||
for action in actions:
|
||||
choices.append((f'{model_key}.{action.name}', action.name))
|
||||
self.fields['registered_actions'].choices = choices
|
||||
|
||||
# Make the actions field optional since the form uses it only for non-CRUD actions
|
||||
self.fields['actions'].required = False
|
||||
|
||||
@@ -419,31 +394,11 @@ class ObjectPermissionForm(forms.ModelForm):
|
||||
self.fields['groups'].initial = self.instance.groups.values_list('id', flat=True)
|
||||
self.fields['users'].initial = self.instance.users.values_list('id', flat=True)
|
||||
|
||||
# Work with a copy to avoid mutating the instance
|
||||
remaining_actions = list(self.instance.actions)
|
||||
|
||||
# Check the appropriate CRUD checkboxes
|
||||
for action in RESERVED_ACTIONS:
|
||||
if action in remaining_actions:
|
||||
# Check the appropriate checkboxes when editing an existing ObjectPermission
|
||||
for action in ['view', 'add', 'change', 'delete']:
|
||||
if action in self.instance.actions:
|
||||
self.fields[f'can_{action}'].initial = True
|
||||
remaining_actions.remove(action)
|
||||
|
||||
# Pre-select registered actions
|
||||
selected_registered = []
|
||||
consumed_actions = set()
|
||||
for ct in self.instance.object_types.all():
|
||||
model_key = f'{ct.app_label}.{ct.model}'
|
||||
if model_key in model_actions:
|
||||
for ma in model_actions[model_key]:
|
||||
if ma.name in remaining_actions:
|
||||
selected_registered.append(f'{model_key}.{ma.name}')
|
||||
consumed_actions.add(ma.name)
|
||||
self.fields['registered_actions'].initial = selected_registered
|
||||
|
||||
# Remaining actions go to the additional actions field
|
||||
self.initial['actions'] = [
|
||||
a for a in remaining_actions if a not in consumed_actions
|
||||
]
|
||||
self.instance.actions.remove(action)
|
||||
|
||||
# Populate initial data for a new ObjectPermission
|
||||
elif self.initial:
|
||||
@@ -453,7 +408,7 @@ class ObjectPermissionForm(forms.ModelForm):
|
||||
if isinstance(self.initial['actions'], str):
|
||||
self.initial['actions'] = [self.initial['actions']]
|
||||
if cloned_actions := self.initial['actions']:
|
||||
for action in RESERVED_ACTIONS:
|
||||
for action in ['view', 'add', 'change', 'delete']:
|
||||
if action in cloned_actions:
|
||||
self.fields[f'can_{action}'].initial = True
|
||||
self.initial['actions'].remove(action)
|
||||
@@ -465,38 +420,15 @@ class ObjectPermissionForm(forms.ModelForm):
|
||||
def clean(self):
|
||||
super().clean()
|
||||
|
||||
object_types = self.cleaned_data.get('object_types', [])
|
||||
registered_actions = self.cleaned_data.get('registered_actions', [])
|
||||
object_types = self.cleaned_data.get('object_types')
|
||||
constraints = self.cleaned_data.get('constraints')
|
||||
|
||||
# Build set of selected model keys for validation
|
||||
selected_models = {f'{ct.app_label}.{ct.model}' for ct in object_types}
|
||||
|
||||
# Validate registered actions match selected object_types and collect action names
|
||||
final_actions = []
|
||||
for action_key in registered_actions:
|
||||
model_key, action_name = action_key.rsplit('.', 1)
|
||||
if model_key not in selected_models:
|
||||
raise forms.ValidationError({
|
||||
'registered_actions': _(
|
||||
'Action "{action}" is for {model} which is not selected.'
|
||||
).format(action=action_name, model=model_key)
|
||||
})
|
||||
if action_name not in final_actions:
|
||||
final_actions.append(action_name)
|
||||
|
||||
# Append any of the selected CRUD checkboxes to the actions list
|
||||
for action in RESERVED_ACTIONS:
|
||||
if self.cleaned_data.get(f'can_{action}') and action not in final_actions:
|
||||
final_actions.append(action)
|
||||
|
||||
# Add additional/manual actions
|
||||
if additional_actions := self.cleaned_data.get('actions'):
|
||||
for action in additional_actions:
|
||||
if action not in final_actions:
|
||||
final_actions.append(action)
|
||||
|
||||
self.cleaned_data['actions'] = final_actions
|
||||
if not self.cleaned_data.get('actions'):
|
||||
self.cleaned_data['actions'] = list()
|
||||
for action in ['view', 'add', 'change', 'delete']:
|
||||
if self.cleaned_data[f'can_{action}'] and action not in self.cleaned_data['actions']:
|
||||
self.cleaned_data['actions'].append(action)
|
||||
|
||||
# At least one action must be specified
|
||||
if not self.cleaned_data['actions']:
|
||||
|
||||
@@ -10,7 +10,6 @@ from utilities.query import count_related
|
||||
from utilities.views import GetRelatedModelsMixin, register_model_view
|
||||
|
||||
from . import filtersets, forms, tables
|
||||
from .constants import RESERVED_ACTIONS
|
||||
from .models import Group, ObjectPermission, Owner, OwnerGroup, Token, User
|
||||
|
||||
#
|
||||
@@ -215,11 +214,6 @@ class ObjectPermissionView(generic.ObjectView):
|
||||
queryset = ObjectPermission.objects.all()
|
||||
template_name = 'users/objectpermission.html'
|
||||
|
||||
def get_extra_context(self, request, instance):
|
||||
return {
|
||||
'reserved_actions': RESERVED_ACTIONS,
|
||||
}
|
||||
|
||||
|
||||
@register_model_view(ObjectPermission, 'add', detail=False)
|
||||
@register_model_view(ObjectPermission, 'edit')
|
||||
|
||||
@@ -6,6 +6,7 @@ __all__ = (
|
||||
'AbortScript',
|
||||
'AbortTransaction',
|
||||
'PermissionsViolation',
|
||||
'PreconditionFailed',
|
||||
'RQWorkerNotRunningException',
|
||||
)
|
||||
|
||||
@@ -40,6 +41,20 @@ class PermissionsViolation(Exception):
|
||||
message = "Operation failed due to object-level permissions violation"
|
||||
|
||||
|
||||
class PreconditionFailed(APIException):
|
||||
"""
|
||||
Raised when an If-Match precondition is not satisfied (HTTP 412).
|
||||
Optionally carries the current ETag so it can be included in the response.
|
||||
"""
|
||||
status_code = status.HTTP_412_PRECONDITION_FAILED
|
||||
default_detail = 'Precondition failed.'
|
||||
default_code = 'precondition_failed'
|
||||
|
||||
def __init__(self, detail=None, code=None, etag=None):
|
||||
super().__init__(detail=detail, code=code)
|
||||
self.etag = etag
|
||||
|
||||
|
||||
class RQWorkerNotRunningException(APIException):
|
||||
"""
|
||||
Indicates the temporary inability to enqueue a new task (e.g. custom script execution) because no RQ worker
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
from .actions import *
|
||||
from .apiselect import *
|
||||
from .datetime import *
|
||||
from .misc import *
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
from django import forms
|
||||
from django.apps import apps
|
||||
|
||||
__all__ = (
|
||||
'RegisteredActionsWidget',
|
||||
)
|
||||
|
||||
|
||||
class RegisteredActionsWidget(forms.CheckboxSelectMultiple):
|
||||
"""
|
||||
Widget rendering checkboxes for registered model actions.
|
||||
Groups actions by model with data attributes for JS show/hide.
|
||||
"""
|
||||
template_name = 'widgets/registered_actions.html'
|
||||
|
||||
def __init__(self, *args, model_actions=None, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.model_actions = model_actions or {}
|
||||
|
||||
def get_context(self, name, value, attrs):
|
||||
context = super().get_context(name, value, attrs)
|
||||
|
||||
model_actions_with_labels = {}
|
||||
for model_key, actions in self.model_actions.items():
|
||||
app_label, model_name = model_key.split('.')
|
||||
try:
|
||||
model = apps.get_model(app_label, model_name)
|
||||
app_config = apps.get_app_config(app_label)
|
||||
label = f"{app_config.verbose_name} | {model._meta.verbose_name.title()}"
|
||||
except LookupError:
|
||||
label = model_key
|
||||
model_actions_with_labels[model_key] = {
|
||||
'label': label,
|
||||
'actions': actions,
|
||||
}
|
||||
|
||||
context['widget']['model_actions'] = model_actions_with_labels
|
||||
context['widget']['value'] = value or []
|
||||
return context
|
||||
@@ -9,7 +9,6 @@ __all__ = (
|
||||
'ClearableSelect',
|
||||
'ColorSelect',
|
||||
'HTMXSelect',
|
||||
'ObjectTypeSplitMultiSelectWidget',
|
||||
'SelectWithPK',
|
||||
'SplitMultiSelectWidget',
|
||||
)
|
||||
@@ -151,16 +150,14 @@ class SplitMultiSelectWidget(forms.MultiWidget):
|
||||
be enabled only if the order of the selected choices is significant.
|
||||
"""
|
||||
template_name = 'widgets/splitmultiselect.html'
|
||||
available_widget_class = AvailableOptions
|
||||
selected_widget_class = SelectedOptions
|
||||
|
||||
def __init__(self, choices, attrs=None, ordering=False):
|
||||
widgets = [
|
||||
self.available_widget_class(
|
||||
AvailableOptions(
|
||||
attrs={'size': 8},
|
||||
choices=choices
|
||||
),
|
||||
self.selected_widget_class(
|
||||
SelectedOptions(
|
||||
attrs={'size': 8, 'class': 'select-all'},
|
||||
choices=choices
|
||||
),
|
||||
@@ -183,48 +180,3 @@ class SplitMultiSelectWidget(forms.MultiWidget):
|
||||
def value_from_datadict(self, data, files, name):
|
||||
# Return only the choices from the SelectedOptions widget
|
||||
return super().value_from_datadict(data, files, name)[1]
|
||||
|
||||
|
||||
#
|
||||
# ObjectType-specific widgets for ObjectPermissionForm
|
||||
#
|
||||
|
||||
class ObjectTypeSelectMultiple(SelectMultipleBase):
|
||||
"""
|
||||
SelectMultiple that adds data-model-key attribute to options for JS targeting.
|
||||
"""
|
||||
pk_to_model_key = None
|
||||
|
||||
def create_option(self, name, value, label, selected, index, subindex=None, attrs=None):
|
||||
option = super().create_option(name, value, label, selected, index, subindex, attrs)
|
||||
if self.pk_to_model_key:
|
||||
model_key = self.pk_to_model_key.get(value) or self.pk_to_model_key.get(str(value))
|
||||
if model_key:
|
||||
option['attrs']['data-model-key'] = model_key
|
||||
return option
|
||||
|
||||
|
||||
class ObjectTypeAvailableOptions(ObjectTypeSelectMultiple):
|
||||
include_selected = False
|
||||
|
||||
def get_context(self, name, value, attrs):
|
||||
context = super().get_context(name, value, attrs)
|
||||
context['widget']['attrs']['required'] = False
|
||||
return context
|
||||
|
||||
|
||||
class ObjectTypeSelectedOptions(ObjectTypeSelectMultiple):
|
||||
include_selected = True
|
||||
|
||||
|
||||
class ObjectTypeSplitMultiSelectWidget(SplitMultiSelectWidget):
|
||||
"""
|
||||
SplitMultiSelectWidget that adds data-model-key attributes to options.
|
||||
Used by ObjectPermissionForm to enable JS show/hide of custom actions.
|
||||
"""
|
||||
available_widget_class = ObjectTypeAvailableOptions
|
||||
selected_widget_class = ObjectTypeSelectedOptions
|
||||
|
||||
def set_model_key_map(self, pk_to_model_key):
|
||||
for widget in self.widgets:
|
||||
widget.pk_to_model_key = pk_to_model_key
|
||||
|
||||
@@ -1,64 +1,19 @@
|
||||
from dataclasses import dataclass
|
||||
|
||||
from django.apps import apps
|
||||
from django.conf import settings
|
||||
from django.db.models import Model, Q
|
||||
from django.db.models import Q
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from netbox.registry import registry
|
||||
from users.constants import CONSTRAINT_TOKEN_USER, RESERVED_ACTIONS
|
||||
from users.constants import CONSTRAINT_TOKEN_USER
|
||||
|
||||
__all__ = (
|
||||
'ModelAction',
|
||||
'get_permission_for_model',
|
||||
'permission_is_exempt',
|
||||
'qs_filter_from_constraints',
|
||||
'register_model_actions',
|
||||
'resolve_permission',
|
||||
'resolve_permission_type',
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class ModelAction:
|
||||
"""
|
||||
Represents a custom permission action for a model.
|
||||
|
||||
Attributes:
|
||||
name: The action identifier (e.g. 'sync', 'render_config')
|
||||
help_text: Optional description displayed in the ObjectPermission form
|
||||
"""
|
||||
name: str
|
||||
help_text: str = ''
|
||||
|
||||
def __hash__(self):
|
||||
return hash(self.name)
|
||||
|
||||
def __eq__(self, other):
|
||||
if isinstance(other, ModelAction):
|
||||
return self.name == other.name
|
||||
return self.name == other
|
||||
|
||||
|
||||
def register_model_actions(model: type[Model], actions: list[ModelAction | str]):
|
||||
"""
|
||||
Register custom permission actions for a model. These actions will appear as
|
||||
checkboxes in the ObjectPermission form when the model is selected.
|
||||
|
||||
Args:
|
||||
model: The model class to register actions for
|
||||
actions: A list of ModelAction instances or action name strings
|
||||
"""
|
||||
label = f'{model._meta.app_label}.{model._meta.model_name}'
|
||||
for action in actions:
|
||||
if isinstance(action, str):
|
||||
action = ModelAction(name=action)
|
||||
if action.name in RESERVED_ACTIONS:
|
||||
raise ValueError(f"'{action.name}' is a reserved action and cannot be registered.")
|
||||
if action not in registry['model_actions'][label]:
|
||||
registry['model_actions'][label].append(action)
|
||||
|
||||
|
||||
def get_permission_for_model(model, action):
|
||||
"""
|
||||
Resolve the named permission for a given model (or instance) and action (e.g. view or add).
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
{% load i18n %}
|
||||
<div class="registered-actions-container" id="id_registered_actions_container">
|
||||
{% for model_key, model_data in widget.model_actions.items %}
|
||||
<div class="model-actions" data-model="{{ model_key }}" style="display: none;">
|
||||
<h5 class="mb-2 mt-3">{{ model_data.label }}</h5>
|
||||
{% for action in model_data.actions %}
|
||||
<div class="form-check">
|
||||
<input type="checkbox"
|
||||
class="form-check-input"
|
||||
name="{{ widget.name }}"
|
||||
value="{{ model_key }}.{{ action.name }}"
|
||||
id="id_{{ widget.name }}_{{ forloop.parentloop.counter }}_{{ forloop.counter }}"
|
||||
{% if model_key|add:"."|add:action.name in widget.value %}checked{% endif %}>
|
||||
<label class="form-check-label" for="id_{{ widget.name }}_{{ forloop.parentloop.counter }}_{{ forloop.counter }}">
|
||||
{{ action.name }}
|
||||
{% if action.help_text %}
|
||||
<small class="text-muted ms-1">{{ action.help_text }}</small>
|
||||
{% endif %}
|
||||
</label>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% empty %}
|
||||
<p class="text-muted" id="no-custom-actions-message">
|
||||
{% trans "No custom actions registered." %}
|
||||
</p>
|
||||
{% endfor %}
|
||||
</div>
|
||||
@@ -114,7 +114,12 @@ class APIViewTestCases:
|
||||
|
||||
# Try GET to permitted object
|
||||
url = self._get_detail_url(instance1)
|
||||
self.assertHttpStatus(self.client.get(url, **self.header), status.HTTP_200_OK)
|
||||
response = self.client.get(url, **self.header)
|
||||
self.assertHttpStatus(response, status.HTTP_200_OK)
|
||||
|
||||
# Verify ETag header is present for objects with timestamps
|
||||
if issubclass(self.model, ChangeLoggingMixin):
|
||||
self.assertIn('ETag', response, "ETag header missing from detail response")
|
||||
|
||||
# Try GET to non-permitted object
|
||||
url = self._get_detail_url(instance2)
|
||||
@@ -367,6 +372,46 @@ class APIViewTestCases:
|
||||
self.assertEqual(objectchange.action, ObjectChangeActionChoices.ACTION_UPDATE)
|
||||
self.assertEqual(objectchange.message, data['changelog_message'])
|
||||
|
||||
def test_update_object_with_etag(self):
|
||||
"""
|
||||
PATCH an object using a valid If-Match ETag → expect 200.
|
||||
PATCH again with the now-stale ETag → expect 412.
|
||||
"""
|
||||
if not issubclass(self.model, ChangeLoggingMixin):
|
||||
self.skipTest("Model does not support ETags")
|
||||
|
||||
self.add_permissions(
|
||||
f'{self.model._meta.app_label}.view_{self.model._meta.model_name}',
|
||||
f'{self.model._meta.app_label}.change_{self.model._meta.model_name}',
|
||||
)
|
||||
instance = self._get_queryset().first()
|
||||
url = self._get_detail_url(instance)
|
||||
update_data = self.update_data or getattr(self, 'create_data')[0]
|
||||
|
||||
# Fetch current ETag
|
||||
get_response = self.client.get(url, **self.header)
|
||||
self.assertHttpStatus(get_response, status.HTTP_200_OK)
|
||||
etag = get_response.get('ETag')
|
||||
self.assertIsNotNone(etag, "No ETag returned by GET")
|
||||
|
||||
# PATCH with correct ETag → 200
|
||||
response = self.client.patch(
|
||||
url, update_data, format='json',
|
||||
**{**self.header, 'HTTP_IF_MATCH': etag}
|
||||
)
|
||||
self.assertHttpStatus(response, status.HTTP_200_OK)
|
||||
new_etag = response.get('ETag')
|
||||
self.assertIsNotNone(new_etag)
|
||||
self.assertNotEqual(etag, new_etag) # ETag must change after update
|
||||
|
||||
# PATCH with the old (stale) ETag → 412
|
||||
with disable_warnings('django.request'):
|
||||
response = self.client.patch(
|
||||
url, update_data, format='json',
|
||||
**{**self.header, 'HTTP_IF_MATCH': etag}
|
||||
)
|
||||
self.assertHttpStatus(response, status.HTTP_412_PRECONDITION_FAILED)
|
||||
|
||||
def test_bulk_update_objects(self):
|
||||
"""
|
||||
PATCH a set of objects in a single request.
|
||||
|
||||
@@ -187,6 +187,116 @@ class APIPaginationTestCase(APITestCase):
|
||||
self.assertIsNone(response.data['previous'])
|
||||
self.assertEqual(len(response.data['results']), 100)
|
||||
|
||||
def test_cursor_pagination(self):
|
||||
"""Basic cursor pagination returns results ordered by PK with correct next link."""
|
||||
first_pk = Site.objects.order_by('pk').values_list('pk', flat=True).first()
|
||||
response = self.client.get(f'{self.url}?start={first_pk}&limit=10', format='json', **self.header)
|
||||
|
||||
self.assertHttpStatus(response, status.HTTP_200_OK)
|
||||
self.assertIsNone(response.data['count'])
|
||||
self.assertIsNone(response.data['previous'])
|
||||
self.assertEqual(len(response.data['results']), 10)
|
||||
|
||||
# Results should be ordered by PK
|
||||
pks = [r['id'] for r in response.data['results']]
|
||||
self.assertEqual(pks, sorted(pks))
|
||||
|
||||
# Next link should use start parameter
|
||||
last_pk = pks[-1]
|
||||
self.assertIn(f'start={last_pk + 1}', response.data['next'])
|
||||
self.assertIn('limit=10', response.data['next'])
|
||||
|
||||
def test_cursor_pagination_last_page(self):
|
||||
"""Cursor pagination returns null next link when fewer results than limit."""
|
||||
last_pk = Site.objects.order_by('pk').values_list('pk', flat=True).last()
|
||||
response = self.client.get(f'{self.url}?start={last_pk}&limit=10', format='json', **self.header)
|
||||
|
||||
self.assertHttpStatus(response, status.HTTP_200_OK)
|
||||
self.assertEqual(len(response.data['results']), 1)
|
||||
self.assertIsNone(response.data['next'])
|
||||
self.assertIsNone(response.data['previous'])
|
||||
|
||||
def test_cursor_pagination_no_results(self):
|
||||
"""Cursor pagination beyond all PKs returns empty results."""
|
||||
max_pk = Site.objects.order_by('pk').values_list('pk', flat=True).last()
|
||||
response = self.client.get(f'{self.url}?start={max_pk + 1000}&limit=10', format='json', **self.header)
|
||||
|
||||
self.assertHttpStatus(response, status.HTTP_200_OK)
|
||||
self.assertEqual(len(response.data['results']), 0)
|
||||
self.assertIsNone(response.data['next'])
|
||||
|
||||
def test_cursor_and_offset_conflict(self):
|
||||
"""Specifying both start and offset returns a 400 error."""
|
||||
with disable_warnings('django.request'):
|
||||
response = self.client.get(f'{self.url}?start=1&offset=10', format='json', **self.header)
|
||||
self.assertHttpStatus(response, status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
def test_cursor_and_ordering_conflict(self):
|
||||
"""Specifying both start and ordering returns a 400 error."""
|
||||
with disable_warnings('django.request'):
|
||||
response = self.client.get(f'{self.url}?start=1&ordering=name', format='json', **self.header)
|
||||
self.assertHttpStatus(response, status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
def test_cursor_negative_start(self):
|
||||
"""Negative start value returns a 400 error."""
|
||||
with disable_warnings('django.request'):
|
||||
response = self.client.get(f'{self.url}?start=-1', format='json', **self.header)
|
||||
self.assertHttpStatus(response, status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
def test_cursor_with_filters(self):
|
||||
"""Cursor pagination works alongside other query filters."""
|
||||
response = self.client.get(f'{self.url}?start=0&limit=10&name=Site 1', format='json', **self.header)
|
||||
|
||||
self.assertHttpStatus(response, status.HTTP_200_OK)
|
||||
self.assertIsNone(response.data['count'])
|
||||
results = response.data['results']
|
||||
self.assertEqual(len(results), 1)
|
||||
self.assertEqual(results[0]['name'], 'Site 1')
|
||||
|
||||
def test_offset_multi_page_traversal(self):
|
||||
"""Traverse all 100 objects using offset pagination and verify complete, non-overlapping coverage."""
|
||||
collected_pks = []
|
||||
url = f'{self.url}?limit=10'
|
||||
|
||||
while url:
|
||||
response = self.client.get(url, format='json', **self.header)
|
||||
self.assertHttpStatus(response, status.HTTP_200_OK)
|
||||
self.assertEqual(response.data['count'], 100)
|
||||
collected_pks.extend(r['id'] for r in response.data['results'])
|
||||
url = response.data['next']
|
||||
|
||||
# Should have collected exactly 100 unique objects
|
||||
self.assertEqual(len(set(collected_pks)), 100)
|
||||
|
||||
def test_cursor_multi_page_traversal(self):
|
||||
"""Traverse all 100 objects using cursor pagination and verify complete, non-overlapping coverage."""
|
||||
collected_pks = []
|
||||
first_pk = Site.objects.order_by('pk').values_list('pk', flat=True).first()
|
||||
url = f'{self.url}?start={first_pk}&limit=10'
|
||||
|
||||
while url:
|
||||
response = self.client.get(url, format='json', **self.header)
|
||||
self.assertHttpStatus(response, status.HTTP_200_OK)
|
||||
self.assertIsNone(response.data['count'])
|
||||
self.assertIsNone(response.data['previous'])
|
||||
|
||||
page_pks = [r['id'] for r in response.data['results']]
|
||||
|
||||
# Each page should be ordered by PK
|
||||
self.assertEqual(page_pks, sorted(page_pks))
|
||||
|
||||
# No overlap with previously collected PKs
|
||||
self.assertFalse(set(page_pks) & set(collected_pks))
|
||||
|
||||
collected_pks.extend(page_pks)
|
||||
url = response.data['next']
|
||||
|
||||
# Should have collected exactly 100 unique objects
|
||||
self.assertEqual(len(set(collected_pks)), 100)
|
||||
|
||||
# Full result set should be in PK order
|
||||
self.assertEqual(collected_pks, sorted(collected_pks))
|
||||
|
||||
|
||||
class APIOrderingTestCase(APITestCase):
|
||||
user_permissions = ('dcim.view_site',)
|
||||
|
||||
@@ -1,126 +0,0 @@
|
||||
from django.test import TestCase
|
||||
|
||||
from core.models import ObjectType
|
||||
from dcim.models import Device, Site
|
||||
from netbox.registry import registry
|
||||
from users.forms.model_forms import ObjectPermissionForm
|
||||
from users.models import ObjectPermission
|
||||
from utilities.permissions import ModelAction, register_model_actions
|
||||
from virtualization.models import VirtualMachine
|
||||
|
||||
|
||||
class ModelActionTest(TestCase):
|
||||
|
||||
def test_hash(self):
|
||||
action1 = ModelAction(name='sync')
|
||||
action2 = ModelAction(name='sync', help_text='Different help')
|
||||
self.assertEqual(hash(action1), hash(action2))
|
||||
|
||||
def test_equality_with_model_action(self):
|
||||
action1 = ModelAction(name='sync')
|
||||
action2 = ModelAction(name='sync', help_text='Different help')
|
||||
action3 = ModelAction(name='merge')
|
||||
self.assertEqual(action1, action2)
|
||||
self.assertNotEqual(action1, action3)
|
||||
|
||||
def test_equality_with_string(self):
|
||||
action = ModelAction(name='sync')
|
||||
self.assertEqual(action, 'sync')
|
||||
self.assertNotEqual(action, 'merge')
|
||||
|
||||
def test_usable_in_set(self):
|
||||
action1 = ModelAction(name='sync')
|
||||
action2 = ModelAction(name='sync', help_text='Different')
|
||||
action3 = ModelAction(name='merge')
|
||||
actions = {action1, action2, action3}
|
||||
self.assertEqual(len(actions), 2)
|
||||
|
||||
|
||||
class RegisterModelActionsTest(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.original_actions = dict(registry['model_actions'])
|
||||
|
||||
def tearDown(self):
|
||||
registry['model_actions'].clear()
|
||||
registry['model_actions'].update(self.original_actions)
|
||||
|
||||
def test_register_model_action_objects(self):
|
||||
register_model_actions(Site, [
|
||||
ModelAction('test_action', help_text='Test help'),
|
||||
])
|
||||
actions = registry['model_actions']['dcim.site']
|
||||
self.assertEqual(len(actions), 1)
|
||||
self.assertEqual(actions[0].name, 'test_action')
|
||||
self.assertEqual(actions[0].help_text, 'Test help')
|
||||
|
||||
def test_register_string_actions(self):
|
||||
register_model_actions(Site, ['action1', 'action2'])
|
||||
actions = registry['model_actions']['dcim.site']
|
||||
self.assertEqual(len(actions), 2)
|
||||
self.assertIsInstance(actions[0], ModelAction)
|
||||
self.assertEqual(actions[0].name, 'action1')
|
||||
self.assertEqual(actions[1].name, 'action2')
|
||||
|
||||
def test_register_mixed_actions(self):
|
||||
register_model_actions(Site, [
|
||||
ModelAction('with_help', help_text='Has help'),
|
||||
'without_help',
|
||||
])
|
||||
actions = registry['model_actions']['dcim.site']
|
||||
self.assertEqual(len(actions), 2)
|
||||
self.assertEqual(actions[0].help_text, 'Has help')
|
||||
self.assertEqual(actions[1].help_text, '')
|
||||
|
||||
def test_multiple_registrations_append(self):
|
||||
register_model_actions(Site, [ModelAction('first')])
|
||||
register_model_actions(Site, [ModelAction('second')])
|
||||
actions = registry['model_actions']['dcim.site']
|
||||
self.assertEqual(len(actions), 2)
|
||||
self.assertEqual(actions[0].name, 'first')
|
||||
self.assertEqual(actions[1].name, 'second')
|
||||
|
||||
def test_duplicate_registration_ignored(self):
|
||||
register_model_actions(Site, [ModelAction('sync')])
|
||||
register_model_actions(Site, [ModelAction('sync', help_text='Different help')])
|
||||
actions = registry['model_actions']['dcim.site']
|
||||
self.assertEqual(len(actions), 1)
|
||||
|
||||
def test_reserved_action_rejected(self):
|
||||
for action_name in ('view', 'add', 'change', 'delete'):
|
||||
with self.assertRaises(ValueError):
|
||||
register_model_actions(Site, [ModelAction(action_name)])
|
||||
|
||||
|
||||
class ObjectPermissionFormTest(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.original_actions = dict(registry['model_actions'])
|
||||
|
||||
def tearDown(self):
|
||||
registry['model_actions'].clear()
|
||||
registry['model_actions'].update(self.original_actions)
|
||||
|
||||
def test_shared_action_preselection(self):
|
||||
register_model_actions(Device, [ModelAction('render_config')])
|
||||
register_model_actions(VirtualMachine, [ModelAction('render_config')])
|
||||
|
||||
device_ct = ObjectType.objects.get_for_model(Device)
|
||||
vm_ct = ObjectType.objects.get_for_model(VirtualMachine)
|
||||
|
||||
permission = ObjectPermission.objects.create(
|
||||
name='Test Permission',
|
||||
actions=['view', 'render_config'],
|
||||
)
|
||||
permission.object_types.set([device_ct, vm_ct])
|
||||
|
||||
form = ObjectPermissionForm(instance=permission)
|
||||
|
||||
initial = form.fields['registered_actions'].initial
|
||||
self.assertIn('dcim.device.render_config', initial)
|
||||
self.assertIn('virtualization.virtualmachine.render_config', initial)
|
||||
|
||||
# Should not leak into the additional actions field
|
||||
self.assertEqual(form.initial['actions'], [])
|
||||
|
||||
permission.delete()
|
||||
@@ -5,11 +5,8 @@ class VirtualizationConfig(AppConfig):
|
||||
name = 'virtualization'
|
||||
|
||||
def ready(self):
|
||||
from django.utils.translation import gettext as _
|
||||
|
||||
from netbox.models.features import register_models
|
||||
from utilities.counters import connect_counters
|
||||
from utilities.permissions import ModelAction, register_model_actions
|
||||
|
||||
from . import search, signals # noqa: F401
|
||||
from .models import VirtualMachine
|
||||
@@ -19,8 +16,3 @@ class VirtualizationConfig(AppConfig):
|
||||
|
||||
# Register counters
|
||||
connect_counters(VirtualMachine)
|
||||
|
||||
# Register custom permission actions
|
||||
register_model_actions(VirtualMachine, [
|
||||
ModelAction('render_config', help_text=_('Render VM configuration')),
|
||||
])
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
colorama==0.4.6
|
||||
Django==5.2.11
|
||||
Django==6.0.3
|
||||
django-cors-headers==4.9.0
|
||||
django-debug-toolbar==6.2.0
|
||||
django-filter==25.2
|
||||
@@ -7,7 +7,7 @@ django-graphiql-debug-toolbar==0.2.0
|
||||
django-htmx==1.27.0
|
||||
django-mptt==0.18.0
|
||||
django-pglocks==1.0.4
|
||||
django-prometheus==2.4.1
|
||||
django-prometheus==2.4.0
|
||||
django-redis==6.0.0
|
||||
django-rich==2.2.0
|
||||
django-rq==3.2.2
|
||||
|
||||
Reference in New Issue
Block a user