Explorar o código

Fixes #10997: Fix exception when editing NAT IP for VM with no cluster

jeremystretch %!s(int64=3) %!d(string=hai) anos
pai
achega
b1da374df2
Modificáronse 2 ficheiros con 3 adicións e 1 borrados
  1. 1 0
      docs/release-notes/version-3.3.md
  2. 2 1
      netbox/ipam/forms/models.py

+ 1 - 0
docs/release-notes/version-3.3.md

@@ -20,6 +20,7 @@
 * [#10938](https://github.com/netbox-community/netbox/issues/10938) - `render_field` template tag should respect `label` kwarg
 * [#10938](https://github.com/netbox-community/netbox/issues/10938) - `render_field` template tag should respect `label` kwarg
 * [#10969](https://github.com/netbox-community/netbox/issues/10969) - Update cable paths ending at associated rear port when creating new front ports
 * [#10969](https://github.com/netbox-community/netbox/issues/10969) - Update cable paths ending at associated rear port when creating new front ports
 * [#10996](https://github.com/netbox-community/netbox/issues/10996) - Hide checkboxes on child object lists when no bulk operations are available
 * [#10996](https://github.com/netbox-community/netbox/issues/10996) - Hide checkboxes on child object lists when no bulk operations are available
+* [#10997](https://github.com/netbox-community/netbox/issues/10997) - Fix exception when editing NAT IP for VM with no cluster
 
 
 ---
 ---
 
 

+ 2 - 1
netbox/ipam/forms/models.py

@@ -429,7 +429,8 @@ class IPAddressForm(TenancyForm, NetBoxModelForm):
                         initial['nat_rack'] = nat_inside_parent.device.rack.pk
                         initial['nat_rack'] = nat_inside_parent.device.rack.pk
                     initial['nat_device'] = nat_inside_parent.device.pk
                     initial['nat_device'] = nat_inside_parent.device.pk
                 elif type(nat_inside_parent) is VMInterface:
                 elif type(nat_inside_parent) is VMInterface:
-                    initial['nat_cluster'] = nat_inside_parent.virtual_machine.cluster.pk
+                    if cluster := nat_inside_parent.virtual_machine.cluster:
+                        initial['nat_cluster'] = cluster.pk
                     initial['nat_virtual_machine'] = nat_inside_parent.virtual_machine.pk
                     initial['nat_virtual_machine'] = nat_inside_parent.virtual_machine.pk
         kwargs['initial'] = initial
         kwargs['initial'] = initial