4444from catalystwan .typed_list import DataSequence
4545from catalystwan .utils .device_model import DeviceModel
4646from catalystwan .utils .dict import merge
47+ from catalystwan .utils .personality import Personality
4748from catalystwan .utils .pydantic_field import get_extra_field
4849from catalystwan .utils .template_type import TemplateType
4950
@@ -190,7 +191,9 @@ def get_device_specific_variables(name: str):
190191 endpoint = "/dataservice/template/device/config/attachfeature"
191192 logger .info (f"Attaching a template: { name } to the device: { device .hostname } ." )
192193 response = self .session .post (url = endpoint , json = payload ).json ()
193- task = Task (session = self .session , task_id = response ["id" ]).wait_for_completed (timeout_seconds = timeout_seconds )
194+ task = Task (session = self .session , task_id = response ["id" ]).wait_for_completed (
195+ timeout_seconds = timeout_seconds , expect_conn_drop = device .personality is Personality .VMANAGE
196+ )
194197 if task .result :
195198 return True
196199 logger .warning (f"Failed to attach template: { name } to the device: { device .hostname } ." )
@@ -235,7 +238,9 @@ def _attach_cli(self, name: str, device: Device, is_edited: bool = False, timeou
235238 endpoint = "/dataservice/template/device/config/attachcli"
236239 logger .info (f"Attaching a template: { name } to the device: { device .hostname } ." )
237240 response = self .session .post (url = endpoint , json = payload ).json ()
238- task = Task (session = self .session , task_id = response ["id" ]).wait_for_completed (timeout_seconds = timeout_seconds )
241+ task = Task (session = self .session , task_id = response ["id" ]).wait_for_completed (
242+ timeout_seconds = timeout_seconds , expect_conn_drop = device .personality is Personality .VMANAGE
243+ )
239244 if task .result :
240245 return True
241246 logger .warning (f"Failed to attach tempate: { name } to the device: { device .hostname } ." )
@@ -259,7 +264,9 @@ def deatach(self, device: Device) -> bool:
259264 endpoint = "/dataservice/template/config/device/mode/cli"
260265 logger .info (f"Changing mode to cli mode for { device .hostname } ." )
261266 response = self .session .post (url = endpoint , json = payload ).json ()
262- task = Task (session = self .session , task_id = response ["id" ]).wait_for_completed ()
267+ task = Task (session = self .session , task_id = response ["id" ]).wait_for_completed (
268+ expect_conn_drop = device .personality is Personality .VMANAGE
269+ )
263270 if task .result :
264271 return True
265272 logger .warning (f"Failed to change to cli mode for device: { device .hostname } ." )
@@ -353,16 +360,13 @@ def _delete_cli_template(self, name: str) -> bool:
353360 return True
354361
355362 @overload
356- def edit (self , template : FeatureTemplate ) -> Any :
357- ...
363+ def edit (self , template : FeatureTemplate ) -> Any : ...
358364
359365 @overload
360- def edit (self , template : CLITemplate ) -> Any :
361- ...
366+ def edit (self , template : CLITemplate ) -> Any : ...
362367
363368 @overload
364- def edit (self , template : DeviceTemplate ) -> Any :
365- ...
369+ def edit (self , template : DeviceTemplate ) -> Any : ...
366370
367371 def edit (self , template ):
368372 template_info = self .get (template ).filter (name = template .template_name ).single_or_default ()
@@ -394,16 +398,13 @@ def _edit_feature_template(self, template: FeatureTemplate, data: FeatureTemplat
394398 return response
395399
396400 @overload
397- def create (self , template : FeatureTemplate , debug = False ) -> str :
398- ...
401+ def create (self , template : FeatureTemplate , debug = False ) -> str : ...
399402
400403 @overload
401- def create (self , template : DeviceTemplate ) -> str :
402- ...
404+ def create (self , template : DeviceTemplate ) -> str : ...
403405
404406 @overload
405- def create (self , template : CLITemplate ) -> str :
406- ...
407+ def create (self , template : CLITemplate ) -> str : ...
407408
408409 def create (self , template , debug : bool = False ):
409410 if isinstance (template , list ):
0 commit comments