class AOSW < Oxidized::Model # AOSW Aruba Wireless # Used in Alcatel OAW-4750 WLAN controller # Also Dell controllers comment '# ' prompt /^\(?.+\)?\s?[#>]/ cmd :all do |cfg| cfg.each_line.to_a[1..-2].join end cmd :secret do |cfg| cfg.gsub!(/enable secret (\S+)$/, 'enable secret ') cfg.gsub!(/PRE-SHARE (\S+)$/, 'PRE-SHARE ') cfg.gsub!(/ipsec (\S+)$/, 'ipsec ') cfg.gsub!(/community (\S+)$/, 'community ') cfg.gsub!(/ sha (\S+)/, ' sha ') cfg.gsub!(/ des (\S+)/, ' des ') cfg.gsub!(/mobility-manager (\S+) user (\S+) (\S+)/, 'mobility-manager \1 user \2 ') cfg.gsub!(/mgmt-user (\S+) (root|guest\-provisioning|network\-operations|read\-only|location\-api\-mgmt) (\S+)$/, 'mgmt-user \1 \2 ') #MAS & Wireless Controler cfg.gsub!(/mgmt-user (\S+) (\S+)( (read\-only|guest\-mgmt))?$/, 'mgmt-user \1 \3') #IAP #MAS format: mgmt-user #IAP format: mgmt-user #IAP format: mgmt-user cfg.gsub!(/key (\S+)$/, 'key ') cfg.gsub!(/wpa-passphrase (\S+)$/, 'wpa-passphrase ') cfg.gsub!(/bkup-passwords (\S+)$/, 'bkup-passwords ') cfg.gsub!(/user (\S+) (\S+) (\S+)$/, 'user \1 \3') cfg.gsub!(/virtual-controller-key (\S+)$/, 'virtual-controller-key ') cfg end cmd 'show version' do |cfg| cfg = cfg.each_line.select { |line| not line.match /(Switch|AP) uptime/i } rstrip_cfg comment cfg.join end cmd 'show inventory' do |cfg| cfg = "" if cfg.match /(Invalid input detected at '\^' marker|Parse error)/ #Don't show for unsupported devices rstrip_cfg clean cfg end cmd 'show slots' do |cfg| cfg = "" if cfg.match /(Invalid input detected at '\^' marker|Parse error)/ #Don't show for unsupported devices rstrip_cfg comment cfg end cmd 'show license' do |cfg| cfg = "" if cfg.match /(Invalid input detected at '\^' marker|Parse error)/ #Don't show for unsupported devices rstrip_cfg comment cfg end cmd 'show running-config' do |cfg| out = [] cfg.each_line do |line| next if line.match /^controller config \d+$/ next if line.match /^Building Configuration/ out << line.strip end out = out.join "\n" out << "\n" end cfg :telnet do username /^User:\s*/ password /^Password:\s*/ end cfg :telnet, :ssh do if vars :enable post_login do send "enable\n" cmd vars(:enable) end end post_login 'no paging' post_login 'encrypt disable' if vars :enable pre_logout 'exit' end pre_logout 'exit' end def rstrip_cfg cfg out = [] cfg.each_line do |line| out << line.rstrip end out = out.join "\n" out << "\n" end def clean cfg out = [] cfg.each_line do |line| # drop the temperature, fan speed and voltage, which change each run next if line.match /Output \d Config/i next if line.match /(Tachometers|Temperatures|Voltages)/ next if line.match /((Card|CPU) Temperature|Chassis Fan|VMON1[0-9])/ next if line.match /[0-9]+\s+(RPMS?|m?V|C)/i out << line.strip end out = comment out.join "\n" out << "\n" end end