netbox-plugin-sonance-amp 0.9.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- netbox_plugin_sonance_amp-0.9.3/LICENSE +21 -0
- netbox_plugin_sonance_amp-0.9.3/PKG-INFO +103 -0
- netbox_plugin_sonance_amp-0.9.3/README.md +81 -0
- netbox_plugin_sonance_amp-0.9.3/netbox_plugin_sonance_amp/__init__.py +17 -0
- netbox_plugin_sonance_amp-0.9.3/netbox_plugin_sonance_amp/admin.py +15 -0
- netbox_plugin_sonance_amp-0.9.3/netbox_plugin_sonance_amp/api/__init__.py +0 -0
- netbox_plugin_sonance_amp-0.9.3/netbox_plugin_sonance_amp/api/serializers.py +36 -0
- netbox_plugin_sonance_amp-0.9.3/netbox_plugin_sonance_amp/api/urls.py +11 -0
- netbox_plugin_sonance_amp-0.9.3/netbox_plugin_sonance_amp/api/views.py +17 -0
- netbox_plugin_sonance_amp-0.9.3/netbox_plugin_sonance_amp/choices.py +50 -0
- netbox_plugin_sonance_amp-0.9.3/netbox_plugin_sonance_amp/filtersets.py +38 -0
- netbox_plugin_sonance_amp-0.9.3/netbox_plugin_sonance_amp/forms.py +89 -0
- netbox_plugin_sonance_amp-0.9.3/netbox_plugin_sonance_amp/migrations/0001_initial.py +68 -0
- netbox_plugin_sonance_amp-0.9.3/netbox_plugin_sonance_amp/migrations/__init__.py +0 -0
- netbox_plugin_sonance_amp-0.9.3/netbox_plugin_sonance_amp/models.py +135 -0
- netbox_plugin_sonance_amp-0.9.3/netbox_plugin_sonance_amp/navigation.py +39 -0
- netbox_plugin_sonance_amp-0.9.3/netbox_plugin_sonance_amp/tables.py +39 -0
- netbox_plugin_sonance_amp-0.9.3/netbox_plugin_sonance_amp/template_content.py +15 -0
- netbox_plugin_sonance_amp-0.9.3/netbox_plugin_sonance_amp/templates/netbox_plugin_sonance_amp/amp_parameters_edit.html +88 -0
- netbox_plugin_sonance_amp-0.9.3/netbox_plugin_sonance_amp/templates/netbox_plugin_sonance_amp/ampinputsettings.html +33 -0
- netbox_plugin_sonance_amp-0.9.3/netbox_plugin_sonance_amp/templates/netbox_plugin_sonance_amp/ampoutputsettings.html +92 -0
- netbox_plugin_sonance_amp-0.9.3/netbox_plugin_sonance_amp/templates/netbox_plugin_sonance_amp/inc/interface_panel.html +104 -0
- netbox_plugin_sonance_amp-0.9.3/netbox_plugin_sonance_amp/tests/__init__.py +0 -0
- netbox_plugin_sonance_amp-0.9.3/netbox_plugin_sonance_amp/tests/test_models.py +45 -0
- netbox_plugin_sonance_amp-0.9.3/netbox_plugin_sonance_amp/urls.py +47 -0
- netbox_plugin_sonance_amp-0.9.3/netbox_plugin_sonance_amp/views.py +157 -0
- netbox_plugin_sonance_amp-0.9.3/netbox_plugin_sonance_amp.egg-info/PKG-INFO +103 -0
- netbox_plugin_sonance_amp-0.9.3/netbox_plugin_sonance_amp.egg-info/SOURCES.txt +30 -0
- netbox_plugin_sonance_amp-0.9.3/netbox_plugin_sonance_amp.egg-info/dependency_links.txt +1 -0
- netbox_plugin_sonance_amp-0.9.3/netbox_plugin_sonance_amp.egg-info/top_level.txt +1 -0
- netbox_plugin_sonance_amp-0.9.3/pyproject.toml +36 -0
- netbox_plugin_sonance_amp-0.9.3/setup.cfg +4 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Stefan Bethke
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: netbox-plugin-sonance-amp
|
|
3
|
+
Version: 0.9.3
|
|
4
|
+
Summary: NetBox plugin modeling Sonance SonAmp input and output parameters on interfaces
|
|
5
|
+
Author-email: Stefan Bethke <stb@lassitu.de>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/stblassitude/netbox-plugin-sonance-amp
|
|
8
|
+
Project-URL: Issues, https://github.com/stblassitude/netbox-plugin-sonance-amp/issues
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Framework :: Django
|
|
11
|
+
Classifier: Intended Audience :: System Administrators
|
|
12
|
+
Classifier: Natural Language :: English
|
|
13
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Requires-Python: >=3.10
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE
|
|
21
|
+
Dynamic: license-file
|
|
22
|
+
|
|
23
|
+
# Netbox Plugin for Sonance Amp Input and Output Parameters
|
|
24
|
+
|
|
25
|
+
This plugin models SonAmp input and output parameters as an extension to an "Other" Interface.
|
|
26
|
+
|
|
27
|
+
## Data Model
|
|
28
|
+
|
|
29
|
+
Configuration parameters for inputs and outputs are stored in two models: AmpInputSettings and AmpOutputSettings, which are tied to an Interface through a one-to-one foreign key relationship.
|
|
30
|
+
|
|
31
|
+
For AmpInputSettings, the following fields are managed:
|
|
32
|
+
* Level Trim dB: value of -6.0 to 6.0 in 0.5 steps
|
|
33
|
+
|
|
34
|
+
The Interface Label field is applied to the Input Name parameter.
|
|
35
|
+
|
|
36
|
+
For AmpOutputSettings, the following fields are managed:
|
|
37
|
+
* Output Setup
|
|
38
|
+
* Stereo/Mono: "stereo" or "mono"
|
|
39
|
+
* DSP Preset: preset name (freeform string)
|
|
40
|
+
* Output Group: choice of "A" to "H"
|
|
41
|
+
* Bridge Mode: "on" or "off"
|
|
42
|
+
* Output Source
|
|
43
|
+
* Output Source 1: choice of "1L", "1R", ... to "4R"
|
|
44
|
+
* Output Source 2: as above
|
|
45
|
+
* Mode Source 2: choice of "mute", "mix", or "off"
|
|
46
|
+
* Output Volume
|
|
47
|
+
* Output Volume: value between -70 and 12
|
|
48
|
+
* Turn On Volume: as above
|
|
49
|
+
* Maximum Volume: as above
|
|
50
|
+
* Gain Offset: value of -6.0 to 6.0 in 0.5 steps
|
|
51
|
+
* Mute: "on" or "off"
|
|
52
|
+
|
|
53
|
+
The Interface Label field is applied to the Output Name parameter.
|
|
54
|
+
|
|
55
|
+
## User Interface
|
|
56
|
+
|
|
57
|
+
The plugin ties the custom model editing into the Interface detail form. The editing form allows choosing "No amp parameters", "Input amp parameters", or "Output amp parameters" for each interface. Changing the type will add or remove the respective model entry, and show the correct form for the type.
|
|
58
|
+
|
|
59
|
+
## Compatibility
|
|
60
|
+
|
|
61
|
+
| NetBox Version | Plugin Version |
|
|
62
|
+
|-----------------|----------------|
|
|
63
|
+
| 4.1 - 4.99 | 0.1.0 |
|
|
64
|
+
|
|
65
|
+
## Installation
|
|
66
|
+
|
|
67
|
+
Install the plugin into your NetBox virtual environment:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
pip install netbox-plugin-sonance-amp
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Enable it in your NetBox `configuration.py` (or `plugins.py`, if using [netbox-docker](https://github.com/netbox-community/netbox-docker)):
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
PLUGINS = [
|
|
77
|
+
"netbox_plugin_sonance_amp",
|
|
78
|
+
]
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Then run migrations and restart NetBox:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
python manage.py migrate
|
|
85
|
+
python manage.py collectstatic --no-input
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Development / Testing
|
|
89
|
+
|
|
90
|
+
A self-contained Docker Compose setup is included for trying the plugin out against a real NetBox instance. It builds a NetBox image with the plugin installed from this repository's source, so no packaging or PyPI publish is required.
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
docker compose up -d --build
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Once the `netbox` service reports healthy, log in at <http://localhost:8000/> with `admin` / `admin`. A demo device, `sonamp-1`, is created automatically with an `Input 1` and an `Output 1` interface (both type "Other") so you can open either interface's detail page and add amp parameters right away.
|
|
97
|
+
|
|
98
|
+
To stop and remove the stack (including its database volume):
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
docker compose down -v
|
|
102
|
+
```
|
|
103
|
+
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# Netbox Plugin for Sonance Amp Input and Output Parameters
|
|
2
|
+
|
|
3
|
+
This plugin models SonAmp input and output parameters as an extension to an "Other" Interface.
|
|
4
|
+
|
|
5
|
+
## Data Model
|
|
6
|
+
|
|
7
|
+
Configuration parameters for inputs and outputs are stored in two models: AmpInputSettings and AmpOutputSettings, which are tied to an Interface through a one-to-one foreign key relationship.
|
|
8
|
+
|
|
9
|
+
For AmpInputSettings, the following fields are managed:
|
|
10
|
+
* Level Trim dB: value of -6.0 to 6.0 in 0.5 steps
|
|
11
|
+
|
|
12
|
+
The Interface Label field is applied to the Input Name parameter.
|
|
13
|
+
|
|
14
|
+
For AmpOutputSettings, the following fields are managed:
|
|
15
|
+
* Output Setup
|
|
16
|
+
* Stereo/Mono: "stereo" or "mono"
|
|
17
|
+
* DSP Preset: preset name (freeform string)
|
|
18
|
+
* Output Group: choice of "A" to "H"
|
|
19
|
+
* Bridge Mode: "on" or "off"
|
|
20
|
+
* Output Source
|
|
21
|
+
* Output Source 1: choice of "1L", "1R", ... to "4R"
|
|
22
|
+
* Output Source 2: as above
|
|
23
|
+
* Mode Source 2: choice of "mute", "mix", or "off"
|
|
24
|
+
* Output Volume
|
|
25
|
+
* Output Volume: value between -70 and 12
|
|
26
|
+
* Turn On Volume: as above
|
|
27
|
+
* Maximum Volume: as above
|
|
28
|
+
* Gain Offset: value of -6.0 to 6.0 in 0.5 steps
|
|
29
|
+
* Mute: "on" or "off"
|
|
30
|
+
|
|
31
|
+
The Interface Label field is applied to the Output Name parameter.
|
|
32
|
+
|
|
33
|
+
## User Interface
|
|
34
|
+
|
|
35
|
+
The plugin ties the custom model editing into the Interface detail form. The editing form allows choosing "No amp parameters", "Input amp parameters", or "Output amp parameters" for each interface. Changing the type will add or remove the respective model entry, and show the correct form for the type.
|
|
36
|
+
|
|
37
|
+
## Compatibility
|
|
38
|
+
|
|
39
|
+
| NetBox Version | Plugin Version |
|
|
40
|
+
|-----------------|----------------|
|
|
41
|
+
| 4.1 - 4.99 | 0.1.0 |
|
|
42
|
+
|
|
43
|
+
## Installation
|
|
44
|
+
|
|
45
|
+
Install the plugin into your NetBox virtual environment:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pip install netbox-plugin-sonance-amp
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Enable it in your NetBox `configuration.py` (or `plugins.py`, if using [netbox-docker](https://github.com/netbox-community/netbox-docker)):
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
PLUGINS = [
|
|
55
|
+
"netbox_plugin_sonance_amp",
|
|
56
|
+
]
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Then run migrations and restart NetBox:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
python manage.py migrate
|
|
63
|
+
python manage.py collectstatic --no-input
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Development / Testing
|
|
67
|
+
|
|
68
|
+
A self-contained Docker Compose setup is included for trying the plugin out against a real NetBox instance. It builds a NetBox image with the plugin installed from this repository's source, so no packaging or PyPI publish is required.
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
docker compose up -d --build
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Once the `netbox` service reports healthy, log in at <http://localhost:8000/> with `admin` / `admin`. A demo device, `sonamp-1`, is created automatically with an `Input 1` and an `Output 1` interface (both type "Other") so you can open either interface's detail page and add amp parameters right away.
|
|
75
|
+
|
|
76
|
+
To stop and remove the stack (including its database volume):
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
docker compose down -v
|
|
80
|
+
```
|
|
81
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from netbox.plugins import PluginConfig
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class SonanceAmpConfig(PluginConfig):
|
|
5
|
+
name = 'netbox_plugin_sonance_amp'
|
|
6
|
+
verbose_name = 'Sonance Amp'
|
|
7
|
+
description = 'Model Sonance SonAmp input and output parameters on NetBox interfaces'
|
|
8
|
+
version = '0.1.0'
|
|
9
|
+
author = 'Stefan Bethke'
|
|
10
|
+
author_email = 'stb@lassitu.de'
|
|
11
|
+
base_url = 'sonance-amp'
|
|
12
|
+
min_version = '4.1.0'
|
|
13
|
+
max_version = '4.99.99'
|
|
14
|
+
default_settings = {}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
config = SonanceAmpConfig
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from django.contrib import admin
|
|
2
|
+
|
|
3
|
+
from .models import AmpInputSettings, AmpOutputSettings
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@admin.register(AmpInputSettings)
|
|
7
|
+
class AmpInputSettingsAdmin(admin.ModelAdmin):
|
|
8
|
+
list_display = ('interface', 'level_trim_db')
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@admin.register(AmpOutputSettings)
|
|
12
|
+
class AmpOutputSettingsAdmin(admin.ModelAdmin):
|
|
13
|
+
list_display = (
|
|
14
|
+
'interface', 'stereo_mono', 'dsp_preset', 'output_group', 'bridge_mode', 'output_volume', 'mute',
|
|
15
|
+
)
|
|
File without changes
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
from dcim.api.serializers import InterfaceSerializer
|
|
2
|
+
from netbox.api.fields import ChoiceField
|
|
3
|
+
from netbox.api.serializers import NetBoxModelSerializer
|
|
4
|
+
|
|
5
|
+
from ..choices import ModeSource2Choices, OutputGroupChoices, OutputSourceChoices, StereoModeChoices
|
|
6
|
+
from ..models import AmpInputSettings, AmpOutputSettings
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class AmpInputSettingsSerializer(NetBoxModelSerializer):
|
|
10
|
+
interface = InterfaceSerializer(nested=True)
|
|
11
|
+
|
|
12
|
+
class Meta:
|
|
13
|
+
model = AmpInputSettings
|
|
14
|
+
fields = (
|
|
15
|
+
'id', 'url', 'display', 'interface', 'level_trim_db', 'tags', 'custom_fields', 'created',
|
|
16
|
+
'last_updated',
|
|
17
|
+
)
|
|
18
|
+
brief_fields = ('id', 'url', 'display', 'interface', 'level_trim_db')
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class AmpOutputSettingsSerializer(NetBoxModelSerializer):
|
|
22
|
+
interface = InterfaceSerializer(nested=True)
|
|
23
|
+
stereo_mono = ChoiceField(choices=StereoModeChoices)
|
|
24
|
+
output_group = ChoiceField(choices=OutputGroupChoices, required=False)
|
|
25
|
+
output_source_1 = ChoiceField(choices=OutputSourceChoices, required=False)
|
|
26
|
+
output_source_2 = ChoiceField(choices=OutputSourceChoices, required=False)
|
|
27
|
+
mode_source_2 = ChoiceField(choices=ModeSource2Choices, required=False)
|
|
28
|
+
|
|
29
|
+
class Meta:
|
|
30
|
+
model = AmpOutputSettings
|
|
31
|
+
fields = (
|
|
32
|
+
'id', 'url', 'display', 'interface', 'stereo_mono', 'dsp_preset', 'output_group', 'bridge_mode',
|
|
33
|
+
'output_source_1', 'output_source_2', 'mode_source_2', 'output_volume', 'turn_on_volume',
|
|
34
|
+
'maximum_volume', 'gain_offset', 'mute', 'tags', 'custom_fields', 'created', 'last_updated',
|
|
35
|
+
)
|
|
36
|
+
brief_fields = ('id', 'url', 'display', 'interface', 'stereo_mono', 'dsp_preset')
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
from netbox.api.routers import NetBoxRouter
|
|
2
|
+
|
|
3
|
+
from . import views
|
|
4
|
+
|
|
5
|
+
app_name = 'netbox_plugin_sonance_amp'
|
|
6
|
+
|
|
7
|
+
router = NetBoxRouter()
|
|
8
|
+
router.register('input-settings', views.AmpInputSettingsViewSet)
|
|
9
|
+
router.register('output-settings', views.AmpOutputSettingsViewSet)
|
|
10
|
+
|
|
11
|
+
urlpatterns = router.urls
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from netbox.api.viewsets import NetBoxModelViewSet
|
|
2
|
+
|
|
3
|
+
from ..filtersets import AmpInputSettingsFilterSet, AmpOutputSettingsFilterSet
|
|
4
|
+
from ..models import AmpInputSettings, AmpOutputSettings
|
|
5
|
+
from .serializers import AmpInputSettingsSerializer, AmpOutputSettingsSerializer
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class AmpInputSettingsViewSet(NetBoxModelViewSet):
|
|
9
|
+
queryset = AmpInputSettings.objects.prefetch_related('interface', 'tags')
|
|
10
|
+
serializer_class = AmpInputSettingsSerializer
|
|
11
|
+
filterset_class = AmpInputSettingsFilterSet
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class AmpOutputSettingsViewSet(NetBoxModelViewSet):
|
|
15
|
+
queryset = AmpOutputSettings.objects.prefetch_related('interface', 'tags')
|
|
16
|
+
serializer_class = AmpOutputSettingsSerializer
|
|
17
|
+
filterset_class = AmpOutputSettingsFilterSet
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
from utilities.choices import ChoiceSet
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class AmpParameterTypeChoices(ChoiceSet):
|
|
5
|
+
"""
|
|
6
|
+
Which amp parameter set, if any, is attached to a given interface.
|
|
7
|
+
"""
|
|
8
|
+
NONE = 'none'
|
|
9
|
+
INPUT = 'input'
|
|
10
|
+
OUTPUT = 'output'
|
|
11
|
+
|
|
12
|
+
CHOICES = [
|
|
13
|
+
(NONE, 'No amp parameters', 'gray'),
|
|
14
|
+
(INPUT, 'Input amp parameters', 'blue'),
|
|
15
|
+
(OUTPUT, 'Output amp parameters', 'green'),
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class StereoModeChoices(ChoiceSet):
|
|
20
|
+
STEREO = 'stereo'
|
|
21
|
+
MONO = 'mono'
|
|
22
|
+
|
|
23
|
+
CHOICES = [
|
|
24
|
+
(STEREO, 'Stereo', 'blue'),
|
|
25
|
+
(MONO, 'Mono', 'purple'),
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class OutputGroupChoices(ChoiceSet):
|
|
30
|
+
CHOICES = [(letter, letter) for letter in 'ABCDEFGH']
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class OutputSourceChoices(ChoiceSet):
|
|
34
|
+
CHOICES = [
|
|
35
|
+
(f'{number}{channel}', f'{number}{channel}')
|
|
36
|
+
for number in range(1, 5)
|
|
37
|
+
for channel in ('L', 'R')
|
|
38
|
+
]
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class ModeSource2Choices(ChoiceSet):
|
|
42
|
+
MUTE = 'mute'
|
|
43
|
+
MIX = 'mix'
|
|
44
|
+
OFF = 'off'
|
|
45
|
+
|
|
46
|
+
CHOICES = [
|
|
47
|
+
(MUTE, 'Mute', 'red'),
|
|
48
|
+
(MIX, 'Mix', 'blue'),
|
|
49
|
+
(OFF, 'Off', 'gray'),
|
|
50
|
+
]
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
from django.db.models import Q
|
|
2
|
+
|
|
3
|
+
from netbox.filtersets import NetBoxModelFilterSet
|
|
4
|
+
|
|
5
|
+
from .models import AmpInputSettings, AmpOutputSettings
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class AmpInputSettingsFilterSet(NetBoxModelFilterSet):
|
|
9
|
+
|
|
10
|
+
class Meta:
|
|
11
|
+
model = AmpInputSettings
|
|
12
|
+
fields = ('id', 'interface', 'level_trim_db')
|
|
13
|
+
|
|
14
|
+
def search(self, queryset, name, value):
|
|
15
|
+
if not value.strip():
|
|
16
|
+
return queryset
|
|
17
|
+
return queryset.filter(
|
|
18
|
+
Q(interface__name__icontains=value) |
|
|
19
|
+
Q(interface__device__name__icontains=value)
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class AmpOutputSettingsFilterSet(NetBoxModelFilterSet):
|
|
24
|
+
|
|
25
|
+
class Meta:
|
|
26
|
+
model = AmpOutputSettings
|
|
27
|
+
fields = (
|
|
28
|
+
'id', 'interface', 'stereo_mono', 'dsp_preset', 'output_group', 'bridge_mode', 'mode_source_2', 'mute',
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
def search(self, queryset, name, value):
|
|
32
|
+
if not value.strip():
|
|
33
|
+
return queryset
|
|
34
|
+
return queryset.filter(
|
|
35
|
+
Q(interface__name__icontains=value) |
|
|
36
|
+
Q(interface__device__name__icontains=value) |
|
|
37
|
+
Q(output_group__icontains=value)
|
|
38
|
+
)
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
from django import forms
|
|
2
|
+
|
|
3
|
+
from dcim.models import Interface
|
|
4
|
+
from netbox.forms import NetBoxModelForm
|
|
5
|
+
from utilities.forms.fields import DynamicModelChoiceField
|
|
6
|
+
from utilities.forms.rendering import FieldSet
|
|
7
|
+
|
|
8
|
+
from .choices import (
|
|
9
|
+
AmpParameterTypeChoices, ModeSource2Choices, OutputGroupChoices, OutputSourceChoices, StereoModeChoices,
|
|
10
|
+
)
|
|
11
|
+
from .models import AmpInputSettings, AmpOutputSettings
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class AmpInputSettingsForm(NetBoxModelForm):
|
|
15
|
+
interface = DynamicModelChoiceField(
|
|
16
|
+
queryset=Interface.objects.all(),
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
fieldsets = (
|
|
20
|
+
FieldSet('interface', 'level_trim_db', name='Input Settings'),
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
class Meta:
|
|
24
|
+
model = AmpInputSettings
|
|
25
|
+
fields = ('interface', 'level_trim_db', 'tags')
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class AmpOutputSettingsForm(NetBoxModelForm):
|
|
29
|
+
interface = DynamicModelChoiceField(
|
|
30
|
+
queryset=Interface.objects.all(),
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
fieldsets = (
|
|
34
|
+
FieldSet('interface', name='Interface'),
|
|
35
|
+
FieldSet('stereo_mono', 'dsp_preset', 'output_group', 'bridge_mode', name='Output Setup'),
|
|
36
|
+
FieldSet('output_source_1', 'output_source_2', 'mode_source_2', name='Output Source'),
|
|
37
|
+
FieldSet('output_volume', 'turn_on_volume', 'maximum_volume', 'gain_offset', 'mute', name='Output Volume'),
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
class Meta:
|
|
41
|
+
model = AmpOutputSettings
|
|
42
|
+
fields = (
|
|
43
|
+
'interface', 'stereo_mono', 'dsp_preset', 'output_group', 'bridge_mode',
|
|
44
|
+
'output_source_1', 'output_source_2', 'mode_source_2',
|
|
45
|
+
'output_volume', 'turn_on_volume', 'maximum_volume', 'gain_offset', 'mute', 'tags',
|
|
46
|
+
)
|
|
47
|
+
widgets = {
|
|
48
|
+
'gain_offset': forms.NumberInput(attrs={'step': '0.5'}),
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class AmpParameterForm(forms.Form):
|
|
53
|
+
"""
|
|
54
|
+
Combined form used from an Interface's detail page to choose whether it carries no amp
|
|
55
|
+
parameters, input amp parameters, or output amp parameters, and to edit whichever
|
|
56
|
+
parameter set applies.
|
|
57
|
+
"""
|
|
58
|
+
parameter_type = forms.ChoiceField(
|
|
59
|
+
label='Amp parameters',
|
|
60
|
+
choices=AmpParameterTypeChoices,
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
# AmpInputSettings fields
|
|
64
|
+
level_trim_db = forms.DecimalField(
|
|
65
|
+
label='Level trim (dB)', max_digits=4, decimal_places=1, min_value=-18, max_value=18, required=False,
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
# AmpOutputSettings fields
|
|
69
|
+
stereo_mono = forms.ChoiceField(choices=StereoModeChoices, required=False)
|
|
70
|
+
dsp_preset = forms.CharField(max_length=100, required=False)
|
|
71
|
+
output_group = forms.ChoiceField(choices=OutputGroupChoices, required=False)
|
|
72
|
+
bridge_mode = forms.BooleanField(required=False)
|
|
73
|
+
output_source_1 = forms.ChoiceField(choices=OutputSourceChoices, required=False)
|
|
74
|
+
output_source_2 = forms.ChoiceField(choices=OutputSourceChoices, required=False)
|
|
75
|
+
mode_source_2 = forms.ChoiceField(choices=ModeSource2Choices, required=False)
|
|
76
|
+
output_volume = forms.DecimalField(
|
|
77
|
+
max_digits=4, decimal_places=1, min_value=-70, max_value=12, required=False,
|
|
78
|
+
)
|
|
79
|
+
turn_on_volume = forms.DecimalField(
|
|
80
|
+
max_digits=4, decimal_places=1, min_value=-70, max_value=12, required=False,
|
|
81
|
+
)
|
|
82
|
+
maximum_volume = forms.DecimalField(
|
|
83
|
+
max_digits=4, decimal_places=1, min_value=-70, max_value=12, required=False,
|
|
84
|
+
)
|
|
85
|
+
gain_offset = forms.DecimalField(
|
|
86
|
+
max_digits=3, decimal_places=1, min_value=-6, max_value=6, required=False,
|
|
87
|
+
widget=forms.NumberInput(attrs={'step': '0.5'}),
|
|
88
|
+
)
|
|
89
|
+
mute = forms.BooleanField(required=False)
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Generated by Django 6.1 on 2026-09-07 09:00
|
|
2
|
+
|
|
3
|
+
import django.core.validators
|
|
4
|
+
import django.db.models.deletion
|
|
5
|
+
import netbox.models.deletion
|
|
6
|
+
import taggit.managers
|
|
7
|
+
import utilities.json
|
|
8
|
+
from django.db import migrations, models
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class Migration(migrations.Migration):
|
|
12
|
+
|
|
13
|
+
initial = True
|
|
14
|
+
|
|
15
|
+
dependencies = [
|
|
16
|
+
('dcim', '0250_cooling_infrastructure'),
|
|
17
|
+
('extras', '0144_customfield_status'),
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
operations = [
|
|
21
|
+
migrations.CreateModel(
|
|
22
|
+
name='AmpInputSettings',
|
|
23
|
+
fields=[
|
|
24
|
+
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False)),
|
|
25
|
+
('created', models.DateTimeField(auto_now_add=True, null=True)),
|
|
26
|
+
('last_updated', models.DateTimeField(auto_now=True, null=True)),
|
|
27
|
+
('custom_field_data', models.JSONField(blank=True, default=dict, encoder=utilities.json.CustomFieldJSONEncoder)),
|
|
28
|
+
('level_trim_db', models.DecimalField(decimal_places=1, default=0, max_digits=4, validators=[django.core.validators.MinValueValidator(-18), django.core.validators.MaxValueValidator(18)])),
|
|
29
|
+
('interface', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='sonance_amp_input_settings', to='dcim.interface')),
|
|
30
|
+
('tags', taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag')),
|
|
31
|
+
],
|
|
32
|
+
options={
|
|
33
|
+
'verbose_name': 'amp input settings',
|
|
34
|
+
'verbose_name_plural': 'amp input settings',
|
|
35
|
+
'ordering': ('interface',),
|
|
36
|
+
},
|
|
37
|
+
bases=(netbox.models.deletion.DeleteMixin, models.Model),
|
|
38
|
+
),
|
|
39
|
+
migrations.CreateModel(
|
|
40
|
+
name='AmpOutputSettings',
|
|
41
|
+
fields=[
|
|
42
|
+
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False)),
|
|
43
|
+
('created', models.DateTimeField(auto_now_add=True, null=True)),
|
|
44
|
+
('last_updated', models.DateTimeField(auto_now=True, null=True)),
|
|
45
|
+
('custom_field_data', models.JSONField(blank=True, default=dict, encoder=utilities.json.CustomFieldJSONEncoder)),
|
|
46
|
+
('stereo_mono', models.CharField(default='stereo', max_length=10)),
|
|
47
|
+
('dsp_preset', models.CharField(blank=True, max_length=100)),
|
|
48
|
+
('output_group', models.CharField(blank=True, max_length=1)),
|
|
49
|
+
('bridge_mode', models.BooleanField(default=False)),
|
|
50
|
+
('output_source_1', models.CharField(blank=True, max_length=2)),
|
|
51
|
+
('output_source_2', models.CharField(blank=True, max_length=2)),
|
|
52
|
+
('mode_source_2', models.CharField(blank=True, default='off', max_length=10)),
|
|
53
|
+
('output_volume', models.DecimalField(decimal_places=1, default=0, max_digits=4, validators=[django.core.validators.MinValueValidator(-70), django.core.validators.MaxValueValidator(12)])),
|
|
54
|
+
('turn_on_volume', models.DecimalField(decimal_places=1, default=-70, max_digits=4, validators=[django.core.validators.MinValueValidator(-70), django.core.validators.MaxValueValidator(12)])),
|
|
55
|
+
('maximum_volume', models.DecimalField(decimal_places=1, default=12, max_digits=4, validators=[django.core.validators.MinValueValidator(-70), django.core.validators.MaxValueValidator(12)])),
|
|
56
|
+
('gain_offset', models.DecimalField(decimal_places=1, default=0, max_digits=3, validators=[django.core.validators.MinValueValidator(-6), django.core.validators.MaxValueValidator(6)])),
|
|
57
|
+
('mute', models.BooleanField(default=False)),
|
|
58
|
+
('interface', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='sonance_amp_output_settings', to='dcim.interface')),
|
|
59
|
+
('tags', taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag')),
|
|
60
|
+
],
|
|
61
|
+
options={
|
|
62
|
+
'verbose_name': 'amp output settings',
|
|
63
|
+
'verbose_name_plural': 'amp output settings',
|
|
64
|
+
'ordering': ('interface',),
|
|
65
|
+
},
|
|
66
|
+
bases=(netbox.models.deletion.DeleteMixin, models.Model),
|
|
67
|
+
),
|
|
68
|
+
]
|
|
File without changes
|