Class: Lvm2MdParser
- Inherits:
-
Object
- Object
- Lvm2MdParser
- Defined in:
- lib/VolumeManager/LVM/parser.rb
Constant Summary collapse
- HASH_START =
'{'
- HASH_END =
'}'
- ARRAY_START =
'['
- ARRAY_END =
']'
- STRING_START =
'"'
- STRING_END =
'"'
Instance Attribute Summary collapse
-
#vgName ⇒ Object
readonly
Returns the value of attribute vgName.
Class Method Summary collapse
-
.dumpMetadata(md) ⇒ Object
def parse.
Instance Method Summary collapse
-
#initialize(mdStr, pvHdrs) ⇒ Lvm2MdParser
constructor
A new instance of Lvm2MdParser.
-
#parse ⇒ Object
def initialize.
Constructor Details
#initialize(mdStr, pvHdrs) ⇒ Lvm2MdParser
Returns a new instance of Lvm2MdParser.
13 14 15 16 17 |
# File 'lib/VolumeManager/LVM/parser.rb', line 13 def initialize(mdStr, pvHdrs) @pvHdrs = pvHdrs # PV headers hashed by UUID @mda = mdStr.gsub(/#.*$/, "").gsub("[", "[ ").gsub("]", " ]").gsub('"', ' " ').delete("=,").gsub(/\s+/, " ").split(' ') @vgName = @mda.shift end |
Instance Attribute Details
#vgName ⇒ Object (readonly)
Returns the value of attribute vgName.
11 12 13 |
# File 'lib/VolumeManager/LVM/parser.rb', line 11 def vgName @vgName end |
Class Method Details
.dumpMetadata(md) ⇒ Object
def parse
27 28 29 30 31 32 33 34 35 |
# File 'lib/VolumeManager/LVM/parser.rb', line 27 def self.dumpMetadata(md) level = 0 md.lines do |line| line.strip! level -= 1 if line[0, 1] == HASH_END || line[0, 1] == ARRAY_END $log.debug((level > 0 ? " " * level : "") + line) level += 1 if line[-1, 1] == HASH_START || line[-1, 1] == ARRAY_START end end |
Instance Method Details
#parse ⇒ Object
def initialize
19 20 21 22 23 24 25 |
# File 'lib/VolumeManager/LVM/parser.rb', line 19 def parse vgHash = {} parseObj(vgHash, @vgName) vg = vgHash[@vgName] getVgObj(@vgName, vg) end |