Sha256: 751d0d135e3845aa604e536b1a3ee54cc00005249bea8f5b06fe07dbee9fc111

Contents?: true

Size: 881 Bytes

Versions: 1

Compression:

Stored size: 881 Bytes

Contents

# frozen_string_literal: true

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.25 lib/uricp/strategy/rbd_cache_upload.rb