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.
90 91 92 93 94 |
# File 'lib/disk_reporter/disk_handler.rb', line 90 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.
88 89 90 |
# File 'lib/disk_reporter/disk_handler.rb', line 88 def disk @disk end |
#fs ⇒ Object
Returns the value of attribute fs.
88 89 90 |
# File 'lib/disk_reporter/disk_handler.rb', line 88 def fs @fs end |
#mounted ⇒ Object
Returns the value of attribute mounted.
88 89 90 |
# File 'lib/disk_reporter/disk_handler.rb', line 88 def mounted @mounted end |
#name ⇒ Object
Returns the value of attribute name.
88 89 90 |
# File 'lib/disk_reporter/disk_handler.rb', line 88 def name @name end |
#type ⇒ Object
Returns the value of attribute type.
88 89 90 |
# File 'lib/disk_reporter/disk_handler.rb', line 88 def type @type end |
#uuid ⇒ Object
Returns the value of attribute uuid.
88 89 90 |
# File 'lib/disk_reporter/disk_handler.rb', line 88 def uuid @uuid end |
#uuid_sub ⇒ Object
Returns the value of attribute uuid_sub.
88 89 90 |
# File 'lib/disk_reporter/disk_handler.rb', line 88 def uuid_sub @uuid_sub end |
Instance Method Details
#blkid ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/disk_reporter/disk_handler.rb', line 112 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
108 109 110 |
# File 'lib/disk_reporter/disk_handler.rb', line 108 def fs? !!fs end |
#is_ceph? ⇒ Boolean
96 97 98 |
# File 'lib/disk_reporter/disk_handler.rb', line 96 def is_ceph? mounted? && mounted.match(%r{/var/lib/ceph/}) end |
#mounted? ⇒ Boolean
104 105 106 |
# File 'lib/disk_reporter/disk_handler.rb', line 104 def mounted? !!mounted end |
#should_have_ceph? ⇒ Boolean
100 101 102 |
# File 'lib/disk_reporter/disk_handler.rb', line 100 def should_have_ceph? true end |