예제 #1
0
파일: monitor.py 프로젝트: wngzhe/feilong
 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'] = {}
예제 #2
0
파일: monitor.py 프로젝트: wngzhe/feilong
 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)
예제 #3
0
파일: monitor.py 프로젝트: wngzhe/feilong
 def _reset(self, types):
     with zvmutils.acquire_lock(self._lock):
         for type in types:
             self._cache[type] = {
                 'expiration': time.time(),
                 'data': {},
             }
예제 #4
0
파일: monitor.py 프로젝트: wngzhe/feilong
 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)
예제 #5
0
파일: monitor.py 프로젝트: wngzhe/feilong
    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
예제 #6
0
파일: volumeop.py 프로젝트: wngzhe/feilong
 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
예제 #7
0
    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
예제 #8
0
파일: monitor.py 프로젝트: wngzhe/feilong
 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]