summaryrefslogtreecommitdiff
path: root/lib/oxidized/input/cli.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/input/cli.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/input/cli.rb')
-rw-r--r--lib/oxidized/input/cli.rb18
1 files changed, 13 insertions, 5 deletions
diff --git a/lib/oxidized/input/cli.rb b/lib/oxidized/input/cli.rb
index 1d58e85..8daddac 100644
--- a/lib/oxidized/input/cli.rb
+++ b/lib/oxidized/input/cli.rb
@@ -8,18 +8,26 @@ module Oxidized
end
def get
- @post_login.each { |command| cmd command }
+ @post_login.each { |command, block| block ? block.call : (cmd command) }
d = @node.model.get
disconnect
d
end
+
+ def disconnect_cli
+ @pre_logout.each { |command, block| block ? block.call : (cmd command) }
+ end
- def post_login _post_login
- @post_login << _post_login unless @exec
+ def post_login _post_login=nil, &block
+ unless @exec
+ @post_login << [_post_login, block]
+ end
end
- def pre_logout _pre_logout
- @pre_logout << _pre_logout unless @exec
+ def pre_logout _pre_logout=nil, &block
+ unless @exec
+ @pre_logout << [_pre_logout, block]
+ end
end
end
end