class RARE < Oxidized::Model prompt /([\w.@()-]+#\s?)$/ comment '! ' cmd :all do |cfg| cfg end cmd :secret do |cfg| cfg end cmd 'show platform' do |cfg| cfg.gsub! /^uptime:.*?$/, '' comment "---------- show platform" comments = [] comments << cfg.lines.first lines = cfg.lines lines.each_with_index do |line, i| if line !~ /^mem:|^uptime:/ comments << line.strip! end end comments << "\n" comment comments.join "\n" end cmd 'show interfaces description' do |cfg| comment "---------- show interface description" comment cfg end cmd 'show running-config hide' do |cfg| comment "---------- show startup-config" cfg = cfg.each_line.to_a[0..-1] cfg = cfg.reject { |line| line.match /^ntp clock-period / }.join cfg.gsub! /^Current configuration : [^\n]*\n/, '' cfg.gsub! /^ tunnel mpls traffic-eng bandwidth[^\n]*\n*( (?: [^\n]*\n*)* tunnel mpls traffic-eng auto-bw)/mx, '\1' cfg end cfg :telnet do username /^Username:/i password /^Password:/i end cfg :telnet, :ssh do # preferred way to handle additional passwords post_login do if vars(:enable) == true cmd "enable" elsif vars(:enable) cmd "enable", /^[pP]assword:/ cmd vars(:enable) end end post_login 'terminal length 0' post_login 'terminal width 0' pre_logout 'exit' end end