Class: Aio::Module::Cmd::Cisco::ShowInv
- Inherits:
-
Aio::Module::Cmd::Cisco
- Object
- Aio::Module::Cmd
- Aio::Module::Cmd::Cisco
- Aio::Module::Cmd::Cisco::ShowInv
- Includes:
- Aio::Module
- Defined in:
- lib/modules/cmd/cisco/show_inv.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 ⇒ ShowInv
constructor
A new instance of ShowInv.
- #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 ⇒ ShowInv
Returns a new instance of ShowInv.
8 9 10 11 12 13 14 15 16 |
# File 'lib/modules/cmd/cisco/show_inv.rb', line 8 def initialize super({ :cmd_full => "show inventory", :cmd_short => "sh inv", :author => "Elin", :description => "This is Cisco Command# show inventory", :platform => "all", }) end |
Instance Method Details
#parse ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/modules/cmd/cisco/show_inv.rb', line 18 def parse context = self.context.dup inv_info = {} useful[:inventory] = inv_info context.readline_range_loop(/NAME:/, reg_blank) do |cont| slot_info = {} name = "" description = "" cont.readline_match_block(/NAME: "(?<name>.*)", DESCR: "(?<description>.*)"/) do |block| name = block[:name] description = block[:description] end cont.readline_match_block(/PID: (?<pid>[^\s]+).*SN: (?<sn>[^\s]+)/) do |block| sn = block[:sn] inv_info[sn.to_sym] = slot_info block.update(slot_info, :name, name) block.update(slot_info, :description, description) block.update(slot_info, :pid) block.update(slot_info, :sn) end end end |