Class: Ceph::Crush::Location::OSD

Inherits:
Object
  • Object
show all
Defined in:
lib/ceph/crush/location/osd.rb

Overview

This class stores metadata about this OSD

Constant Summary collapse

CEPH_OSD_ROOT_PATH =
'/var/lib/ceph/osd'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeOSD

Returns a new instance of OSD.



9
10
11
12
13
# 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

Instance Attribute Details

#clusterObject

Returns the value of attribute cluster.



7
8
9
# File 'lib/ceph/crush/location/osd.rb', line 7

def cluster
  @cluster
end

#idObject

Returns the value of attribute id.



7
8
9
# File 'lib/ceph/crush/location/osd.rb', line 7

def id
  @id
end

Instance Method Details

#chassisObject



63
64
65
66
# 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 = '') ⇒ Object



116
117
118
119
# 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

#datacenterObject



88
89
90
91
# 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 = '') ⇒ Object



101
102
103
104
# 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?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/ceph/crush/location/osd.rb', line 20

def default_root?
  !::File.exist? root_path
end

#disk_chassisObject



42
43
44
# 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 = '') ⇒ Object



125
126
127
128
# 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_pathObject



33
34
35
36
# 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

#enclosureObject



55
56
57
# File 'lib/ceph/crush/location/osd.rb', line 55

def enclosure
  ::File.read enclosure_path if knows_enclosure?
end

#enclosure_artifact(append = '') ⇒ Object



130
131
132
133
# 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_pathObject



46
47
48
49
# 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 = '') ⇒ Object



121
122
123
# File 'lib/ceph/crush/location/osd.rb', line 121

def host_artifact(append = '')
  chassis_artifact("#{hostname}_#{append}")
end

#hostnameObject



93
94
95
# File 'lib/ceph/crush/location/osd.rb', line 93

def hostname
  Socket.gethostname.strip.split('.').first
end

#knows_chassis?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/ceph/crush/location/osd.rb', line 59

def knows_chassis?
  !chassis.nil?
end

#knows_datacenter?Boolean

Returns:

  • (Boolean)


84
85
86
# File 'lib/ceph/crush/location/osd.rb', line 84

def knows_datacenter?
  !datacenter.nil?
end

#knows_disk_chassis?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/ceph/crush/location/osd.rb', line 38

def knows_disk_chassis?
  ::File.exist? disk_chassis_path
end

#knows_enclosure?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/ceph/crush/location/osd.rb', line 51

def knows_enclosure?
  ::File.exist? enclosure_path
end

#knows_rack?Boolean

Returns:

  • (Boolean)


68
69
70
# File 'lib/ceph/crush/location/osd.rb', line 68

def knows_rack?
  !rack.nil?
end

#knows_row?Boolean

Returns:

  • (Boolean)


76
77
78
# File 'lib/ceph/crush/location/osd.rb', line 76

def knows_row?
  !row.nil?
end

#osd_directoryObject



15
16
17
18
# 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

#rackObject



72
73
74
# File 'lib/ceph/crush/location/osd.rb', line 72

def rack
  @rack ||= Ceph::Crush::Location.nodeinfo['rack']
end

#rack_artifact(append = '') ⇒ Object



111
112
113
114
# 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

#rootObject



28
29
30
31
# File 'lib/ceph/crush/location/osd.rb', line 28

def root
  return 'default' if default_root?
  ::File.read root_path
end

#root_artifact(append = '') ⇒ Object



97
98
99
# File 'lib/ceph/crush/location/osd.rb', line 97

def root_artifact(append = '')
  "#{root}_#{append}"
end

#root_pathObject



24
25
26
# File 'lib/ceph/crush/location/osd.rb', line 24

def root_path
  @root_path ||= ::File.join(osd_directory, 'crush_root')
end

#rowObject



80
81
82
# File 'lib/ceph/crush/location/osd.rb', line 80

def row
  @row ||= Ceph::Crush::Location.nodeinfo['row']
end

#row_artifact(append = '') ⇒ Object



106
107
108
109
# 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