Sha256: 13adb20692bb0e0f076b70172c0cc07884e622fe46c2259390004f6cfc4bc71a

Contents?: true

Size: 851 Bytes

Versions: 1

Compression:

Stored size: 851 Bytes

Contents

module Uricp::Strategy
  class RbdCacheUpload
    include Uricp::Strategy::Common

    def appropriate?
      if compression_required? || conversion_required?
        debug "#{self.class.name}: not ready to upload"
        return false
      end
      if rbd_cache_upload_available?
        case from.scheme
        when 'pipe', 'file'
          return proposal if to.scheme == 'rbd'
        end
      end
      debug "#{self.class.name}: not appropriate"
      false
    end

    def command
      "rbd import --no-progress --id #{rbd_id} #{data_source} '#{rbd_cache_name}';"
    end

    def proposal
      @proposed_options = options.dup
      @proposed_options['from_uri'] = rbd_uri(rbd_cache_name)
      self
    end

    def data_source
      if from.scheme == 'pipe'
        '-'
      else
        "'#{from.path}'"
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
uricp-0.0.24 lib/uricp/strategy/rbd_cache_upload.rb