class Ceph::Crush::Location::OSD

This class stores metadata about this OSD

Constants

CEPH_OSD_ROOT_PATH

Attributes

cluster[RW]
id[RW]

Public Class Methods

new() click to toggle source
# File lib/ceph/crush/location/osd.rb, line 9
def initialize
  Ceph::Crush::Location::Logger.send('OSD.initialize')
  self.id = Ceph::Crush::Location.options[:id]
  self.cluster = Ceph::Crush::Location.options[:cluster]
end

Public Instance Methods

chassis() click to toggle source
# File lib/ceph/crush/location/osd.rb, line 63
def chassis
  Ceph::Crush::Location::Logger.send('OSD.chassis')
  @chassis ||= Ceph::Crush::Location.nodeinfo['chassis']
end
chassis_artifact(append = '') click to toggle source
# File lib/ceph/crush/location/osd.rb, line 116
def chassis_artifact(append = '')
  return rack_artifact("#{chassis}_#{append}") if knows_chassis?
  rack_artifact(append)
end
datacenter() click to toggle source
# File lib/ceph/crush/location/osd.rb, line 88
def datacenter
  Ceph::Crush::Location::Logger.send('OSD.datacenter')
  @datacenter ||= Ceph::Crush::Location.nodeinfo['datacenter']
end
datacenter_artifact(append = '') click to toggle source
# File lib/ceph/crush/location/osd.rb, line 101
def datacenter_artifact(append = '')
  return root_artifact("#{datacenter}_#{append}") if knows_datacenter?
  root_artifact(append)
end
default_root?() click to toggle source
# File lib/ceph/crush/location/osd.rb, line 20
def default_root?
  !::File.exist? root_path
end
disk_chassis() click to toggle source
# File lib/ceph/crush/location/osd.rb, line 42
def disk_chassis
  ::File.read disk_chassis_path if knows_disk_chassis?
end
disk_chassis_artifact(append = '') click to toggle source
# File lib/ceph/crush/location/osd.rb, line 125
def disk_chassis_artifact(append = '')
  return host_artifact(append) unless knows_disk_chassis?
  host_artifact("#{disk_chassis}_#{append}")
end
disk_chassis_path() click to toggle source
# File lib/ceph/crush/location/osd.rb, line 33
def disk_chassis_path
  Ceph::Crush::Location::Logger.send('OSD.disk_chassis_path')
  @disk_chassis_path ||= ::File.join(osd_directory, 'disk_chassis')
end
enclosure() click to toggle source
# File lib/ceph/crush/location/osd.rb, line 55
def enclosure
  ::File.read enclosure_path if knows_enclosure?
end
enclosure_artifact(append = '') click to toggle source
# File lib/ceph/crush/location/osd.rb, line 130
def enclosure_artifact(append = '')
  return disk_chassis_artifact(append) unless knows_enclosure?
  disk_chassis_artifact("#{enclosure}_#{append}")
end
enclosure_path() click to toggle source
# File lib/ceph/crush/location/osd.rb, line 46
def enclosure_path
  Ceph::Crush::Location::Logger.send('OSD.enclosure_path')
  @enclosure_path ||= ::File.join(osd_directory, 'enclosure')
end
host_artifact(append = '') click to toggle source
# File lib/ceph/crush/location/osd.rb, line 121
def host_artifact(append = '')
  chassis_artifact("#{hostname}_#{append}")
end
hostname() click to toggle source
# File lib/ceph/crush/location/osd.rb, line 93
def hostname
  Socket.gethostname.strip.split('.').first
end
knows_chassis?() click to toggle source
# File lib/ceph/crush/location/osd.rb, line 59
def knows_chassis?
  !chassis.nil?
end
knows_datacenter?() click to toggle source
# File lib/ceph/crush/location/osd.rb, line 84
def knows_datacenter?
  !datacenter.nil?
end
knows_disk_chassis?() click to toggle source
# File lib/ceph/crush/location/osd.rb, line 38
def knows_disk_chassis?
  ::File.exist? disk_chassis_path
end
knows_enclosure?() click to toggle source
# File lib/ceph/crush/location/osd.rb, line 51
def knows_enclosure?
  ::File.exist? enclosure_path
end
knows_rack?() click to toggle source
# File lib/ceph/crush/location/osd.rb, line 68
def knows_rack?
  !rack.nil?
end
knows_row?() click to toggle source
# File lib/ceph/crush/location/osd.rb, line 76
def knows_row?
  !row.nil?
end
osd_directory() click to toggle source
# File lib/ceph/crush/location/osd.rb, line 15
def osd_directory
  Ceph::Crush::Location::Logger.send('OSD.osd_directory')
  ::File.join CEPH_OSD_ROOT_PATH, "#{cluster}-#{id}"
end
rack() click to toggle source
# File lib/ceph/crush/location/osd.rb, line 72
def rack
  @rack ||= Ceph::Crush::Location.nodeinfo['rack']
end
rack_artifact(append = '') click to toggle source
# File lib/ceph/crush/location/osd.rb, line 111
def rack_artifact(append = '')
  return row_artifact("#{rack}_#{append}") if knows_rack?
  row_artifact(append)
end
root() click to toggle source
# File lib/ceph/crush/location/osd.rb, line 28
def root
  return 'default' if default_root?
  ::File.read root_path
end
root_artifact(append = '') click to toggle source
# File lib/ceph/crush/location/osd.rb, line 97
def root_artifact(append = '')
  "#{root}_#{append}"
end
root_path() click to toggle source
# File lib/ceph/crush/location/osd.rb, line 24
def root_path
  @root_path ||= ::File.join(osd_directory, 'crush_root')
end
row() click to toggle source
# File lib/ceph/crush/location/osd.rb, line 80
def row
  @row ||= Ceph::Crush::Location.nodeinfo['row']
end
row_artifact(append = '') click to toggle source
# File lib/ceph/crush/location/osd.rb, line 106
def row_artifact(append = '')
  return datacenter_artifact("#{row}_#{append}") if knows_row?
  datacenter_artifact(append)
end