Class: Ceph::Crush::Location::OSD
- Inherits:
-
Object
- Object
- Ceph::Crush::Location::OSD
- 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
-
#cluster ⇒ Object
Returns the value of attribute cluster.
-
#id ⇒ Object
Returns the value of attribute id.
Instance Method Summary collapse
- #chassis ⇒ Object
- #chassis_artifact(append = '') ⇒ Object
- #datacenter ⇒ Object
- #datacenter_artifact(append = '') ⇒ Object
- #default_root? ⇒ Boolean
- #disk_chassis ⇒ Object
- #disk_chassis_artifact(append = '') ⇒ Object
- #disk_chassis_path ⇒ Object
- #enclosure ⇒ Object
- #enclosure_artifact(append = '') ⇒ Object
- #enclosure_path ⇒ Object
- #host_artifact(append = '') ⇒ Object
- #hostname ⇒ Object
-
#initialize ⇒ OSD
constructor
A new instance of OSD.
- #knows_chassis? ⇒ Boolean
- #knows_datacenter? ⇒ Boolean
- #knows_disk_chassis? ⇒ Boolean
- #knows_enclosure? ⇒ Boolean
- #knows_rack? ⇒ Boolean
- #knows_row? ⇒ Boolean
- #osd_directory ⇒ Object
- #rack ⇒ Object
- #rack_artifact(append = '') ⇒ Object
- #root ⇒ Object
- #root_artifact(append = '') ⇒ Object
- #root_path ⇒ Object
- #row ⇒ Object
- #row_artifact(append = '') ⇒ Object
Constructor Details
Instance Attribute Details
#cluster ⇒ Object
Returns the value of attribute cluster.
7 8 9 |
# File 'lib/ceph/crush/location/osd.rb', line 7 def cluster @cluster end |
#id ⇒ Object
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
#chassis ⇒ Object
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 |
#datacenter ⇒ Object
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
20 21 22 |
# File 'lib/ceph/crush/location/osd.rb', line 20 def default_root? !::File.exist? root_path end |
#disk_chassis ⇒ Object
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_path ⇒ Object
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 |
#enclosure ⇒ Object
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_path ⇒ Object
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 |
#hostname ⇒ Object
93 94 95 |
# File 'lib/ceph/crush/location/osd.rb', line 93 def hostname Socket.gethostname.strip.split('.').first end |
#knows_chassis? ⇒ Boolean
59 60 61 |
# File 'lib/ceph/crush/location/osd.rb', line 59 def knows_chassis? !chassis.nil? end |
#knows_datacenter? ⇒ Boolean
84 85 86 |
# File 'lib/ceph/crush/location/osd.rb', line 84 def knows_datacenter? !datacenter.nil? end |
#knows_disk_chassis? ⇒ 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
51 52 53 |
# File 'lib/ceph/crush/location/osd.rb', line 51 def knows_enclosure? ::File.exist? enclosure_path end |
#knows_rack? ⇒ Boolean
68 69 70 |
# File 'lib/ceph/crush/location/osd.rb', line 68 def knows_rack? !rack.nil? end |
#knows_row? ⇒ Boolean
76 77 78 |
# File 'lib/ceph/crush/location/osd.rb', line 76 def knows_row? !row.nil? end |
#osd_directory ⇒ Object
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 |
#rack ⇒ Object
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 |
#root ⇒ Object
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_path ⇒ Object
24 25 26 |
# File 'lib/ceph/crush/location/osd.rb', line 24 def root_path @root_path ||= ::File.join(osd_directory, 'crush_root') end |
#row ⇒ Object
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 |