#coding=utf-8 require "aio/core" class Aio::Module::Cmd::H3C::DisplayVrrpVerbose < Aio::Module::Cmd::H3C include Aio::Module def initialize super({ :cmd_full => "display vrrp verbose", :cmd_short => "dis vrrp ver", :author => "Elin", :description => "This is H3C Command# display vrrp verbose", :ranking => Ranking_1, :platform => "all", :benchmark => {}, }) end def parse cont = self.context.dup vrrp = {} useful[:vrrp] = vrrp cont.readline_match_block(/Run Mode : (?.*)/) do |block| block.update(vrrp, :run_mode) end cont.readline_match_block(/Run Method : (?.*)/) do |block| block.update(vrrp, :run_method) end cont.readline_match_block(/Total number of virtual routers : (?\d+)/) do |block| block.update(vrrp, :total_number_vrrp) end cont.readline_range(/Interface/, /Interface/) do |cont_layer| parse_vrrp(cont_layer) end end def parse_vrrp(cont) vrrp = {} useful[:vrrp][:vrid] = {} iface_id = nil case device_template when Template_1 cont.readline_match_block(/Interface (?.*)/) do |block| iface_id = block[:iface_id] end when Template_2 cont.readline_match_block(/Interface : (?.[^\s]+)/) do |block| iface_id = block[:iface_id] end end cont.readline_match_block(/VRID : (?\d+)/) do |block| vrid = block[:vrid] useful[:vrrp][:vrid][vrid] = vrrp block.update(vrrp, :interface, iface_id) block.update(vrrp, :vrid) end cont.readline_match_block(/Admin Status : (?.*) State : (?.*)/) do |block| block.update(vrrp, :status) block.update(vrrp, :state) end cont.readline_match_block(/Config Pri : (?.*) Running Pri : (?.*)/) do |block| block.update(vrrp, :config_pri) block.update(vrrp, :running_pri) end cont.readline_match_block(/Preempt Mode : (?.*) Delay Time : (?\d+)/) do |block| block.update(vrrp, :preempt_mode) block.update(vrrp, :delay_time) end cont.readline_match_block(/Auth Type : (?.*)/) do |block| block.update(vrrp, :auth_type) end cont.readline_match_block(/Virtual IP : (?.*)/) do |block| block.update(vrrp, :virtual_ip) end cont.readline_match_block(/Virtual MAC : (?.*)/) do |block| block.update(vrrp, :virtual_mac) end cont.readline_match_block(/Master IP : (?.*)/) do |block| block.update(vrrp, :master_ip) end end end