oxidized 0.21.0 → 0.22.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (170) hide show
  1. checksums.yaml +5 -5
  2. data/.github/no-response.yml +13 -0
  3. data/.gitignore +3 -0
  4. data/.rubocop.yml +37 -0
  5. data/.rubocop_todo.yml +714 -0
  6. data/.travis.yml +7 -1
  7. data/CHANGELOG.md +341 -243
  8. data/Dockerfile +44 -16
  9. data/LICENSE +201 -0
  10. data/README.md +114 -82
  11. data/Rakefile +19 -0
  12. data/TODO.md +29 -23
  13. data/bin/oxidized +1 -2
  14. data/docs/Configuration.md +71 -31
  15. data/docs/Creating-Models.md +78 -0
  16. data/docs/Hooks.md +145 -41
  17. data/docs/Model-Notes/AireOS.md +12 -0
  18. data/docs/Model-Notes/ArbOS.md +12 -0
  19. data/docs/Model-Notes/Comware.md +14 -0
  20. data/docs/Model-Notes/EOS.md +9 -0
  21. data/docs/Model-Notes/JunOS.md +34 -0
  22. data/docs/Model-Notes/Netgear.md +68 -0
  23. data/docs/Model-Notes/README.md +19 -0
  24. data/docs/{VRP-Huawei.md → Model-Notes/VRP-Huawei.md} +10 -2
  25. data/docs/Model-Notes/XGS4600-Zyxel.md +39 -0
  26. data/docs/Outputs.md +27 -28
  27. data/docs/Ruby-API.md +38 -18
  28. data/docs/Sources.md +78 -16
  29. data/docs/Supported-OS-Types.md +171 -148
  30. data/extra/oxidized.logrotate +7 -0
  31. data/extra/oxidized.service +1 -1
  32. data/extra/rest_client.rb +4 -5
  33. data/extra/syslog.rb +16 -16
  34. data/lib/oxidized/cli.rb +3 -3
  35. data/lib/oxidized/config.rb +7 -4
  36. data/lib/oxidized/core.rb +3 -3
  37. data/lib/oxidized/hook.rb +64 -65
  38. data/lib/oxidized/hook/awssns.rb +2 -3
  39. data/lib/oxidized/hook/ciscosparkdiff.rb +49 -0
  40. data/lib/oxidized/hook/exec.rb +5 -5
  41. data/lib/oxidized/hook/githubrepo.rb +20 -14
  42. data/lib/oxidized/hook/slackdiff.rb +38 -19
  43. data/lib/oxidized/hook/xmppdiff.rb +58 -0
  44. data/lib/oxidized/input/cli.rb +5 -6
  45. data/lib/oxidized/input/ftp.rb +8 -7
  46. data/lib/oxidized/input/http.rb +39 -0
  47. data/lib/oxidized/input/ssh.rb +24 -22
  48. data/lib/oxidized/input/telnet.rb +38 -32
  49. data/lib/oxidized/jobs.rb +3 -4
  50. data/lib/oxidized/manager.rb +9 -4
  51. data/lib/oxidized/model/acos.rb +15 -16
  52. data/lib/oxidized/model/acsw.rb +3 -8
  53. data/lib/oxidized/model/aen.rb +1 -2
  54. data/lib/oxidized/model/aireos.rb +3 -5
  55. data/lib/oxidized/model/alteonos.rb +16 -18
  56. data/lib/oxidized/model/alvarion.rb +0 -4
  57. data/lib/oxidized/model/aos.rb +2 -4
  58. data/lib/oxidized/model/aos7.rb +2 -3
  59. data/lib/oxidized/model/aosw.rb +13 -15
  60. data/lib/oxidized/model/apc_aos.rb +0 -3
  61. data/lib/oxidized/model/arbos.rb +26 -0
  62. data/lib/oxidized/model/aricentiss.rb +51 -0
  63. data/lib/oxidized/model/asa.rb +33 -35
  64. data/lib/oxidized/model/asyncos.rb +41 -44
  65. data/lib/oxidized/model/audiocodes.rb +4 -8
  66. data/lib/oxidized/model/awplus.rb +84 -0
  67. data/lib/oxidized/model/boss.rb +6 -5
  68. data/lib/oxidized/model/br6910.rb +43 -45
  69. data/lib/oxidized/model/c4cmts.rb +3 -5
  70. data/lib/oxidized/model/cambium.rb +22 -0
  71. data/lib/oxidized/model/catos.rb +0 -2
  72. data/lib/oxidized/model/cisconga.rb +1 -3
  73. data/lib/oxidized/model/ciscosma.rb +37 -40
  74. data/lib/oxidized/model/ciscosmb.rb +7 -4
  75. data/lib/oxidized/model/comnetms.rb +43 -0
  76. data/lib/oxidized/model/comware.rb +9 -9
  77. data/lib/oxidized/model/coriant8600.rb +3 -5
  78. data/lib/oxidized/model/coriantgroove.rb +3 -5
  79. data/lib/oxidized/model/corianttmos.rb +1 -3
  80. data/lib/oxidized/model/cumulus.rb +26 -32
  81. data/lib/oxidized/model/datacom.rb +0 -2
  82. data/lib/oxidized/model/dcnos.rb +46 -0
  83. data/lib/oxidized/model/dlink.rb +1 -1
  84. data/lib/oxidized/model/dnos.rb +9 -5
  85. data/lib/oxidized/model/edgecos.rb +45 -0
  86. data/lib/oxidized/model/edgeos.rb +5 -3
  87. data/lib/oxidized/model/edgeswitch.rb +1 -3
  88. data/lib/oxidized/model/enterasys.rb +1 -3
  89. data/lib/oxidized/model/eos.rb +6 -8
  90. data/lib/oxidized/model/fabricos.rb +3 -5
  91. data/lib/oxidized/model/firewareos.rb +2 -5
  92. data/lib/oxidized/model/fortios.rb +21 -17
  93. data/lib/oxidized/model/ftos.rb +2 -4
  94. data/lib/oxidized/model/fujitsupy.rb +2 -4
  95. data/lib/oxidized/model/gaiaos.rb +6 -10
  96. data/lib/oxidized/model/gcombnps.rb +82 -0
  97. data/lib/oxidized/model/hatteras.rb +8 -5
  98. data/lib/oxidized/model/hirschmann.rb +8 -10
  99. data/lib/oxidized/model/hpebladesystem.rb +19 -17
  100. data/lib/oxidized/model/hpemsa.rb +0 -3
  101. data/lib/oxidized/model/ios.rb +54 -55
  102. data/lib/oxidized/model/iosxe.rb +5 -0
  103. data/lib/oxidized/model/iosxr.rb +1 -3
  104. data/lib/oxidized/model/ipos.rb +1 -3
  105. data/lib/oxidized/model/ironware.rb +12 -15
  106. data/lib/oxidized/model/isam.rb +4 -5
  107. data/lib/oxidized/model/junos.rb +8 -7
  108. data/lib/oxidized/model/masteros.rb +1 -3
  109. data/lib/oxidized/model/mlnxos.rb +3 -4
  110. data/lib/oxidized/model/model.rb +15 -7
  111. data/lib/oxidized/model/mtrlrfs.rb +1 -4
  112. data/lib/oxidized/model/ndms.rb +24 -0
  113. data/lib/oxidized/model/netgear.rb +3 -4
  114. data/lib/oxidized/model/netscaler.rb +0 -2
  115. data/lib/oxidized/model/nos.rb +1 -3
  116. data/lib/oxidized/model/nxos.rb +13 -3
  117. data/lib/oxidized/model/oneos.rb +6 -8
  118. data/lib/oxidized/model/openbsd.rb +76 -0
  119. data/lib/oxidized/model/opengear.rb +3 -5
  120. data/lib/oxidized/model/openwrt.rb +77 -0
  121. data/lib/oxidized/model/opnsense.rb +19 -0
  122. data/lib/oxidized/model/outputs.rb +1 -3
  123. data/lib/oxidized/model/panos.rb +1 -2
  124. data/lib/oxidized/model/pfsense.rb +9 -5
  125. data/lib/oxidized/model/planet.rb +8 -12
  126. data/lib/oxidized/model/powerconnect.rb +6 -9
  127. data/lib/oxidized/model/procurve.rb +18 -4
  128. data/lib/oxidized/model/quantaos.rb +3 -5
  129. data/lib/oxidized/model/routeros.rb +3 -2
  130. data/lib/oxidized/model/saos.rb +0 -1
  131. data/lib/oxidized/model/screenos.rb +3 -5
  132. data/lib/oxidized/model/sgos.rb +2 -3
  133. data/lib/oxidized/model/siklu.rb +0 -2
  134. data/lib/oxidized/model/slxos.rb +59 -0
  135. data/lib/oxidized/model/sros.rb +117 -0
  136. data/lib/oxidized/model/stoneos.rb +32 -0
  137. data/lib/oxidized/model/supermicro.rb +6 -41
  138. data/lib/oxidized/model/timos.rb +6 -114
  139. data/lib/oxidized/model/tmos.rb +1 -3
  140. data/lib/oxidized/model/tplink.rb +7 -11
  141. data/lib/oxidized/model/trango.rb +6 -7
  142. data/lib/oxidized/model/ucs.rb +0 -1
  143. data/lib/oxidized/model/voltaire.rb +3 -6
  144. data/lib/oxidized/model/voss.rb +1 -2
  145. data/lib/oxidized/model/vrp.rb +4 -5
  146. data/lib/oxidized/model/vyatta.rb +6 -4
  147. data/lib/oxidized/model/weos.rb +1 -3
  148. data/lib/oxidized/model/xos.rb +6 -5
  149. data/lib/oxidized/model/zhoneolt.rb +2 -2
  150. data/lib/oxidized/model/zynos.rb +1 -3
  151. data/lib/oxidized/model/zynoscli.rb +36 -0
  152. data/lib/oxidized/node.rb +11 -11
  153. data/lib/oxidized/node/stats.rb +15 -2
  154. data/lib/oxidized/nodes.rb +8 -8
  155. data/lib/oxidized/output/file.rb +41 -42
  156. data/lib/oxidized/output/git.rb +113 -115
  157. data/lib/oxidized/output/gitcrypt.rb +241 -242
  158. data/lib/oxidized/output/http.rb +23 -27
  159. data/lib/oxidized/output/output.rb +1 -2
  160. data/lib/oxidized/source/csv.rb +44 -45
  161. data/lib/oxidized/source/http.rb +52 -49
  162. data/lib/oxidized/source/source.rb +6 -7
  163. data/lib/oxidized/source/sql.rb +55 -51
  164. data/lib/oxidized/string.rb +3 -4
  165. data/lib/oxidized/version.rb +17 -1
  166. data/lib/oxidized/worker.rb +12 -3
  167. data/oxidized.gemspec +19 -13
  168. metadata +139 -51
  169. data/.ruby-version +0 -1
  170. data/Gemfile.lock +0 -44
@@ -1,8 +1,8 @@
1
1
  class Trango < Oxidized::Model
2
2
  # take a Trangolink sysinfo output and turn it into a configuration file
3
-
3
+
4
4
  prompt /^#>\s?/
5
- comment '# '
5
+ comment '# '
6
6
 
7
7
  cmd 'sysinfo' do |cfg|
8
8
  out = []
@@ -47,16 +47,15 @@ class Trango < Oxidized::Model
47
47
  end
48
48
  if line.match /\[IP\] (\S+) \[Subnet Mask\] (\S+) \[Gateway\] (\S+)/
49
49
  out << "ipconfig " + Regexp.last_match[1] + ' ' +
50
- Regexp.last_match[2] + ' ' +
51
- Regexp.last_match[3]
50
+ Regexp.last_match[2] + ' ' +
51
+ Regexp.last_match[3]
52
52
  end
53
- end
53
+ end
54
54
  comments.push(*out).join "\n"
55
- end
55
+ end
56
56
 
57
57
  cfg :telnet do
58
58
  password /Password:/
59
59
  pre_logout 'exit'
60
60
  end
61
-
62
61
  end
@@ -1,5 +1,4 @@
1
1
  class UCS < Oxidized::Model
2
-
3
2
  prompt /^(\r?[\w.@_()-]+[#]\s?)$/
4
3
  comment '! '
5
4
 
@@ -1,18 +1,16 @@
1
1
  class VOLTAIRE < Oxidized::Model
2
-
3
2
  prompt /([\w.@()-\[:\s\]]+[#>]\s|(One or more tests have failed.*))$/
4
- comment '## '
5
-
3
+ comment '## '
4
+
6
5
  # Pager Handling
7
6
  expect /.+lines\s\d+\-\d+([\s]|\/\d+\s\(END\)\s).+$/ do |data, re|
8
7
  send ' '
9
8
  data.sub re, ''
10
9
  end
11
10
 
12
-
13
11
  cmd :all do |cfg|
14
12
  cfg.gsub! /\[\?1h=\r/, '' # Pager Handling
15
- cfg.gsub! /\r\[K/,'' # Pager Handling
13
+ cfg.gsub! /\r\[K/, '' # Pager Handling
16
14
  cfg.gsub! /\s/, '' # Linebreak Handling
17
15
  cfg.gsub! /^CPU\ load\ averages\:\s.+/, '' # Omit constantly changing CPU info
18
16
  cfg.gsub! /^System\ memory\:\s.+/, '' # Omit constantly changing memory info
@@ -27,7 +25,6 @@ class VOLTAIRE < Oxidized::Model
27
25
  cfg
28
26
  end
29
27
 
30
-
31
28
  cmd 'version show' do |cfg|
32
29
  comment cfg
33
30
  end
@@ -10,7 +10,7 @@ class Voss < Oxidized::Model
10
10
 
11
11
  # needed for proper formatting after post_login
12
12
  cmd('') { |cfg| comment "#{cfg}\n" }
13
-
13
+
14
14
  # Get sys-info and remove information that changes such has temperature and power
15
15
  cmd 'show sys-info' do |cfg|
16
16
  cfg.gsub! /(^((.*)SysUpTime(.*))$)/, 'removed SysUpTime'
@@ -38,5 +38,4 @@ class Voss < Oxidized::Model
38
38
  post_login 'enable'
39
39
  post_login 'terminal more disable'
40
40
  end
41
-
42
41
  end
@@ -1,6 +1,6 @@
1
1
  class VRP < Oxidized::Model
2
2
  # Huawei VRP
3
-
3
+
4
4
  prompt /^(<[\w.-]+>)$/
5
5
  comment '# '
6
6
 
@@ -13,19 +13,19 @@ class VRP < Oxidized::Model
13
13
  cmd :all do |cfg|
14
14
  cfg.each_line.to_a[1..-2].join
15
15
  end
16
-
16
+
17
17
  cfg :telnet do
18
18
  username /^Username:$/
19
19
  password /^Password:$/
20
20
  end
21
21
 
22
- cfg :telnet, :ssh do
22
+ cfg :telnet, :ssh do
23
23
  post_login 'screen-length 0 temporary'
24
24
  pre_logout 'quit'
25
25
  end
26
26
 
27
27
  cmd 'display version' do |cfg|
28
- cfg = cfg.each_line.select {|l| not l.match /uptime/ }.join
28
+ cfg = cfg.each_line.reject { |l| l.match /uptime/ }.join
29
29
  comment cfg
30
30
  end
31
31
 
@@ -36,5 +36,4 @@ class VRP < Oxidized::Model
36
36
  cmd 'display current-configuration all' do |cfg|
37
37
  cfg
38
38
  end
39
-
40
39
  end
@@ -1,7 +1,6 @@
1
1
  class Vyatta < Oxidized::Model
2
-
3
2
  # Brocade Vyatta / VyOS model #
4
-
3
+
5
4
  prompt /\@.*?\:~\$\s/
6
5
 
7
6
  cmd :all do |cfg|
@@ -9,11 +8,15 @@ class Vyatta < Oxidized::Model
9
8
  end
10
9
 
11
10
  cmd :secret do |cfg|
11
+ cfg.gsub! /encrypted-password (\S+).*/, 'encrypted-password <secret removed>'
12
+ cfg.gsub! /plaintext-password (\S+).*/, 'plaintext-password <secret removed>'
13
+ cfg.gsub! /password (\S+).*/, 'password <secret removed>'
14
+ cfg.gsub! /pre-shared-secret (\S+).*/, 'pre-shared-secret <secret removed>'
12
15
  cfg.gsub! /community (\S+) {/, 'community <hidden> {'
13
16
  cfg
14
17
  end
15
18
 
16
- cmd 'show configuration | no-more'
19
+ cmd 'show configuration commands | no-more'
17
20
 
18
21
  cfg :telnet do
19
22
  username /login:\s/
@@ -23,5 +26,4 @@ class Vyatta < Oxidized::Model
23
26
  cfg :telnet, :ssh do
24
27
  pre_logout 'exit'
25
28
  end
26
-
27
29
  end
@@ -1,6 +1,5 @@
1
1
  class WEOS < Oxidized::Model
2
-
3
- #Westell WEOS, works with Westell 8178G, Westell 8266G
2
+ # Westell WEOS, works with Westell 8178G, Westell 8266G
4
3
 
5
4
  prompt /^(\s[\w.@-]+[#>]\s?)$/
6
5
 
@@ -18,5 +17,4 @@ class WEOS < Oxidized::Model
18
17
  post_login 'cli more disable'
19
18
  pre_logout 'logout'
20
19
  end
21
-
22
20
  end
@@ -1,5 +1,4 @@
1
1
  class XOS < Oxidized::Model
2
-
3
2
  # Extreme Networks XOS
4
3
 
5
4
  prompt /^*?[\w .-]+# $/
@@ -8,7 +7,7 @@ class XOS < Oxidized::Model
8
7
  cmd :all do |cfg|
9
8
  # xos inserts leading \r characters and other trailing white space.
10
9
  # this deletes extraneous \r and trailing white space.
11
- cfg.each_line.to_a[1..-2].map{|line|line.delete("\r").rstrip}.join("\n") + "\n"
10
+ cfg.each_line.to_a[1..-2].map { |line| line.delete("\r").rstrip }.join("\n") + "\n"
12
11
  end
13
12
 
14
13
  cmd 'show version' do |cfg|
@@ -23,11 +22,14 @@ class XOS < Oxidized::Model
23
22
  comment cfg
24
23
  end
25
24
 
26
- cmd 'show switch'do |cfg|
25
+ cmd 'show switch' do |cfg|
27
26
  comment cfg.each_line.reject { |line| line.match /Time:/ or line.match /boot/i }.join
28
27
  end
29
28
 
30
- cmd 'show configuration'
29
+ cmd 'show configuration' do |cfg|
30
+ cfg = cfg.each_line.reject { |line| line.match /^#(\s[\w]+\s)(Configuration generated)/ }.join
31
+ cfg
32
+ end
31
33
 
32
34
  cmd 'show policy detail' do |cfg|
33
35
  comment cfg
@@ -45,5 +47,4 @@ class XOS < Oxidized::Model
45
47
  send "n\n"
46
48
  end
47
49
  end
48
-
49
50
  end
@@ -18,7 +18,7 @@ class ZhoneOLT < Oxidized::Model
18
18
  end
19
19
 
20
20
  cmd :all do |cfg|
21
- cfg.each_line.to_a[1..-2].map{|line|line.delete("\r").rstrip}.join("\n") + "\n"
21
+ cfg.each_line.to_a[1..-2].map { |line| line.delete("\r").rstrip }.join("\n") + "\n"
22
22
  end
23
23
 
24
24
  cmd 'swversion' do |cfg|
@@ -39,7 +39,7 @@ class ZhoneOLT < Oxidized::Model
39
39
  end
40
40
 
41
41
  cmd 'dump console' do |cfg|
42
- cfg = cfg.each_line.select { |line| not line.match /To Abort the operation enter Ctrl-C/ }.join
42
+ cfg = cfg.each_line.reject { |line| line.match /To Abort the operation enter Ctrl-C/ }.join
43
43
  end
44
44
 
45
45
  # zhone technically supports ssh, but it locks up a ton. Especially when
@@ -1,12 +1,10 @@
1
1
  class ZyNOS < Oxidized::Model
2
-
3
2
  # Used in Zyxel DSLAMs, such as SAM1316
4
3
 
5
- comment '! '
4
+ comment '! '
6
5
 
7
6
  cmd 'config-0'
8
7
 
9
8
  cfg :ftp do
10
9
  end
11
-
12
10
  end
@@ -0,0 +1,36 @@
1
+ class ZyNOSCLI < Oxidized::Model
2
+ # Used in Zyxel DSLAMs, such as SAM1316
3
+
4
+ # Typical prompt "XGS4600#"
5
+ prompt /^([\w.@()-]+[#>]\s\e7)$/
6
+ comment ';; '
7
+
8
+ cmd :all do |cfg|
9
+ cfg.gsub! /^.*\e7/, ''
10
+ end
11
+ cmd 'show stacking'
12
+
13
+ cmd 'show version'
14
+
15
+ cmd 'show running-config'
16
+
17
+ cfg :telnet do
18
+ username /^User name:/i
19
+ password /^Password:/i
20
+ end
21
+
22
+ cfg :telnet, :ssh do
23
+ if vars :enable
24
+ post_login do
25
+ send "enable\n"
26
+ # Interpret enable: true as meaning we won't be prompted for a password
27
+ unless vars(:enable).is_a? TrueClass
28
+ expect /[pP]assword:\s?$/
29
+ send vars(:enable) + "\n"
30
+ end
31
+ expect /^.+[#]$/
32
+ end
33
+ end
34
+ pre_logout 'exit'
35
+ end
36
+ end
@@ -15,7 +15,8 @@ module Oxidized
15
15
  ip_addr, _ = opt[:ip].to_s.split("/")
16
16
  Oxidized.logger.debug 'IPADDR %s' % ip_addr.to_s
17
17
  @name = opt[:name]
18
- @ip = IPAddr.new(ip_addr).to_s rescue nil
18
+ @ip = @name unless Oxidized.config.resolve_dns?
19
+ @ip ||= IPAddr.new(ip_addr).to_s rescue nil
19
20
  @ip ||= Resolv.new.getaddress @name
20
21
  @group = opt[:group]
21
22
  @input = resolve_input opt
@@ -39,7 +40,7 @@ module Oxidized
39
40
  cfg_name = input.to_s.split('::').last.downcase
40
41
  next unless @model.cfg[cfg_name] and not @model.cfg[cfg_name].empty?
41
42
  @model.input = input = input.new
42
- if config=run_input(input)
43
+ if config = run_input(input)
43
44
  Oxidized.logger.debug "lib/oxidized/node.rb: #{input.class.name} ran for #{name} successfully"
44
45
  status = :success
45
46
  break
@@ -55,7 +56,7 @@ module Oxidized
55
56
  def run_input input
56
57
  rescue_fail = {}
57
58
  [input.class::RescueFail, input.class.superclass::RescueFail].each do |hash|
58
- hash.each do |level,errors|
59
+ hash.each do |level, errors|
59
60
  errors.each do |err|
60
61
  rescue_fail[err] = level
61
62
  end
@@ -64,9 +65,9 @@ module Oxidized
64
65
  begin
65
66
  input.connect(self) and input.get
66
67
  rescue *rescue_fail.keys => err
67
- resc = ''
68
+ resc = ''
68
69
  if not level = rescue_fail[err.class]
69
- resc = err.class.ancestors.find{|e|rescue_fail.keys.include? e}
70
+ resc = err.class.ancestors.find { |e| rescue_fail.keys.include? e }
70
71
  level = rescue_fail[resc]
71
72
  resc = " (rescued #{resc})"
72
73
  end
@@ -196,20 +197,20 @@ module Oxidized
196
197
  end
197
198
  end
198
199
 
199
- def resolve_key key, opt, global=nil
200
+ def resolve_key key, opt, global = nil
200
201
  # resolve key, first get global, then get group then get node config
201
202
  key_sym = key.to_sym
202
203
  key_str = key.to_s
203
204
  value = global
204
205
  Oxidized.logger.debug "node.rb: resolving node key '#{key}', with passed global value of '#{value}' and node value '#{opt[key_sym]}'"
205
206
 
206
- #global
207
+ # global
207
208
  if not value and Oxidized.config.has_key?(key_str)
208
209
  value = Oxidized.config[key_str]
209
210
  Oxidized.logger.debug "node.rb: setting node key '#{key}' to value '#{value}' from global"
210
211
  end
211
212
 
212
- #group
213
+ # group
213
214
  if Oxidized.config.groups.has_key?(@group)
214
215
  if Oxidized.config.groups[@group].has_key?(key_str)
215
216
  value = Oxidized.config.groups[@group][key_str]
@@ -217,7 +218,7 @@ module Oxidized
217
218
  end
218
219
  end
219
220
 
220
- #model
221
+ # model
221
222
  # FIXME: warning: instance variable @model not initialized
222
223
  if Oxidized.config.models.has_key?(@model.class.name.to_s.downcase)
223
224
  if Oxidized.config.models[@model.class.name.to_s.downcase].has_key?(key_str)
@@ -226,7 +227,7 @@ module Oxidized
226
227
  end
227
228
  end
228
229
 
229
- #node
230
+ # node
230
231
  value = opt[key_sym] || value
231
232
  Oxidized.logger.debug "node.rb: returning node key '#{key}' with value '#{value}'"
232
233
  value
@@ -239,6 +240,5 @@ module Oxidized
239
240
  def is_gitcrypt? opt
240
241
  (opt[:output] || Oxidized.config.output.default) == 'gitcrypt'
241
242
  end
242
-
243
243
  end
244
244
  end
@@ -14,20 +14,33 @@ module Oxidized
14
14
  @stats[job.status] ||= []
15
15
  @stats[job.status].shift if @stats[job.status].size > MAX_STAT
16
16
  @stats[job.status].push stat
17
+ @stats[:counter][job.status] += 1
17
18
  end
18
19
 
19
20
  # @param [Symbol] status stats for specific status
20
21
  # @return [Hash,Array] Hash of stats for every status or Array of stats for specific status
21
- def get status=nil
22
+ def get status = nil
22
23
  status ? @stats[status] : @stats
23
24
  end
24
25
 
26
+ def get_counter counter = nil
27
+ counter ? @stats[:counter][counter] : @stats[:counter]
28
+ end
29
+
30
+ def successes
31
+ @stats[:counter][:success]
32
+ end
33
+
34
+ def failures
35
+ @stats[:counter].reduce(0) { |m, h| h[0] == :success ? m : m + h[1] }
36
+ end
37
+
25
38
  private
26
39
 
27
40
  def initialize
28
41
  @stats = {}
42
+ @stats[:counter] = Hash.new 0
29
43
  end
30
-
31
44
  end
32
45
  end
33
46
  end
@@ -6,13 +6,14 @@ module Oxidized
6
6
  class Nodes < Array
7
7
  attr_accessor :source, :jobs
8
8
  alias :put :unshift
9
- def load node_want=nil
9
+ def load node_want = nil
10
10
  with_lock do
11
11
  new = []
12
12
  @source = Oxidized.config.source.default
13
13
  Oxidized.mgr.add_source @source
14
14
  Oxidized.logger.info "lib/oxidized/nodes.rb: Loading nodes"
15
- Oxidized.mgr.source[@source].new.load.each do |node|
15
+ nodes = Oxidized.mgr.source[@source].new.load node_want
16
+ nodes.each do |node|
16
17
  # we want to load specific node(s), not all of them
17
18
  next unless node_want? node_want, node
18
19
  begin
@@ -42,7 +43,6 @@ module Oxidized
42
43
  end
43
44
  end
44
45
 
45
-
46
46
  def list
47
47
  with_lock do
48
48
  map { |e| e.serialize }
@@ -63,7 +63,7 @@ module Oxidized
63
63
  end
64
64
 
65
65
  # @param node [String] name of the node moved into the head of array
66
- def next node, opt={}
66
+ def next node, opt = {}
67
67
  if waiting.find_node_index(node)
68
68
  with_lock do
69
69
  n = del node
@@ -113,10 +113,10 @@ module Oxidized
113
113
 
114
114
  private
115
115
 
116
- def initialize opts={}
116
+ def initialize opts = {}
117
117
  super()
118
118
  node = opts.delete :node
119
- @mutex= Mutex.new # we compete for the nodes with webapi thread
119
+ @mutex = Mutex.new # we compete for the nodes with webapi thread
120
120
  if nodes = opts.delete(:nodes)
121
121
  replace nodes
122
122
  else
@@ -129,7 +129,7 @@ module Oxidized
129
129
  end
130
130
 
131
131
  def find_index node
132
- index { |e| e.name == node or e.ip == node}
132
+ index { |e| e.name == node or e.ip == node }
133
133
  end
134
134
 
135
135
  # @param node node which is removed from nodes list
@@ -162,7 +162,7 @@ module Oxidized
162
162
  node.stats = old[i].stats
163
163
  node.last = old[i].last
164
164
  end
165
- rescue Oxidized::NodeNotFound
165
+ rescue Oxidized::NodeNotFound
166
166
  end
167
167
  end
168
168
  sort_by! { |x| x.last.nil? ? Time.new(0) : x.last.end }