Пример #1
0
 def _get_rdir_addr(self, volume_id):
     # Initial lookup in the cache
     if volume_id in self._addr_cache:
         return self._addr_cache[volume_id]
     # Not cached, try a direct lookup
     try:
         resp = self.directory.list(RDIR_ACCT, volume_id,
                                    service_type='rdir')
         host = _filter_rdir_host(resp)
         # Add the new service to the cache
         self._addr_cache[volume_id] = host
         return host
     except NotFound:
         raise VolumeException('No rdir assigned to volume %s' % volume_id)
Пример #2
0
 def _get_rdir_addr(self, volume_id, reqid=None):
     # Initial lookup in the cache
     if volume_id in self._addr_cache:
         return self._addr_cache[volume_id]
     # Not cached, try a direct lookup
     try:
         headers = {REQID_HEADER: reqid or request_id()}
         resp = self.directory.list(RDIR_ACCT, volume_id,
                                    service_type='rdir',
                                    headers=headers)
         host = _filter_rdir_host(resp)
         # Add the new service to the cache
         self._addr_cache[volume_id] = host
         return host
     except NotFound:
         raise VolumeException('No rdir assigned to volume %s' % volume_id)
Пример #3
0
    def _get_rdir_addr(self, volume_id, create=False, nocache=False):
        if not nocache and volume_id in self._addr_cache:
            return self._addr_cache[volume_id]
        resp = {}
        try:
            resp = self.directory_client.show(acct=RDIR_ACCT, ref=volume_id,
                                              srv_type='rdir')
        except NotFound:
            if not create:
                raise VolumeException('No such volume %s' % volume_id)

        try:
            host = self._lookup_rdir_host(resp)
        except ClientException:
            # Reference exists but no rdir linked
            if not create:
                raise
            resp = self._link_rdir(volume_id)
            host = self._lookup_rdir_host(resp)
        self._addr_cache[volume_id] = host
        return host