Sha256: 7bccd80c5ba52e0aa14d4de3d97f08463ffdb48aa4f7af41889335e47699d47e

Contents?: true

Size: 923 Bytes

Versions: 1

Compression:

Stored size: 923 Bytes

Contents

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

    def appropriate?
      return proposal if to.scheme == 'rbd' &&
        rbd_snapshot_spec?(from) && 
        rbd_cache_name.nil? &&
        !rbd_sequence_complete?

      debug "#{self.class.name}: not appropriate"
      false
    end

    def command
      "rbd clone --no-progress --id #{rbd_id} '#{rbd_image_spec(from)}' '#{rbd_image_spec(to)}';"
    end

    def proposal
      @proposed_options = options.dup
      @proposed_options['from_uri'] = to
      if options['rbd_cache_target']
        @proposed_options['to_uri'] = options['rbd_cache_target']
        @proposed_options['rbd_cache_name'] = rbd_image_spec(to)
        @proposed_options['rbd_flatten'] ||= @proposed_options['rbd_cache_name']
        @proposed_options.delete('rbd_cache_target')
      end
      self
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
uricp-0.0.20 lib/uricp/strategy/rbd_cached_put.rb