@@ -69,6 +69,7 @@ def __init__(self, session: ManagerSession):
6969 self ._interfaces_with_attached_dhcp_server : Dict [str , LanVpnDhcpServerParcel ] = {}
7070 # Trackers
7171 self .init_tracker ()
72+ self ._dhcp_server_uuids : Dict [str , UUID ] = {}
7273
7374 def add_profile_name_and_description (self , feature_profile : FeatureProfileCreationPayload ) -> None :
7475 """
@@ -216,7 +217,7 @@ def build(self) -> FeatureProfileBuildReport:
216217 continue
217218
218219 if dhcp_server :
219- dhcp_server_uuid = self ._create_parcel (profile_uuid , dhcp_server )
220+ dhcp_server_uuid = self ._get_or_create_dhcp_server_uuid (profile_uuid , dhcp_server )
220221 if dhcp_server_uuid is not None :
221222 with handle_association_request (self .build_report , sub_parcel ):
222223 self ._endpoints .associate_dhcp_server_with_vpn_interface (
@@ -246,3 +247,11 @@ def build(self) -> FeatureProfileBuildReport:
246247 @handle_create_parcel
247248 def _create_parcel (self , profile_uuid : UUID , parcel : AnyServiceParcel , vpn_uuid : Optional [None ] = None ) -> UUID :
248249 return self ._api .create_parcel (profile_uuid , parcel , vpn_uuid ).id
250+
251+ def _get_or_create_dhcp_server_uuid (self , profile_uuid : UUID , dhcp_server : LanVpnDhcpServerParcel ) -> UUID :
252+ existing_uuid = self ._dhcp_server_uuids .get (dhcp_server .parcel_name )
253+ if existing_uuid :
254+ return existing_uuid
255+ dhcp_server_uuid = self ._create_parcel (profile_uuid , dhcp_server )
256+ self ._dhcp_server_uuids [dhcp_server .parcel_name ] = dhcp_server_uuid
257+ return dhcp_server_uuid
0 commit comments