Class: Aio::Module::Cmd::H3C::DisplayVersion

Inherits:
Aio::Module::Cmd::H3C show all
Includes:
Aio::Module
Defined in:
lib/modules/cmd/h3c/display_version.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

#initializeDisplayVersion

Returns a new instance of DisplayVersion.



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/modules/cmd/h3c/display_version.rb', line 8

def initialize
  super({
    :cmd_full 	=> "display version",
    :cmd_short	=> "dis ver",
    :author			=> "Elin",
    :description => "This is H3C Command# display version",
    :ranking		=> Ranking_1,
    :key_stand	=> true,
    :platform		=> "route",
    :benchmark	=> {
    }
  })
end

Instance Method Details

#parseObject



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
# File 'lib/modules/cmd/h3c/display_version.rb', line 22

def parse
  cont = self.context.dup
  soft_info = {}
  useful[:software] = soft_info
  cont.readline_match_block(/(?<device_type>H3C) Comware Platform Software/) do |block|
    key_stand_h3c
  end
  cont.readline_match_block(/Comware Software, Version (?<version>.*)/) do |block|
    block.update(soft_info, :version)
    key_stand_version(block[:version])

    # 按版本来确定
    case block[:version]
    when /^7\./  # 当是7.x 版本的时候,show memory 会不一样
      key_stand_template Template_3
    else
      key_stand_template Template_1
    end

  end
  cont.readline_match_block(/.*/)
  cont.readline_match_block(/H3C (?<device_model>.*) uptime is (?<uptime>.*)/) do |block|
    key_stand_h3c
    block.update(soft_info, :device_model)
    block.update(soft_info, :uptime)
    key_stand_model(block[:device_model])

    # 按设备类型来确定
    case block[:device_model]
    when /3600|8800/ # 当是S3600,S5500,S8800 的时候
      key_stand_template Template_2
    end
  end

  cont.readline_match_block_loop(/\[SubSlot (?<slot_id>\d)\](?<slot>.*)/, reg_blank) do |block|
    next if block[:slot] =~ /No/
    slot_id = block[:slot_id].to_i
    block.update_hash(soft_info, :slot, "slot_#{slot_id}", block[:slot])
  end

end