Class: Aio::Module::Cmd::H3C::DisplayIpRouting
- Inherits:
-
Aio::Module::Cmd::H3C
- Object
- Aio::Module::Cmd
- Aio::Module::Cmd::H3C
- Aio::Module::Cmd::H3C::DisplayIpRouting
- Includes:
- Aio::Module
- Defined in:
- lib/modules/cmd/h3c/display_ip_routing.rb
Instance Attribute Summary
Attributes inherited from Aio::Module::Cmd
#cmd_info, #context, #device_info, #ext_info, #useful, #warning_klass
Instance Method Summary collapse
-
#initialize ⇒ DisplayIpRouting
constructor
A new instance of DisplayIpRouting.
- #parse ⇒ Object
- #parse_routing(context) ⇒ Object
Methods inherited from Aio::Module::Cmd
#author, #benchmark, #clear_useful, #cmd_full, #cmd_short, #description, #division, #key_stand, #license, #platform, #ranking, #set_defaults, #type
Methods included from Ui::Verbose
#clear_line, #print_error, #print_good, #progress_bar
Constructor Details
#initialize ⇒ DisplayIpRouting
Returns a new instance of DisplayIpRouting.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/modules/cmd/h3c/display_ip_routing.rb', line 8 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 |
Instance Method Details
#parse ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/modules/cmd/h3c/display_ip_routing.rb', line 20 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 |
#parse_routing(context) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/modules/cmd/h3c/display_ip_routing.rb', line 39 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 |