Sha256: 3802be3798bc663b0c57924426cfd2f1b06b16e67d1fdc376818886888f192b0

Contents?: true

Size: 1.87 KB

Versions: 2

Compression:

Stored size: 1.87 KB

Contents

#coding=utf-8

require "aio/core"

class Aio::Module::Cmd::Maipu::ShowSystemModuleBrief < Aio::Module::Cmd::Maipu
  include Aio::Module

  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

  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
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
aio_elin-1.1.8 lib/modules/cmd/maipu/show_system_module_brief.rb
aio_elin-1.1.7 lib/modules/cmd/maipu/show_system_module_brief.rb