Sha256: 23eae9d0324f2dd2b57fb42408e4e7abec5253876289921eddcd65130c9c9014
Contents?: true
Size: 1.8 KB
Versions: 18
Compression:
Stored size: 1.8 KB
Contents
#coding=utf-8 require "aio/core" class Aio::Module::Cmd::H3C::DisplayIpRouting < Aio::Module::Cmd::H3C include Aio::Module def initialize super({ :cmd_full => "display ip routing-table", :cmd_short => "dis ip rout", :author => "Elin", :ranking => Ranking_2, :description => "This is H3C Command# display ip routing-table", :platform => "all", :benchmark => {} }) end def parse cont = self.context.dup routing = {} useful[:routing] = routing cont.readline_match_block(/Destinations : (?<destinations>\d+) Routes : (?<routes>\d+)/) do |block| block.update(routing, :destinations) block.update(routing, :routes) end cont.readline_match_block(//) cont.readline_match_block(/Destination\/Mask Proto Pre Cost NextHop Interface/) cont.readline_match_block(//) loop do cont.readline_range_if(/^\d+/, /^\s+/) do |cont_layer| parse_routing(cont_layer) end end end def parse_routing(context) router = nil context.readline_match_block(/(?<dest>[^\s]*) (?<proto>[^\s]*) (?<pre>\d+) (?<cost>\d+) (?<next_hop>.*) (?<iface>.*)/) do |block| route = {} router = block[:dest] useful[:routing][router] = {} useful[:routing][router][:first] = route block.update(useful[:routing][router], :dest) block.update(route, :proto) block.update(route, :pre) block.update(route, :cost) block.update(route, :next_hop) block.update(route, :iface) end if context.size == 2 context.readline_match_block(/ (?<proto>.*) (?<pre>\d+) (?<cost>\d+) (?<next_hop>.*) (?<iface>.*)/) do |block| route = {} router = block[:dest] useful[:routing][router][:secend] = route block.update(route, :proto) block.update(route, :pre) block.update(route, :cost) block.update(route, :next_hop) block.update(route, :iface) end end end end
Version data entries
18 entries across 18 versions & 1 rubygems