Sha256: 5290476b58c47c31da1f78f2c755e59b9b0d6e83c2d17d0fd1a83878822de1a3

Contents?: true

Size: 1.17 KB

Versions: 12

Compression:

Stored size: 1.17 KB

Contents

# frozen_string_literal: true

require 'uri'

module Uricp::Strategy
  class RbdCacheCheck
    include Uricp::Strategy::Common
    include Uricp::Strategy::CacheCommon

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

      with_active_cache do
        if from.scheme == 'rbd'
          cache_check = in_rbd_cache(rbd_cache_image_spec(from))
          return proposal(cache_check) if cache_check
          debug "#{self.class.name}: no rbd cache entry for #{options['from_uri']}"
        elsif to.scheme == 'rbd'
          cache_check = in_rbd_cache(rbd_cache_image_spec(to))
          return proposal(cache_check) if cache_check
          debug "#{self.class.name}: no rbd cache entry for #{options['to_uri']}"
        end
        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

12 entries across 12 versions & 1 rubygems

Version Path
uricp-0.0.37 lib/uricp/strategy/rbd_cache_check.rb
uricp-0.0.36 lib/uricp/strategy/rbd_cache_check.rb
uricp-0.0.35 lib/uricp/strategy/rbd_cache_check.rb
uricp-0.0.34 lib/uricp/strategy/rbd_cache_check.rb
uricp-0.0.32 lib/uricp/strategy/rbd_cache_check.rb
uricp-0.0.31 lib/uricp/strategy/rbd_cache_check.rb
uricp-0.0.30 lib/uricp/strategy/rbd_cache_check.rb
uricp-0.0.29 lib/uricp/strategy/rbd_cache_check.rb
uricp-0.0.28 lib/uricp/strategy/rbd_cache_check.rb
uricp-0.0.27 lib/uricp/strategy/rbd_cache_check.rb
uricp-0.0.26 lib/uricp/strategy/rbd_cache_check.rb
uricp-0.0.25 lib/uricp/strategy/rbd_cache_check.rb