mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-25 01:48:38 -06:00
Add max/allocated current draw fields to PowerPort
This commit is contained in:
parent
c1127148e2
commit
8230ea1c83
@ -210,7 +210,7 @@ class PowerPortTemplateSerializer(ValidatedModelSerializer):
|
|||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = PowerPortTemplate
|
model = PowerPortTemplate
|
||||||
fields = ['id', 'device_type', 'name']
|
fields = ['id', 'device_type', 'name', 'maximum_draw', 'allocated_draw']
|
||||||
|
|
||||||
|
|
||||||
class PowerOutletTemplateSerializer(ValidatedModelSerializer):
|
class PowerOutletTemplateSerializer(ValidatedModelSerializer):
|
||||||
@ -391,7 +391,7 @@ class PowerPortSerializer(TaggitSerializer, ConnectedEndpointSerializer):
|
|||||||
class Meta:
|
class Meta:
|
||||||
model = PowerPort
|
model = PowerPort
|
||||||
fields = [
|
fields = [
|
||||||
'id', 'device', 'name', 'description', 'connected_endpoint_type', 'connected_endpoint', 'connection_status',
|
'id', 'device', 'name', 'maximum_draw', 'allocated_draw', 'description', 'connected_endpoint_type', 'connected_endpoint', 'connection_status',
|
||||||
'cable', 'tags',
|
'cable', 'tags',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -10,17 +10,16 @@ from mptt.forms import TreeNodeChoiceField
|
|||||||
from taggit.forms import TagField
|
from taggit.forms import TagField
|
||||||
from timezone_field import TimeZoneFormField
|
from timezone_field import TimeZoneFormField
|
||||||
|
|
||||||
from circuits.models import Circuit, CircuitTermination, Provider
|
from circuits.models import Circuit, Provider
|
||||||
from extras.forms import AddRemoveTagsForm, CustomFieldForm, CustomFieldBulkEditForm, CustomFieldFilterForm
|
from extras.forms import AddRemoveTagsForm, CustomFieldForm, CustomFieldBulkEditForm, CustomFieldFilterForm
|
||||||
from ipam.models import IPAddress, VLAN, VLANGroup
|
from ipam.models import IPAddress, VLAN, VLANGroup
|
||||||
from tenancy.forms import TenancyForm
|
from tenancy.forms import TenancyForm
|
||||||
from tenancy.models import Tenant
|
from tenancy.models import Tenant
|
||||||
from utilities.forms import (
|
from utilities.forms import (
|
||||||
APISelect, APISelectMultiple, add_blank_choice, ArrayFieldSelectMultiple, BootstrapMixin, BulkEditForm,
|
APISelect, APISelectMultiple, add_blank_choice, ArrayFieldSelectMultiple, BootstrapMixin, BulkEditForm,
|
||||||
BulkEditNullBooleanSelect, ChainedFieldsMixin, ChainedModelChoiceField, ColorSelect, CommentField,
|
BulkEditNullBooleanSelect, ChainedFieldsMixin, ChainedModelChoiceField, ColorSelect, CommentField, ComponentForm,
|
||||||
ComponentForm, ConfirmationForm, ContentTypeSelect, CSVChoiceField, ExpandableNameField,
|
ConfirmationForm, CSVChoiceField, ExpandableNameField, FilterChoiceField, FlexibleModelChoiceField, JSONField,
|
||||||
FilterChoiceField, FlexibleModelChoiceField, JSONField, SelectWithPK, SmallTextarea, SlugField,
|
SelectWithPK, SmallTextarea, SlugField, StaticSelect2, StaticSelect2Multiple, BOOLEAN_WITH_BLANK_CHOICES
|
||||||
StaticSelect2, StaticSelect2Multiple, BOOLEAN_WITH_BLANK_CHOICES
|
|
||||||
)
|
)
|
||||||
from virtualization.models import Cluster, ClusterGroup
|
from virtualization.models import Cluster, ClusterGroup
|
||||||
from .constants import *
|
from .constants import *
|
||||||
@ -964,7 +963,7 @@ class PowerPortTemplateForm(BootstrapMixin, forms.ModelForm):
|
|||||||
class Meta:
|
class Meta:
|
||||||
model = PowerPortTemplate
|
model = PowerPortTemplate
|
||||||
fields = [
|
fields = [
|
||||||
'device_type', 'name',
|
'device_type', 'name', 'maximum_draw', 'allocated_draw',
|
||||||
]
|
]
|
||||||
widgets = {
|
widgets = {
|
||||||
'device_type': forms.HiddenInput(),
|
'device_type': forms.HiddenInput(),
|
||||||
@ -1948,7 +1947,7 @@ class PowerPortForm(BootstrapMixin, forms.ModelForm):
|
|||||||
class Meta:
|
class Meta:
|
||||||
model = PowerPort
|
model = PowerPort
|
||||||
fields = [
|
fields = [
|
||||||
'device', 'name', 'description', 'tags',
|
'device', 'name', 'maximum_draw', 'allocated_draw', 'description', 'tags',
|
||||||
]
|
]
|
||||||
widgets = {
|
widgets = {
|
||||||
'device': forms.HiddenInput(),
|
'device': forms.HiddenInput(),
|
||||||
|
@ -84,6 +84,26 @@ class Migration(migrations.Migration):
|
|||||||
name='_connected_powerfeed',
|
name='_connected_powerfeed',
|
||||||
field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='dcim.PowerFeed'),
|
field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='dcim.PowerFeed'),
|
||||||
),
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='powerport',
|
||||||
|
name='allocated_draw',
|
||||||
|
field=models.PositiveSmallIntegerField(blank=True, null=True, validators=[django.core.validators.MinValueValidator(1)]),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='powerport',
|
||||||
|
name='maximum_draw',
|
||||||
|
field=models.PositiveSmallIntegerField(blank=True, null=True, validators=[django.core.validators.MinValueValidator(1)]),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='powerporttemplate',
|
||||||
|
name='allocated_draw',
|
||||||
|
field=models.PositiveSmallIntegerField(blank=True, null=True, validators=[django.core.validators.MinValueValidator(1)]),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='powerporttemplate',
|
||||||
|
name='maximum_draw',
|
||||||
|
field=models.PositiveSmallIntegerField(blank=True, null=True, validators=[django.core.validators.MinValueValidator(1)]),
|
||||||
|
),
|
||||||
migrations.AlterUniqueTogether(
|
migrations.AlterUniqueTogether(
|
||||||
name='powerpanel',
|
name='powerpanel',
|
||||||
unique_together={('site', 'name')},
|
unique_together={('site', 'name')},
|
||||||
|
@ -1053,6 +1053,18 @@ class PowerPortTemplate(ComponentTemplateModel):
|
|||||||
name = models.CharField(
|
name = models.CharField(
|
||||||
max_length=50
|
max_length=50
|
||||||
)
|
)
|
||||||
|
maximum_draw = models.PositiveSmallIntegerField(
|
||||||
|
blank=True,
|
||||||
|
null=True,
|
||||||
|
validators=[MinValueValidator(1)],
|
||||||
|
help_text="Maximum current draw (watts)"
|
||||||
|
)
|
||||||
|
allocated_draw = models.PositiveSmallIntegerField(
|
||||||
|
blank=True,
|
||||||
|
null=True,
|
||||||
|
validators=[MinValueValidator(1)],
|
||||||
|
help_text="Allocated current draw (watts)"
|
||||||
|
)
|
||||||
|
|
||||||
objects = DeviceComponentManager()
|
objects = DeviceComponentManager()
|
||||||
|
|
||||||
@ -1828,6 +1840,18 @@ class PowerPort(CableTermination, ComponentModel):
|
|||||||
name = models.CharField(
|
name = models.CharField(
|
||||||
max_length=50
|
max_length=50
|
||||||
)
|
)
|
||||||
|
maximum_draw = models.PositiveSmallIntegerField(
|
||||||
|
blank=True,
|
||||||
|
null=True,
|
||||||
|
validators=[MinValueValidator(1)],
|
||||||
|
help_text="Maximum current draw (watts)"
|
||||||
|
)
|
||||||
|
allocated_draw = models.PositiveSmallIntegerField(
|
||||||
|
blank=True,
|
||||||
|
null=True,
|
||||||
|
validators=[MinValueValidator(1)],
|
||||||
|
help_text="Allocated current draw (watts)"
|
||||||
|
)
|
||||||
_connected_poweroutlet = models.OneToOneField(
|
_connected_poweroutlet = models.OneToOneField(
|
||||||
to='dcim.PowerOutlet',
|
to='dcim.PowerOutlet',
|
||||||
on_delete=models.SET_NULL,
|
on_delete=models.SET_NULL,
|
||||||
@ -1850,7 +1874,7 @@ class PowerPort(CableTermination, ComponentModel):
|
|||||||
objects = DeviceComponentManager()
|
objects = DeviceComponentManager()
|
||||||
tags = TaggableManager(through=TaggedItem)
|
tags = TaggableManager(through=TaggedItem)
|
||||||
|
|
||||||
csv_headers = ['device', 'name', 'description']
|
csv_headers = ['device', 'name', 'maximum_draw', 'allocated_draw', 'description']
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = ['device', 'name']
|
ordering = ['device', 'name']
|
||||||
@ -1866,6 +1890,8 @@ class PowerPort(CableTermination, ComponentModel):
|
|||||||
return (
|
return (
|
||||||
self.device.identifier,
|
self.device.identifier,
|
||||||
self.name,
|
self.name,
|
||||||
|
self.maximum_draw,
|
||||||
|
self.allocated_draw,
|
||||||
self.description,
|
self.description,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
<td>
|
<td>
|
||||||
<i class="fa fa-fw fa-keyboard-o"></i> {{ cp }}
|
<i class="fa fa-fw fa-keyboard-o"></i> {{ cp }}
|
||||||
</td>
|
</td>
|
||||||
|
<td></td>
|
||||||
|
|
||||||
{# Description #}
|
{# Description #}
|
||||||
<td>
|
<td>
|
||||||
|
@ -5,6 +5,15 @@
|
|||||||
<i class="fa fa-fw fa-bolt"></i> {{ pp }}
|
<i class="fa fa-fw fa-bolt"></i> {{ pp }}
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
|
{# Current draw #}
|
||||||
|
<td>
|
||||||
|
{% if pp.allocated_draw %}
|
||||||
|
{{ pp.allocated_draw }}W{% if pp.maximum_draw %} ({{ pp.maximum_draw }}W max){% endif %}
|
||||||
|
{% elif pp.maximum_draw %}
|
||||||
|
{{ pp.maximum_draw }}W
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
|
||||||
{# Description #}
|
{# Description #}
|
||||||
<td>
|
<td>
|
||||||
{{ pp.description }}
|
{{ pp.description }}
|
||||||
|
Loading…
Reference in New Issue
Block a user