mirror of
https://github.com/netbox-community/netbox.git
synced 2025-12-20 12:22:23 -06:00
* Standardize description & comments fields on primary models * Update REST API serializers * Update forms * Update tables * Update templates
This commit is contained in:
@@ -58,8 +58,8 @@ class ClusterSerializer(NetBoxModelSerializer):
|
||||
class Meta:
|
||||
model = Cluster
|
||||
fields = [
|
||||
'id', 'url', 'display', 'name', 'type', 'group', 'status', 'tenant', 'site', 'comments', 'tags',
|
||||
'custom_fields', 'created', 'last_updated', 'device_count', 'virtualmachine_count',
|
||||
'id', 'url', 'display', 'name', 'type', 'group', 'status', 'tenant', 'site', 'description', 'comments',
|
||||
'tags', 'custom_fields', 'created', 'last_updated', 'device_count', 'virtualmachine_count',
|
||||
]
|
||||
|
||||
|
||||
@@ -84,8 +84,8 @@ class VirtualMachineSerializer(NetBoxModelSerializer):
|
||||
model = VirtualMachine
|
||||
fields = [
|
||||
'id', 'url', 'display', 'name', 'status', 'site', 'cluster', 'device', 'role', 'tenant', 'platform',
|
||||
'primary_ip', 'primary_ip4', 'primary_ip6', 'vcpus', 'memory', 'disk', 'comments', 'local_context_data',
|
||||
'tags', 'custom_fields', 'created', 'last_updated',
|
||||
'primary_ip', 'primary_ip4', 'primary_ip6', 'vcpus', 'memory', 'disk', 'description', 'comments',
|
||||
'local_context_data', 'tags', 'custom_fields', 'created', 'last_updated',
|
||||
]
|
||||
validators = []
|
||||
|
||||
|
||||
@@ -84,6 +84,10 @@ class ClusterBulkEditForm(NetBoxModelBulkEditForm):
|
||||
'group_id': '$site_group',
|
||||
}
|
||||
)
|
||||
description = forms.CharField(
|
||||
max_length=200,
|
||||
required=False
|
||||
)
|
||||
comments = CommentField(
|
||||
widget=SmallTextarea,
|
||||
label='Comments'
|
||||
@@ -91,11 +95,11 @@ class ClusterBulkEditForm(NetBoxModelBulkEditForm):
|
||||
|
||||
model = Cluster
|
||||
fieldsets = (
|
||||
(None, ('type', 'group', 'status', 'tenant',)),
|
||||
('Site', ('region', 'site_group', 'site',)),
|
||||
(None, ('type', 'group', 'status', 'tenant', 'description')),
|
||||
('Site', ('region', 'site_group', 'site')),
|
||||
)
|
||||
nullable_fields = (
|
||||
'group', 'site', 'comments', 'tenant',
|
||||
'group', 'site', 'tenant', 'description', 'comments',
|
||||
)
|
||||
|
||||
|
||||
@@ -153,6 +157,10 @@ class VirtualMachineBulkEditForm(NetBoxModelBulkEditForm):
|
||||
required=False,
|
||||
label='Disk (GB)'
|
||||
)
|
||||
description = forms.CharField(
|
||||
max_length=200,
|
||||
required=False
|
||||
)
|
||||
comments = CommentField(
|
||||
widget=SmallTextarea,
|
||||
label='Comments'
|
||||
@@ -160,11 +168,11 @@ class VirtualMachineBulkEditForm(NetBoxModelBulkEditForm):
|
||||
|
||||
model = VirtualMachine
|
||||
fieldsets = (
|
||||
(None, ('site', 'cluster', 'device', 'status', 'role', 'tenant', 'platform')),
|
||||
(None, ('site', 'cluster', 'device', 'status', 'role', 'tenant', 'platform', 'description')),
|
||||
('Resources', ('vcpus', 'memory', 'disk'))
|
||||
)
|
||||
nullable_fields = (
|
||||
'site', 'cluster', 'device', 'role', 'tenant', 'platform', 'vcpus', 'memory', 'disk', 'comments',
|
||||
'site', 'cluster', 'device', 'role', 'tenant', 'platform', 'vcpus', 'memory', 'disk', 'description', 'comments',
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ class ClusterCSVForm(NetBoxModelCSVForm):
|
||||
|
||||
class Meta:
|
||||
model = Cluster
|
||||
fields = ('name', 'type', 'group', 'status', 'site', 'comments')
|
||||
fields = ('name', 'type', 'group', 'status', 'site', 'description', 'comments')
|
||||
|
||||
|
||||
class VirtualMachineCSVForm(NetBoxModelCSVForm):
|
||||
@@ -114,7 +114,7 @@ class VirtualMachineCSVForm(NetBoxModelCSVForm):
|
||||
model = VirtualMachine
|
||||
fields = (
|
||||
'name', 'status', 'role', 'site', 'cluster', 'device', 'tenant', 'platform', 'vcpus', 'memory', 'disk',
|
||||
'comments',
|
||||
'description', 'comments',
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ class ClusterForm(TenancyForm, NetBoxModelForm):
|
||||
comments = CommentField()
|
||||
|
||||
fieldsets = (
|
||||
('Cluster', ('name', 'type', 'group', 'status', 'tags')),
|
||||
('Cluster', ('name', 'type', 'group', 'status', 'description', 'tags')),
|
||||
('Site', ('region', 'site_group', 'site')),
|
||||
('Tenancy', ('tenant_group', 'tenant')),
|
||||
)
|
||||
@@ -98,7 +98,8 @@ class ClusterForm(TenancyForm, NetBoxModelForm):
|
||||
class Meta:
|
||||
model = Cluster
|
||||
fields = (
|
||||
'name', 'type', 'group', 'status', 'tenant', 'region', 'site_group', 'site', 'comments', 'tags',
|
||||
'name', 'type', 'group', 'status', 'tenant', 'region', 'site_group', 'site', 'description', 'comments',
|
||||
'tags',
|
||||
)
|
||||
widgets = {
|
||||
'status': StaticSelect(),
|
||||
@@ -220,9 +221,10 @@ class VirtualMachineForm(TenancyForm, NetBoxModelForm):
|
||||
required=False,
|
||||
label=''
|
||||
)
|
||||
comments = CommentField()
|
||||
|
||||
fieldsets = (
|
||||
('Virtual Machine', ('name', 'role', 'status', 'tags')),
|
||||
('Virtual Machine', ('name', 'role', 'status', 'description', 'tags')),
|
||||
('Site/Cluster', ('site', 'cluster_group', 'cluster', 'device')),
|
||||
('Tenancy', ('tenant_group', 'tenant')),
|
||||
('Management', ('platform', 'primary_ip4', 'primary_ip6')),
|
||||
@@ -234,7 +236,7 @@ class VirtualMachineForm(TenancyForm, NetBoxModelForm):
|
||||
model = VirtualMachine
|
||||
fields = [
|
||||
'name', 'status', 'site', 'cluster_group', 'cluster', 'device', 'role', 'tenant_group', 'tenant',
|
||||
'platform', 'primary_ip4', 'primary_ip6', 'vcpus', 'memory', 'disk', 'comments', 'tags',
|
||||
'platform', 'primary_ip4', 'primary_ip6', 'vcpus', 'memory', 'disk', 'description', 'comments', 'tags',
|
||||
'local_context_data',
|
||||
]
|
||||
help_texts = {
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
# Generated by Django 4.1.2 on 2022-11-03 18:24
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('virtualization', '0033_unique_constraints'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='cluster',
|
||||
name='description',
|
||||
field=models.CharField(blank=True, max_length=200),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='virtualmachine',
|
||||
name='description',
|
||||
field=models.CharField(blank=True, max_length=200),
|
||||
),
|
||||
]
|
||||
@@ -10,7 +10,7 @@ from dcim.models import BaseInterface, Device
|
||||
from extras.models import ConfigContextModel
|
||||
from extras.querysets import ConfigContextModelQuerySet
|
||||
from netbox.config import get_config
|
||||
from netbox.models import OrganizationalModel, NetBoxModel
|
||||
from netbox.models import NetBoxModel, OrganizationalModel, PrimaryModel
|
||||
from utilities.fields import NaturalOrderingField
|
||||
from utilities.ordering import naturalize_interface
|
||||
from utilities.query_functions import CollateAsChar
|
||||
@@ -64,7 +64,7 @@ class ClusterGroup(OrganizationalModel):
|
||||
# Clusters
|
||||
#
|
||||
|
||||
class Cluster(NetBoxModel):
|
||||
class Cluster(PrimaryModel):
|
||||
"""
|
||||
A cluster of VirtualMachines. Each Cluster may optionally be associated with one or more Devices.
|
||||
"""
|
||||
@@ -102,9 +102,6 @@ class Cluster(NetBoxModel):
|
||||
blank=True,
|
||||
null=True
|
||||
)
|
||||
comments = models.TextField(
|
||||
blank=True
|
||||
)
|
||||
|
||||
# Generic relations
|
||||
vlan_groups = GenericRelation(
|
||||
@@ -165,7 +162,7 @@ class Cluster(NetBoxModel):
|
||||
# Virtual machines
|
||||
#
|
||||
|
||||
class VirtualMachine(NetBoxModel, ConfigContextModel):
|
||||
class VirtualMachine(PrimaryModel, ConfigContextModel):
|
||||
"""
|
||||
A virtual machine which runs inside a Cluster.
|
||||
"""
|
||||
@@ -262,9 +259,6 @@ class VirtualMachine(NetBoxModel, ConfigContextModel):
|
||||
null=True,
|
||||
verbose_name='Disk (GB)'
|
||||
)
|
||||
comments = models.TextField(
|
||||
blank=True
|
||||
)
|
||||
|
||||
# Generic relation
|
||||
contacts = GenericRelation(
|
||||
|
||||
@@ -86,7 +86,7 @@ class ClusterTable(TenancyColumnsMixin, ContactsColumnMixin, NetBoxTable):
|
||||
class Meta(NetBoxTable.Meta):
|
||||
model = Cluster
|
||||
fields = (
|
||||
'pk', 'id', 'name', 'type', 'group', 'status', 'tenant', 'tenant_group', 'site', 'comments', 'device_count',
|
||||
'vm_count', 'contacts', 'tags', 'created', 'last_updated',
|
||||
'pk', 'id', 'name', 'type', 'group', 'status', 'tenant', 'tenant_group', 'site', 'description', 'comments',
|
||||
'device_count', 'vm_count', 'contacts', 'tags', 'created', 'last_updated',
|
||||
)
|
||||
default_columns = ('pk', 'name', 'type', 'group', 'status', 'tenant', 'site', 'device_count', 'vm_count')
|
||||
|
||||
@@ -75,8 +75,8 @@ class VirtualMachineTable(TenancyColumnsMixin, ContactsColumnMixin, NetBoxTable)
|
||||
model = VirtualMachine
|
||||
fields = (
|
||||
'pk', 'id', 'name', 'status', 'site', 'cluster', 'device', 'role', 'tenant', 'tenant_group', 'platform',
|
||||
'vcpus', 'memory', 'disk', 'primary_ip4', 'primary_ip6', 'primary_ip', 'comments', 'contacts', 'tags',
|
||||
'created', 'last_updated',
|
||||
'vcpus', 'memory', 'disk', 'primary_ip4', 'primary_ip6', 'primary_ip', 'description', 'comments',
|
||||
'contacts', 'tags', 'created', 'last_updated',
|
||||
)
|
||||
default_columns = (
|
||||
'pk', 'name', 'status', 'site', 'cluster', 'role', 'tenant', 'vcpus', 'memory', 'disk', 'primary_ip',
|
||||
|
||||
Reference in New Issue
Block a user