Class: Aio::Module::Cmd::Maipu::ShowIpRoute
- Inherits:
-
Aio::Module::Cmd::Maipu
- Object
- Aio::Module::Cmd
- Aio::Module::Cmd::Maipu
- Aio::Module::Cmd::Maipu::ShowIpRoute
- Includes:
- Aio::Module
- Defined in:
- lib/modules/cmd/maipu/show_ip_route.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 ⇒ ShowIpRoute
constructor
A new instance of ShowIpRoute.
- #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 ⇒ ShowIpRoute
Returns a new instance of ShowIpRoute.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/modules/cmd/maipu/show_ip_route.rb', line 8 def initialize super({ :cmd_full => "show ip route", :cmd_short => "sh ip rou", :author => "Elin", :ranking => Ranking_2, :description => "This is Maipu Command# show ip route", :platform => "all", :benchmark => {} }) end |
Instance Method Details
#parse ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/modules/cmd/maipu/show_ip_route.rb', line 20 def parse cont = self.context.dup routing = {} useful[:routing] = routing cont.readline_match_block(reg_blank) {|b|b} cont.readline_match_block(reg_blank) {|b|b} cont.readline_range_if_loop(/^\w/, /^\s+/) do |cont_layer| parse_routing(cont_layer) end end |
#parse_routing(context) ⇒ Object
33 34 35 36 37 38 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 67 68 69 70 71 72 73 |
# File 'lib/modules/cmd/maipu/show_ip_route.rb', line 33 def parse_routing(context) router = nil if context[0] =~ /^C/ context.readline_match_block(/C (?<dest>.*) is directly connected, .*, (?<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, "C") block.update(route, :iface) end return end context.readline_match_block(/(?<proto>.*) (?<dest>.*) \[(?<metric>\d+)\/(?<ad>\d+)\] via (?<next_hop>.*), (?<time>.*), (?<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, :metric) block.update(route, :ad) block.update(route, :next_hop) block.update(route, :iface) end if context.size == 2 context.readline_match_block(/\[(?<metric>\d+)\/(?<ad>\d+)\] via (?<next_hop>.*), (?<time>.*), (?<iface>.*)/) do |block| route = {} useful[:routing][router][:secend] = route block.update(route, :metric) block.update(route, :ad) block.update(route, :next_hop) block.update(route, :iface) end end end |