Class: Elesai::Megacli::AdpBbuCmd_aAll

Inherits:
Megacli
  • Object
show all
Defined in:
lib/elesai/megacli/_adpbbucmd_aall.rb

Instance Method Summary collapse

Methods inherited from Megacli

#adapter_line, #adapter_match, #attribute_line, #attribute_match, #exit_line, #exit_match, #on_adapter_entry, #on_adapter_exit, #on_attribute_entry, #on_attribute_exit, #on_exit_entry, #on_start_exit

Constructor Details

#initializeAdpBbuCmd_aAll

Returns a new instance of AdpBbuCmd_aAll.



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/elesai/megacli/_adpbbucmd_aall.rb', line 5

def initialize
  @megacli = {  :bbu            => { :re => /^BBU status for Adapter:\s+(?<value>\d+)/,         :method => self.method(:bbu_match)       },
                :firmwarestatus => { :re => /^BBU Firmware Status:/,                            :method => self.method(:section_match)   },
                :designinfo     => { :re => /^BBU Design Info for Adapter:\s+(?<value>\d+)/,    :method => self.method(:section_match)   },
                :properties     => { :re => /^BBU Properties for Adapter:\s+(?<value>\d+)/,     :method => self.method(:section_match)   },
                :gasgaugestatus => { :re => /^GasGuageStatus:/,                                 :method => self.method(:section_match)   },
                :capacityinfo   => { :re => /^BBU Capacity Info for Adapter:\s+(?<value>\d+)/,  :method => self.method(:section_match)   },
                :exit           => { :re => /^Exit Code: /,                                     :method => self.method(:exit_match)      },
                :attribute      => { :re => /^(?<key>[A-Za-z0-9()\s#'-.&]+)[:|=](?<value>.*)/,  :method => self.method(:attribute_match) }
  }.freeze
  @command_arguments = "-adpbbucmd -aall".freeze
  @command_output_file = "adpbbucmd_aall".freeze
end

Instance Method Details

#bbu_line(bbu, key, value) ⇒ Object

Line Handlers



70
71
72
73
# File 'lib/elesai/megacli/_adpbbucmd_aall.rb', line 70

def bbu_line(bbu,key,value)
  @log.debug "  [#{current_state}] event: bbu_line: new #{bbu.inspect}"
  bbu[key.to_sym] = value.to_i
end

#bbu_match(k, match) ⇒ Object

Regular Expression Match Handlers



55
56
57
58
59
60
61
# File 'lib/elesai/megacli/_adpbbucmd_aall.rb', line 55

def bbu_match(k,match)
  @log.debug "BBU! #{match.string}"
  key = 'id'
  value = match[:value]
  adapter_line(LSI::Adapter.new,key,value)
  bbu_line!(LSI::BBU.new,key,value)
end

#on_bbu_entry(old_state, event, *args) ⇒ Object



75
76
77
78
# File 'lib/elesai/megacli/_adpbbucmd_aall.rb', line 75

def on_bbu_entry(old_state, event, *args)
  @log.debug "        [#{current_state}] on_entry: leaving #{old_state}; args: #{args}"
  @context.open args[0]
end

#on_bbu_exit(new_state, event, *args) ⇒ Object



80
81
82
83
# File 'lib/elesai/megacli/_adpbbucmd_aall.rb', line 80

def on_bbu_exit(new_state, event, *args)
  @log.debug "      [#{current_state}] on_exit: entering #{new_state}; args: #{args}"
  @context.flash!(new_state)
end

#on_section_entry(old_state, event, *args) ⇒ Object



89
90
91
92
93
94
95
96
# File 'lib/elesai/megacli/_adpbbucmd_aall.rb', line 89

def on_section_entry(old_state, event, *args)
  @log.debug "     [#{current_state}] on_entry: leaving #{old_state}; args: #{args}"
  unless @context.current.nil?
    @context.close if Elesai::LSI::BBU::Section === @context.current
  end
  @context.current.add_section(args[0])
  @context.open(args[0])
end

#on_section_exit(new_state, event, *args) ⇒ Object



98
99
100
101
# File 'lib/elesai/megacli/_adpbbucmd_aall.rb', line 98

def on_section_exit(new_state, event, *args)
  @log.debug "      [#{current_state}] on_exit: entering #{new_state}; args: #{args}"
  @context.flash!(new_state)
end

#parse!(lsi, opts) ⇒ Object



19
20
21
22
# File 'lib/elesai/megacli/_adpbbucmd_aall.rb', line 19

def parse!(lsi,opts)
  fake = opts[:fake].nil? ? @command_arguments : File.join(opts[:fake],@command_output_file)
  super lsi, :fake => fake, :megacli => opts[:megacli]
end

#section_line(section) ⇒ Object



85
86
87
# File 'lib/elesai/megacli/_adpbbucmd_aall.rb', line 85

def section_line(section)
  @log.debug "  [#{current_state}] event: section_line: new #{section.inspect}"
end

#section_match(k, match) ⇒ Object



63
64
65
66
# File 'lib/elesai/megacli/_adpbbucmd_aall.rb', line 63

def section_match(k,match)
  @log.debug "ADPINFO_SECTION! #{k} -> #{match.string}"
  section_line!(LSI::BBU::Section.new(k))
end