class Aio::Module::Cmd::Maipu::ShowSystemModuleBrief

Public Class Methods

new() click to toggle source
Calls superclass method Aio::Module::Cmd::new
# File lib/modules/cmd/maipu/show_system_module_brief.rb, line 8
def initialize
  super({
    :cmd_full         => "show system module brief",
    :cmd_short        => "sh sys mod b",
    :author                   => "Elin",
    :description      => "This is Maipu Command# show system module brief",
    :ranking          => Ranking_1,
    :platform         => "all",
    :benchmark        => {}
  })
end

Public Instance Methods

parse() click to toggle source
# File lib/modules/cmd/maipu/show_system_module_brief.rb, line 20
def parse
  cont = self.context.dup
  useful[:module] = {}
  all_module = useful[:module]

  cont.readline_match_block(/-------------------/) {|b|b}
  cont.readline_match_block_loop(/.*/, reg_blank) do |block|
    bl = block[0].to_s
    arr = bl.split(' ')
    # 当是7个的时候,说明是
    # Mpu 0           online Start Ok    SM3120-28TC(V1)   ******************
    if arr.size == 7
      md     = arr.shift + " " + arr.shift
      online = arr.shift
      status = arr.shift + " " + arr.shift
      name   = arr.shift
      sn     = arr.shift

      one_module = {}
      all_module[md] = one_module

      block.update(one_module, :module, md)
      block.update(one_module, :online, online)
      block.update(one_module, :status, status)
      block.update(one_module, :name,   name)
      block.update(one_module, :sn,     sn)

    # Power 1         online Normal      /
    elsif
      md     = arr.shift + " " + arr.shift
      online = arr.shift
      status = arr.shift
      name   = arr.shift
      sn     = arr.shift unless arr.empty?
      sn     ||= '/'

      one_module = {}
      all_module[md] = one_module

      block.update(one_module, :module, md)
      block.update(one_module, :online, online)
      block.update(one_module, :status, status)
      block.update(one_module, :name,   name)
      block.update(one_module, :sn,     sn)
    end

  end
end