Sha256: f9ad4490fa2087445c7ac49aa8cdece966543bd791d5ce0a8c77823cf8f98bbc

Contents?: true

Size: 1.03 KB

Versions: 3

Compression:

Stored size: 1.03 KB

Contents

require 'uri'

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

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

      with_active_cache do
        options['cache_name'] = File.basename(options['to_uri'].path)
        cache_target = rbd_cache_image_spec(from)
        cache_check = in_rbd_cache(rbd_cache_image_spec(from))
        if cache_check 
          debug "#{self.class.name}: Unexpected existing cache entry for #{options['to_uri']}"
          unsupported_transfer
        end
        proposal(cache_target)
      end
    end

    def command
      ':;'
    end

    def proposal(cache_check)
      @proposed_options = options.dup
      @proposed_options['rbd_cache_target'] = 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

3 entries across 3 versions & 1 rubygems

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