Sha256: 7cb062b2b8ac5b92abcfea2d267b84450bf7e2a81d1df7c97c68f66a47456b13

Contents?: true

Size: 908 Bytes

Versions: 2

Compression:

Stored size: 908 Bytes

Contents

# frozen_string_literal: true

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 --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.delete('rbd_cache_target')
      end
      self
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
uricp-0.0.26 lib/uricp/strategy/rbd_cached_put.rb
uricp-0.0.25 lib/uricp/strategy/rbd_cached_put.rb