Explorar o código

Fixes #3125: Fix exception when viewing PDUs

Jeremy Stretch %!s(int64=6) %!d(string=hai) anos
pai
achega
088903218d
Modificáronse 4 ficheiros con 7 adicións e 6 borrados
  1. 1 0
      CHANGELOG.md
  2. 4 4
      netbox/dcim/models.py
  3. 1 1
      netbox/dcim/views.py
  4. 1 1
      netbox/templates/dcim/device.html

+ 1 - 0
CHANGELOG.md

@@ -3,6 +3,7 @@ v2.6.0 (FUTURE)
 ## Bug Fixes (From Beta)
 
 * [#3123](https://github.com/digitalocean/netbox/issues/3123) - Exempt `/metrics` view from authentication
+* [#3125](https://github.com/digitalocean/netbox/issues/3125) - Fix exception when viewing PDUs
 
 
 ---

+ 4 - 4
netbox/dcim/models.py

@@ -1956,8 +1956,8 @@ class PowerPort(CableTermination, ComponentModel):
 
         outlet_ids = PowerOutlet.objects.filter(power_port=self).values_list('pk', flat=True)
         utilization = PowerPort.objects.filter(_connected_poweroutlet_id__in=outlet_ids).aggregate(
-            maximum_draw=Sum('maximum_draw'),
-            allocated_draw=Sum('allocated_draw'),
+            maximum_draw_total=Sum('maximum_draw'),
+            allocated_draw_total=Sum('allocated_draw'),
         )
         utilization['outlets'] = len(outlet_ids)
         utilization['available_power'] = powerfeed_available
@@ -1968,8 +1968,8 @@ class PowerPort(CableTermination, ComponentModel):
             for leg, leg_name in POWERFEED_LEG_CHOICES:
                 outlet_ids = PowerOutlet.objects.filter(power_port=self, feed_leg=leg).values_list('pk', flat=True)
                 utilization = PowerPort.objects.filter(_connected_poweroutlet_id__in=outlet_ids).aggregate(
-                    maximum_draw=Sum('maximum_draw'),
-                    allocated_draw=Sum('allocated_draw'),
+                    maximum_draw_total=Sum('maximum_draw'),
+                    allocated_draw_total=Sum('allocated_draw'),
                 )
                 utilization['name'] = 'Leg {}'.format(leg_name)
                 utilization['outlets'] = len(outlet_ids)

+ 1 - 1
netbox/dcim/views.py

@@ -934,7 +934,7 @@ class DeviceView(PermissionRequiredMixin, View):
         power_ports = device.powerports.select_related('_connected_poweroutlet__device', 'cable')
 
         # Power outlets
-        poweroutlets = device.poweroutlets.select_related('connected_endpoint__device', 'cable')
+        poweroutlets = device.poweroutlets.select_related('connected_endpoint__device', 'cable', 'power_port')
 
         # Interfaces
         interfaces = device.vc_interfaces.select_related(

+ 1 - 1
netbox/templates/dcim/device.html

@@ -361,7 +361,7 @@
                                         <td>{{ pp }}</td>
                                     {% endif %}
                                     <td>{{ leg.outlets|placeholder }}</td>
-                                    <td>{{ leg.allocated_draw }} / {{ leg.maximum_draw }}</td>
+                                    <td>{{ leg.allocated_draw_total }} / {{ leg.maximum_draw_total }}</td>
                                     <td>{{ leg.available_power }}</td>
                                 </tr>
                             {% endfor %}