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 netinfo.slaves(bond.name): self.configApplier.addBondSlave(bond, slave) slave.configure(**opts) self.configApplier.setIfaceConfigAndUp(bond) self.runningConfig.setBonding( bond.name, {'options': bond.options, 'nics': [slave.name for slave in bond.slaves]})
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 netinfo.bondings() and netinfo.operstate(self.name) == netinfo.OPERSTATE_UP and netinfo.ifaceUsed(self.name) and self.mtu <= netinfo.getMtu(self.name) and self.areOptionsApplied() and frozenset(slave.name for slave in self.slaves) == frozenset( netinfo.slaves(self.name))): return self.configurator.configureBond(self, **opts)
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 netinfo.bondings() and netinfo.operstate(self.name) == netinfo.OPERSTATE_UP and netinfo.NetInfo().ifaceUsers(self.name) and self.mtu <= netinfo.getMtu(self.name) and self.areOptionsApplied() and frozenset(slave.name for slave in self.slaves) == frozenset(netinfo.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 netinfo.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]} )
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 netinfo.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]})
def setBondingMtu(self, bonding, newmtu): self.setIfaceMtu(bonding, newmtu) slaves = netinfo.slaves(bonding) for slave in slaves: self.setIfaceMtu(slave, newmtu)
def _net_nics(attrs): if 'bonding' in attrs: return netinfo.slaves(attrs['bonding']) else: return [attrs.pop('nic')] if 'nic' in attrs else ()
def _customization(self): nics = ethtool.get_devices() validValues = [] enslaved = set() interfaces = set() for nic in nics: try: flags = ethtool.get_flags(nic) if flags & ethtool.IFF_LOOPBACK: self.logger.debug('Detected loopback device %s' % nic) elif ethtool.get_module(nic) == 'bridge': self.logger.debug('Detected bridge device %s' % nic) if os.path.exists('/sys/class/net/%s/brif' % nic): slaves = os.listdir('/sys/class/net/%s/brif' % nic) self.logger.debug('Detected slaves for device %s: %s' % (nic, ','.join(slaves))) for iface in slaves: if iface in nics: enslaved.update([iface]) elif netinfo.isbonding(nic): slaves = netinfo.slaves(nic) if not slaves: self.logger.debug( 'Detected bond device %s without slaves' % nic) else: self.logger.debug('Detected slaves for device %s: %s' % (nic, ','.join(slaves))) enslaved.update(slaves) interfaces.update([nic]) else: interfaces.update([nic]) except IOError as ioe: if ioe.errno in (None, errno.EOPNOTSUPP): self.logger.debug('Detected unsupported device %s' % nic) else: raise ioe validValues = list(interfaces - enslaved) self.logger.debug('Nics detected: %s' % ','.join(nics)) self.logger.debug('Nics enslaved: %s' % ','.join(enslaved)) self.logger.debug('Nics valid: %s' % ','.join(validValues)) if not validValues: if enslaved: raise RuntimeError( _('The following existing interfaces are not suitable ' 'for vdsm: {enslaved}. You might want to pull out an ' 'interface out of a bridge to be able to use it').format( enslaved=','.join(enslaved))) else: raise RuntimeError(_('A Network interface is required')) interactive = self.environment[ ohostedcons.NetworkEnv.BRIDGE_IF] is None if interactive: default = ohostedcons.Defaults.DEFAULT_BRIDGE_IF if default not in validValues: default = validValues[0] self.environment[ ohostedcons.NetworkEnv.BRIDGE_IF] = self.dialog.queryString( name='ovehosted_bridge_if', note=_( 'Please indicate a nic to set ' '{bridge} bridge on: (@VALUES@) [@DEFAULT@]: ').format( bridge=self.environment[ ohostedcons.NetworkEnv.BRIDGE_NAME]), prompt=True, caseSensitive=True, default=default, validValues=validValues, )
def _customization(self): nics = ethtool.get_devices() validValues = [] enslaved = set() interfaces = set() for nic in nics: try: flags = ethtool.get_flags(nic) if flags & ethtool.IFF_LOOPBACK: self.logger.debug('Detected loopback device %s' % nic) elif ethtool.get_module(nic) == 'bridge': self.logger.debug('Detected bridge device %s' % nic) if os.path.exists('/sys/class/net/%s/brif' % nic): slaves = os.listdir('/sys/class/net/%s/brif' % nic) self.logger.debug( 'Detected slaves for device %s: %s' % ( nic, ','.join(slaves) ) ) for iface in slaves: if iface in nics: enslaved.update([iface]) elif netinfo.isbonding(nic): slaves = netinfo.slaves(nic) if not slaves: self.logger.debug( 'Detected bond device %s without slaves' % nic ) else: self.logger.debug( 'Detected slaves for device %s: %s' % ( nic, ','.join(slaves) ) ) enslaved.update(slaves) interfaces.update([nic]) else: interfaces.update([nic]) except IOError as ioe: if ioe.errno in (None, errno.EOPNOTSUPP): self.logger.debug('Detected unsupported device %s' % nic) else: raise ioe validValues = list(interfaces - enslaved) self.logger.debug('Nics detected: %s' % ','.join(nics)) self.logger.debug('Nics enslaved: %s' % ','.join(enslaved)) self.logger.debug('Nics valid: %s' % ','.join(validValues)) if not validValues: if enslaved: raise RuntimeError( _( 'The following existing interfaces are not suitable ' 'for vdsm: {enslaved}. You might want to pull out an ' 'interface out of a bridge to be able to use it' ).format( enslaved=','.join(enslaved) ) ) else: raise RuntimeError(_('A Network interface is required')) interactive = self.environment[ ohostedcons.NetworkEnv.BRIDGE_IF ] is None if interactive: default = ohostedcons.Defaults.DEFAULT_BRIDGE_IF if default not in validValues: default = validValues[0] self.environment[ ohostedcons.NetworkEnv.BRIDGE_IF ] = self.dialog.queryString( name='ovehosted_bridge_if', note=_( 'Please indicate a nic to set ' '{bridge} bridge on: (@VALUES@) [@DEFAULT@]: ' ).format( bridge=self.environment[ ohostedcons.NetworkEnv.BRIDGE_NAME ] ), prompt=True, caseSensitive=True, default=default, validValues=validValues, )