blob: ec1540227af64377e3b2185c2fecdb8b6c1cee7d (
plain)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
class PowerConnect < Oxidized::Model
prompt /^([\w\s.@-]+[#>]\s?)$/ # allow spaces in hostname..dell does not limit it.. #
comment '! '
expect /^\s*--More--\s+.*$/ do |data, re|
send ' '
data.sub re, ''
end
cmd :all do |cfg|
cfg.each_line.to_a[1..-3].join
end
cmd 'show version' do |cfg|
cfg = cfg.split("\n").select { |line| not line[/Up\sTime/] }
comment cfg.join("\n") + "\n"
end
cmd 'show system' do |cfg|
@model = $1 if cfg.match /Power[C|c]onnect (\d{4})[P|F]?/
clean cfg
end
cmd 'show running-config'
cfg :telnet, :ssh do
username /^User( Name)?:/
password /^\r?Password:/
end
cfg :telnet, :ssh do
if vars :enable
post_login do
send "enable\n"
send vars(:enable) + "\n"
end
end
post_login "terminal datadump"
post_login "terminal length 0"
pre_logout "logout"
pre_logout "exit"
end
def clean cfg
out = []
skip_block = false
cfg.each_line do |line|
if line.match /Up\sTime|Temperature|Power Supplies/i
# For 34xx, 35xx, 54xx, 55xx, 62xx and 8024F we should skip this block (terminated by a blank line)
skip_block = true if @model =~ /^(34|35)(24|48)$|^(54|55)(24|48)$|^(62)(24|48)$|^8024$/
end
# If we have lines to skip do this until we reach and empty line
if skip_block
skip_block = false if /\S/ !~ line
next
end
out << line.strip
end
out = comment out.join "\n"
out << "\n"
end
end
|