def configure(self, **opts): # When the bond is up and we are not changing the configuration that # is already applied in any way, we can skip the configuring. if (self.vlan and self.name in bonding.bondings() and (not self.configurator.unifiedPersistence or self.name in self.configurator.runningConfig.bonds) and nics.operstate(self.name) == nics.OPERSTATE_UP and ifaceUsed(self.name) and self.mtu <= mtus.getMtu(self.name) and self.areOptionsApplied() and frozenset(slave.name for slave in self.slaves) == frozenset( bonding.slaves(self.name))): return self.configurator.configureBond(self, **opts)
def configureBond(self, bond, **opts): self.configApplier.addBond(bond) if not bond.areOptionsApplied(): self.configApplier.ifdown(bond) self.configApplier.addBondOptions(bond) for slave in bond.slaves: if slave.name not in bonding.slaves(bond.name): self.configApplier.addBondSlave(bond, slave) slave.configure(**opts) DynamicSourceRoute.addInterfaceTracking(bond) self.configApplier.setIfaceConfigAndUp(bond) self._addSourceRoute(bond) self.runningConfig.setBonding( bond.name, {'options': bond.options, 'nics': [slave.name for slave in bond.slaves], 'switch': 'legacy'})
def configure(self, **opts): # When the bond is up and we are not changing the configuration that # is already applied in any way, we can skip the configuring. if (self.vlan and self.name in bonding.bondings() and (not self.configurator.unifiedPersistence or self.name in self.configurator.runningConfig.bonds) and nics.operstate(self.name) == nics.OPERSTATE_UP and ifaceUsed(self.name) and self.mtu <= mtus.getMtu(self.name) and self.areOptionsApplied() and frozenset(slave.name for slave in self.slaves) == frozenset(bonding.slaves(self.name))): return self.configurator.configureBond(self, **opts)
def setBondingMtu(self, bonding, newmtu): self.setIfaceMtu(bonding, newmtu) slaves = netinfo_bonding.slaves(bonding) for slave in slaves: self.setIfaceMtu(slave, newmtu)
def _net_nics(attrs): if 'bonding' in attrs: return bonding.slaves(attrs['bonding']) else: return [attrs.pop('nic')] if 'nic' in attrs else ()