summaryrefslogtreecommitdiff
path: root/lib/oxidized/model/junos.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/oxidized/model/junos.rb')
-rw-r--r--lib/oxidized/model/junos.rb47
1 files changed, 47 insertions, 0 deletions
diff --git a/lib/oxidized/model/junos.rb b/lib/oxidized/model/junos.rb
new file mode 100644
index 0000000..caa6536
--- /dev/null
+++ b/lib/oxidized/model/junos.rb
@@ -0,0 +1,47 @@
+class JunOS < Oxidized::Model
+
+ comment '# '
+
+ def telnet
+ @input.class.to_s.match /Telnet/
+ end
+
+ cmd 'show configuration' do |cfg|
+ # example how to handle different output from different methods. Other option would be to
+ # pass string to helper method, which checks if top/bottom has prompts and removes
+ cfg = cfg.lines[1..-2].join if telnet
+ cfg
+ end
+
+ cmd 'show version' do |cfg|
+ chassis = model $1 if cfg.match /^Model: (\S+)/
+ comment cfg << chassis.to_s
+ end
+
+ def model chassis
+ case chassis
+ when 'mx960'
+ cmd('show chassis fabric reachability') { |cfg| comment cfg }
+ end
+ end
+
+ cmd 'show chassis hardware' do |cfg|
+ comment cfg
+ end
+
+ cfg :telnet do
+ username /^login:/
+ password /^Password:/
+ end
+
+ cfg :ssh do
+ exec true # don't run shell, run each command in exec channel
+ end
+
+ cfg :telnet, :ssh do
+ post_login 'set cli screen-length 0'
+ post_login 'set cli screen-width 0'
+ pre_logout 'exit'
+ end
+
+end