def _validateNetworkSetup(networks, bondings): for network, networkAttrs in networks.iteritems(): if networkAttrs.get('remove', False): if set(networkAttrs) - set(['remove']): raise ConfigNetworkError(ne.ERR_BAD_PARAMS, 'Cannot specify ' 'any attribute when removing') currentBondings = netinfo.bondings() currentNicsSet = set(netinfo.nics()) for bonding, bondingAttrs in bondings.iteritems(): Bond.validateName(bonding) if 'options' in bondingAttrs: Bond.validateOptions(bonding, bondingAttrs['options']) if bondingAttrs.get('remove', False): if bonding not in currentBondings: raise ConfigNetworkError(ne.ERR_BAD_BONDING, "Cannot remove " "bonding %s: Doesn't exist" % bonding) continue nics = bondingAttrs.get('nics', None) if not nics: raise ConfigNetworkError(ne.ERR_BAD_PARAMS, "Must specify nics for bonding") if not set(nics).issubset(currentNicsSet): raise ConfigNetworkError(ne.ERR_BAD_NIC, "Unknown nics in: %r" % list(nics))
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 __init__(self, log): """ Initialize the (single) clientIF instance :param log: a log object to be used for this object's logging. :type log: :class:`logging.Logger` """ self.vmContainerLock = threading.Lock() self._networkSemaphore = threading.Semaphore() self._shutdownSemaphore = threading.Semaphore() self.log = log self._recovery = True self.channelListener = Listener(self.log) self._generationID = str(uuid.uuid4()) self._initIRS() self.mom = None if _glusterEnabled: self.gluster = gapi.GlusterApi(self, log) else: self.gluster = None try: self.vmContainer = {} ifids = netinfo.nics() + netinfo.bondings() ifrates = map(netinfo.speed, ifids) self._hostStats = sampling.HostStatsThread(cif=self, log=log, ifids=ifids, ifrates=ifrates) self._hostStats.start() self.lastRemoteAccess = 0 self._memLock = threading.Lock() self._enabled = True self._netConfigDirty = False self._prepareMOM() threading.Thread(target=self._recoverExistingVms, name='clientIFinit').start() self.channelListener.settimeout( config.getint('vars', 'guest_agent_timeout')) self.channelListener.start() self.threadLocal = threading.local() self.threadLocal.client = '' except: self.log.error('failed to init clientIF, ' 'shutting down storage dispatcher') if self.irs: self.irs.prepareForShutdown() if self.mom: self.mom.stop() raise self._prepareBindings()
def __init__(self, log): """ Initialize the (single) clientIF instance :param log: a log object to be used for this object's logging. :type log: :class:`logging.Logger` """ self.vmContainerLock = threading.Lock() self._networkSemaphore = threading.Semaphore() self._shutdownSemaphore = threading.Semaphore() self.log = log self._recovery = True self.channelListener = Listener(self.log) self._generationID = str(uuid.uuid4()) self._initIRS() self.mom = None if _glusterEnabled: self.gluster = gapi.GlusterApi(self, log) else: self.gluster = None try: self.vmContainer = {} ifids = netinfo.nics() + netinfo.bondings() ifrates = map(netinfo.speed, ifids) self._hostStats = sampling.HostStatsThread( cif=self, log=log, ifids=ifids, ifrates=ifrates) self._hostStats.start() self.lastRemoteAccess = 0 self._memLock = threading.Lock() self._enabled = True self._netConfigDirty = False self._prepareMOM() threading.Thread(target=self._recoverExistingVms, name='clientIFinit').start() self.channelListener.settimeout( config.getint('vars', 'guest_agent_timeout')) self.channelListener.start() self.threadLocal = threading.local() self.threadLocal.client = '' except: self.log.error('failed to init clientIF, ' 'shutting down storage dispatcher') if self.irs: self.irs.prepareForShutdown() if self.mom: self.mom.stop() raise self._prepareBindings()
def __init__ (self, log): """ Initialize the (single) clientIF instance :param log: a log object to be used for this object's logging. :type log: :class:`logging.Logger` """ self.vmContainerLock = threading.Lock() self._networkSemaphore = threading.Semaphore() self._shutdownSemaphore = threading.Semaphore() self.log = log self._recovery = True self._libvirt = libvirtconnection.get() self._syncLibvirtNetworks() self.channelListener = Listener(self.log) self._generationID = str(uuid.uuid4()) self._initIRS() try: self.vmContainer = {} ifids = netinfo.nics() + netinfo.bondings() ifrates = map(netinfo.speed, ifids) self._hostStats = utils.HostStatsThread(cif=self, log=log, ifids=ifids, ifrates=ifrates) self._hostStats.start() mog = min(config.getint('vars', 'max_outgoing_migrations'), caps.CpuInfo().cores()) vm.MigrationSourceThread.setMaxOutgoingMigrations(mog) self.lastRemoteAccess = 0 self._memLock = threading.Lock() self._enabled = True self.ksmMonitor = ksm.KsmMonitorThread(self) self._netConfigDirty = False threading.Thread(target=self._recoverExistingVms, name='clientIFinit').start() self.channelListener.settimeout(config.getint('vars', 'guest_agent_timeout')) self.channelListener.start() self.threadLocal = threading.local() self.threadLocal.client = '' except: self.log.error('failed to init clientIF, shutting down storage dispatcher') if self.irs: self.irs.prepareForShutdown() raise self._prepareBindings()
def addBond(self, bond): if bond.name not in netinfo.bondings(): logging.debug('Add new bonding %s', bond) with open(netinfo.BONDING_MASTERS, 'w') as f: f.write('+%s' % bond.name)
def addBond(self, bond): if bond.name not in netinfo.bondings(): logging.debug("Add new bonding %s", bond) with open(netinfo.BONDING_MASTERS, "w") as f: f.write("+%s" % bond.name)
def addBond(self, bond): if bond.name not in netinfo.bondings(): self.ip.create(kind='bond', ifname=bond.name).commit()