#coding=utf-8 require "aio/core" class Aio::Module::Cmd::Cisco::ShowVersion < Aio::Module::Cmd::Cisco include Aio::Module def initialize super({ :cmd_full => "show version", :cmd_short => "sh ver", :author => "Elin", :description => "This is Cisco Command# show version", :ranking => Ranking_1, :key_stand => true, :platform => "all", :benchmark => { :register => ["==", "0x2102", "0xF", "0x1", "0x10F"], }, :license => Aio::AIO_LICENSE}) end def parse cont = self.context.dup soft_info = {} useful[:software] = soft_info cont.readline_match_block(/Cisco (?.*)/) do |block| key_stand_cisco case block[:info] when /Adaptive Security Appliance/ ver = /Software Version (?.*)/.match(block[:info]) block.update(soft_info, :version, ver[:version]) key_stand_version(ver[:version]) parse_asa(cont, soft_info) else parse_def(cont, soft_info) end end end # ASA 系列 def parse_asa(cont, soft_info) cont.readline_match_block(/System image file is "(?)"/) do |block| block.update(soft_info, :soft_image) end cont.readline_match_block(/up (?.*)/) do |block| block.update(soft_info, :uptime) end cont.readline_match_block(/failover cluster up (?.*)/) do |block| block.update(soft_info, :uptime_failover) end cont.readline_match_block(/Hardware: (?.[^,]+),/) do |block| block.update(soft_info, :device_model) key_stand_model(block[:device_model]) key_stand_template Template_3 # 当是asa时使用模板3 end cont.readline_match_block(/Serial Number: (?.*)/) do |block| block.update(soft_info, :sn) end end # 包括了一般的以及 7600 系列 def parse_def(cont, soft_info) cont.readline_match_block(/Version (?.*),/) do |block| block.update(soft_info, :version) key_stand_version(block[:version]) end cont.readline_match_block(/(?.*) uptime is (?.*)/) do |block| block.update(soft_info, :device_name) block.update(soft_info, :uptime) end cont.readline_match_block(/System image file is "(?.*)"/) do |block| block.update(soft_info, :soft_image) end cont.readline_match_block(//) cont.readline_match_block(/^[Cc]isco (?[^\s]+)/) do |block| block.update(soft_info, :device_model) key_stand_model(block[:device_model]) case block[:device_model] when /76|65/ # 当是7600的时候,使用模板2 key_stand_template Template_2 else key_stand_template Template_1 end end cont.readline_match_block(/Processor board ID (?.*)/) do |block| block.update(soft_info, :board_id) end cont.readline_match_block(/Configuration register is (?.*)/) do |block| block.warning_serious(soft_info, :register, self) end end end