Sha256: 5381ca096596e20295e145cc0e1a1086ecae99b716e68383774921e4da6cecba

Contents?: true

Size: 898 Bytes

Versions: 4

Compression:

Stored size: 898 Bytes

Contents

require 'uri'

module Uricp::Strategy
  class RbdCachedGet
    include Uricp::Strategy::Common
    include Uricp::Strategy::CacheCommon
    include Methadone::SH

    def appropriate?
      if from.scheme != 'rbd' || rbd_snapshot_spec?(from)
        debug "#{self.class.name}: not appropriate"
        return false
      end

      with_active_cache do
        cache_check = in_rbd_cache(rbd_image_spec(from))
        return proposal(cache_check) if cache_check
        debug "#{self.class.name}: no rbd cache entry for #{options['from_uri']}"
        false
      end
    end

    def command
      ':;'
    end

    def proposal(cache_check)
      @proposed_options = options.dup
      @proposed_options['from_uri'] = rbd_uri(cache_check)
      @proposed_options.delete('cache')
      @proposed_options.delete('cache_name')
      @proposed_options.delete('dry-cache')
      self
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
uricp-0.0.23 lib/uricp/strategy/rbd_cached_get.rb
uricp-0.0.22 lib/uricp/strategy/rbd_cached_get.rb
uricp-0.0.21 lib/uricp/strategy/rbd_cached_get.rb
uricp-0.0.20 lib/uricp/strategy/rbd_cached_get.rb