summaryrefslogtreecommitdiff
path: root/lib/oxidized/model/ios.rb
diff options
context:
space:
mode:
authorSaku Ytti <saku@ytti.fi>2013-05-01 13:45:02 +0300
committerSaku Ytti <saku@ytti.fi>2013-05-01 14:06:44 +0300
commitc252a589b6b0274a17bfe40db3fd57ebeea3beb8 (patch)
tree0115a10db0f37506e72aaf4a873aeea93734f6ab /lib/oxidized/model/ios.rb
parent387b725fcd248d052cfe68da97f03192959ad6a4 (diff)
Add Model#expect, support block at post/pre config
Now we can deal with pager and additional PW prompts, such as 'enable' Examples in IOS model how to use. The Telnet implementation is particularly fugly, I just need one line in 'waitfor' to handle pager while waiting for prompt, but couldn't figure out clean way to do it, so needed to rewrit whole Telnet#waitfor just to add that line.
Diffstat (limited to 'lib/oxidized/model/ios.rb')
-rw-r--r--lib/oxidized/model/ios.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/oxidized/model/ios.rb b/lib/oxidized/model/ios.rb
index c3027e2..7da5ed2 100644
--- a/lib/oxidized/model/ios.rb
+++ b/lib/oxidized/model/ios.rb
@@ -2,7 +2,22 @@ class IOS < Oxidized::Model
comment '! '
+ # example how to handle pager
+ #expect /^\s--More--\s+.*$/ do |data, re|
+ # send ' '
+ # data.sub re, ''
+ #end
+
+ # non-preferred way to handle additional PW prompt
+ #expect /^[\w.]+>$/ do |data|
+ # send "enable\n"
+ # send CFG.passwords[:enable] + "\n"
+ # data
+ #end
+
cmd :all do |cfg|
+ #cfg.gsub! /\cH+\s{8}/, '' # example how to handle pager
+ #cfg.gsub! /\cH+/, '' # example how to handle pager
cfg.each_line.to_a[1..-3].join
end
@@ -24,6 +39,11 @@ class IOS < Oxidized::Model
cfg :telnet, :ssh do
post_login 'terminal length 0'
post_login 'terminal width 0'
+ # preferred way to handle additional passwords
+ #post_login do
+ # send "enable\n"
+ # send CFG.passwords[:enable] + "\n"
+ #end
pre_logout 'exit'
end