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,19 +1,17 @@
1
1
  class IronWare < Oxidized::Model
2
-
3
2
  prompt /^.*(telnet|ssh)\@.+[>#]\s?$/i
4
3
  comment '! '
5
4
 
6
- #to handle pager without enable
7
- #expect /^((.*)--More--(.*))$/ do |data, re|
5
+ # to handle pager without enable
6
+ # expect /^((.*)--More--(.*))$/ do |data, re|
8
7
  # send ' '
9
8
  # data.sub re, ''
10
- #end
11
-
9
+ # end
12
10
 
13
- #to remove backspace (if handle pager without enable)
14
- #expect /^((.*)[\b](.*))$/ do |data, re|
11
+ # to remove backspace (if handle pager without enable)
12
+ # expect /^((.*)[\b](.*))$/ do |data, re|
15
13
  # data.sub re, ''
16
- #end
14
+ # end
17
15
 
18
16
  cmd :all do |cfg|
19
17
  # sometimes ironware inserts arbitrary whitespace after commands are
@@ -22,17 +20,17 @@ class IronWare < Oxidized::Model
22
20
  end
23
21
 
24
22
  cmd 'show version' do |cfg|
25
- cfg.gsub! /(^((.*)[Ss]ystem uptime(.*))$)/, '' #remove unwanted line system uptime
23
+ cfg.gsub! /(^((.*)[Ss]ystem uptime(.*))$)/, '' # remove unwanted line system uptime
26
24
  cfg.gsub! /(^((.*)[Tt]he system started at(.*))$)/, ''
27
- cfg.gsub! /[Uu]p\s?[Tt]ime is .*/,''
25
+ cfg.gsub! /[Uu]p\s?[Tt]ime is .*/, ''
28
26
 
29
27
  comment cfg
30
28
  end
31
29
 
32
30
  cmd 'show chassis' do |cfg|
33
- cfg.encode!("UTF-8", :invalid => :replace, :undef => :replace) #sometimes ironware returns broken encoding
34
- cfg.gsub! /(^((.*)Current temp(.*))$)/, '' #remove unwanted lines current temperature
35
- cfg.gsub! /Speed = [A-Z-]{2,6} \(\d{2,3}\%\)/, '' #remove unwanted lines Speed Fans
31
+ cfg.encode!("UTF-8", :invalid => :replace, :undef => :replace) # sometimes ironware returns broken encoding
32
+ cfg.gsub! /(^((.*)Current temp(.*))$)/, '' # remove unwanted lines current temperature
33
+ cfg.gsub! /Speed = [A-Z-]{2,6} \(\d{2,3}\%\)/, '' # remove unwanted lines Speed Fans
36
34
  cfg.gsub! /current speed is [A-Z]{2,6} \(\d{2,3}\%\)/, ''
37
35
  cfg.gsub! /Fan \d* - STATUS: OK \D*\d*./, '' # Fix for ADX Fan speed reporting
38
36
  cfg.gsub! /\d* deg C/, '' # Fix for ADX temperature reporting
@@ -73,7 +71,7 @@ class IronWare < Oxidized::Model
73
71
  password /^(Please Enter Password ?|Password):/
74
72
  end
75
73
 
76
- #handle pager with enable
74
+ # handle pager with enable
77
75
  cfg :telnet, :ssh do
78
76
  if vars :enable
79
77
  post_login do
@@ -86,5 +84,4 @@ class IronWare < Oxidized::Model
86
84
  post_login 'terminal length 0'
87
85
  pre_logout "logout\nexit\nexit\n"
88
86
  end
89
-
90
87
  end
@@ -1,6 +1,6 @@
1
1
  class ISAM < Oxidized::Model
2
- #Alcatel ISAM 7302/7330 FTTN
3
-
2
+ # Alcatel ISAM 7302/7330 FTTN
3
+
4
4
  prompt /^([\w.:@-]+>#\s)$/
5
5
  comment '# '
6
6
 
@@ -8,7 +8,7 @@ class ISAM < Oxidized::Model
8
8
  cfg.each_line.to_a[1..-2].join
9
9
  end
10
10
 
11
- cfg :telnet do
11
+ cfg :telnet do
12
12
  username /^login:\s*/
13
13
  password /^password:\s*/
14
14
  end
@@ -19,7 +19,7 @@ class ISAM < Oxidized::Model
19
19
  post_login 'environment inhibit-alarms print no-more'
20
20
  pre_logout 'logout'
21
21
  end
22
-
22
+
23
23
  cmd 'show software-mngt oswp detail' do |cfg|
24
24
  comment cfg
25
25
  end
@@ -31,5 +31,4 @@ class ISAM < Oxidized::Model
31
31
  cmd 'info configure flat' do |cfg|
32
32
  cfg
33
33
  end
34
-
35
34
  end
@@ -1,6 +1,5 @@
1
1
  class JunOS < Oxidized::Model
2
-
3
- comment '# '
2
+ comment '# '
4
3
 
5
4
  def telnet
6
5
  @input.class.to_s.match(/Telnet/)
@@ -8,12 +7,15 @@ class JunOS < Oxidized::Model
8
7
 
9
8
  cmd :all do |cfg|
10
9
  cfg = cfg.lines.to_a[1..-2].join if screenscrape
11
- cfg.gsub!(/ scale-subscriber (\s+)(\d+)/,' scale-subscriber <count>')
10
+ cfg.gsub!(/ scale-subscriber (\s+)(\d+)/, ' scale-subscriber <count>')
12
11
  cfg.lines.map { |line| line.rstrip }.join("\n") + "\n"
13
12
  end
14
13
 
15
14
  cmd :secret do |cfg|
16
- cfg.gsub!(/encrypted-password (\S+).*/, '<secret removed>')
15
+ cfg.gsub!(/encrypted-password (\S+).*/, 'encrypted-password <secret removed>')
16
+ cfg.gsub!(/pre-shared-key ascii-text (\S+).*/, 'pre-shared-key ascii-text <secret removed>')
17
+ cfg.gsub!(/pre-shared-key hexadecimal (\S+).*/, 'pre-shared-key hexadecimal <secret removed>')
18
+ cfg.gsub!(/authentication-key (\S+).*/, 'authentication-key <secret removed>')
17
19
  cfg.gsub!(/community (\S+) {/, 'community <hidden> {')
18
20
  cfg
19
21
  end
@@ -29,7 +31,7 @@ class JunOS < Oxidized::Model
29
31
  out = ''
30
32
  case @model
31
33
  when 'mx960'
32
- out << cmd('show chassis fabric reachability') { |cfg| comment cfg }
34
+ out << cmd('show chassis fabric reachability') { |cfg| comment cfg }
33
35
  when /^(ex22|ex33|ex4|ex8|qfx)/
34
36
  out << cmd('show virtual-chassis') { |cfg| comment cfg }
35
37
  end
@@ -46,7 +48,7 @@ class JunOS < Oxidized::Model
46
48
  end
47
49
 
48
50
  cfg :ssh do
49
- exec true # don't run shell, run each command in exec channel
51
+ exec true # don't run shell, run each command in exec channel
50
52
  end
51
53
 
52
54
  cfg :telnet, :ssh do
@@ -54,5 +56,4 @@ class JunOS < Oxidized::Model
54
56
  post_login 'set cli screen-width 0'
55
57
  pre_logout 'exit'
56
58
  end
57
-
58
59
  end
@@ -1,8 +1,7 @@
1
1
  class MasterOS < Oxidized::Model
2
-
3
2
  # MRV MasterOS model #
4
3
 
5
- comment '!'
4
+ comment '!'
6
5
 
7
6
  cmd :secret do |cfg|
8
7
  cfg.gsub! /^(snmp-server community).*/, '\\1 <configuration removed>'
@@ -43,5 +42,4 @@ comment '!'
43
42
  end
44
43
  pre_logout 'exit'
45
44
  end
46
-
47
45
  end
@@ -1,8 +1,7 @@
1
1
  class MLNXOS < Oxidized::Model
2
-
3
2
  prompt /([\w.@()-\[:\s\]]+[#>]\s)$/
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 ' '
@@ -11,7 +10,7 @@ class MLNXOS < Oxidized::Model
11
10
 
12
11
  cmd :all do |cfg|
13
12
  cfg.gsub! /\[\?1h=\r/, '' # Pager Handling
14
- cfg.gsub! /\r\[K/,'' # Pager Handling
13
+ cfg.gsub! /\r\[K/, '' # Pager Handling
15
14
  cfg.gsub! /\s/, '' # Linebreak Handling
16
15
  cfg.gsub! /^CPU\ load\ averages\:\s.+/, '' # Omit constantly changing CPU info
17
16
  cfg.gsub! /^System\ memory\:\s.+/, '' # Omit constantly changing memory info
@@ -7,29 +7,34 @@ module Oxidized
7
7
 
8
8
  class << self
9
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] = [] }
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
13
  klass.instance_variable_set '@expect', []
14
14
  klass.instance_variable_set '@comment', nil
15
15
  klass.instance_variable_set '@prompt', nil
16
16
  end
17
- def comment _comment='# '
17
+
18
+ def comment _comment = '# '
18
19
  return @comment if @comment
19
20
  @comment = block_given? ? yield : _comment
20
21
  end
21
- def prompt _prompt=nil
22
+
23
+ def prompt _prompt = nil
22
24
  @prompt or @prompt = _prompt
23
25
  end
26
+
24
27
  def cfg *methods, &block
25
28
  [methods].flatten.each do |method|
26
29
  @cfg[method.to_s] << block
27
30
  end
28
31
  end
32
+
29
33
  def cfgs
30
34
  @cfg
31
35
  end
32
- def cmd _cmd=nil, &block
36
+
37
+ def cmd _cmd = nil, &block
33
38
  if _cmd.class == Symbol
34
39
  @cmd[_cmd] << block
35
40
  else
@@ -37,12 +42,15 @@ module Oxidized
37
42
  end
38
43
  Oxidized.logger.debug "lib/oxidized/model/model.rb Added #{_cmd} to the commands list"
39
44
  end
45
+
40
46
  def cmds
41
47
  @cmd
42
48
  end
49
+
43
50
  def expect re, &block
44
51
  @expect << [re, block]
45
52
  end
53
+
46
54
  def expects
47
55
  @expect
48
56
  end
@@ -83,6 +91,7 @@ module Oxidized
83
91
  Oxidized.logger.debug "lib/oxidized/model/model.rb Executing #{string}"
84
92
  out = @input.cmd(string)
85
93
  return false unless out
94
+ out = out.b unless Oxidized.config.input.utf8_encoded?
86
95
  self.class.cmds[:all].each do |all_block|
87
96
  out = instance_exec Oxidized::String.new(out), string, &all_block
88
97
  end
@@ -166,6 +175,5 @@ module Oxidized
166
175
  output.set_cmd(name)
167
176
  output
168
177
  end
169
-
170
178
  end
171
179
  end
@@ -1,5 +1,4 @@
1
1
  class Mtrlrfs < Oxidized::Model
2
-
3
2
  # Motorola RFS/Extreme WM
4
3
 
5
4
  comment '# '
@@ -7,7 +6,7 @@ class Mtrlrfs < Oxidized::Model
7
6
  cmd :all do |cfg|
8
7
  # xos inserts leading \r characters and other trailing white space.
9
8
  # this deletes extraneous \r and trailing white space.
10
- cfg.each_line.to_a[1..-2].map{|line|line.delete("\r").rstrip}.join("\n") + "\n"
9
+ cfg.each_line.to_a[1..-2].map { |line| line.delete("\r").rstrip }.join("\n") + "\n"
11
10
  end
12
11
 
13
12
  cmd 'show version' do |cfg|
@@ -32,6 +31,4 @@ class Mtrlrfs < Oxidized::Model
32
31
  send "n\n"
33
32
  end
34
33
  end
35
-
36
34
  end
37
-
@@ -0,0 +1,24 @@
1
+ class NDMS < Oxidized::Model
2
+ # Pull config from Zyxel Keenetic devices from version NDMS >= 2.0
3
+
4
+ comment '! '
5
+
6
+ prompt /^([\w.@()-]+[#>]\s?)/m
7
+
8
+ cmd 'show version' do |cfg|
9
+ cfg = cfg.each_line.to_a[1..-3].join
10
+ comment cfg
11
+ end
12
+
13
+ cmd 'show running-config' do |cfg|
14
+ cfg = cfg.each_line.to_a[1..-2]
15
+ cfg = cfg.reject { |line| line.match /(clock date|checksum)/ }.join
16
+ cfg
17
+ end
18
+
19
+ cfg :telnet do
20
+ username /^Login:/
21
+ password /^Password:/
22
+ pre_logout 'exit'
23
+ end
24
+ end
@@ -1,15 +1,15 @@
1
1
  class Netgear < Oxidized::Model
2
-
3
2
  comment '!'
4
- prompt /^(\([\w-]+\)\s[#>])$/
3
+ prompt /^(\([\w\s\-.]+\)\s[#>])$/
5
4
 
6
5
  cmd :secret do |cfg|
7
6
  cfg.gsub!(/password (\S+)/, 'password <hidden>')
7
+ cfg.gsub!(/encrypted (\S+)/, 'encrypted <hidden>')
8
8
  cfg
9
9
  end
10
10
 
11
11
  cfg :telnet do
12
- username /^User:/
12
+ username /^(User:|Applying Interface configuration, please wait ...)/
13
13
  end
14
14
 
15
15
  cfg :telnet, :ssh do
@@ -36,5 +36,4 @@ class Netgear < Oxidized::Model
36
36
  cmd 'show running-config' do |cfg|
37
37
  cfg.gsub! /^(!.*Time).*$/, '\1'
38
38
  end
39
-
40
39
  end
@@ -1,5 +1,4 @@
1
1
  class NetScaler < Oxidized::Model
2
-
3
2
  prompt /^\>\s*$/
4
3
  comment '# '
5
4
 
@@ -20,5 +19,4 @@ class NetScaler < Oxidized::Model
20
19
  cfg :ssh do
21
20
  pre_logout 'exit'
22
21
  end
23
-
24
22
  end
@@ -1,5 +1,4 @@
1
1
  class NOS < Oxidized::Model
2
-
3
2
  # Brocade Network Operating System
4
3
 
5
4
  prompt /^(?:\e\[..h)?[\w.-]+# $/
@@ -38,8 +37,7 @@ class NOS < Oxidized::Model
38
37
 
39
38
  cfg :telnet, :ssh do
40
39
  post_login 'terminal length 0'
41
- #post_login 'terminal width 0'
40
+ # post_login 'terminal width 0'
42
41
  pre_logout 'exit'
43
42
  end
44
-
45
43
  end
@@ -1,8 +1,12 @@
1
1
  class NXOS < Oxidized::Model
2
-
3
2
  prompt /^(\r?[\w.@_()-]+[#]\s?)$/
4
3
  comment '! '
5
4
 
5
+ def filter cfg
6
+ cfg.gsub! /\r\n?/, "\n"
7
+ cfg.gsub! prompt, ''
8
+ end
9
+
6
10
  cmd :secret do |cfg|
7
11
  cfg.gsub! /^(snmp-server community).*/, '\\1 <configuration removed>'
8
12
  cfg.gsub! /^(snmp-server user (\S+) (\S+) auth (\S+)) (\S+) (priv) (\S+)/, '\\1 <configuration removed> '
@@ -10,18 +14,24 @@ class NXOS < Oxidized::Model
10
14
  cfg.gsub! /^(radius-server key).*/, '\\1 <secret hidden>'
11
15
  cfg
12
16
  end
13
-
17
+
14
18
  cmd 'show version' do |cfg|
19
+ cfg = filter cfg
15
20
  cfg = cfg.each_line.take_while { |line| not line.match(/uptime/i) }
16
21
  comment cfg.join ""
17
22
  end
18
23
 
19
24
  cmd 'show inventory' do |cfg|
25
+ cfg = filter cfg
20
26
  comment cfg
21
- end
27
+ end
22
28
 
23
29
  cmd 'show running-config' do |cfg|
30
+ cfg = filter cfg
31
+ cfg.gsub! /^(show run.*)$/, '! \1'
24
32
  cfg.gsub! /^!Time:[^\n]*\n/, ''
33
+ cfg.gsub! /^[\w.@_()-]+[#].*$/, ''
34
+ cfg
25
35
  end
26
36
 
27
37
  cfg :ssh, :telnet do
@@ -1,24 +1,23 @@
1
1
  class OneOS < Oxidized::Model
2
-
3
2
  prompt /^([\w.@()-]+#\s?)$/
4
3
  comment '! '
5
4
 
6
5
  # example how to handle pager
7
- #expect /^\s--More--\s+.*$/ do |data, re|
6
+ # expect /^\s--More--\s+.*$/ do |data, re|
8
7
  # send ' '
9
8
  # data.sub re, ''
10
- #end
9
+ # end
11
10
 
12
11
  # non-preferred way to handle additional PW prompt
13
- #expect /^[\w.]+>$/ do |data|
12
+ # expect /^[\w.]+>$/ do |data|
14
13
  # send "enable\n"
15
14
  # send vars(:enable) + "\n"
16
15
  # data
17
- #end
16
+ # end
18
17
 
19
18
  cmd :all do |cfg|
20
- #cfg.gsub! /\cH+\s{8}/, '' # example how to handle pager
21
- #cfg.gsub! /\cH+/, '' # example how to handle pager
19
+ # cfg.gsub! /\cH+\s{8}/, '' # example how to handle pager
20
+ # cfg.gsub! /\cH+/, '' # example how to handle pager
22
21
  cfg.each_line.to_a[1..-2].join
23
22
  end
24
23
 
@@ -54,5 +53,4 @@ class OneOS < Oxidized::Model
54
53
  post_login 'term len 0'
55
54
  pre_logout 'exit'
56
55
  end
57
-
58
56
  end
@@ -0,0 +1,76 @@
1
+ class Openbsd < Oxidized::Model
2
+ # OpenBSD with custom promp, like user@hostname:~$
3
+ # you can edit the one that your user uses, with root would be /root/.profile using the next PS1 def
4
+ # export PS1="\033[32m\u@\h\033[00m:\033[36m\w\033[00m$ "
5
+
6
+ prompt /^.+@.+\:.+\$/
7
+ comment '# '
8
+
9
+ # Add a comment between files/configs
10
+ def add_comment comment
11
+ "\n+++++++++++++++++++++++++++++++++++++++++ #{comment} ++++++++++++++++++++++++++++++++++++++++++++++\n"
12
+ end
13
+
14
+ def add_small_comment comment
15
+ "\n=============== #{comment} ===============\n"
16
+ end
17
+
18
+ cmd :all do |cfg|
19
+ cfg.each_line.to_a[1..-2].join
20
+ end
21
+
22
+ # Issue the show commands
23
+ pre do
24
+ cfg = add_comment('HOSTNAME FILE')
25
+ cfg += cmd('cat /etc/myname')
26
+
27
+ cfg += add_comment('HOSTS FILE')
28
+ cfg += cmd('cat /etc/hosts')
29
+
30
+ cfg += add_comment('INTERFACE FILES')
31
+ cfg += cmd('tail -n +1 /etc/hostname.*')
32
+
33
+ cfg += add_comment('RESOLV.CONF FILE')
34
+ cfg += cmd('cat /etc/resolv.conf')
35
+
36
+ cfg += add_comment('NTP.CONF FILE')
37
+ cfg += cmd('cat /etc/ntp.conf')
38
+
39
+ cfg += add_comment('IP ROUTES PER ROUTING DOMAIN')
40
+ cfg += add_small_comment('Routing Domain 0')
41
+ cfg += cmd('route -T0 exec netstat -rn')
42
+ cfg += add_small_comment('Routing Domain 1')
43
+ cfg += cmd('route -T1 exec netstat -rn')
44
+ cfg += add_small_comment('Routing Domain 2')
45
+ cfg += cmd('route -T2 exec netstat -rn')
46
+ cfg += add_small_comment('Routing Domain 3')
47
+ cfg += cmd('route -T3 exec netstat -rn')
48
+ cfg += add_small_comment('Routing Domain 4')
49
+ cfg += cmd('route -T4 exec netstat -rn')
50
+ cfg += add_small_comment('Routing Domain 5')
51
+ cfg += cmd('route -T5 exec netstat -rn')
52
+
53
+ cfg += add_comment('SNMP FILE')
54
+ cfg += cmd('cat /etc/snmpd.conf')
55
+
56
+ cfg += add_comment('PF FILE')
57
+ cfg += cmd('cat /etc/pf.conf')
58
+
59
+ cfg += add_comment('MOTD FILE')
60
+ cfg += cmd('cat /etc/motd')
61
+
62
+ cfg += add_comment('PASSWD FILE')
63
+ cfg += cmd('cat /etc/passwd')
64
+
65
+ cfg += add_small_comment('END')
66
+ end
67
+
68
+ cfg :telnet do
69
+ username /^Username:/
70
+ password /^Password:/
71
+ end
72
+
73
+ cfg :telnet, :ssh do
74
+ pre_logout 'exit'
75
+ end
76
+ end