forked from ytti/oxidized
-
Notifications
You must be signed in to change notification settings - Fork 0
/
smartcs.rb
42 lines (36 loc) · 1.04 KB
/
smartcs.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
class SmartCS < Oxidized::Model
using Refinements
prompt /^\r?([\w.@() -]+[#>]\s?)$/
comment '# '
expect /-more <Press SPACE for another page, 'q' to quit>-/ do |data, re|
send ' '
data.sub re, ''
end
cmd :all do |cfg|
cfg
end
cmd 'show version' do |cfg|
comment cfg.insert(0, "--------------------------------------------------------------------------------! \n")
# Unhash below to write a comment in the config file.
cfg.insert(0, "Starting: show version cmd \n")
cfg << "\n \nEnding: show version cmd"
comment cfg << "\n--------------------------------------------------------------------------------! \n \n"
comment cfg
end
cmd 'show config' do |cfg|
# remove "Press SPACE for another page" add SPACE(\s)
cfg.gsub! /\s{5,}/, ""
end
cfg :telnet, :ssh do
# preferred way to handle additional passwords
post_login do
pw = vars(:enable)
pw ||= ""
send "su\r"
expect /[pP]assword:\s?$/
cmd pw
end
pre_logout 'exit'
pre_logout 'exit'
end
end