oxidized 0.28.0 → 0.29.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (233) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +31 -0
  3. data/.github/workflows/codeql.yml +76 -0
  4. data/.github/workflows/publishdocker.yml +11 -2
  5. data/.github/workflows/ruby.yml +42 -0
  6. data/.github/workflows/stale.yml +16 -0
  7. data/.rubocop.yml +30 -10
  8. data/.rubocop_todo.yml +97 -43
  9. data/CHANGELOG.md +149 -2
  10. data/Dockerfile +15 -9
  11. data/README.md +63 -32
  12. data/Rakefile +2 -0
  13. data/docs/Configuration.md +49 -7
  14. data/docs/Creating-Models.md +24 -19
  15. data/docs/Hooks.md +35 -6
  16. data/docs/Model-Notes/ADVA.md +12 -0
  17. data/docs/Model-Notes/Cumulus.md +7 -1
  18. data/docs/Model-Notes/IOS.md +36 -0
  19. data/docs/Model-Notes/JunOS.md +3 -3
  20. data/docs/Model-Notes/LenovoNOS.md +29 -0
  21. data/docs/Model-Notes/LinksysSRW.md +15 -0
  22. data/docs/Model-Notes/Nokia.md +3 -0
  23. data/docs/Model-Notes/OS10.md +33 -0
  24. data/docs/Model-Notes/PanOS_API.md +28 -0
  25. data/docs/Model-Notes/README.md +2 -0
  26. data/docs/Ruby-API.md +12 -8
  27. data/docs/Sources.md +18 -0
  28. data/docs/Supported-OS-Types.md +51 -6
  29. data/docs/Troubleshooting.md +1 -1
  30. data/extra/gitdiff-msteams.sh +91 -0
  31. data/extra/nagios_check_failing_nodes.rb +6 -9
  32. data/extra/oxidized-report-git-commits +71 -14
  33. data/extra/oxidized.init +2 -5
  34. data/extra/oxidized.logrotate +1 -0
  35. data/extra/oxidized.runit +4 -1
  36. data/extra/oxidized.service +5 -8
  37. data/extra/rest_client.rb +1 -1
  38. data/extra/syslog.rb +2 -2
  39. data/lib/oxidized/cli.rb +1 -1
  40. data/lib/oxidized/config/vars.rb +5 -2
  41. data/lib/oxidized/config.rb +6 -3
  42. data/lib/oxidized/core.rb +1 -1
  43. data/lib/oxidized/hook/exec.rb +6 -6
  44. data/lib/oxidized/hook/githubrepo.rb +42 -11
  45. data/lib/oxidized/hook/slackdiff.rb +2 -2
  46. data/lib/oxidized/hook/xmppdiff.rb +45 -25
  47. data/lib/oxidized/hook.rb +4 -8
  48. data/lib/oxidized/input/exec.rb +1 -1
  49. data/lib/oxidized/input/input.rb +1 -0
  50. data/lib/oxidized/input/ssh.rb +23 -20
  51. data/lib/oxidized/input/telnet.rb +52 -44
  52. data/lib/oxidized/job.rb +1 -0
  53. data/lib/oxidized/jobs.rb +11 -6
  54. data/lib/oxidized/manager.rb +1 -0
  55. data/lib/oxidized/model/acmepacket.rb +40 -0
  56. data/lib/oxidized/model/acos.rb +3 -1
  57. data/lib/oxidized/model/acsw.rb +2 -0
  58. data/lib/oxidized/model/adtran.rb +7 -3
  59. data/lib/oxidized/model/adva.rb +68 -0
  60. data/lib/oxidized/model/aen.rb +2 -0
  61. data/lib/oxidized/model/aireos.rb +2 -0
  62. data/lib/oxidized/model/airfiber.rb +3 -1
  63. data/lib/oxidized/model/airos.rb +2 -0
  64. data/lib/oxidized/model/alteonos.rb +2 -0
  65. data/lib/oxidized/model/alvarion.rb +2 -0
  66. data/lib/oxidized/model/aos.rb +2 -0
  67. data/lib/oxidized/model/aos7.rb +2 -0
  68. data/lib/oxidized/model/aoscx.rb +98 -0
  69. data/lib/oxidized/model/aosw.rb +4 -2
  70. data/lib/oxidized/model/apc_aos.rb +2 -0
  71. data/lib/oxidized/model/arbos.rb +2 -0
  72. data/lib/oxidized/model/aricentiss.rb +2 -0
  73. data/lib/oxidized/model/asa.rb +4 -0
  74. data/lib/oxidized/model/asyncos.rb +2 -0
  75. data/lib/oxidized/model/audiocodes.rb +2 -0
  76. data/lib/oxidized/model/audiocodesmp.rb +2 -0
  77. data/lib/oxidized/model/awplus.rb +3 -1
  78. data/lib/oxidized/model/axos.rb +2 -0
  79. data/lib/oxidized/model/bdcom.rb +51 -0
  80. data/lib/oxidized/model/boss.rb +3 -1
  81. data/lib/oxidized/model/br6910.rb +2 -0
  82. data/lib/oxidized/model/c4cmts.rb +2 -0
  83. data/lib/oxidized/model/cambium.rb +2 -0
  84. data/lib/oxidized/model/cambiumepmp.rb +19 -0
  85. data/lib/oxidized/model/casa.rb +6 -1
  86. data/lib/oxidized/model/catos.rb +2 -0
  87. data/lib/oxidized/model/ciscoce.rb +14 -0
  88. data/lib/oxidized/model/cisconga.rb +2 -0
  89. data/lib/oxidized/model/ciscosma.rb +2 -0
  90. data/lib/oxidized/model/ciscosmb.rb +4 -0
  91. data/lib/oxidized/model/ciscovpn3k.rb +2 -0
  92. data/lib/oxidized/model/cnos.rb +2 -0
  93. data/lib/oxidized/model/comnetms.rb +2 -0
  94. data/lib/oxidized/model/comtrol.rb +2 -0
  95. data/lib/oxidized/model/comware.rb +17 -1
  96. data/lib/oxidized/model/coriant8600.rb +2 -0
  97. data/lib/oxidized/model/coriantgroove.rb +2 -0
  98. data/lib/oxidized/model/corianttmos.rb +2 -0
  99. data/lib/oxidized/model/cumulus.rb +60 -44
  100. data/lib/oxidized/model/datacom.rb +2 -0
  101. data/lib/oxidized/model/dcnos.rb +2 -0
  102. data/lib/oxidized/model/dellx.rb +3 -3
  103. data/lib/oxidized/model/dlink.rb +4 -1
  104. data/lib/oxidized/model/dnos.rb +2 -0
  105. data/lib/oxidized/model/eciapollo.rb +2 -0
  106. data/lib/oxidized/model/edgecos.rb +24 -2
  107. data/lib/oxidized/model/edgeos.rb +2 -0
  108. data/lib/oxidized/model/edgeswitch.rb +6 -4
  109. data/lib/oxidized/model/eltex.rb +50 -0
  110. data/lib/oxidized/model/enterasys.rb +20 -3
  111. data/lib/oxidized/model/enterasys800.rb +31 -0
  112. data/lib/oxidized/model/eos.rb +4 -1
  113. data/lib/oxidized/model/fabricos.rb +3 -1
  114. data/lib/oxidized/model/fastiron.rb +5 -2
  115. data/lib/oxidized/model/fiberdriver.rb +2 -0
  116. data/lib/oxidized/model/firebrick.rb +2 -0
  117. data/lib/oxidized/model/firelinuxos.rb +2 -0
  118. data/lib/oxidized/model/firewareos.rb +2 -0
  119. data/lib/oxidized/model/fortios.rb +26 -11
  120. data/lib/oxidized/model/fortiwlc.rb +26 -0
  121. data/lib/oxidized/model/ftos.rb +2 -0
  122. data/lib/oxidized/model/fujitsupy.rb +2 -0
  123. data/lib/oxidized/model/gaiaos.rb +42 -3
  124. data/lib/oxidized/model/gcombnps.rb +2 -0
  125. data/lib/oxidized/model/grandstream.rb +2 -0
  126. data/lib/oxidized/model/h3c.rb +42 -0
  127. data/lib/oxidized/model/hatteras.rb +4 -2
  128. data/lib/oxidized/model/hios.rb +40 -0
  129. data/lib/oxidized/model/hirschmann.rb +2 -0
  130. data/lib/oxidized/model/hpebladesystem.rb +3 -1
  131. data/lib/oxidized/model/hpemsa.rb +2 -0
  132. data/lib/oxidized/model/hpmsm.rb +2 -0
  133. data/lib/oxidized/model/ibos.rb +2 -0
  134. data/lib/oxidized/model/icotera.rb +2 -0
  135. data/lib/oxidized/model/ios.rb +15 -10
  136. data/lib/oxidized/model/iosxe.rb +1 -1
  137. data/lib/oxidized/model/iosxr.rb +2 -0
  138. data/lib/oxidized/model/ipos.rb +2 -0
  139. data/lib/oxidized/model/ironware.rb +10 -4
  140. data/lib/oxidized/model/isam.rb +2 -0
  141. data/lib/oxidized/model/junos.rb +7 -1
  142. data/lib/oxidized/model/lancom.rb +25 -0
  143. data/lib/oxidized/model/lenovonos.rb +84 -0
  144. data/lib/oxidized/model/linksyssrw.rb +73 -0
  145. data/lib/oxidized/model/linuxgeneric.rb +2 -0
  146. data/lib/oxidized/model/masteros.rb +2 -0
  147. data/lib/oxidized/model/mlnxos.rb +4 -0
  148. data/lib/oxidized/model/model.rb +35 -8
  149. data/lib/oxidized/model/mtrlrfs.rb +2 -0
  150. data/lib/oxidized/model/ndms.rb +3 -1
  151. data/lib/oxidized/model/necix.rb +32 -0
  152. data/lib/oxidized/model/netgear.rb +7 -2
  153. data/lib/oxidized/model/netonix.rb +2 -0
  154. data/lib/oxidized/model/netscaler.rb +40 -1
  155. data/lib/oxidized/model/nodegrid.rb +25 -0
  156. data/lib/oxidized/model/nos.rb +2 -0
  157. data/lib/oxidized/model/nsxconfig.rb +2 -0
  158. data/lib/oxidized/model/nsxfirewall.rb +2 -0
  159. data/lib/oxidized/model/nxos.rb +5 -2
  160. data/lib/oxidized/model/oneos.rb +2 -0
  161. data/lib/oxidized/model/openbsd.rb +11 -0
  162. data/lib/oxidized/model/opengear.rb +3 -1
  163. data/lib/oxidized/model/openwrt.rb +2 -0
  164. data/lib/oxidized/model/opnsense.rb +14 -4
  165. data/lib/oxidized/model/os10.rb +2 -0
  166. data/lib/oxidized/model/outputs.rb +2 -0
  167. data/lib/oxidized/model/panos.rb +2 -0
  168. data/lib/oxidized/model/panos_api.rb +73 -0
  169. data/lib/oxidized/model/pfsense.rb +14 -7
  170. data/lib/oxidized/model/planet.rb +2 -0
  171. data/lib/oxidized/model/powerconnect.rb +3 -3
  172. data/lib/oxidized/model/procurve.rb +4 -2
  173. data/lib/oxidized/model/purityos.rb +10 -1
  174. data/lib/oxidized/model/qtech.rb +2 -0
  175. data/lib/oxidized/model/quantaos.rb +3 -5
  176. data/lib/oxidized/model/raisecom.rb +2 -0
  177. data/lib/oxidized/model/routeros.rb +17 -2
  178. data/lib/oxidized/model/saos.rb +2 -0
  179. data/lib/oxidized/model/screenos.rb +2 -0
  180. data/lib/oxidized/model/sgos.rb +2 -0
  181. data/lib/oxidized/model/siklu.rb +2 -0
  182. data/lib/oxidized/model/slxos.rb +3 -0
  183. data/lib/oxidized/model/smartax.rb +2 -0
  184. data/lib/oxidized/model/smartcs.rb +42 -0
  185. data/lib/oxidized/model/sonicos.rb +11 -1
  186. data/lib/oxidized/model/speedtouch.rb +2 -0
  187. data/lib/oxidized/model/sros.rb +3 -1
  188. data/lib/oxidized/model/srosmd.rb +99 -0
  189. data/lib/oxidized/model/stoneos.rb +8 -2
  190. data/lib/oxidized/model/supermicro.rb +1 -1
  191. data/lib/oxidized/model/swos.rb +11 -0
  192. data/lib/oxidized/model/tdre.rb +2 -0
  193. data/lib/oxidized/model/telco.rb +2 -0
  194. data/lib/oxidized/model/timos.rb +1 -1
  195. data/lib/oxidized/model/tmos.rb +5 -2
  196. data/lib/oxidized/model/tplink.rb +4 -0
  197. data/lib/oxidized/model/trango.rb +13 -11
  198. data/lib/oxidized/model/truenas.rb +22 -0
  199. data/lib/oxidized/model/ucs.rb +2 -0
  200. data/lib/oxidized/model/viptela.rb +2 -0
  201. data/lib/oxidized/model/voltaire.rb +2 -0
  202. data/lib/oxidized/model/voss.rb +2 -0
  203. data/lib/oxidized/model/vrp.rb +3 -1
  204. data/lib/oxidized/model/vyatta.rb +2 -0
  205. data/lib/oxidized/model/weos.rb +2 -0
  206. data/lib/oxidized/model/xos.rb +6 -3
  207. data/lib/oxidized/model/yamaha.rb +59 -0
  208. data/lib/oxidized/model/zhoneolt.rb +2 -0
  209. data/lib/oxidized/model/zteolt.rb +54 -0
  210. data/lib/oxidized/model/zy1308.rb +13 -0
  211. data/lib/oxidized/model/zynos.rb +2 -0
  212. data/lib/oxidized/model/zynoscli.rb +2 -0
  213. data/lib/oxidized/model/zynosgs.rb +2 -0
  214. data/lib/oxidized/node/stats.rb +1 -0
  215. data/lib/oxidized/node.rb +16 -11
  216. data/lib/oxidized/nodes.rb +7 -6
  217. data/lib/oxidized/output/file.rb +2 -1
  218. data/lib/oxidized/output/git.rb +5 -3
  219. data/lib/oxidized/output/gitcrypt.rb +5 -8
  220. data/lib/oxidized/output/http.rb +2 -0
  221. data/lib/oxidized/source/csv.rb +1 -0
  222. data/lib/oxidized/source/http.rb +4 -0
  223. data/lib/oxidized/source/source.rb +7 -2
  224. data/lib/oxidized/source/sql.rb +15 -5
  225. data/lib/oxidized/version.rb +2 -2
  226. data/lib/oxidized/worker.rb +5 -5
  227. data/lib/oxidized.rb +1 -1
  228. data/lib/refinements.rb +43 -0
  229. data/oxidized.gemspec +22 -16
  230. metadata +120 -31
  231. data/.github/no-response.yml +0 -13
  232. data/.travis.yml +0 -10
  233. data/lib/oxidized/string.rb +0 -36
@@ -1,4 +1,6 @@
1
1
  class GaiaOS < Oxidized::Model
2
+ using Refinements
3
+
2
4
  # CheckPoint - Gaia OS Model
3
5
 
4
6
  # Gaia Prompt
@@ -21,6 +23,12 @@ class GaiaOS < Oxidized::Model
21
23
  cfg
22
24
  end
23
25
 
26
+ # check for vsx / multiple context
27
+ cmd 'show vsx' do |cfg|
28
+ @is_vsx = cfg.include? 'VSX Enabled'
29
+ Oxidized.logger.debug cfg
30
+ end
31
+
24
32
  cmd 'show asset all' do |cfg|
25
33
  comment cfg
26
34
  end
@@ -29,9 +37,40 @@ class GaiaOS < Oxidized::Model
29
37
  comment cfg
30
38
  end
31
39
 
32
- cmd 'show configuration' do |cfg|
33
- cfg.gsub! /^# Exported by \S+ on .*/, '# '
34
- cfg
40
+ post do
41
+ if @is_vsx
42
+ multiple_context
43
+ else
44
+ single_context
45
+ end
46
+ end
47
+
48
+ def single_context
49
+ Oxidized.logger.debug 'Single context tasks'
50
+ cmd 'show configuration' do |cfg|
51
+ cfg.gsub! /^# Exported by \S+ on .*/, '# '
52
+ cfg
53
+ end
54
+ end
55
+
56
+ def multiple_context
57
+ Oxidized.logger.debug 'Multi context tasks'
58
+ cmd 'show virtual-system all' do |systems|
59
+ vs_items = systems.scan(/^(?<VSID>\d+)\s+(?<VSNAME>.*[^\s])/)
60
+ allcfg = ''
61
+ vs_items.each do |item|
62
+ allcfg += "\n\n\n#--------======== [ VS #{item[0]} - #{item[1]} ] ========--------\n\n"
63
+ allcfg += "set virtual-system #{item[0]}\n\n"
64
+ cmd "set virtual-system #{item[0]}" do |vs|
65
+ Oxidized.logger.debug vs
66
+ cmd 'show configuration' do |vscfg|
67
+ vscfg.gsub! /^# Exported by \S+ on .*/, '# '
68
+ allcfg += vscfg
69
+ end
70
+ end
71
+ end
72
+ allcfg
73
+ end
35
74
  end
36
75
 
37
76
  cfg :ssh do
@@ -1,4 +1,6 @@
1
1
  class GcomBNPS < Oxidized::Model
2
+ using Refinements
3
+
2
4
  # For switches from GCOM Technologies Co.,Ltd. running the "Broadband Network Platform Software"
3
5
  # Author: Frederik Kriewitz <frederik@kriewitz.eu>
4
6
  #
@@ -1,4 +1,6 @@
1
1
  class GrandStream < Oxidized::Model
2
+ using Refinements
3
+
2
4
  cmd "/cgi-bin/dologin?password=%<password>s" do |cfg| # rubocop:disable Style/FormatStringToken
3
5
  sid = JSON.parse(cfg)["body"]["sid"]
4
6
  cmd "/cgi-bin/download_cfg?sid=#{sid}"
@@ -0,0 +1,42 @@
1
+ class H3C < Oxidized::Model
2
+ using Refinements
3
+
4
+ # H3C
5
+
6
+ prompt /^.*(<[\w.-]+>)$/
7
+ comment '# '
8
+
9
+ cmd :secret do |cfg|
10
+ cfg.gsub! /(pin verify (?:auto|)).*/, '\\1 <PIN hidden>'
11
+ cfg.gsub! /(%\^%#.*%\^%#)/, '<secret hidden>'
12
+ cfg
13
+ end
14
+
15
+ cmd :all do |cfg|
16
+ cfg.cut_both
17
+ end
18
+
19
+ cfg :telnet do
20
+ username /^Username:$/
21
+ password /^Password:$/
22
+ end
23
+
24
+ cfg :telnet, :ssh do
25
+ post_login 'screen-length disable'
26
+ pre_logout 'quit'
27
+ end
28
+
29
+ cmd 'display version' do |cfg|
30
+ cfg = cfg.each_line.reject { |l| l.match /uptime/ }.join
31
+ cfg = cfg.each_line.reject { |l| l.match /Uptime is/ }.join
32
+ comment cfg
33
+ end
34
+
35
+ cmd 'display device' do |cfg|
36
+ comment cfg
37
+ end
38
+
39
+ cmd 'display current-configuration' do |cfg|
40
+ cfg
41
+ end
42
+ end
@@ -1,4 +1,6 @@
1
1
  class Hatteras < Oxidized::Model
2
+ using Refinements
3
+
2
4
  # Hatteras Networks
3
5
 
4
6
  prompt /^(\r?[\w.@()-]+[#>]\s?)$/
@@ -24,7 +26,7 @@ class Hatteras < Oxidized::Model
24
26
  cfg = cfg.each_line.reject do |line|
25
27
  line.match(/Switch uptime|Switch temperature|Last reset reason/) ||
26
28
  line.match(/TermCpuUtil|^\s+\^$|ERROR: Bad command/)
27
- end .join
29
+ end.join
28
30
  comment cfg
29
31
  end
30
32
 
@@ -32,7 +34,7 @@ class Hatteras < Oxidized::Model
32
34
  cfg = cfg.each_line.reject do |line|
33
35
  line.match(/Card uptime|Card temperature|Last reset reason/) ||
34
36
  line.match(/TermCpuUtil|^\s+\^$|ERROR: Bad command/)
35
- end .join
37
+ end.join
36
38
  comment cfg
37
39
  end
38
40
 
@@ -0,0 +1,40 @@
1
+ class Hios < Oxidized::Model
2
+ using Refinements
3
+
4
+ ## Docker location: /var/lib/gems/2.7.0/gems/oxidized-0.28.0/lib/oxidized/model/hios.rb
5
+ prompt /^\[[\w\s\W]+\][>|#]+?$/
6
+
7
+ comment '## '
8
+
9
+ # Handle pager
10
+ expect /^--More--.*$/ do |data, re|
11
+ send 'n'
12
+ data.sub re, ''
13
+ end
14
+
15
+ cmd :all do |cfg|
16
+ cfg.cut_both
17
+ end
18
+
19
+ cmd 'show system info' do |cfg|
20
+ cfg.gsub! /^System uptime.*\n/, ""
21
+ cfg.gsub! /^Operating hours.*\n/, ""
22
+ cfg.gsub! /^System date.*\n/, ""
23
+ cfg.gsub! /^Current temperature.*\n/, ""
24
+ comment cfg
25
+ end
26
+
27
+ cmd 'show running-config script' do |cfg|
28
+ cfg
29
+ end
30
+
31
+ cfg :telnet do
32
+ username /^User:/
33
+ password /^Password:/
34
+ end
35
+
36
+ cfg :telnet, :ssh do
37
+ post_login 'enable'
38
+ pre_logout "logout\nY\r\n"
39
+ end
40
+ end
@@ -1,4 +1,6 @@
1
1
  class Hirschmann < Oxidized::Model
2
+ using Refinements
3
+
2
4
  prompt /^[(\w\s)]+\s[>|#]+?$/
3
5
 
4
6
  comment '## '
@@ -1,4 +1,6 @@
1
1
  class HPEBladeSystem < Oxidized::Model
2
+ using Refinements
3
+
2
4
  # HPE Onboard Administrator
3
5
 
4
6
  prompt /.*> /
@@ -69,7 +71,7 @@ class HPEBladeSystem < Oxidized::Model
69
71
  end
70
72
 
71
73
  cmd 'show config' do |cfg|
72
- cfg.gsub! /^#(Generated on:) .*$/, '\\1 <removed>'
74
+ cfg.gsub! /^(#Generated on:) .*$/, '\\1 <removed>'
73
75
  cfg.gsub /^\s+/, ''
74
76
  end
75
77
 
@@ -1,4 +1,6 @@
1
1
  class HpeMsa < Oxidized::Model
2
+ using Refinements
3
+
2
4
  prompt /^#\s?$/
3
5
 
4
6
  cmd 'show configuration'
@@ -1,4 +1,6 @@
1
1
  class HPMSM < Oxidized::Model
2
+ using Refinements
3
+
2
4
  prompt /^CLI[>#] +$/
3
5
 
4
6
  comment '! '
@@ -1,4 +1,6 @@
1
1
  class IBOS < Oxidized::Model
2
+ using Refinements
3
+
2
4
  # IBOS model, Intelligent Broadband Operating System (iBOS)
3
5
  # Used in Waystream (previously PacketFront) Routers and Switches
4
6
 
@@ -1,4 +1,6 @@
1
1
  class Icotera < Oxidized::Model
2
+ using Refinements
3
+
2
4
  comment '## '
3
5
 
4
6
  cmd :all do |cfg|
@@ -1,4 +1,6 @@
1
1
  class IOS < Oxidized::Model
2
+ using Refinements
3
+
2
4
  prompt /^([\w.@()-]+[#>]\s?)$/
3
5
  comment '! '
4
6
 
@@ -105,16 +107,19 @@ class IOS < Oxidized::Model
105
107
  comment cfg
106
108
  end
107
109
 
108
- cmd 'show running-config' do |cfg|
109
- cfg = cfg.each_line.to_a[3..-1]
110
- cfg = cfg.reject { |line| line.match /^ntp clock-period / }.join
111
- cfg.gsub! /^Current configuration : [^\n]*\n/, ''
112
- cfg.gsub! /^! (Last|No) configuration change (at|since).*\n/, ''
113
- cfg.gsub! /^! NVRAM config last updated.*\n/, ''
114
- cfg.gsub! /^ tunnel mpls traffic-eng bandwidth[^\n]*\n*(
115
- (?: [^\n]*\n*)*
116
- tunnel mpls traffic-eng auto-bw)/mx, '\1'
117
- cfg
110
+ post do
111
+ cmd_line = 'show running-config'
112
+ cmd_line += ' view full' if vars(:ios_rbac)
113
+ cmd cmd_line do |cfg|
114
+ cfg = cfg.each_line.to_a[3..-1]
115
+ cfg = cfg.reject { |line| line.match /^ntp clock-period / }.join
116
+ cfg = cfg.each_line.reject { |line| line.match /^! (Last|No) configuration change (at|since).*/ unless line =~ /\d+\sby\s\S+$/ }.join
117
+ cfg.gsub! /^Current configuration : [^\n]*\n/, ''
118
+ cfg.gsub! /^ tunnel mpls traffic-eng bandwidth[^\n]*\n*(
119
+ (?: [^\n]*\n*)*
120
+ tunnel mpls traffic-eng auto-bw)/mx, '\1'
121
+ cfg
122
+ end
118
123
  end
119
124
 
120
125
  cfg :telnet do
@@ -1,5 +1,5 @@
1
1
  # IOS parser should work here
2
2
 
3
- require_relative 'ios.rb'
3
+ require_relative 'ios'
4
4
 
5
5
  IOSXE = IOS
@@ -1,4 +1,6 @@
1
1
  class IOSXR < Oxidized::Model
2
+ using Refinements
3
+
2
4
  # IOS XR model #
3
5
 
4
6
  prompt /^(\r?[\w.@:\/-]+[#>]\s?)$/
@@ -1,4 +1,6 @@
1
1
  class IPOS < Oxidized::Model
2
+ using Refinements
3
+
2
4
  # Ericsson SSR (IPOS)
3
5
  # Redback SE (SEOS)
4
6
 
@@ -1,4 +1,6 @@
1
1
  class IronWare < Oxidized::Model
2
+ using Refinements
3
+
2
4
  prompt /^.*(telnet|ssh)@.+[>#]\s?$/i
3
5
  comment '! '
4
6
 
@@ -31,7 +33,7 @@ class IronWare < Oxidized::Model
31
33
  cfg.encode!("UTF-8", invalid: :replace, undef: :replace) # sometimes ironware returns broken encoding
32
34
  cfg.gsub! /(^((.*)Current temp(.*))$)/, '' # remove unwanted lines current temperature
33
35
  cfg.gsub! /Speed = [A-Z-]{2,6} \(\d{2,3}%\)/, '' # remove unwanted lines Speed Fans
34
- cfg.gsub! /current speed is [A-Z]{2,6} \(\d{2,3}%\)/, ''
36
+ cfg.gsub! /current speed is [A-Z-]{2,6} \(\d{2,3}%\)/, ''
35
37
  cfg.gsub! /Fan \d* - STATUS: OK \D*\d*./, '' # Fix for ADX Fan speed reporting
36
38
  cfg.gsub! /\d* deg C/, '' # Fix for ADX temperature reporting
37
39
  cfg.gsub! /([\[]*)1([\]]*)<->([\[]*)2([\]]*)(<->([\[]*)3([\]]*))*/, ''
@@ -75,9 +77,13 @@ class IronWare < Oxidized::Model
75
77
  # handle pager with enable
76
78
  cfg :telnet, :ssh do
77
79
  if vars :enable
78
- post_login do
79
- send "enable\r\n"
80
- cmd vars(:enable)
80
+ if vars(:enable).is_a? TrueClass
81
+ post_login 'enable'
82
+ else
83
+ post_login do
84
+ send "enable\r\n"
85
+ cmd vars(:enable)
86
+ end
81
87
  end
82
88
  end
83
89
  post_login ''
@@ -1,4 +1,6 @@
1
1
  class ISAM < Oxidized::Model
2
+ using Refinements
3
+
2
4
  # Alcatel ISAM 7302/7330 FTTN
3
5
 
4
6
  prompt /^([\w.:@-]+>#\s)$/
@@ -1,4 +1,6 @@
1
1
  class JunOS < Oxidized::Model
2
+ using Refinements
3
+
2
4
  comment '# '
3
5
 
4
6
  def telnet
@@ -34,7 +36,11 @@ class JunOS < Oxidized::Model
34
36
  end
35
37
 
36
38
  cmd('show chassis hardware') { |cfg| comment cfg }
37
- cmd('show system license') { |cfg| comment cfg }
39
+ cmd('show system license') do |cfg|
40
+ cfg.gsub!(/ fib-scale\s+(\d+)/, ' fib-scale <count>')
41
+ cfg.gsub!(/ rib-scale\s+(\d+)/, ' rib-scale <count>')
42
+ comment cfg
43
+ end
38
44
  cmd('show system license keys') { |cfg| comment cfg }
39
45
 
40
46
  cmd 'show configuration | display omit'
@@ -0,0 +1,25 @@
1
+ class LANCOM < Oxidized::Model
2
+ using Refinements
3
+
4
+ # LANCOM Systems GmbH
5
+ # tested on LANCOM 1781EF+ router using Lancom OS 10.32.0176RU9 / 21.04.2020
6
+ comment '# '
7
+
8
+ prompt />\s?$/
9
+
10
+ cmd "sysinfo\r" do |cfg|
11
+ cfg.gsub! /^TIME:.*\n/, ''
12
+ comment cfg
13
+ end
14
+
15
+ cmd "readscript\r"
16
+
17
+ cfg :telnet do
18
+ username /login:\s/
19
+ password /^Password:\s/
20
+ end
21
+
22
+ cfg :telnet, :ssh do
23
+ pre_logout "exit\r"
24
+ end
25
+ end
@@ -0,0 +1,84 @@
1
+ class LenovoNOS < Oxidized::Model
2
+ using Refinements
3
+
4
+ prompt /^([\w.@()-]+[#>]\s?)$/
5
+ comment '! '
6
+
7
+ def comment_ext(header, output)
8
+ data = ''
9
+ data << header
10
+ data << "\n"
11
+ data << output
12
+ data << "\n"
13
+ comment data
14
+ end
15
+
16
+ cmd :all do |cfg|
17
+ cfg.gsub! /^% Invalid input detected at '\^' marker\.$|^\s+\^$/, ''
18
+ cfg.cut_both
19
+ end
20
+
21
+ cmd :secret do |cfg|
22
+ cfg.gsub! /^(enable password) \S+(.*)/, '\\1 <secret hidden>\\2'
23
+ cfg.gsub! /^(access user \S+ password) \S+(.*)/, '\\1 <secret hidden>\\2'
24
+ cfg.gsub! /^(snmp-server \S+-community) \S+(.*)/, '\\1 <secret hidden>\\2'
25
+ cfg.gsub! /^(tacacs-server \S+ \S+ ekey) \S+(.*)/, '\\1 <secret hidden>\\2'
26
+ cfg.gsub! /^(ntp message-digest-key \S+ md5-ekey) \S+(.*)/, '\\1 <secret hidden>\\2'
27
+ cfg.gsub! /(.* password )"[0-9a-f]+"(.*)/, '\\1<secret hidden>\\2'
28
+ cfg.gsub! /(.*ekey )"[0-9a-f]+"(.*)/, '\\1<secret hidden>\\2'
29
+ cfg
30
+ end
31
+
32
+ expect /^Select Command Line Interface mode.*iscli.*:/ do |data, re|
33
+ send "iscli\n"
34
+ data.sub re, ''
35
+ end
36
+
37
+ cmd 'show version' do |cfg|
38
+ cfg = cfg.each_line.to_a
39
+
40
+ cfg = cfg.reject { |line| line.match /^System Information at/ }
41
+ cfg = cfg.reject { |line| line.match /^Switch has been up for/ }
42
+ cfg = cfg.reject { |line| line.match /^Last boot:/ }
43
+ cfg = cfg.reject { |line| line.match /^Temperature / }
44
+ cfg = cfg.reject { |line| line.match /^Power Consumption/ }
45
+
46
+ cfg = cfg.join
47
+ comment_ext("=== show version ===", cfg)
48
+ end
49
+
50
+ cmd 'show boot' do |cfg|
51
+ comment_ext("=== show boot ===", cfg)
52
+ end
53
+
54
+ cmd 'show transceiver' do |cfg|
55
+ comment_ext("=== show transceiver ===", cfg)
56
+ end
57
+
58
+ cmd 'show software-key' do |cfg|
59
+ comment_ext("=== show software-key ===", cfg)
60
+ end
61
+
62
+ cmd 'show running-config' do |cfg|
63
+ cfg.gsub! /^Current configuration:[^\n]*\n/, ''
64
+ if vars(:remove_unstable_lines) == true
65
+ cfg.gsub! /(.* password )"[0-9a-f]+"(.*)/, '\\1<unstable line hidden>\\2'
66
+ cfg.gsub! /(.*ekey )"[0-9a-f]+"(.*)/, '\\1<unstable line hidden>\\2'
67
+ end
68
+ cfg
69
+ end
70
+
71
+ cfg :ssh do
72
+ # preferred way to handle additional passwords
73
+ post_login do
74
+ if vars(:enable) == true
75
+ cmd "enable"
76
+ elsif vars(:enable)
77
+ cmd "enable", /^[pP]assword:/
78
+ cmd vars(:enable)
79
+ end
80
+ end
81
+ post_login 'terminal-length 0'
82
+ pre_logout 'exit'
83
+ end
84
+ end
@@ -0,0 +1,73 @@
1
+ class LinksysSRW < Oxidized::Model
2
+ using Refinements
3
+
4
+ comment '! '
5
+
6
+ prompt /^([\r\w.@-]+[#>]\s?)$/
7
+
8
+ # Graphical login screen
9
+ # Just login to get to Main Menu
10
+ expect /Login Screen/ do
11
+ Oxidized.logger.send(:debug, "#{self.class.name}: Login Screen")
12
+ # This is to ensure the whole thing have rendered before we send stuff
13
+ sleep 0.2
14
+ send 0x18.chr # CAN Cancel
15
+ send @node.auth[:username]
16
+ send "\t"
17
+ send @node.auth[:password]
18
+ send "\r"
19
+ ''
20
+ end
21
+
22
+ # Main menu, escape into Pre-cli-shell
23
+ expect /Switch Main Menu/ do
24
+ Oxidized.logger.send(:debug, "#{self.class.name}: Switch menu")
25
+ send 0x1a.chr # SUB Substitite ^z
26
+ ''
27
+ end
28
+
29
+ # Pre-cli-shell, start lcli which is ios-ish
30
+ expect />/ do
31
+ Oxidized.logger.send(:debug, "#{self.class.name}: >")
32
+ send "lcli\r"
33
+ ''
34
+ end
35
+
36
+ cmd :all do |cfg|
37
+ # Remove \r from first response row
38
+ cfg.gsub! /^\r/, ''
39
+ cfg.cut_tail + "\n"
40
+ end
41
+
42
+ cmd :secret do |cfg|
43
+ cfg.gsub! /^(snmp-server community).*/, '\\1 <configuration removed>'
44
+ cfg.gsub! /^(enable (password|secret)( level \d+)? \d) .+/, '\\1 <secret hidden>'
45
+ end
46
+
47
+ cmd 'show startup-config' do |cfg|
48
+ # Repair some linewraps which terminal datadump doesn't take care of
49
+ # and there's no terminal width either.
50
+ cfg.gsub! /(lldpPortConfigT)\n(LVsTxEnable)/, '\\1\\2'
51
+ cfg.gsub! /(lldpPortConfigTL)\n(VsTxEnable)/, '\\1\\2'
52
+ # And comment out the echo of the command
53
+ "#{comment cfg.lines.first}#{cfg.cut_head}"
54
+ end
55
+
56
+ cmd 'show version' do |cfg|
57
+ comment cfg
58
+ end
59
+
60
+ cmd 'show system' do |cfg|
61
+ cfg.gsub! /(System Up Time \(days,hour:min:sec\):\s+).*/, '\\1 <uptime removed>'
62
+ comment cfg
63
+ end
64
+
65
+ cfg :telnet, :ssh do
66
+ # Some pre-cli-shell just expects a username, who its going to log in.
67
+ username /^User Name:/
68
+ password /Password:/
69
+ post_login 'terminal datadump'
70
+ pre_logout 'exit'
71
+ pre_logout 'logout'
72
+ end
73
+ end
@@ -1,4 +1,6 @@
1
1
  class LinuxGeneric < Oxidized::Model
2
+ using Refinements
3
+
2
4
  prompt /^(\w.*|\W.*)(:|#) /
3
5
  comment '# '
4
6
 
@@ -1,4 +1,6 @@
1
1
  class MasterOS < Oxidized::Model
2
+ using Refinements
3
+
2
4
  # MRV MasterOS model #
3
5
 
4
6
  comment '!'
@@ -1,4 +1,6 @@
1
1
  class MLNXOS < Oxidized::Model
2
+ using Refinements
3
+
2
4
  prompt /([\w.@()-\[:\s\]]+[#>]\s)$/
3
5
  comment '## '
4
6
 
@@ -10,7 +12,9 @@ class MLNXOS < Oxidized::Model
10
12
 
11
13
  cmd :all do |cfg|
12
14
  cfg.gsub! /\[\?1h=\r/, '' # Pager Handling
15
+ cfg.gsub! /\[24;1H/, '' # Pager Handling
13
16
  cfg.gsub! /\r\[K/, '' # Pager Handling
17
+ cfg.gsub! /\[K/, '' # Pager Handling
14
18
  cfg.gsub! /\s/, '' # Linebreak Handling
15
19
  cfg.gsub! /^CPU load averages:\s.+/, '' # Omit constantly changing CPU info
16
20
  cfg.gsub! /^System memory:\s.+/, '' # Omit constantly changing memory info