Class: DiskHandler::Partition
- Inherits:
-
Object
- Object
- DiskHandler::Partition
- Defined in:
- lib/disk_reporter/disk_handler.rb
Constant Summary collapse
- BLKID_REGEX =
%r[/dev/.*:\sUUID="(.{36})"\s(UUID_SUB="(.{36})"\s)*TYPE="(.*)"\s]
Instance Attribute Summary collapse
-
#disk ⇒ Object
Returns the value of attribute disk.
-
#fs ⇒ Object
Returns the value of attribute fs.
-
#mounted ⇒ Object
Returns the value of attribute mounted.
-
#name ⇒ Object
Returns the value of attribute name.
-
#type ⇒ Object
Returns the value of attribute type.
-
#uuid ⇒ Object
Returns the value of attribute uuid.
-
#uuid_sub ⇒ Object
Returns the value of attribute uuid_sub.
Instance Method Summary collapse
- #blkid ⇒ Object
- #fs? ⇒ Boolean
-
#initialize(disk, name) ⇒ Partition
constructor
A new instance of Partition.
- #is_ceph? ⇒ Boolean
- #mounted? ⇒ Boolean
- #should_have_ceph? ⇒ Boolean
Constructor Details
#initialize(disk, name) ⇒ Partition
Returns a new instance of Partition.
85 86 87 88 89 |
# File 'lib/disk_reporter/disk_handler.rb', line 85 def initialize(disk, name) self.disk = disk self.name = name.gsub("\n", "") blkid end |
Instance Attribute Details
#disk ⇒ Object
Returns the value of attribute disk.
83 84 85 |
# File 'lib/disk_reporter/disk_handler.rb', line 83 def disk @disk end |
#fs ⇒ Object
Returns the value of attribute fs.
83 84 85 |
# File 'lib/disk_reporter/disk_handler.rb', line 83 def fs @fs end |
#mounted ⇒ Object
Returns the value of attribute mounted.
83 84 85 |
# File 'lib/disk_reporter/disk_handler.rb', line 83 def mounted @mounted end |
#name ⇒ Object
Returns the value of attribute name.
83 84 85 |
# File 'lib/disk_reporter/disk_handler.rb', line 83 def name @name end |
#type ⇒ Object
Returns the value of attribute type.
83 84 85 |
# File 'lib/disk_reporter/disk_handler.rb', line 83 def type @type end |
#uuid ⇒ Object
Returns the value of attribute uuid.
83 84 85 |
# File 'lib/disk_reporter/disk_handler.rb', line 83 def uuid @uuid end |
#uuid_sub ⇒ Object
Returns the value of attribute uuid_sub.
83 84 85 |
# File 'lib/disk_reporter/disk_handler.rb', line 83 def uuid_sub @uuid_sub end |
Instance Method Details
#blkid ⇒ Object
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# 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? ⇒ Boolean
103 104 105 |
# File 'lib/disk_reporter/disk_handler.rb', line 103 def fs? !!fs end |
#is_ceph? ⇒ Boolean
91 92 93 |
# File 'lib/disk_reporter/disk_handler.rb', line 91 def is_ceph? mounted? && mounted.match(%r{/var/lib/ceph/}) end |
#mounted? ⇒ Boolean
99 100 101 |
# File 'lib/disk_reporter/disk_handler.rb', line 99 def mounted? !!mounted end |
#should_have_ceph? ⇒ Boolean
95 96 97 |
# File 'lib/disk_reporter/disk_handler.rb', line 95 def should_have_ceph? true end |