Exemplo n.º 1
0
 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'] = {}
Exemplo n.º 2
0
 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)
Exemplo n.º 3
0
 def _reset(self, types):
     with zvmutils.acquire_lock(self._lock):
         for type in types:
             self._cache[type] = {
                 'expiration': time.time(),
                 'data': {},
             }
Exemplo n.º 4
0
 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)
Exemplo n.º 5
0
    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
Exemplo n.º 6
0
 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
Exemplo n.º 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
Exemplo n.º 8
0
 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]