lib/modules/cmd/cisco/show_version.rb in aio_elin-0.0.1 vs lib/modules/cmd/cisco/show_version.rb in aio_elin-1.0.0

- old
+ new

@@ -1,97 +1,97 @@ #coding=utf-8 require "aio/core" class Aio::Module::Cmd::Cisco::ShowVersion < Aio::Module::Cmd::Cisco - include Aio::Module + 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 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 + def parse + cont = self.context.dup + soft_info = {} + useful[:software] = soft_info - cont.readline_match_block(/Cisco (?<info>.*)/) do |block| - key_stand_cisco - case block[:info] - when /Adaptive Security Appliance/ - ver = /Software Version (?<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 + cont.readline_match_block(/Cisco (?<info>.*)/) do |block| + key_stand_cisco + case block[:info] + when /Adaptive Security Appliance/ + ver = /Software Version (?<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 "(?<soft_image>)"/) do |block| - block.update(soft_info, :soft_image) - end - cont.readline_match_block(/up (?<uptime>.*)/) do |block| - block.update(soft_info, :uptime) - end - cont.readline_match_block(/failover cluster up (?<uptime_failover>.*)/) do |block| - block.update(soft_info, :uptime_failover) - end - cont.readline_match_block(/Hardware: (?<device_model>.[^,]+),/) 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: (?<sn>.*)/) do |block| - block.update(soft_info, :sn) - end - end + # ASA 系列 + def parse_asa(cont, soft_info) + cont.readline_match_block(/System image file is "(?<soft_image>)"/) do |block| + block.update(soft_info, :soft_image) + end + cont.readline_match_block(/up (?<uptime>.*)/) do |block| + block.update(soft_info, :uptime) + end + cont.readline_match_block(/failover cluster up (?<uptime_failover>.*)/) do |block| + block.update(soft_info, :uptime_failover) + end + cont.readline_match_block(/Hardware: (?<device_model>.[^,]+),/) 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: (?<sn>.*)/) do |block| + block.update(soft_info, :sn) + end + end - # 包括了一般的以及 7600 系列 - def parse_def(cont, soft_info) - cont.readline_match_block(/Version (?<version>.*),/) do |block| - block.update(soft_info, :version) - key_stand_version(block[:version]) - end - cont.readline_match_block(/(?<device_name>.*) uptime is (?<uptime>.*)/) do |block| - block.update(soft_info, :device_name) - block.update(soft_info, :uptime) - end - cont.readline_match_block(/System image file is "(?<soft_image>.*)"/) do |block| - block.update(soft_info, :soft_image) - end - cont.readline_match_block(//) - cont.readline_match_block(/^[Cc]isco (?<device_model>[^\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 (?<board_id>.*)/) do |block| - block.update(soft_info, :board_id) - end - cont.readline_match_block(/Configuration register is (?<register>.*)/) do |block| - block.warning_serious(soft_info, :register, self) - end - end + # 包括了一般的以及 7600 系列 + def parse_def(cont, soft_info) + cont.readline_match_block(/Version (?<version>.*),/) do |block| + block.update(soft_info, :version) + key_stand_version(block[:version]) + end + cont.readline_match_block(/(?<device_name>.*) uptime is (?<uptime>.*)/) do |block| + block.update(soft_info, :device_name) + block.update(soft_info, :uptime) + end + cont.readline_match_block(/System image file is "(?<soft_image>.*)"/) do |block| + block.update(soft_info, :soft_image) + end + cont.readline_match_block(//) + cont.readline_match_block(/^[Cc]isco (?<device_model>[^\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 (?<board_id>.*)/) do |block| + block.update(soft_info, :board_id) + end + cont.readline_match_block(/Configuration register is (?<register>.*)/) do |block| + block.warning_serious(soft_info, :register, self) + end + end end - +