33
33
_in_target ,
34
34
_is_w_same ,
35
35
)
36
+ from ansible_collections .vyos .vyos .plugins .module_utils .network .vyos .utils .version import (
37
+ LooseVersion ,
38
+ )
39
+ from ansible_collections .vyos .vyos .plugins .module_utils .network .vyos .vyos import get_os_version
36
40
37
41
38
42
class Ospfv3 (ConfigBase ):
@@ -264,10 +268,12 @@ def _render_list_dict_param(self, attr, want, have, cmd=None, opr=True):
264
268
name = {
265
269
"redistribute" : "route_type" ,
266
270
"range" : "address" ,
271
+ "interface" : "name" ,
267
272
}
268
273
leaf_dict = {
269
274
"redistribute" : ("route_map" , "route_type" ),
270
275
"range" : ("address" , "advertise" , "not_advertise" ),
276
+ "interface" : ("name" ),
271
277
}
272
278
leaf = leaf_dict [attr ]
273
279
w = want .get (attr ) or []
@@ -282,14 +288,26 @@ def _render_list_dict_param(self, attr, want, have, cmd=None, opr=True):
282
288
cmd = self ._compute_command (opr = opr )
283
289
h_item = search_obj_in_list (w_item [name [attr ]], h , name [attr ])
284
290
if opr and key in leaf and not _is_w_same (w_item , h_item , key ):
285
- if key == "route_type" or (
291
+ if key in [ "route_type" , "name" ] or (
286
292
key == "address"
287
293
and "advertise" not in w_item
288
294
and "not-advertise" not in w_item
289
295
):
290
296
if not val :
291
297
cmd = cmd .replace ("set" , "delete" )
292
- commands .append (cmd + attr + " " + str (val ))
298
+ if (
299
+ LooseVersion (get_os_version (self ._module )) >= LooseVersion ("1.4" )
300
+ and attr == "interface"
301
+ ):
302
+ words = cmd .split ()
303
+ cmd14_list = []
304
+ for word in words :
305
+ cmd14_list .append (word )
306
+ if word == "ospfv3" :
307
+ cmd14_list .append (attr + " " + str (val ))
308
+ commands .append (" " .join (cmd14_list ))
309
+ else :
310
+ commands .append (cmd + attr + " " + str (val ))
293
311
elif key in leaf_dict ["range" ] and key != "address" :
294
312
commands .append (
295
313
cmd + attr + " " + w_item [name [attr ]] + " " + key .replace ("_" , "-" ),
@@ -306,8 +324,20 @@ def _render_list_dict_param(self, attr, want, have, cmd=None, opr=True):
306
324
+ str (val ),
307
325
)
308
326
elif not opr and key in leaf and not _in_target (h_item , key ):
309
- if key in ("route_type" , "address" ):
310
- commands .append (cmd + attr + " " + str (val ))
327
+ if key in ("route_type" , "address" , "name" ):
328
+ if (
329
+ LooseVersion (get_os_version (self ._module )) >= LooseVersion ("1.4" )
330
+ and attr == "interface"
331
+ ):
332
+ words = cmd .split ()
333
+ cmd14_list = []
334
+ for word in words :
335
+ cmd14_list .append (word )
336
+ if word == "ospfv3" :
337
+ cmd14_list .append (attr + " " + str (val ))
338
+ commands .append (" " .join (cmd14_list ))
339
+ else :
340
+ commands .append (cmd + attr + " " + str (val ))
311
341
else :
312
342
commands .append (cmd + (attr + " " + w_item [name [attr ]] + " " + key ))
313
343
return commands
@@ -373,6 +403,10 @@ def _render_areas(self, attr, want, have, opr=True):
373
403
commands .extend (
374
404
self ._render_list_dict_param (key , w_area , h_area , cmd , opr ),
375
405
)
406
+ elif key == "interface" :
407
+ commands .extend (
408
+ self ._render_list_dict_param (key , w_area , h_area , cmd , opr ),
409
+ )
376
410
return commands
377
411
378
412
def _form_attr_cmd (self , key = None , attr = None , val = None , opr = True ):
0 commit comments