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 RouterOS < Oxidized::Model
2
+ using Refinements
3
+
2
4
  prompt /\[\w+@\S+(\s+\S+)*\]\s?>\s?$/
3
5
  comment "# "
4
6
 
@@ -13,11 +15,14 @@ class RouterOS < Oxidized::Model
13
15
  end
14
16
 
15
17
  cmd '/system routerboard print without-paging' do |cfg|
18
+ cfg = cfg.each_line.grep(/(model|firmware-type|current-firmware|serial-number):/).join
16
19
  comment cfg
17
20
  end
18
21
 
19
22
  cmd '/system package update print without-paging' do |cfg|
20
- comment cfg
23
+ version_line = cfg.each_line.grep(/installed-version: /)[0]
24
+ @ros_version = /: ([0-9])/.match(version_line)[1].to_i
25
+ comment version_line
21
26
  end
22
27
 
23
28
  cmd '/system history print without-paging' do |cfg|
@@ -25,11 +30,21 @@ class RouterOS < Oxidized::Model
25
30
  end
26
31
 
27
32
  post do
28
- run_cmd = vars(:remove_secret) ? '/export hide-sensitive' : '/export'
33
+ Oxidized.logger.debug "lib/oxidized/model/routeros.rb: running /export for routeros version #{@ros_version}"
34
+ run_cmd = if vars(:remove_secret)
35
+ '/export hide-sensitive'
36
+ elsif (not @ros_version.nil?) && (@ros_version >= 7)
37
+ '/export show-sensitive'
38
+ else
39
+ '/export'
40
+ end
29
41
  cmd run_cmd do |cfg|
30
42
  cfg.gsub! /\\\r?\n\s+/, '' # strip new line
31
43
  cfg.gsub! /# inactive time\r\n/, '' # Remove time based system comment
32
44
  cfg.gsub! /# received packet from \S+ bad format\r\n/, '' # Remove intermittent VRRP/CARP collision comment
45
+ cfg.gsub! /# poe-out status: short_circuit\r\n/, '' # Remove intermittent POE short_circuit comment
46
+ cfg.gsub! /# Firmware upgraded successfully, please reboot for changes to take effect!\r\n/, '' # Remove transient firmware upgrade comment
47
+ cfg.gsub! /# \S+ not ready\r\n/, '' # Remove intermittent $interface not ready comment
33
48
  cfg = cfg.split("\n").reject { |line| line[/^#\s\w{3}\/\d{2}\/\d{4}.*$/] }
34
49
  cfg.join("\n") + "\n"
35
50
  end
@@ -1,4 +1,6 @@
1
1
  class SAOS < Oxidized::Model
2
+ using Refinements
3
+
2
4
  # Ciena SAOS switch
3
5
  # used for 6.x devices
4
6
 
@@ -1,4 +1,6 @@
1
1
  class ScreenOS < Oxidized::Model
2
+ using Refinements
3
+
2
4
  # Netscreen ScreenOS model #
3
5
 
4
6
  comment '! '
@@ -1,4 +1,6 @@
1
1
  class SGOS < Oxidized::Model
2
+ using Refinements
3
+
2
4
  comment '!- '
3
5
  prompt /\w+>|#/
4
6
 
@@ -1,4 +1,6 @@
1
1
  class Siklu < Oxidized::Model
2
+ using Refinements
3
+
2
4
  # Siklu EtherHaul #
3
5
 
4
6
  prompt /^[\^M\s]{0,}[\w\-\s\.\"]+>$/
@@ -1,4 +1,6 @@
1
1
  class SLXOS < Oxidized::Model
2
+ using Refinements
3
+
2
4
  prompt /^.*[>#]\s?$/i
3
5
  comment '! '
4
6
 
@@ -12,6 +14,7 @@ class SLXOS < Oxidized::Model
12
14
  cmd 'show chassis' do |cfg|
13
15
  cfg.encode!("UTF-8", invalid: :replace, undef: :replace) # sometimes ironware returns broken encoding
14
16
  cfg.gsub! /.*Power Usage.*/, '' # remove unwanted lines power usage
17
+ cfg.gsub! /^Update\:.*$/, '' # remove unwanted current date
15
18
  cfg.gsub! /Time A(live|wake).*/, '' # remove unwanted lines time alive/awake
16
19
  cfg.gsub! /([\[]*)1([\]]*)<->([\[]*)2([\]]*)(<->([\[]*)3([\]]*))*/, ''
17
20
 
@@ -1,4 +1,6 @@
1
1
  class SmartAX < Oxidized::Model
2
+ using Refinements
3
+
2
4
  # Huawei SmartAX GPON/EPON/DOCSIS network access devices
3
5
  prompt /^([\w.-]+[>#])$/
4
6
 
@@ -0,0 +1,42 @@
1
+ class SmartCS < Oxidized::Model
2
+ using Refinements
3
+
4
+ prompt /^\r?([\w.@() -]+[#>]\s?)$/
5
+ comment '# '
6
+
7
+ expect /-more <Press SPACE for another page, 'q' to quit>-/ do |data, re|
8
+ send ' '
9
+ data.sub re, ''
10
+ end
11
+
12
+ cmd :all do |cfg|
13
+ cfg
14
+ end
15
+
16
+ cmd 'show version' do |cfg|
17
+ comment cfg.insert(0, "--------------------------------------------------------------------------------! \n")
18
+ # Unhash below to write a comment in the config file.
19
+ cfg.insert(0, "Starting: show version cmd \n")
20
+ cfg << "\n \nEnding: show version cmd"
21
+ comment cfg << "\n--------------------------------------------------------------------------------! \n \n"
22
+ comment cfg
23
+ end
24
+
25
+ cmd 'show config' do |cfg|
26
+ # remove "Press SPACE for another page" add SPACE(\s)
27
+ cfg.gsub! /\s{5,}/, ""
28
+ end
29
+
30
+ cfg :telnet, :ssh do
31
+ # preferred way to handle additional passwords
32
+ post_login do
33
+ pw = vars(:enable)
34
+ pw ||= ""
35
+ send "su\r"
36
+ expect /[pP]assword:\s?$/
37
+ cmd pw
38
+ end
39
+ pre_logout 'exit'
40
+ pre_logout 'exit'
41
+ end
42
+ end
@@ -1,4 +1,6 @@
1
1
  class SonicOS < Oxidized::Model
2
+ using Refinements
3
+
2
4
  # Applies to Sonicwall NSA series firewalls
3
5
 
4
6
  prompt /^\w+@\w+[>]\(?.+\)?\s?/
@@ -17,6 +19,12 @@ class SonicOS < Oxidized::Model
17
19
  cfg.gsub! /bind-password \d\,(\S+)/, 'bind-password <secret hidden> \2'
18
20
  cfg.gsub! /authentication sha1 \d\,(\S+)/, 'authentication sha1 <secret hidden> \2'
19
21
  cfg.gsub! /encryption aes \d\,(\S+)/, 'encryption aes <secret hidden> \2'
22
+ cfg.gsub! /smtp-pass \d\,(\S+)/, 'smtp-pass <secret hidden> \2'
23
+ cfg.gsub! /pop-pass \d\,(\S+)/, 'pop-pass <secret hidden> \2'
24
+ cfg.gsub! /sslvpn password \d\,(\S+)/, 'sslvpn password <secret hidden> \2'
25
+ cfg.gsub! /administrator password \d\,(\S+)/, 'administrator password <secret hidden> \2'
26
+ cfg.gsub! /ftp password \d\,(\S+)/, 'ftp password <secret hidden> \2'
27
+ cfg.gsub! /shared-key \d\,(\S+)/, 'shared-key <secret hidden> \2'
20
28
  cfg
21
29
  end
22
30
 
@@ -38,8 +46,10 @@ class SonicOS < Oxidized::Model
38
46
  def clean(cfg)
39
47
  out = []
40
48
  cfg.each_line do |line|
49
+ next if line =~ /date \d{4}\:\d{2}\:\d{2}/
50
+ next if line =~ /time \d{2}\:\d{2}:\d{2}/
41
51
  next if line =~ /system-time \"\d{2}\/\d{2}\/\d{4} \d{2}\:\d{2}:\d{2}.\d+\"/
42
- next if line =~ /system-uptime "(\s+up\s+\d+\s+)|(.*Days.*)"/
52
+ next if line =~ /system-uptime "((\s+up\s+\d+\s+)|(\d+\s\w+(,\s)?)*)"/
43
53
  next if line =~ /checksum \d+/
44
54
 
45
55
  line = line[1..-1] if line[0] == "\r"
@@ -1,4 +1,6 @@
1
1
  class SpeedTouch < Oxidized::Model
2
+ using Refinements
3
+
2
4
  prompt /([\w{}=]+[>])$/
3
5
  comment '! '
4
6
 
@@ -1,10 +1,12 @@
1
1
  class SROS < Oxidized::Model
2
+ using Refinements
3
+
2
4
  #
3
5
  # Nokia SR OS (TiMOS) (formerly TiMetra, Alcatel, Alcatel-Lucent).
4
6
  # Used in 7705 SAR, 7210 SAS, 7450 ESS, 7750 SR, 7950 XRS, and NSP.
5
7
  #
6
8
 
7
- comment '# '
9
+ comment '# '
8
10
 
9
11
  prompt /^([-\w.:>*]+\s?[#>]\s?)$/
10
12
 
@@ -0,0 +1,99 @@
1
+ class SROSMD < Oxidized::Model
2
+ using Refinements
3
+
4
+ #
5
+ # Nokia SR OS (TiMOS) (formerly TiMetra, Alcatel, Alcatel-Lucent)
6
+ # Working in Model-Driven CLI mode.
7
+ # Used in 7705 SAR, 7210 SAS, 7450 ESS, 7750 SR, 7950 XRS, and NSP.
8
+ #
9
+
10
+ comment '# '
11
+
12
+ prompt /^([-\w.@:>*]+\s?[#>]\s?)$/
13
+
14
+ cmd :all do |cfg, cmdstring|
15
+ new_cfg = comment "COMMAND: #{cmdstring}\n"
16
+ cfg.gsub! /# Finished .*/, ''
17
+ cfg.gsub! /# Generated .*/, ''
18
+ cfg.delete! "\r"
19
+ new_cfg << cfg.cut_both
20
+ end
21
+
22
+ #
23
+ # Show the system information.
24
+ #
25
+ cmd 'show system information' do |cfg|
26
+ #
27
+ # Strip uptime.
28
+ #
29
+ cfg.sub! /^System Up Time.*\n/, ''
30
+ comment cfg
31
+ end
32
+
33
+ #
34
+ # Show the card state.
35
+ #
36
+ cmd 'show card state' do |cfg|
37
+ comment cfg
38
+ end
39
+
40
+ #
41
+ # Show the chassis information.
42
+ #
43
+ cmd 'show chassis' do |cfg|
44
+ comment cfg.lines.to_a[0..25].reject { |line| line.match /state|Time|Temperature|Status/ }.join
45
+ end
46
+
47
+ #
48
+ # Show the boot log.
49
+ #
50
+ cmd 'file show bootlog.txt' do |cfg|
51
+ cfg.gsub! /[\b][\b][\b]/, "\n"
52
+ comment cfg
53
+ end
54
+
55
+ #
56
+ # Show the running debug configuration.
57
+ #
58
+ cmd 'admin show configuration debug full-context' do |cfg|
59
+ comment cfg
60
+ end
61
+
62
+ #
63
+ # Show the saved debug configuration (admin debug-save).
64
+ #
65
+ cmd 'file show config.dbg' do |cfg|
66
+ comment cfg
67
+ end
68
+
69
+ #
70
+ # Show the running persistent indices.
71
+ #
72
+ cmd 'admin show configuration configure | match persistent-indices post-lines 10000' do |cfg|
73
+ comment cfg
74
+ end
75
+
76
+ #
77
+ # Show the boot options file.
78
+ #
79
+ cmd 'admin show configuration bof full-context' do |cfg|
80
+ cfg
81
+ end
82
+
83
+ #
84
+ # Show the running configuration.
85
+ #
86
+ cmd 'admin show configuration configure full-context' do |cfg|
87
+ cfg
88
+ end
89
+
90
+ cfg :telnet do
91
+ username /^Login: /
92
+ password /^Password: /
93
+ end
94
+
95
+ cfg :telnet, :ssh do
96
+ post_login 'environment more false'
97
+ pre_logout 'logout'
98
+ end
99
+ end
@@ -1,7 +1,9 @@
1
1
  class StoneOS < Oxidized::Model
2
+ using Refinements
3
+
2
4
  # Hillstone Networks StoneOS software
3
5
 
4
- prompt /^\r?[\w.()-]+[#>](\s)?$/
6
+ prompt /^\r?[\w.()-]+~?[#>](\s)?$/
5
7
  comment '# '
6
8
 
7
9
  expect /^\s.*--More--.*$/ do |data, re|
@@ -10,12 +12,16 @@ class StoneOS < Oxidized::Model
10
12
  end
11
13
 
12
14
  cmd :all do |cfg|
15
+ cfg.gsub! /+.*+/, '' # Linebreak handling
13
16
  cfg.cut_both
14
17
  end
15
18
 
16
- cmd 'show configuration running'
19
+ cmd 'show configuration running' do |cfg|
20
+ cfg.gsub! /^Building configuration.*$/, ''
21
+ end
17
22
 
18
23
  cmd 'show version' do |cfg|
24
+ cfg.gsub! /^Uptime is .*$/, ''
19
25
  comment cfg
20
26
  end
21
27
 
@@ -1,7 +1,7 @@
1
1
  # Backward compatibility shim for deprecated model `supermicro`.
2
2
  # Migrate your source from `supermicro` to `edgecos`.
3
3
 
4
- require_relative 'edgecos.rb'
4
+ require_relative 'edgecos'
5
5
 
6
6
  Supermicro = EdgeCOS
7
7
 
@@ -0,0 +1,11 @@
1
+ # Mikrotik SwOS (Lite)
2
+ class SwOS < Oxidized::Model
3
+ using Refinements
4
+
5
+ cmd '/backup.swb'
6
+ cfg :http do
7
+ @username = @node.auth[:username]
8
+ @password = @node.auth[:password]
9
+ @secure = false
10
+ end
11
+ end
@@ -1,4 +1,6 @@
1
1
  class TDRE < Oxidized::Model
2
+ using Refinements
3
+
2
4
  prompt /^>$/
3
5
  cmd "get -f"
4
6
 
@@ -1,4 +1,6 @@
1
1
  class TELCO < Oxidized::Model
2
+ using Refinements
3
+
2
4
  # Telco Systems T-Marc 3306
3
5
 
4
6
  prompt /^(\r?[\w.@_()-]+[#]\s?)$/
@@ -1,7 +1,7 @@
1
1
  # Backward compatibility shim for deprecated model `timos`.
2
2
  # Migrate your source from `timos` to `sros`.
3
3
 
4
- require_relative 'sros.rb'
4
+ require_relative 'sros'
5
5
 
6
6
  TiMOS = SROS
7
7
 
@@ -1,5 +1,7 @@
1
1
  class TMOS < Oxidized::Model
2
- comment '# '
2
+ using Refinements
3
+
4
+ comment '# '
3
5
 
4
6
  cmd :secret do |cfg|
5
7
  cfg.gsub!(/^([\s\t]*)secret \S+/, '\1secret <secret removed>')
@@ -18,6 +20,7 @@ class TMOS < Oxidized::Model
18
20
  cmd 'tmsh -q show sys hardware field-fmt' do |cfg|
19
21
  cfg.gsub!(/fan-speed (\S+)/, '')
20
22
  cfg.gsub!(/temperature (\S+)/, '')
23
+ cfg.gsub!(/humidity (\S+)/, '')
21
24
  comment cfg
22
25
  end
23
26
 
@@ -47,7 +50,7 @@ class TMOS < Oxidized::Model
47
50
 
48
51
  cmd('[ -d "/config/zebos" ] && cat /config/zebos/*/ZebOS.conf') { |cfg| comment cfg }
49
52
 
50
- cmd('cat /config/partitions/*/bigip.conf') { |cfg| comment cfg }
53
+ cmd('cat /config/partitions/*/bigip*.conf') { |cfg| comment cfg }
51
54
 
52
55
  cfg :ssh do
53
56
  exec true # don't run shell, run each command in exec channel
@@ -1,4 +1,6 @@
1
1
  class TPLink < Oxidized::Model
2
+ using Refinements
3
+
2
4
  # tp-link prompt
3
5
  prompt /^\r?([\w.@()-]+[#>]\s?)$/
4
6
  comment '! '
@@ -35,6 +37,8 @@ class TPLink < Oxidized::Model
35
37
  end
36
38
 
37
39
  cmd 'show system-info' do |cfg|
40
+ cfg.gsub! /(System Time\s+-).*/, '\\1 <stripped>'
41
+ cfg.gsub! /(Running Time\s+-).*/, '\\1 <stripped>'
38
42
  comment cfg.each_line.to_a[3..-3].join
39
43
  end
40
44
 
@@ -1,4 +1,6 @@
1
1
  class Trango < Oxidized::Model
2
+ using Refinements
3
+
2
4
  # take a Trangolink sysinfo output and turn it into a configuration file
3
5
 
4
6
  prompt /^#>\s?/
@@ -9,16 +11,16 @@ class Trango < Oxidized::Model
9
11
  comments = []
10
12
  cfg.each_line do |line|
11
13
  if line =~ /\[Opmode\] (off|on) \[Default Opmode\] (off|on)/
12
- out << "opmode " + Regexp.last_match[1]
13
- out << "defaultopmode " + Regexp.last_match[2]
14
+ out << ("opmode " + Regexp.last_match[1])
15
+ out << ("defaultopmode " + Regexp.last_match[2])
14
16
  end
15
- out << "power " + Regexp.last_match[1] if line =~ /\[Tx Power\] ([\-\d]+) dBm/
16
- out << "freq " + Regexp.last_match[1] + ' ' + Regexp.last_match[2] if line =~ /\[Active Channel\] (\d+) (v|h)/
17
- out << "peerid " + Regexp.last_match[1] if line =~ /\[Peer ID\] ([A-F0-9]+)/
18
- out << "utype " + Regexp.last_match[1] if line =~ /\[Unit Type\] (\S+)/
19
- comments << '# ' + Regexp.last_match[1] + ': ' + Regexp.last_match[2] if line =~ /\[(Hardware Version|Firmware Version|Model|S\/N)\] (\S+)/
20
- out << "remarks " + Regexp.last_match[1] if line =~ /\[Remarks\] (\S+)/
21
- out << "rssiled " + Regexp.last_match[1] if line =~ /\[RSSI LED\] (on|off)/
17
+ out << ("power " + Regexp.last_match[1]) if line =~ /\[Tx Power\] ([\-\d]+) dBm/
18
+ out << ("freq " + Regexp.last_match[1] + ' ' + Regexp.last_match[2]) if line =~ /\[Active Channel\] (\d+) (v|h)/
19
+ out << ("peerid " + Regexp.last_match[1]) if line =~ /\[Peer ID\] ([A-F0-9]+)/
20
+ out << ("utype " + Regexp.last_match[1]) if line =~ /\[Unit Type\] (\S+)/
21
+ comments << ('# ' + Regexp.last_match[1] + ': ' + Regexp.last_match[2]) if line =~ /\[(Hardware Version|Firmware Version|Model|S\/N)\] (\S+)/
22
+ out << ("remarks " + Regexp.last_match[1]) if line =~ /\[Remarks\] (\S+)/
23
+ out << ("rssiled " + Regexp.last_match[1]) if line =~ /\[RSSI LED\] (on|off)/
22
24
  speed = Regexp.last_match[1] if line =~ /\[Speed\] (\d+) Mbps/
23
25
  out << "mir ".concat(Regexp.last_match[1]) if line =~ /\[Tx MIR\] (\d+) Kbps/
24
26
  if line =~ /\[Auto Rate Shift\] (on|off)/
@@ -27,9 +29,9 @@ class Trango < Oxidized::Model
27
29
  end
28
30
  next unless line =~ /\[IP\] (\S+) \[Subnet Mask\] (\S+) \[Gateway\] (\S+)/
29
31
 
30
- out << "ipconfig " + Regexp.last_match[1] + ' ' +
32
+ out << ("ipconfig " + Regexp.last_match[1] + ' ' +
31
33
  Regexp.last_match[2] + ' ' +
32
- Regexp.last_match[3]
34
+ Regexp.last_match[3])
33
35
  end
34
36
  comments.push(*out).join "\n"
35
37
  end
@@ -0,0 +1,22 @@
1
+ class TrueNAS < Oxidized::Model
2
+ using Refinements
3
+
4
+ comment '# '
5
+
6
+ cmd('uname -a') { |cfg| comment cfg }
7
+ cmd('cat /etc/version') { |cfg| comment cfg }
8
+ cmd('sqlite3 "file:///data/freenas-v1.db?mode=ro&immutable=1" .dump') do |cfg|
9
+ cfg.lines.reject do |line|
10
+ line.match(/^INSERT INTO storage_replication /) ||
11
+ line.match(/^INSERT INTO system_alert /)
12
+ end.join
13
+ end
14
+
15
+ cfg :ssh do
16
+ exec true # don't run shell, run each command in exec channel
17
+ end
18
+
19
+ cfg :ssh do
20
+ pre_logout 'exit'
21
+ end
22
+ end
@@ -1,4 +1,6 @@
1
1
  class UCS < Oxidized::Model
2
+ using Refinements
3
+
2
4
  prompt /^(\r?[\w.@_()-]+[#]\s?)$/
3
5
  comment '! '
4
6
 
@@ -1,4 +1,6 @@
1
1
  class Viptela < Oxidized::Model
2
+ using Refinements
3
+
2
4
  # Cisco Vipetla
3
5
 
4
6
  prompt /[-\w]+#\s$/
@@ -1,4 +1,6 @@
1
1
  class VOLTAIRE < Oxidized::Model
2
+ using Refinements
3
+
2
4
  prompt /([\w.@()-\[:\s\]]+[#>]\s|(One or more tests have failed.*))$/
3
5
  comment '## '
4
6
 
@@ -1,4 +1,6 @@
1
1
  class Voss < Oxidized::Model
2
+ using Refinements
3
+
2
4
  # Extreme/Avaya VSP Operating System Software(VOSS)
3
5
  # Created by danielcoxman@gmail.com
4
6
  # March 16, 2019
@@ -1,7 +1,9 @@
1
1
  class VRP < Oxidized::Model
2
+ using Refinements
3
+
2
4
  # Huawei VRP
3
5
 
4
- prompt /^(<[\w.-]+>)$/
6
+ prompt /^.*(<[\w.-]+>)$/
5
7
  comment '# '
6
8
 
7
9
  cmd :secret do |cfg|
@@ -1,4 +1,6 @@
1
1
  class Vyatta < Oxidized::Model
2
+ using Refinements
3
+
2
4
  # Brocade Vyatta / VyOS model #
3
5
 
4
6
  prompt /@.*?:~\$\s/
@@ -1,4 +1,6 @@
1
1
  class WEOS < Oxidized::Model
2
+ using Refinements
3
+
2
4
  # Westell WEOS, works with Westell 8178G, Westell 8266G
3
5
 
4
6
  prompt /^(\s[\w.@-]+[#>]\s?)$/
@@ -1,7 +1,9 @@
1
1
  class XOS < Oxidized::Model
2
+ using Refinements
3
+
2
4
  # Extreme Networks XOS
3
5
 
4
- prompt /^\*?\s?[-\w.~]+(:\d+)? [#>] $/
6
+ prompt /^\s?\*?\s?[-\w]+\s?[-\w.~]+(:\d+)? [#>] $/
5
7
  comment '# '
6
8
 
7
9
  cmd :all do |cfg|
@@ -23,7 +25,8 @@ class XOS < Oxidized::Model
23
25
  end
24
26
 
25
27
  cmd 'show switch' do |cfg|
26
- comment cfg.each_line.reject { |line| line.match(/Time:/) || line.match(/boot/i) }.join
28
+ cfg.gsub! /Next periodic save on.*/, ''
29
+ comment cfg.each_line.reject { |line| line.match(/Time:/) || line.match(/boot/i) || line.match(/Next periodic/) }.join
27
30
  end
28
31
 
29
32
  cmd 'show configuration' do |cfg|
@@ -43,7 +46,7 @@ class XOS < Oxidized::Model
43
46
  cfg :telnet, :ssh do
44
47
  post_login do
45
48
  data = cmd 'disable clipaging session'
46
- match = data.match /^disable clipaging session\n\*?[\w .-]+(:\d+)? [#>] $/m
49
+ match = data.match /^disable clipaging session\n\r?\*?\s?[-\w]+\s?[-\w.~]+(:\d+)? [#>] $/m
47
50
  next if match
48
51
 
49
52
  cmd 'disable clipaging'
@@ -0,0 +1,59 @@
1
+ class Yamaha < Oxidized::Model
2
+ using Refinements
3
+
4
+ prompt /^([\w.@()-]+[#>]\s?)$/
5
+ comment '# '
6
+
7
+ expect /^---more---$/ do |data, re|
8
+ send ' '
9
+ data.sub re, ''
10
+ end
11
+
12
+ # non-preferred way to handle additional PW prompt
13
+ # expect /^[\w.]+>$/ do |data|
14
+ # send "enable\n"
15
+ # send vars(:enable) + "\n"
16
+ # data
17
+ # end
18
+
19
+ expect /^Save new configuration/ do |data, re|
20
+ send "N\n"
21
+ data.sub re, ''
22
+ end
23
+
24
+ cmd :all do |cfg|
25
+ # cfg.gsub! /\cH+\s{8}/, '' # example how to handle pager
26
+ # cfg.gsub! /\cH+/, '' # example how to handle pager
27
+ # get rid of errors for commands that don't work on some devices
28
+ cfg.gsub! /^Error: Invalid command name$|^\s+\^$/, ''
29
+ cfg.cut_both
30
+ end
31
+
32
+ cmd 'show config' do |cfg|
33
+ cfg.gsub! /^(# Reporting Date:\s+)(.*)$/, '\1<stripped>'
34
+ cfg
35
+ end
36
+
37
+ cfg :telnet do
38
+ password /^Password:/i
39
+ end
40
+
41
+ cfg :telnet, :ssh do
42
+ # preferred way to handle additional passwords
43
+ post_login 'console lines infinity'
44
+ post_login 'console columns 200'
45
+ post_login 'console character ascii'
46
+ post_login do
47
+ if vars(:enable) == true
48
+ cmd "administrator"
49
+ elsif vars(:enable)
50
+ cmd "administrator", /^[pP]assword:/
51
+ cmd vars(:enable)
52
+ end
53
+ end
54
+ pre_logout do
55
+ cmd 'exit'
56
+ end
57
+ pre_logout 'exit'
58
+ end
59
+ end
@@ -1,4 +1,6 @@
1
1
  class ZhoneOLT < Oxidized::Model
2
+ using Refinements
3
+
2
4
  # Zhone OLT/MetroE/DSL devices (ONT uses a completely different CLI)
3
5
 
4
6
  # the prompt can be anything on zhone, but it defaults to 'zXX>' and we