Repository: netbox-community/netbox

Issue:
Allow configuration of Netbox powerfeed defaults
### NetBox version

v3.0.7

### Feature type

Change to existing functionality

### Proposed functionality

At the moment the POWERFEED_VOLTAGE_DEFAULT, POWERFEED_AMPERAGE_DEFAULT and POWERFEED_MAX_UTILIZATION_DEFAULT are picked up from dcim/constants.py and set for typical US datacentre values.

It would be good to adapt that to allow them to pick up either the defaults in constants.py or defaults supplied from an environment variable or config file instead.

### Use case

This would remove a UX "papercut" for users outside of the US.

### Database changes

_No response_

### External dependencies

_No response_


Discussion:
I think this makes sense, but it probably lends itself more toward user-configurable preferences. Unfortunately we don't have any real framework in place for that yet. v3.1 will introduce support for toggling certain configuration parameters directly within the UI (see #5883); maybe that's a reasonable stopgap for now.
Marking this as blocked by #7759 (currently planned for v3.2).
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Please see our [contributing guide](https://github.com/netbox-community/netbox/blob/develop/CONTRIBUTING.md).
This should be easily doable now with v3.2 finalized.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Please see our [contributing guide](https://github.com/netbox-community/netbox/blob/develop/CONTRIBUTING.md).
I will work to support this.

My thoughts are to let the user override the default values via the Preferences page under a 'Power' title.

The values would be prepopulated with defaults that match the content but allow a user to select other standards for each option.

Any additional thoughts/concerns on this?

Resolving patch:
diff --git a/netbox/dcim/models/power.py b/netbox/dcim/models/power.py
--- a/netbox/dcim/models/power.py
+++ b/netbox/dcim/models/power.py
@@ -6,6 +6,7 @@
 
 from dcim.choices import *
 from dcim.constants import *
+from netbox.config import ConfigItem
 from netbox.models import NetBoxModel
 from utilities.validators import ExclusionValidator
 from .device_components import LinkTermination, PathEndpoint
@@ -105,16 +106,16 @@ class PowerFeed(NetBoxModel, PathEndpoint, LinkTermination):
         default=PowerFeedPhaseChoices.PHASE_SINGLE
     )
     voltage = models.SmallIntegerField(
-        default=POWERFEED_VOLTAGE_DEFAULT,
+        default=ConfigItem('POWERFEED_DEFAULT_VOLTAGE'),
         validators=[ExclusionValidator([0])]
     )
     amperage = models.PositiveSmallIntegerField(
         validators=[MinValueValidator(1)],
-        default=POWERFEED_AMPERAGE_DEFAULT
+        default=ConfigItem('POWERFEED_DEFAULT_AMPERAGE')
     )
     max_utilization = models.PositiveSmallIntegerField(
         validators=[MinValueValidator(1), MaxValueValidator(100)],
-        default=POWERFEED_MAX_UTILIZATION_DEFAULT,
+        default=ConfigItem('POWERFEED_DEFAULT_MAX_UTILIZATION'),
         help_text="Maximum permissible draw (percentage)"
     )
     available_power = models.PositiveIntegerField(
diff --git a/netbox/extras/admin.py b/netbox/extras/admin.py
--- a/netbox/extras/admin.py
+++ b/netbox/extras/admin.py
@@ -15,6 +15,9 @@ class ConfigRevisionAdmin(admin.ModelAdmin):
         ('Rack Elevations', {
             'fields': ('RACK_ELEVATION_DEFAULT_UNIT_HEIGHT', 'RACK_ELEVATION_DEFAULT_UNIT_WIDTH'),
         }),
+        ('Power', {
+            'fields': ('POWERFEED_DEFAULT_VOLTAGE', 'POWERFEED_DEFAULT_AMPERAGE', 'POWERFEED_DEFAULT_MAX_UTILIZATION')
+        }),
         ('IPAM', {
             'fields': ('ENFORCE_GLOBAL_UNIQUE', 'PREFER_IPV4'),
         }),
diff --git a/netbox/netbox/config/parameters.py b/netbox/netbox/config/parameters.py
--- a/netbox/netbox/config/parameters.py
+++ b/netbox/netbox/config/parameters.py
@@ -82,6 +82,31 @@ def __init__(self, name, label, default, description='', field=None, field_kwarg
         field=forms.IntegerField
     ),
 
+    # Power
+    ConfigParam(
+        name='POWERFEED_DEFAULT_VOLTAGE',
+        label='Powerfeed voltage',
+        default=120,
+        description="Default voltage for powerfeeds",
+        field=forms.IntegerField
+    ),
+
+    ConfigParam(
+        name='POWERFEED_DEFAULT_AMPERAGE',
+        label='Powerfeed amperage',
+        default=15,
+        description="Default amperage for powerfeeds",
+        field=forms.IntegerField
+    ),
+
+    ConfigParam(
+        name='POWERFEED_DEFAULT_MAX_UTILIZATION',
+        label='Powerfeed max utilization',
+        default=80,
+        description="Default max utilization for powerfeeds",
+        field=forms.IntegerField
+    ),
+
     # Security
     ConfigParam(
         name='ALLOWED_URL_SCHEMES',


Test patch: