From ea5d33f35821ef1273b278737ab1d71c5ce661a1 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Fri, 5 Jan 2024 11:52:14 -0500 Subject: [PATCH] Fixes #14663: Fix terminating to a VM interface when creating a new tunnel --- netbox/vpn/forms/model_forms.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/netbox/vpn/forms/model_forms.py b/netbox/vpn/forms/model_forms.py index 3068bfac2..06e20b282 100644 --- a/netbox/vpn/forms/model_forms.py +++ b/netbox/vpn/forms/model_forms.py @@ -7,7 +7,7 @@ from ipam.models import IPAddress, RouteTarget, VLAN from netbox.forms import NetBoxModelForm from tenancy.forms import TenancyForm from utilities.forms.fields import CommentField, DynamicModelChoiceField, DynamicModelMultipleChoiceField, SlugField -from utilities.forms.utils import add_blank_choice +from utilities.forms.utils import add_blank_choice, get_field_value from utilities.forms.widgets import HTMXSelect from virtualization.models import VirtualMachine, VMInterface from vpn.choices import * @@ -157,7 +157,7 @@ class TunnelCreateForm(TunnelForm): def __init__(self, *args, initial=None, **kwargs): super().__init__(*args, initial=initial, **kwargs) - if initial and initial.get('termination1_type') == TunnelTerminationTypeChoices.TYPE_VIRUTALMACHINE: + if get_field_value(self, 'termination1_type') == TunnelTerminationTypeChoices.TYPE_VIRUTALMACHINE: self.fields['termination1_parent'].label = _('Virtual Machine') self.fields['termination1_parent'].queryset = VirtualMachine.objects.all() self.fields['termination1_termination'].queryset = VMInterface.objects.all() @@ -168,7 +168,7 @@ class TunnelCreateForm(TunnelForm): 'virtual_machine_id': '$termination1_parent', }) - if initial and initial.get('termination2_type') == TunnelTerminationTypeChoices.TYPE_VIRUTALMACHINE: + if get_field_value(self, 'termination2_type') == TunnelTerminationTypeChoices.TYPE_VIRUTALMACHINE: self.fields['termination2_parent'].label = _('Virtual Machine') self.fields['termination2_parent'].queryset = VirtualMachine.objects.all() self.fields['termination2_termination'].queryset = VMInterface.objects.all()