class Aoscx < Oxidized::Model using Refinements # previous command is repeated followed by "\eE", which sometimes ends up on last line # ssh switches prompt may start with \r, followed by the prompt itself, regex ([\w\s.-]+[#>] ), which ends the line # telnet switchs may start with various vt100 control characters, regex (\e\[24;[0-9][hH]), follwed by the prompt, followed # by at least 3 other vt100 characters prompt /(^\r|\e\[24;[0-9][hH])?([\w\s.-]+[#>] )($|(\e\[24;[0-9][0-9]?[hH]){3})/ comment '! ' # replace next line control sequence with a new line expect /(\e\[1M\e\[\??\d+(;\d+)*[A-Za-z]\e\[1L)|(\eE)/ do |data, re| data.gsub re, "\n" end # replace all used vt100 control sequences expect /\e\[\??\d+(;\d+)*[A-Za-z]/ do |data, re| data.gsub re, '' end expect /Press any key to continue(\e\[\??\d+(;\d+)*[A-Za-z])*$/ do send ' ' "" end expect /Enter switch number/ do send "\n" "" end cmd :all do |cfg| cfg = cfg.cut_both cfg = cfg.gsub /^\r/, '' # Additional filtering for elder switches sending vt100 control chars via telnet cfg.gsub! /\e\[\??\d+(;\d+)*[A-Za-z]/, '' # Additional filtering for power usage reporting which obviously changes over time cfg.gsub! /^(.*AC [0-9]{3}V\/?([0-9]{3}V)?) *([0-9]{1,3}) (.*)/, '\\1 \\4' cfg end cmd :secret do |cfg| cfg.gsub! /^(snmp-server community) \S+(.*)/, '\\1