Sha256: 5a236d7c00e4cb0376618ae4779566669d78852f7c0a0f238a5d52e599af13ae

Contents?: true

Size: 833 Bytes

Versions: 1

Compression:

Stored size: 833 Bytes

Contents

module CephRuby
  # Rados BlockDevice helper Methods
  module RadosBlockDeviceHelper
    def self.parse_stat(stat)
      Hash[[:size, :obj_size, :num_objs, :order].map { |k| [k, stat[k]] }]
        .tap do |hash|
        hash[:block_name_prefix] = stat[:block_name_prefix].to_ptr.read_string
      end
    end

    def self.close_handle(handle)
      Lib::Rbd.rbd_close(handle)
      true
    end

    def self.parse_dst_pool(dst_pool, pool)
      if dst_pool.is_a? String
        dst_pool = cluster.pool(dst_pool)
      elsif dst_pool.nil?
        dst_pool = pool
      end
      dst_pool.ensure_open
      dst_pool
    end

    def open?
      !handle.nil?
    end

    def ensure_open
      return if open?
      open
    end

    def log(message)
      CephRuby.log("rbd image #{pool.name}/#{name} #{message}")
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ceph-ruby-livelink-1.5.1 lib/ceph-ruby/rados_block_device_helper.rb