Class: Aio::Module::Cmd::Maipu::ShowSystemModuleBrief

Inherits:
Aio::Module::Cmd::Maipu show all
Includes:
Aio::Module
Defined in:
lib/modules/cmd/maipu/show_system_module_brief.rb

Instance Attribute Summary

Attributes inherited from Aio::Module::Cmd

#cmd_info, #context, #device_info, #ext_info, #useful, #warning_klass

Instance Method Summary collapse

Methods inherited from Aio::Module::Cmd

#author, #benchmark, #clear_useful, #cmd_full, #cmd_short, #description, #division, #key_stand, #license, #platform, #ranking, #set_defaults, #type

Methods included from Ui::Verbose

#clear_line, #print_error, #print_good, #progress_bar

Constructor Details

#initializeShowSystemModuleBrief

Returns a new instance of ShowSystemModuleBrief.



8
9
10
11
12
13
14
15
16
17
18
# 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

Instance Method Details

#parseObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# 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