class Ceph::Crush::Location::Bucket

Derives a Bucket line for Crush

Public Class Methods

new() click to toggle source
# File lib/ceph/crush/location/bucket.rb, line 6
def initialize
  Ceph::Crush::Location::Logger.send('Bucket.initialize')
  @osd = OSD.new
end

Public Instance Methods

from_config() click to toggle source
# File lib/ceph/crush/location/bucket.rb, line 11
def from_config
  require 'shellwords'
  ceph_conf_bin = '/usr/bin/ceph-conf'
  cluster = ::Shellwords.escape @osd.cluster
  type = 'osd'
  id = ::Shellwords.escape @osd.id
  location_command = "#{ceph_conf_bin} --cluster=#{cluster} "\
                     "--name=#{type}.#{id} --lookup crush_location"
  `#{location_command}`
rescue
  ''
end
to_s() click to toggle source
# File lib/ceph/crush/location/bucket.rb, line 24
def to_s
  Ceph::Crush::Location::Logger.send('Bucket.to_s')
  ceph_location_config = from_config
  return ceph_location_config unless ceph_location_config == ''
  [root_bucket, datacenter_bucket,
   row_bucket, rack_bucket, chassis_bucket,
   host_bucket, disk_chassis_bucket, enclosure_bucket].join('')
end

Private Instance Methods

chassis() click to toggle source
# File lib/ceph/crush/location/bucket.rb, line 75
def chassis
  Ceph::Crush::Location::Logger.send('Bucket.chassis')
  @osd.rack_artifact(@osd.chassis)
end
chassis_bucket() click to toggle source
# File lib/ceph/crush/location/bucket.rb, line 70
def chassis_bucket
  Ceph::Crush::Location::Logger.send('Bucket.chassis_bucket')
  " chassis=#{chassis}" if @osd.knows_chassis?
end
datacenter() click to toggle source
# File lib/ceph/crush/location/bucket.rb, line 45
def datacenter
  Ceph::Crush::Location::Logger.send('Bucket.datacenter')
  @osd.root_artifact(@osd.datacenter)
end
datacenter_bucket() click to toggle source
# File lib/ceph/crush/location/bucket.rb, line 40
def datacenter_bucket
  Ceph::Crush::Location::Logger.send('Bucket.datacenter_bucket')
  " datacenter=#{datacenter}" if @osd.knows_datacenter?
end
disk_chassis() click to toggle source
# File lib/ceph/crush/location/bucket.rb, line 95
def disk_chassis
  Ceph::Crush::Location::Logger.send('Bucket.disk_chassis')
  @osd.host_artifact(@osd.disk_chassis)
end
disk_chassis_bucket() click to toggle source
# File lib/ceph/crush/location/bucket.rb, line 90
def disk_chassis_bucket
  Ceph::Crush::Location::Logger.send('Bucket.disk_chassis_bucket')
  " disk_chassis=#{disk_chassis}" if @osd.knows_disk_chassis?
end
enclosure() click to toggle source
# File lib/ceph/crush/location/bucket.rb, line 105
def enclosure
  Ceph::Crush::Location::Logger.send('Bucket.enclosure')
  @osd.disk_chassis_artifact(@osd.enclosure)
end
enclosure_bucket() click to toggle source
# File lib/ceph/crush/location/bucket.rb, line 100
def enclosure_bucket
  Ceph::Crush::Location::Logger.send('Bucket.enclosure_bucket')
  " enclosure=#{enclosure}" if @osd.knows_enclosure?
end
host() click to toggle source
# File lib/ceph/crush/location/bucket.rb, line 85
def host
  Ceph::Crush::Location::Logger.send('Bucket.host')
  @osd.chassis_artifact(@osd.hostname)
end
host_bucket() click to toggle source
# File lib/ceph/crush/location/bucket.rb, line 80
def host_bucket
  Ceph::Crush::Location::Logger.send('Bucket.host_bucket')
  " host=#{host}"
end
rack() click to toggle source
# File lib/ceph/crush/location/bucket.rb, line 65
def rack
  Ceph::Crush::Location::Logger.send('Bucket.rack')
  @osd.row_artifact(@osd.rack)
end
rack_bucket() click to toggle source
# File lib/ceph/crush/location/bucket.rb, line 60
def rack_bucket
  Ceph::Crush::Location::Logger.send('Bucket.rack_bucket')
  " rack=#{rack}" if @osd.knows_rack?
end
root_bucket() click to toggle source
# File lib/ceph/crush/location/bucket.rb, line 35
def root_bucket
  Ceph::Crush::Location::Logger.send('Bucket.root_bucket')
  "root=#{@osd.root}"
end
row() click to toggle source
# File lib/ceph/crush/location/bucket.rb, line 55
def row
  Ceph::Crush::Location::Logger.send('Bucket.row')
  @osd.datacenter_artifact(@osd.row)
end
row_bucket() click to toggle source
# File lib/ceph/crush/location/bucket.rb, line 50
def row_bucket
  Ceph::Crush::Location::Logger.send('Bucket.row_bucket')
  " row=#{row}" if @osd.knows_row?
end