Sha256: 3017dc7ce2b1f2b0bca72dab55365758ca1e794e766c9f8d0f6ce8ec37c08a5a

Contents?: true

Size: 929 Bytes

Versions: 1

Compression:

Stored size: 929 Bytes

Contents

# frozen_string_literal: true

module Uricp::Strategy
  class RbdPut
    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?
        debug "#{self.class.name}: cacheing in RBD instead"
        return false
      end
      case from.scheme
      when 'pipe', 'file'
        return proposal if to.scheme == 'rbd'
      end
      debug "#{self.class.name}: not appropriate"
      false
    end

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

    def proposal
      @proposed_options = options.dup
      @proposed_options['from_uri'] = to
      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_put.rb