oxidized 0.25.1 → 0.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +30 -9
  3. data/.rubocop_todo.yml +16 -637
  4. data/.travis.yml +2 -3
  5. data/CHANGELOG.md +14 -0
  6. data/Dockerfile +7 -5
  7. data/README.md +18 -14
  8. data/Rakefile +2 -2
  9. data/bin/console +1 -1
  10. data/bin/oxidized +2 -2
  11. data/docs/Configuration.md +6 -0
  12. data/docs/Model-Notes/README.md +1 -0
  13. data/docs/Model-Notes/SmartAX-Huawei.md +35 -0
  14. data/docs/Supported-OS-Types.md +12 -0
  15. data/extra/nagios_check_failing_nodes.rb +1 -1
  16. data/extra/rest_client.rb +6 -8
  17. data/extra/syslog.rb +33 -33
  18. data/lib/oxidized/cli.rb +25 -26
  19. data/lib/oxidized/config.rb +9 -9
  20. data/lib/oxidized/config/vars.rb +3 -7
  21. data/lib/oxidized/core.rb +4 -7
  22. data/lib/oxidized/hook.rb +16 -17
  23. data/lib/oxidized/hook/awssns.rb +4 -4
  24. data/lib/oxidized/hook/exec.rb +16 -20
  25. data/lib/oxidized/hook/githubrepo.rb +8 -14
  26. data/lib/oxidized/hook/noophook.rb +1 -1
  27. data/lib/oxidized/hook/xmppdiff.rb +1 -1
  28. data/lib/oxidized/input/cli.rb +12 -12
  29. data/lib/oxidized/input/ftp.rb +8 -8
  30. data/lib/oxidized/input/http.rb +37 -14
  31. data/lib/oxidized/input/input.rb +6 -6
  32. data/lib/oxidized/input/ssh.rb +31 -31
  33. data/lib/oxidized/input/telnet.rb +24 -24
  34. data/lib/oxidized/input/tftp.rb +9 -10
  35. data/lib/oxidized/jobs.rb +7 -7
  36. data/lib/oxidized/manager.rb +13 -13
  37. data/lib/oxidized/model/acos.rb +2 -2
  38. data/lib/oxidized/model/aireos.rb +3 -3
  39. data/lib/oxidized/model/aos7.rb +1 -1
  40. data/lib/oxidized/model/aosw.rb +12 -14
  41. data/lib/oxidized/model/apc_aos.rb +1 -1
  42. data/lib/oxidized/model/aricentiss.rb +6 -8
  43. data/lib/oxidized/model/asa.rb +1 -1
  44. data/lib/oxidized/model/audiocodesmp.rb +28 -0
  45. data/lib/oxidized/model/awplus.rb +9 -9
  46. data/lib/oxidized/model/boss.rb +1 -1
  47. data/lib/oxidized/model/ciscosmb.rb +1 -1
  48. data/lib/oxidized/model/ciscovpn3k.rb +11 -0
  49. data/lib/oxidized/model/comware.rb +1 -1
  50. data/lib/oxidized/model/cumulus.rb +3 -1
  51. data/lib/oxidized/model/dellx.rb +5 -5
  52. data/lib/oxidized/model/edgeos.rb +1 -1
  53. data/lib/oxidized/model/edgeswitch.rb +1 -1
  54. data/lib/oxidized/model/fabricos.rb +1 -1
  55. data/lib/oxidized/model/fortios.rb +5 -5
  56. data/lib/oxidized/model/ftos.rb +1 -1
  57. data/lib/oxidized/model/gcombnps.rb +7 -7
  58. data/lib/oxidized/model/grandstream.rb +9 -0
  59. data/lib/oxidized/model/hatteras.rb +8 -8
  60. data/lib/oxidized/model/ios.rb +22 -40
  61. data/lib/oxidized/model/ironware.rb +1 -1
  62. data/lib/oxidized/model/junos.rb +1 -1
  63. data/lib/oxidized/model/mlnxos.rb +1 -1
  64. data/lib/oxidized/model/model.rb +32 -38
  65. data/lib/oxidized/model/netgearxs716.rb +23 -0
  66. data/lib/oxidized/model/netonix.rb +1 -1
  67. data/lib/oxidized/model/netscaler.rb +1 -1
  68. data/lib/oxidized/model/nos.rb +2 -2
  69. data/lib/oxidized/model/nxos.rb +1 -1
  70. data/lib/oxidized/model/openbsd.rb +3 -2
  71. data/lib/oxidized/model/outputs.rb +4 -4
  72. data/lib/oxidized/model/planet.rb +4 -4
  73. data/lib/oxidized/model/powerconnect.rb +8 -8
  74. data/lib/oxidized/model/procurve.rb +2 -1
  75. data/lib/oxidized/model/quantaos.rb +3 -3
  76. data/lib/oxidized/model/raisecom.rb +19 -0
  77. data/lib/oxidized/model/siklu.rb +1 -1
  78. data/lib/oxidized/model/slxos.rb +1 -1
  79. data/lib/oxidized/model/smartax.rb +25 -0
  80. data/lib/oxidized/model/sros.rb +4 -4
  81. data/lib/oxidized/model/tdre.rb +30 -0
  82. data/lib/oxidized/model/tmos.rb +3 -0
  83. data/lib/oxidized/model/trango.rb +17 -37
  84. data/lib/oxidized/model/voltaire.rb +1 -1
  85. data/lib/oxidized/model/voss.rb +1 -1
  86. data/lib/oxidized/model/vyatta.rb +1 -1
  87. data/lib/oxidized/model/xos.rb +1 -1
  88. data/lib/oxidized/model/zhoneolt.rb +1 -1
  89. data/lib/oxidized/node.rb +42 -46
  90. data/lib/oxidized/node/stats.rb +6 -6
  91. data/lib/oxidized/nodes.rb +42 -42
  92. data/lib/oxidized/output/file.rb +16 -20
  93. data/lib/oxidized/output/git.rb +68 -78
  94. data/lib/oxidized/output/gitcrypt.rb +77 -91
  95. data/lib/oxidized/output/http.rb +17 -19
  96. data/lib/oxidized/output/output.rb +1 -1
  97. data/lib/oxidized/source/csv.rb +3 -3
  98. data/lib/oxidized/source/http.rb +11 -14
  99. data/lib/oxidized/source/source.rb +3 -3
  100. data/lib/oxidized/source/sql.rb +16 -18
  101. data/lib/oxidized/string.rb +10 -10
  102. data/lib/oxidized/version.rb +4 -4
  103. data/lib/oxidized/worker.rb +15 -15
  104. data/oxidized.gemspec +6 -9
  105. metadata +32 -25
@@ -0,0 +1,9 @@
1
+ class GrandStream < Oxidized::Model
2
+ cmd "/cgi-bin/dologin?password=%<password>s" do |cfg| # rubocop:disable Style/FormatStringToken
3
+ sid = JSON.parse(cfg)["body"]["sid"]
4
+ cmd "/cgi-bin/download_cfg?sid=#{sid}"
5
+ end
6
+
7
+ cfg :http do
8
+ end
9
+ end
@@ -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 { |line|
25
- line.match /Switch uptime|Switch temperature|Last reset reason/ or
26
- line.match /TermCpuUtil|^\s+\^$|ERROR: Bad command/
27
- } .join
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 { |line|
33
- line.match /Card uptime|Card temperature|Last reset reason/ or
34
- line.match /TermCpuUtil|^\s+\^$|ERROR: Bad command/
35
- } .join
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
 
@@ -52,60 +52,42 @@ class IOS < Oxidized::Model
52
52
  slave = ''
53
53
  slaveslot = ''
54
54
 
55
- if line.match /^Slave in slot (\d+) is running/
56
- slave = " Slave:";
57
- slaveslot = ", slot #{$1}";
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.match /^Compiled (.*)$/
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.match /^(?:Cisco )?IOS .* Software,? \(([A-Za-z0-9_-]*)\), .*Version\s+(.*)$/
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.match /^ROM: (IOS \S+ )?(System )?Bootstrap.*(Version.*)$/
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.match /^BOOTFLASH: .*(Version.*)$/
73
- comments << "BOOTFLASH: #{$1}"
74
- end
66
+ comments << "BOOTFLASH: #{Regexp.last_match(1)}" if line =~ /^BOOTFLASH: .*(Version.*)$/
75
67
 
76
- if line.match /^(\d+[kK]) bytes of (non-volatile|NVRAM)/
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.match /^(\d+[kK]) bytes of (flash memory|flash internal|processor board System flash|ATA CompactFlash)/i
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.match (/^(\d+[kK]) bytes of (Flash|ATA)?.*PCMCIA .*(slot|disk) ?(\d)/i)
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.match /(\S+(?:\sseries)?)\s+(?:\((\S+)\)\s+processor|\(revision[^)]+\)).*\s+with (\S+k) bytes/i
89
- sproc = $1
90
- cpu = $2
91
- mem = $3
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].match /processor board id (\S+)/i
97
- comments << "Processor ID: #{$1}";
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.match /^System image file is "([^"]*)"$/
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: ' if (!cfg.empty?)
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", :invalid => :replace, :undef => :replace) # sometimes ironware returns broken encoding
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}%\)/, ''
@@ -20,7 +20,7 @@ class JunOS < Oxidized::Model
20
20
  cmd 'show configuration | display omit'
21
21
 
22
22
  cmd 'show version' do |cfg|
23
- @model = $1 if cfg.match(/^Model: (\S+)/)
23
+ @model = Regexp.last_match(1) if cfg =~ /^Model: (\S+)/
24
24
  comment cfg
25
25
  end
26
26
 
@@ -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 = cfg.lines.to_a[2..-3].join
19
+ cfg.lines.to_a[2..-3].join
20
20
  end
21
21
 
22
22
  cmd :secret do |cfg|
@@ -6,26 +6,26 @@ module Oxidized
6
6
  include Oxidized::Config::Vars
7
7
 
8
8
  class << self
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', []
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', nil
15
+ klass.instance_variable_set '@prompt', nil
16
16
  end
17
17
 
18
- def comment _comment = '# '
18
+ def comment(str = '# ')
19
19
  return @comment if @comment
20
20
 
21
- @comment = block_given? ? yield : _comment
21
+ @comment = block_given? ? yield : str
22
22
  end
23
23
 
24
- def prompt _prompt = nil
25
- @prompt or @prompt = _prompt
24
+ def prompt(regex = nil)
25
+ @prompt || (@prompt = regex)
26
26
  end
27
27
 
28
- def cfg *methods, **args, &block
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 _cmd = nil, **args, &block
39
- if _cmd.class == Symbol
40
- process_args_block(@cmd[_cmd], args, block)
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, [_cmd, block])
42
+ process_args_block(@cmd[:cmd], args, [cmd_arg, block])
43
43
  end
44
- Oxidized.logger.debug "lib/oxidized/model/model.rb Added #{_cmd} to the commands list"
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 re, **args, &block
52
- process_args_block(@expect, args, [re, block])
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 **args, &block
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 **args, &block
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
- def procs
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 string, &block
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 data
122
+ def send(data)
125
123
  @input.send data
126
124
  end
127
125
 
128
- def expect re, &block
129
- self.class.expect re, &block
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 data
138
+ def expects(data)
141
139
  self.class.expects.each do |re, cb|
142
140
  if data.match re
143
- if cb.arity == 2
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 _comment
166
+ def comment(str)
173
167
  data = ''
174
- _comment.each_line do |line|
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 output, name
187
- output = Oxidized::String.new output if ::String === output
188
- output = Oxidized::String.new '' unless Oxidized::String === output
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
@@ -1,5 +1,5 @@
1
1
  class Netonix < Oxidized::Model
2
- prompt /^[\w\s.@_\/:-]+#/
2
+ prompt /^[\w\s\(\).@_\/:-]+#/
3
3
 
4
4
  cmd :all do |cfg|
5
5
  cfg.cut_both
@@ -1,5 +1,5 @@
1
1
  class NetScaler < Oxidized::Model
2
- prompt /^>\s*$/
2
+ prompt /^([\w\.-]*>\s?)$/
3
3
  comment '# '
4
4
 
5
5
  cmd :all do |cfg|
@@ -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 /Time/ or line.match /Update/ }.join
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 cfg.each_line.reject { |line| line.match /Time/ or line.match /speed/ }
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'
@@ -2,7 +2,7 @@ class NXOS < Oxidized::Model
2
2
  prompt /^(\r?[\w.@_()-]+[#]\s?)$/
3
3
  comment '! '
4
4
 
5
- def filter cfg
5
+ def filter(cfg)
6
6
  cfg.gsub! /\r\n?/, "\n"
7
7
  cfg.gsub! prompt, ''
8
8
  end
@@ -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 comment
10
+ def add_comment(comment)
11
11
  "\n+++++++++++++++++++++++++++++++++++++++++ #{comment} ++++++++++++++++++++++++++++++++++++++++++++++\n"
12
12
  end
13
13
 
14
- def add_small_comment 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 want_type
8
+ def type_to_str(want_type)
9
9
  type(want_type).map { |out| out }.join
10
10
  end
11
11
 
12
- def << output
12
+ def <<(output)
13
13
  @outputs << output
14
14
  end
15
15
 
16
- def unshift output
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 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.match /^System Name\w*:\w*GS-.*$/
37
- @planetsgs = true if cfg.match /SGS-(.*) Device, Compiled on .*$/
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 |cfg|
57
- comment cfg
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