Method: Racadm.parse_racadm

Defined in:
lib/puppet_x/racadm/racadm.rb

.parse_racadm(reply) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/puppet_x/racadm/racadm.rb', line 29

def self.parse_racadm(reply)
  parsed = {}
  reply.each_line do |line|
    sub_line_array = line.split('=')
    if sub_line_array.length > 1
      if line.start_with? '[Key='
        parsed[:Key] = sub_line_array[1].strip[0..-2]
      elsif sub_line_array[0].end_with? '[Key'
        subkey = sub_line_array.slice!(0).strip.chomp(' [Key')
        subvalue = '[Key=' + sub_line_array.join('=').strip
        parsed[subkey] = subvalue
      elsif !sub_line_array[0].start_with? '!!'
        subkey = sub_line_array.slice!(0).strip.gsub(%r{\s+}, '')
        subvalue = sub_line_array.join('=').strip
        parsed[subkey] = subvalue
      end
    end
  end
  parsed
end