oxidized 0.25.1 → 0.26.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +30 -9
- data/.rubocop_todo.yml +16 -637
- data/.travis.yml +2 -3
- data/CHANGELOG.md +14 -0
- data/Dockerfile +7 -5
- data/README.md +18 -14
- data/Rakefile +2 -2
- data/bin/console +1 -1
- data/bin/oxidized +2 -2
- data/docs/Configuration.md +6 -0
- data/docs/Model-Notes/README.md +1 -0
- data/docs/Model-Notes/SmartAX-Huawei.md +35 -0
- data/docs/Supported-OS-Types.md +12 -0
- data/extra/nagios_check_failing_nodes.rb +1 -1
- data/extra/rest_client.rb +6 -8
- data/extra/syslog.rb +33 -33
- data/lib/oxidized/cli.rb +25 -26
- data/lib/oxidized/config.rb +9 -9
- data/lib/oxidized/config/vars.rb +3 -7
- data/lib/oxidized/core.rb +4 -7
- data/lib/oxidized/hook.rb +16 -17
- data/lib/oxidized/hook/awssns.rb +4 -4
- data/lib/oxidized/hook/exec.rb +16 -20
- data/lib/oxidized/hook/githubrepo.rb +8 -14
- data/lib/oxidized/hook/noophook.rb +1 -1
- data/lib/oxidized/hook/xmppdiff.rb +1 -1
- data/lib/oxidized/input/cli.rb +12 -12
- data/lib/oxidized/input/ftp.rb +8 -8
- data/lib/oxidized/input/http.rb +37 -14
- data/lib/oxidized/input/input.rb +6 -6
- data/lib/oxidized/input/ssh.rb +31 -31
- data/lib/oxidized/input/telnet.rb +24 -24
- data/lib/oxidized/input/tftp.rb +9 -10
- data/lib/oxidized/jobs.rb +7 -7
- data/lib/oxidized/manager.rb +13 -13
- data/lib/oxidized/model/acos.rb +2 -2
- data/lib/oxidized/model/aireos.rb +3 -3
- data/lib/oxidized/model/aos7.rb +1 -1
- data/lib/oxidized/model/aosw.rb +12 -14
- data/lib/oxidized/model/apc_aos.rb +1 -1
- data/lib/oxidized/model/aricentiss.rb +6 -8
- data/lib/oxidized/model/asa.rb +1 -1
- data/lib/oxidized/model/audiocodesmp.rb +28 -0
- data/lib/oxidized/model/awplus.rb +9 -9
- data/lib/oxidized/model/boss.rb +1 -1
- data/lib/oxidized/model/ciscosmb.rb +1 -1
- data/lib/oxidized/model/ciscovpn3k.rb +11 -0
- data/lib/oxidized/model/comware.rb +1 -1
- data/lib/oxidized/model/cumulus.rb +3 -1
- data/lib/oxidized/model/dellx.rb +5 -5
- data/lib/oxidized/model/edgeos.rb +1 -1
- data/lib/oxidized/model/edgeswitch.rb +1 -1
- data/lib/oxidized/model/fabricos.rb +1 -1
- data/lib/oxidized/model/fortios.rb +5 -5
- data/lib/oxidized/model/ftos.rb +1 -1
- data/lib/oxidized/model/gcombnps.rb +7 -7
- data/lib/oxidized/model/grandstream.rb +9 -0
- data/lib/oxidized/model/hatteras.rb +8 -8
- data/lib/oxidized/model/ios.rb +22 -40
- data/lib/oxidized/model/ironware.rb +1 -1
- data/lib/oxidized/model/junos.rb +1 -1
- data/lib/oxidized/model/mlnxos.rb +1 -1
- data/lib/oxidized/model/model.rb +32 -38
- data/lib/oxidized/model/netgearxs716.rb +23 -0
- data/lib/oxidized/model/netonix.rb +1 -1
- data/lib/oxidized/model/netscaler.rb +1 -1
- data/lib/oxidized/model/nos.rb +2 -2
- data/lib/oxidized/model/nxos.rb +1 -1
- data/lib/oxidized/model/openbsd.rb +3 -2
- data/lib/oxidized/model/outputs.rb +4 -4
- data/lib/oxidized/model/planet.rb +4 -4
- data/lib/oxidized/model/powerconnect.rb +8 -8
- data/lib/oxidized/model/procurve.rb +2 -1
- data/lib/oxidized/model/quantaos.rb +3 -3
- data/lib/oxidized/model/raisecom.rb +19 -0
- data/lib/oxidized/model/siklu.rb +1 -1
- data/lib/oxidized/model/slxos.rb +1 -1
- data/lib/oxidized/model/smartax.rb +25 -0
- data/lib/oxidized/model/sros.rb +4 -4
- data/lib/oxidized/model/tdre.rb +30 -0
- data/lib/oxidized/model/tmos.rb +3 -0
- data/lib/oxidized/model/trango.rb +17 -37
- data/lib/oxidized/model/voltaire.rb +1 -1
- data/lib/oxidized/model/voss.rb +1 -1
- data/lib/oxidized/model/vyatta.rb +1 -1
- data/lib/oxidized/model/xos.rb +1 -1
- data/lib/oxidized/model/zhoneolt.rb +1 -1
- data/lib/oxidized/node.rb +42 -46
- data/lib/oxidized/node/stats.rb +6 -6
- data/lib/oxidized/nodes.rb +42 -42
- data/lib/oxidized/output/file.rb +16 -20
- data/lib/oxidized/output/git.rb +68 -78
- data/lib/oxidized/output/gitcrypt.rb +77 -91
- data/lib/oxidized/output/http.rb +17 -19
- data/lib/oxidized/output/output.rb +1 -1
- data/lib/oxidized/source/csv.rb +3 -3
- data/lib/oxidized/source/http.rb +11 -14
- data/lib/oxidized/source/source.rb +3 -3
- data/lib/oxidized/source/sql.rb +16 -18
- data/lib/oxidized/string.rb +10 -10
- data/lib/oxidized/version.rb +4 -4
- data/lib/oxidized/worker.rb +15 -15
- data/oxidized.gemspec +6 -9
- metadata +32 -25
@@ -21,18 +21,18 @@ class Hatteras < Oxidized::Model
|
|
21
21
|
end
|
22
22
|
|
23
23
|
cmd "show switch\r" do |cfg|
|
24
|
-
cfg = cfg.each_line.reject
|
25
|
-
line.match
|
26
|
-
line.match
|
27
|
-
|
24
|
+
cfg = cfg.each_line.reject do |line|
|
25
|
+
line.match(/Switch uptime|Switch temperature|Last reset reason/) ||
|
26
|
+
line.match(/TermCpuUtil|^\s+\^$|ERROR: Bad command/)
|
27
|
+
end .join
|
28
28
|
comment cfg
|
29
29
|
end
|
30
30
|
|
31
31
|
cmd "show card\r" do |cfg|
|
32
|
-
cfg = cfg.each_line.reject
|
33
|
-
line.match
|
34
|
-
line.match
|
35
|
-
|
32
|
+
cfg = cfg.each_line.reject do |line|
|
33
|
+
line.match(/Card uptime|Card temperature|Last reset reason/) ||
|
34
|
+
line.match(/TermCpuUtil|^\s+\^$|ERROR: Bad command/)
|
35
|
+
end .join
|
36
36
|
comment cfg
|
37
37
|
end
|
38
38
|
|
data/lib/oxidized/model/ios.rb
CHANGED
@@ -52,60 +52,42 @@ class IOS < Oxidized::Model
|
|
52
52
|
slave = ''
|
53
53
|
slaveslot = ''
|
54
54
|
|
55
|
-
if line
|
56
|
-
slave = " Slave:"
|
57
|
-
slaveslot = ", slot #{
|
55
|
+
if line =~ /^Slave in slot (\d+) is running/
|
56
|
+
slave = " Slave:"
|
57
|
+
slaveslot = ", slot #{Regexp.last_match(1)}"
|
58
58
|
end
|
59
59
|
|
60
|
-
if line
|
61
|
-
comments << "Image:#{slave} Compiled: #{$1}"
|
62
|
-
end
|
60
|
+
comments << "Image:#{slave} Compiled: #{Regexp.last_match(1)}" if line =~ /^Compiled (.*)$/
|
63
61
|
|
64
|
-
if line
|
65
|
-
comments << "Image:#{slave} Software: #{$1}, #{$2}"
|
66
|
-
end
|
62
|
+
comments << "Image:#{slave} Software: #{Regexp.last_match(1)}, #{Regexp.last_match(2)}" if line =~ /^(?:Cisco )?IOS .* Software,? \(([A-Za-z0-9_-]*)\), .*Version\s+(.*)$/
|
67
63
|
|
68
|
-
if line
|
69
|
-
comments << "ROM Bootstrap: #{$3}"
|
70
|
-
end
|
64
|
+
comments << "ROM Bootstrap: #{Regexp.last_match(3)}" if line =~ /^ROM: (IOS \S+ )?(System )?Bootstrap.*(Version.*)$/
|
71
65
|
|
72
|
-
if line
|
73
|
-
comments << "BOOTFLASH: #{$1}"
|
74
|
-
end
|
66
|
+
comments << "BOOTFLASH: #{Regexp.last_match(1)}" if line =~ /^BOOTFLASH: .*(Version.*)$/
|
75
67
|
|
76
|
-
if line
|
77
|
-
comments << "Memory: nvram #{$1}"
|
78
|
-
end
|
68
|
+
comments << "Memory: nvram #{Regexp.last_match(1)}" if line =~ /^(\d+[kK]) bytes of (non-volatile|NVRAM)/
|
79
69
|
|
80
|
-
if line
|
81
|
-
comments << "Memory: flash #{$1}"
|
82
|
-
end
|
70
|
+
comments << "Memory: flash #{Regexp.last_match(1)}" if line =~ /^(\d+[kK]) bytes of (flash memory|flash internal|processor board System flash|ATA CompactFlash)/i
|
83
71
|
|
84
|
-
if line
|
85
|
-
comments << "Memory: pcmcia #{$2} #{$3}#{$4} #{$1}";
|
86
|
-
end
|
72
|
+
comments << "Memory: pcmcia #{Regexp.last_match(2)} #{Regexp.last_match(3)}#{Regexp.last_match(4)} #{Regexp.last_match(1)}" if line =~ /^(\d+[kK]) bytes of (Flash|ATA)?.*PCMCIA .*(slot|disk) ?(\d)/i
|
87
73
|
|
88
|
-
if line
|
89
|
-
sproc =
|
90
|
-
cpu =
|
91
|
-
mem =
|
74
|
+
if line =~ /(\S+(?:\sseries)?)\s+(?:\((\S+)\)\s+processor|\(revision[^)]+\)).*\s+with (\S+k) bytes/i
|
75
|
+
sproc = Regexp.last_match(1)
|
76
|
+
cpu = Regexp.last_match(2)
|
77
|
+
mem = Regexp.last_match(3)
|
92
78
|
cpuxtra = ''
|
93
|
-
comments << "Chassis type:#{slave} #{sproc}"
|
94
|
-
comments << "Memory:#{slave} main #{mem}"
|
79
|
+
comments << "Chassis type:#{slave} #{sproc}"
|
80
|
+
comments << "Memory:#{slave} main #{mem}"
|
95
81
|
# check the next two lines for more CPU info
|
96
|
-
if cfg.lines[i + 1]
|
97
|
-
|
98
|
-
end
|
99
|
-
if cfg.lines[i + 2].match /(cpu at |processor: |#{cpu} processor,)/i
|
82
|
+
comments << "Processor ID: #{Regexp.last_match(1)}" if cfg.lines[i + 1] =~ /processor board id (\S+)/i
|
83
|
+
if cfg.lines[i + 2] =~ /(cpu at |processor: |#{cpu} processor,)/i
|
100
84
|
# change implementation to impl and prepend comma
|
101
|
-
cpuxtra = cfg.lines[i + 2].gsub(/implementation/, 'impl').gsub(/^/, ', ').chomp
|
85
|
+
cpuxtra = cfg.lines[i + 2].gsub(/implementation/, 'impl').gsub(/^/, ', ').chomp
|
102
86
|
end
|
103
|
-
comments << "CPU:#{slave} #{cpu}#{cpuxtra}#{slaveslot}"
|
87
|
+
comments << "CPU:#{slave} #{cpu}#{cpuxtra}#{slaveslot}"
|
104
88
|
end
|
105
89
|
|
106
|
-
if line
|
107
|
-
comments << "Image: #{$1}"
|
108
|
-
end
|
90
|
+
comments << "Image: #{Regexp.last_match(1)}" if line =~ /^System image file is "([^"]*)"$/
|
109
91
|
end
|
110
92
|
comments << "\n"
|
111
93
|
comment comments.join "\n"
|
@@ -113,7 +95,7 @@ class IOS < Oxidized::Model
|
|
113
95
|
|
114
96
|
cmd 'show vtp status' do |cfg|
|
115
97
|
cfg.gsub! /^$\n/, ''
|
116
|
-
cfg.gsub! /^/, 'VTP: '
|
98
|
+
cfg.gsub! /^/, 'VTP: ' unless cfg.empty?
|
117
99
|
comment "#{cfg}\n"
|
118
100
|
end
|
119
101
|
|
@@ -28,7 +28,7 @@ class IronWare < Oxidized::Model
|
|
28
28
|
end
|
29
29
|
|
30
30
|
cmd 'show chassis' do |cfg|
|
31
|
-
cfg.encode!("UTF-8", :
|
31
|
+
cfg.encode!("UTF-8", invalid: :replace, undef: :replace) # sometimes ironware returns broken encoding
|
32
32
|
cfg.gsub! /(^((.*)Current temp(.*))$)/, '' # remove unwanted lines current temperature
|
33
33
|
cfg.gsub! /Speed = [A-Z-]{2,6} \(\d{2,3}%\)/, '' # remove unwanted lines Speed Fans
|
34
34
|
cfg.gsub! /current speed is [A-Z]{2,6} \(\d{2,3}%\)/, ''
|
data/lib/oxidized/model/junos.rb
CHANGED
@@ -16,7 +16,7 @@ class MLNXOS < Oxidized::Model
|
|
16
16
|
cfg.gsub! /^System memory:\s.+/, '' # Omit constantly changing memory info
|
17
17
|
cfg.gsub! /^Uptime:\s.+/, '' # Omit constantly changing uptime info
|
18
18
|
cfg.gsub! /.+Generated at\s\d+.+/, '' # Omit constantly changing generation time info
|
19
|
-
cfg
|
19
|
+
cfg.lines.to_a[2..-3].join
|
20
20
|
end
|
21
21
|
|
22
22
|
cmd :secret do |cfg|
|
data/lib/oxidized/model/model.rb
CHANGED
@@ -6,26 +6,26 @@ module Oxidized
|
|
6
6
|
include Oxidized::Config::Vars
|
7
7
|
|
8
8
|
class << self
|
9
|
-
def inherited
|
10
|
-
klass.instance_variable_set '@cmd',
|
11
|
-
klass.instance_variable_set '@cfg',
|
12
|
-
klass.instance_variable_set '@procs',
|
13
|
-
klass.instance_variable_set '@expect',
|
9
|
+
def inherited(klass)
|
10
|
+
klass.instance_variable_set '@cmd', (Hash.new { |h, k| h[k] = [] })
|
11
|
+
klass.instance_variable_set '@cfg', (Hash.new { |h, k| h[k] = [] })
|
12
|
+
klass.instance_variable_set '@procs', (Hash.new { |h, k| h[k] = [] })
|
13
|
+
klass.instance_variable_set '@expect', []
|
14
14
|
klass.instance_variable_set '@comment', nil
|
15
|
-
klass.instance_variable_set '@prompt',
|
15
|
+
klass.instance_variable_set '@prompt', nil
|
16
16
|
end
|
17
17
|
|
18
|
-
def comment
|
18
|
+
def comment(str = '# ')
|
19
19
|
return @comment if @comment
|
20
20
|
|
21
|
-
@comment = block_given? ? yield :
|
21
|
+
@comment = block_given? ? yield : str
|
22
22
|
end
|
23
23
|
|
24
|
-
def prompt
|
25
|
-
@prompt
|
24
|
+
def prompt(regex = nil)
|
25
|
+
@prompt || (@prompt = regex)
|
26
26
|
end
|
27
27
|
|
28
|
-
def cfg
|
28
|
+
def cfg(*methods, **args, &block)
|
29
29
|
[methods].flatten.each do |method|
|
30
30
|
process_args_block(@cfg[method.to_s], args, block)
|
31
31
|
end
|
@@ -35,21 +35,21 @@ module Oxidized
|
|
35
35
|
@cfg
|
36
36
|
end
|
37
37
|
|
38
|
-
def cmd
|
39
|
-
if
|
40
|
-
process_args_block(@cmd[
|
38
|
+
def cmd(cmd_arg = nil, **args, &block)
|
39
|
+
if cmd_arg.class == Symbol
|
40
|
+
process_args_block(@cmd[cmd_arg], args, block)
|
41
41
|
else
|
42
|
-
process_args_block(@cmd[:cmd], args, [
|
42
|
+
process_args_block(@cmd[:cmd], args, [cmd_arg, block])
|
43
43
|
end
|
44
|
-
Oxidized.logger.debug "lib/oxidized/model/model.rb Added #{
|
44
|
+
Oxidized.logger.debug "lib/oxidized/model/model.rb Added #{cmd_arg} to the commands list"
|
45
45
|
end
|
46
46
|
|
47
47
|
def cmds
|
48
48
|
@cmd
|
49
49
|
end
|
50
50
|
|
51
|
-
def expect
|
52
|
-
process_args_block(@expect, args, [
|
51
|
+
def expect(regex, **args, &block)
|
52
|
+
process_args_block(@expect, args, [regex, block])
|
53
53
|
end
|
54
54
|
|
55
55
|
def expects
|
@@ -63,7 +63,7 @@ module Oxidized
|
|
63
63
|
# @since 0.0.39
|
64
64
|
# @yield expects block which should return [String]
|
65
65
|
# @return [void]
|
66
|
-
def pre
|
66
|
+
def pre(**args, &block)
|
67
67
|
process_args_block(@procs[:pre], args, block)
|
68
68
|
end
|
69
69
|
|
@@ -74,16 +74,14 @@ module Oxidized
|
|
74
74
|
# @since 0.0.39
|
75
75
|
# @yield expects block which should return [String]
|
76
76
|
# @return [void]
|
77
|
-
def post
|
77
|
+
def post(**args, &block)
|
78
78
|
process_args_block(@procs[:post], args, block)
|
79
79
|
end
|
80
80
|
|
81
81
|
# @author Saku Ytti <saku@ytti.fi>
|
82
82
|
# @since 0.0.39
|
83
83
|
# @return [Hash] hash proc procs :pre+:post to be prepended/postfixed to output
|
84
|
-
|
85
|
-
@procs
|
86
|
-
end
|
84
|
+
attr_reader :procs
|
87
85
|
|
88
86
|
private
|
89
87
|
|
@@ -99,7 +97,7 @@ module Oxidized
|
|
99
97
|
|
100
98
|
attr_accessor :input, :node
|
101
99
|
|
102
|
-
def cmd
|
100
|
+
def cmd(string, &block)
|
103
101
|
Oxidized.logger.debug "lib/oxidized/model/model.rb Executing #{string}"
|
104
102
|
out = @input.cmd(string)
|
105
103
|
return false unless out
|
@@ -121,12 +119,12 @@ module Oxidized
|
|
121
119
|
@input.output
|
122
120
|
end
|
123
121
|
|
124
|
-
def send
|
122
|
+
def send(data)
|
125
123
|
@input.send data
|
126
124
|
end
|
127
125
|
|
128
|
-
def expect
|
129
|
-
self.class.expect
|
126
|
+
def expect(regex, &block)
|
127
|
+
self.class.expect regex, &block
|
130
128
|
end
|
131
129
|
|
132
130
|
def cfg
|
@@ -137,14 +135,10 @@ module Oxidized
|
|
137
135
|
self.class.prompt
|
138
136
|
end
|
139
137
|
|
140
|
-
def expects
|
138
|
+
def expects(data)
|
141
139
|
self.class.expects.each do |re, cb|
|
142
140
|
if data.match re
|
143
|
-
|
144
|
-
data = instance_exec [data, re], &cb
|
145
|
-
else
|
146
|
-
data = instance_exec data, &cb
|
147
|
-
end
|
141
|
+
data = cb.arity == 2 ? instance_exec([data, re], &cb) : instance_exec(data, &cb)
|
148
142
|
end
|
149
143
|
end
|
150
144
|
data
|
@@ -169,9 +163,9 @@ module Oxidized
|
|
169
163
|
outputs
|
170
164
|
end
|
171
165
|
|
172
|
-
def comment
|
166
|
+
def comment(str)
|
173
167
|
data = ''
|
174
|
-
|
168
|
+
str.each_line do |line|
|
175
169
|
data << self.class.comment << line
|
176
170
|
end
|
177
171
|
data
|
@@ -183,9 +177,9 @@ module Oxidized
|
|
183
177
|
|
184
178
|
private
|
185
179
|
|
186
|
-
def process_cmd_output
|
187
|
-
output = Oxidized::String.new output if ::String
|
188
|
-
output = Oxidized::String.new '' unless Oxidized::String
|
180
|
+
def process_cmd_output(output, name)
|
181
|
+
output = Oxidized::String.new output if ::String == output.class
|
182
|
+
output = Oxidized::String.new '' unless Oxidized::String == output.class
|
189
183
|
output.set_cmd(name)
|
190
184
|
output
|
191
185
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class NetgearXS716 < Oxidized::Model
|
2
|
+
cfg_cb = lambda do
|
3
|
+
c = @m.get("/upload_download/startup-config")
|
4
|
+
c.body
|
5
|
+
end
|
6
|
+
|
7
|
+
cmd cfg_cb do |cfg|
|
8
|
+
cfg
|
9
|
+
end
|
10
|
+
|
11
|
+
cmd :secret do |cfg|
|
12
|
+
cfg.gsub!(/password (\S+)/, 'password <hidden>')
|
13
|
+
cfg.gsub!(/encrypted (\S+)/, 'encrypted <hidden>')
|
14
|
+
cfg
|
15
|
+
end
|
16
|
+
|
17
|
+
cfg :http do
|
18
|
+
@main_page = "/base/main_login.html"
|
19
|
+
define_singleton_method :login do
|
20
|
+
@m_page = @m.post("/base/cheetah_login.html", 'pwd' => @node.auth[:password])
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/oxidized/model/nos.rb
CHANGED
@@ -21,11 +21,11 @@ class NOS < Oxidized::Model
|
|
21
21
|
end
|
22
22
|
|
23
23
|
cmd 'show chassis' do |cfg|
|
24
|
-
comment cfg.each_line.reject { |line| line.match
|
24
|
+
comment cfg.each_line.reject { |line| line.match(/Time/) || line.match(/Update/) }.join
|
25
25
|
end
|
26
26
|
|
27
27
|
cfg 'show system' do |cfg|
|
28
|
-
comment
|
28
|
+
comment(cfg.each_line.reject { |line| line.match(/Time/) || line.match(/speed/) })
|
29
29
|
end
|
30
30
|
|
31
31
|
cmd 'show running-config | nomore'
|
data/lib/oxidized/model/nxos.rb
CHANGED
@@ -7,11 +7,11 @@ class Openbsd < Oxidized::Model
|
|
7
7
|
comment '# '
|
8
8
|
|
9
9
|
# Add a comment between files/configs
|
10
|
-
def add_comment
|
10
|
+
def add_comment(comment)
|
11
11
|
"\n+++++++++++++++++++++++++++++++++++++++++ #{comment} ++++++++++++++++++++++++++++++++++++++++++++++\n"
|
12
12
|
end
|
13
13
|
|
14
|
-
def add_small_comment
|
14
|
+
def add_small_comment(comment)
|
15
15
|
"\n=============== #{comment} ===============\n"
|
16
16
|
end
|
17
17
|
|
@@ -49,6 +49,7 @@ class Openbsd < Oxidized::Model
|
|
49
49
|
cfg += cmd('cat /etc/passwd')
|
50
50
|
|
51
51
|
cfg += add_small_comment('END')
|
52
|
+
cfg
|
52
53
|
end
|
53
54
|
|
54
55
|
cfg :telnet do
|
@@ -5,15 +5,15 @@ module Oxidized
|
|
5
5
|
type_to_str(nil)
|
6
6
|
end
|
7
7
|
|
8
|
-
def type_to_str
|
8
|
+
def type_to_str(want_type)
|
9
9
|
type(want_type).map { |out| out }.join
|
10
10
|
end
|
11
11
|
|
12
|
-
def <<
|
12
|
+
def <<(output)
|
13
13
|
@outputs << output
|
14
14
|
end
|
15
15
|
|
16
|
-
def unshift
|
16
|
+
def unshift(output)
|
17
17
|
@outputs.unshift output
|
18
18
|
end
|
19
19
|
|
@@ -21,7 +21,7 @@ module Oxidized
|
|
21
21
|
@outputs
|
22
22
|
end
|
23
23
|
|
24
|
-
def type
|
24
|
+
def type(type)
|
25
25
|
@outputs.select { |out| out.type == type }
|
26
26
|
end
|
27
27
|
|
@@ -33,8 +33,8 @@ class Planet < Oxidized::Model
|
|
33
33
|
|
34
34
|
cmd 'show version' do |cfg|
|
35
35
|
cfg.gsub! "\n\r", "\n"
|
36
|
-
@planetgs = true if cfg
|
37
|
-
@planetsgs = true if cfg
|
36
|
+
@planetgs = true if cfg =~ /^System Name\w*:\w*GS-.*$/
|
37
|
+
@planetsgs = true if cfg =~ /SGS-(.*) Device, Compiled on .*$/
|
38
38
|
|
39
39
|
cfg = cfg.each_line.to_a[0...-2]
|
40
40
|
|
@@ -53,8 +53,8 @@ class Planet < Oxidized::Model
|
|
53
53
|
cfg = cfg.reject { |line| line.match "Building configuration..." }
|
54
54
|
|
55
55
|
if @planetsgs
|
56
|
-
cfg << cmd('show transceiver detail | include transceiver detail information|found|Type|length|Nominal|wavelength|Base information') do |
|
57
|
-
comment
|
56
|
+
cfg << cmd('show transceiver detail | include transceiver detail information|found|Type|length|Nominal|wavelength|Base information') do |cfg_optic|
|
57
|
+
comment cfg_optic
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|