@@ -319,15 +319,25 @@ def put_config_dicts(self, models):
319319 infer_put_dict (self .name , models )
320320
321321 for model in models .keys ():
322- mod = self .ly .get_module (model )
322+ try :
323+ mod = self .ly .get_module (model )
324+ except libyang .util .LibyangError :
325+ raise Exception (f"YANG model '{ model } ' not found on device. "
326+ f"Model may not be installed or enabled. "
327+ f"Available models can be checked with get_schema_list()" ) from None
323328 lyd = mod .parse_data_dict (models [model ], no_state = True , validate = False )
324329 config += lyd .print_mem ("xml" , with_siblings = True , pretty = False ) + "\n "
325330 # print(f"Send new XML config: {config}")
326331 return self .put_config (config )
327332
328333 def put_config_dict (self , modname , edit ):
329334 """Convert Python dictionary to XMl and send as configuration"""
330- mod = self .ly .get_module (modname )
335+ try :
336+ mod = self .ly .get_module (modname )
337+ except libyang .util .LibyangError :
338+ raise Exception (f"YANG model '{ modname } ' not found on device. "
339+ f"Model may not be installed or enabled. "
340+ f"Available models can be checked with get_schema_list()" ) from None
331341 lyd = mod .parse_data_dict (edit , no_state = True , validate = False )
332342 config = lyd .print_mem ("xml" , with_siblings = True , pretty = False )
333343 # print(f"Send new XML config: {config}")
@@ -339,7 +349,12 @@ def call(self, call):
339349
340350 def call_dict (self , modname , call ):
341351 """Call RPC, Python dictionary version"""
342- mod = self .ly .get_module (modname )
352+ try :
353+ mod = self .ly .get_module (modname )
354+ except libyang .util .LibyangError :
355+ raise Exception (f"YANG model '{ modname } ' not found on device. "
356+ f"Model may not be installed or enabled. "
357+ f"Available models can be checked with get_schema_list()" ) from None
343358 lyd = mod .parse_data_dict (call , rpc = True )
344359 return self .call (lyd .print_mem ("xml" , with_siblings = True , pretty = False ))
345360
0 commit comments