def clear(self, ctype='all'): with zvmutils.acquire_lock(self._lock): if ctype == 'all': self._reset() else: target_cache = self._get_ctype_cache(ctype) target_cache['data'] = {}
def get(self, ctype, key): with zvmutils.acquire_lock(self._lock): target_cache = self._get_ctype_cache(ctype) if (time.time() > target_cache['expiration']): return None else: return target_cache['data'].get(key, None)
def _reset(self, types): with zvmutils.acquire_lock(self._lock): for type in types: self._cache[type] = { 'expiration': time.time(), 'data': {}, }
def refresh(self, ctype, data): with zvmutils.acquire_lock(self._lock): self.clear(ctype) target_cache = self._get_ctype_cache(ctype) target_cache['expiration'] = (time.time() + float(CONF.monitor.cache_interval)) for (k, v) in data.items(): self.set(ctype, k, v)
def set(self, ctype, key, data): """Set or update cache content. :param ctype: cache type :param key: the key to be set value :param data: cache data """ with zvmutils.acquire_lock(self._lock): target_cache = self._get_ctype_cache(ctype) target_cache['data'][key] = data
def volume_refresh_bootmap(self, fcpchannels, wwpns, lun, transportfiles=None, guest_networks=None): ret = None with zvmutils.acquire_lock(self._lock): LOG.debug('Enter lock scope of volume_refresh_bootmap.') ret = self._smtclient.volume_refresh_bootmap(fcpchannels, wwpns, lun, transportfiles=transportfiles, guest_networks=guest_networks) LOG.debug('Exit lock of volume_refresh_bootmap with ret %s.' % ret) return ret
def volume_refresh_bootmap(self, fcpchannels, wwpns, lun, skipzipl=False): """ Refresh a volume's bootmap info. :param list of fcpchannels :param list of wwpns :param string lun :param boolean skipzipl: whether ship zipl, only return physical wwpns """ ret = None with zvmutils.acquire_lock(self._lock): LOG.debug('Enter lock scope of volume_refresh_bootmap.') ret = self._smtclient.volume_refresh_bootmap(fcpchannels, wwpns, lun, skipzipl=skipzipl) LOG.debug('Exit lock of volume_refresh_bootmap with ret %s.' % ret) return ret
def delete(self, ctype, key): with zvmutils.acquire_lock(self._lock): target_cache = self._get_ctype_cache(ctype) if key in target_cache['data']: del target_cache['data'][key]