@@ -402,9 +402,99 @@ def appendPostDown(self, cmd):
402402 """
403403 self ._ensure_list (self ._ifAttributes , "post-down" , cmd )
404404
405+ def setBondMaster (self , master_adapter_name ):
406+ """Set bond-master reference on slave.
407+
408+ Args:
409+ master_adapter_name (str): name of master iface
410+ """
411+ self ._ifAttributes ['bond-master' ] = master_adapter_name
412+
413+ def setBondMode (self , mode ):
414+ """Set bond-mode.
415+
416+ Args:
417+ mode (str, int): mode of bonding
418+ """
419+ if isinstance (mode , str ):
420+ mode = mode .lower ().replace ('_' , '-' )
421+ self ._ifAttributes ['bond-mode' ] = mode
422+
423+ def setBondMiimon (self , miimon ):
424+ """Set bond-miimon parameter.
425+ Specifies the MII link monitoring frequency in milliseconds.
426+
427+ Args:
428+ miimon (int): miimon
429+ """
430+ self ._ifAttributes ['bond-miimon' ] = miimon
431+
432+ def setBondUpDelay (self , delay ):
433+ """Set bond-updelay parameter.
434+ Specifies the time, in milliseconds, to wait before enabling a slave after a link recovery has been detected.
435+ This option is only valid for the miimon link monitor. The updelay value should be a multiple of the miimon value.
436+
437+ Args:
438+ delay (int): delay in milliseconds
439+ """
440+ miimon = self ._ifAttributes .get ('bond-miimon' , 0 )
441+ if miimon and delay % miimon != 0 :
442+ raise ValueError ("Updelay should be multiple of miimon value" )
443+ self ._ifAttributes ['bond-updelay' ] = delay
444+
445+ def setBondDownDelay (self , delay ):
446+ """Set bond-downdelay parameter.
447+ Specifies the time, in milliseconds, to wait before disabling a slave after a link failure has been detected.
448+ This option is only valid for the miimon link monitor. The updelay value should be a multiple of the miimon value.
449+
450+ Args:
451+ delay (int): delay in milliseconds
452+ """
453+ miimon = self ._ifAttributes .get ('bond-miimon' , 0 )
454+ if miimon and delay % miimon != 0 :
455+ raise ValueError ("Downdelay should be multiple of miimon value" )
456+ self ._ifAttributes ['bond-downdelay' ] = delay
457+
458+ def setBondPrimary (self , primary_name ):
459+ """Set bond-primary parameter.
460+ A string specifying which slave is the primary device.
461+ The specified device will always be the active slave while it is available.
462+ Only when the primary is off-line will alternate devices be used.
463+ This is useful when one slave is preferred over another, e.g., when one slave has higher throughput than another.
464+ The primary option is only valid for active-backup (1) mode.
465+
466+ Args:
467+ primary_name (str): name of primary slave
468+ """
469+ self ._ifAttributes ['bond-primary' ] = primary_name
470+
471+ def setBondSlaves (self , slaves ):
472+ """Set bond-primary parameter.
473+ Slave interfaces names
474+
475+ Args:
476+ slaves (list, optional): names of slaves
477+ """
478+ if not isinstance (slaves , list ):
479+ slaves = [slaves ]
480+ self ._ifAttributes ['bond-slaves' ] = slaves
481+
405482 def setUnknown (self , key , val ):
406483 """Stores uncommon options as there are with no special handling
407484 It's impossible to know about all available options
485+ Format key with lower case. Replaces '_' with '-'
486+
487+ Args:
488+ key (str): the option name
489+ val (any): the option value
490+ """
491+ key = key .lower ().replace ('_' , '-' )
492+ self .setUnknownUnformatted (key , val )
493+
494+ def setUnknownUnformatted (self , key , val ):
495+ """Stores uncommon options as there are with no special handling
496+ It's impossible to know about all available options
497+ Stores key as is
408498
409499 Args:
410500 key (str): the option name
@@ -515,7 +605,14 @@ def set_options(self, options):
515605 'hostapd' : self .setHostapd ,
516606 'dns-nameservers' : self .setDnsNameservers ,
517607 'dns-search' : self .setDnsSearch ,
518- 'wpa-conf' : self .setWpaConf
608+ 'wpa-conf' : self .setWpaConf ,
609+ 'bond-master' : self .setBondMaster ,
610+ 'bond-slaves' : self .setBondSlaves ,
611+ 'bond-miimon' : self .setBondMiimon ,
612+ 'bond-mode' : self .setBondMode ,
613+ 'bond-updelay' : self .setBondUpDelay ,
614+ 'bond-downdelay' : self .setBondDownDelay ,
615+ 'bond-primary' : self .setBondPrimary
519616 }
520617 for key , value in options .items ():
521618 if key in roseta :
0 commit comments