Sha256: ea79c670d5df21faf347ad35f247c4b319ad2e1325975958c94252a42ce575e0

Contents?: true

Size: 904 Bytes

Versions: 11

Compression:

Stored size: 904 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
      return if from.scheme == 'pipe'
      " <'#{from.path}'"
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
uricp-0.0.37 lib/uricp/strategy/rbd_put.rb
uricp-0.0.36 lib/uricp/strategy/rbd_put.rb
uricp-0.0.35 lib/uricp/strategy/rbd_put.rb
uricp-0.0.34 lib/uricp/strategy/rbd_put.rb
uricp-0.0.32 lib/uricp/strategy/rbd_put.rb
uricp-0.0.31 lib/uricp/strategy/rbd_put.rb
uricp-0.0.30 lib/uricp/strategy/rbd_put.rb
uricp-0.0.29 lib/uricp/strategy/rbd_put.rb
uricp-0.0.28 lib/uricp/strategy/rbd_put.rb
uricp-0.0.27 lib/uricp/strategy/rbd_put.rb
uricp-0.0.26 lib/uricp/strategy/rbd_put.rb