class DiskHandler::Partition

Constants

BLKID_REGEX

Attributes

disk[RW]
fs[RW]
mounted[RW]
name[RW]
type[RW]
uuid[RW]
uuid_sub[RW]

Public Class Methods

new(disk, name) click to toggle source
# File lib/disk_reporter/disk_handler.rb, line 85
def initialize(disk, name)
  self.disk = disk
  self.name = name.gsub("\n", "")
  blkid
end

Public Instance Methods

blkid() click to toggle source
# File lib/disk_reporter/disk_handler.rb, line 107
def blkid
  response = `blkid #{name}`
  self.fs = $?.exitstatus == 0
  # puts "FS: #{fs}"
  # puts response
  if fs?
    
    resp = response.scan(BLKID_REGEX)
    if resp && resp[0]
      self.uuid = resp[0][0]
      self.uuid_sub = resp[0][2]
      self.type = resp[0][3]
    end
    # puts 'check if mounted'
    # puts "grep #{name} /proc/mounts"
    mtab = `grep #{name} /proc/mounts`
    self.mounted = mtab.split(' ')[1] if $?
  end
end
fs?() click to toggle source
# File lib/disk_reporter/disk_handler.rb, line 103
def fs?
  !!fs
end
is_ceph?() click to toggle source
# File lib/disk_reporter/disk_handler.rb, line 91
def is_ceph?
  mounted? && mounted.match(%r{/var/lib/ceph/})
end
mounted?() click to toggle source
# File lib/disk_reporter/disk_handler.rb, line 99
def mounted?
  !!mounted
end
should_have_ceph?() click to toggle source
# File lib/disk_reporter/disk_handler.rb, line 95
def should_have_ceph?
  true
end