Class: Aio::Module::Cmd::Cisco::ShowIpInterfaceBrief
- Inherits:
-
Aio::Module::Cmd::Cisco
- Object
- Aio::Module::Cmd
- Aio::Module::Cmd::Cisco
- Aio::Module::Cmd::Cisco::ShowIpInterfaceBrief
- Includes:
- Aio::Module
- Defined in:
- lib/modules/cmd/cisco/show_ip_interface_brief.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 ⇒ ShowIpInterfaceBrief
constructor
A new instance of ShowIpInterfaceBrief.
- #parse ⇒ 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 ⇒ ShowIpInterfaceBrief
Returns a new instance of ShowIpInterfaceBrief.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/modules/cmd/cisco/show_ip_interface_brief.rb', line 8 def initialize super({ :cmd_full => "show ip interface brief", :cmd_short => "sh ip int b", :author => "Elin", :description => "This is Cisco Command# show ip interface brief", :ranking => Ranking_1, :platform => RS, :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 38 39 40 |
# File 'lib/modules/cmd/cisco/show_ip_interface_brief.rb', line 20 def parse context = self.context.dup useful[:interface_brief] = {} context.readline_match_block(/Interface IP-Address OK\? Method Status Protocol/) {|b|b} context.readline_match_block_loop(/(?<interface_id>[^\s]+) (?<ip>[^\s]+) (?<ok>[^\s]+) (?<method>[^\s]+) (?<status>(?:administratively\s)?[^\s]+) (?<protocol>[^\s]+)/, reg_blank) do |block| iface = {} iface_id = block[:interface_id] useful[:interface_brief][iface_id.to_sym] = iface block.update(iface, :interface_id) block.update(iface, :ip) block.update(iface, :ok) block.update(iface, :method) block.update(iface, :status) # 当状态是起来的,但是协议为Down,则纳入警告 if (block[:status] =~ /up/) and !(block[:protocol] =~ /up/) block.warning_serious(iface, :protocol, self, {:force => true}) else block.warning_serious(iface, :protocol, self, {:force => false}) end end end |