From a5b0963ccd9f79d26399761dd488223cd05e7bae Mon Sep 17 00:00:00 2001 From: Albert Martinez Date: Sun, 3 Jun 2018 10:19:00 +0200 Subject: Create openbsd.rb (#1356) OpenBSD model implementation. --- .rubocop_todo.yml | 41 +++++++++-------------- CHANGELOG.md | 1 + docs/Supported-OS-Types.md | 1 + lib/oxidized/model/openbsd.rb | 76 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 94 insertions(+), 25 deletions(-) create mode 100644 lib/oxidized/model/openbsd.rb diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index c30ae22..c6a5e0d 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2018-04-25 18:47:11 +0200 using RuboCop version 0.55.0. +# on 2018-06-03 10:03:33 +0200 using RuboCop version 0.55.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -19,7 +19,7 @@ Lint/AmbiguousBlockAssociation: - 'lib/oxidized/model/model.rb' - 'lib/oxidized/model/nos.rb' -# Offense count: 652 +# Offense count: 681 Lint/AmbiguousRegexpLiteral: Enabled: false @@ -92,13 +92,14 @@ Lint/UnusedMethodArgument: - 'lib/oxidized/hook.rb' - 'lib/oxidized/output/file.rb' -# Offense count: 12 +# Offense count: 13 Lint/UselessAssignment: Exclude: - 'lib/oxidized/model/cumulus.rb' - 'lib/oxidized/model/edgeos.rb' - 'lib/oxidized/model/gaiaos.rb' - 'lib/oxidized/model/mlnxos.rb' + - 'lib/oxidized/model/openbsd.rb' - 'lib/oxidized/model/procurve.rb' - 'lib/oxidized/model/trango.rb' - 'lib/oxidized/model/voltaire.rb' @@ -114,11 +115,11 @@ Lint/Void: Exclude: - 'lib/oxidized/model/voss.rb' -# Offense count: 60 +# Offense count: 63 Metrics/AbcSize: Max: 84 -# Offense count: 15 +# Offense count: 19 # Configuration parameters: CountComments, ExcludedMethods. Metrics/BlockLength: Max: 142 @@ -133,11 +134,11 @@ Metrics/BlockNesting: Metrics/ClassLength: Max: 210 -# Offense count: 13 +# Offense count: 14 Metrics/CyclomaticComplexity: Max: 28 -# Offense count: 53 +# Offense count: 56 # Configuration parameters: CountComments. Metrics/MethodLength: Max: 76 @@ -147,7 +148,7 @@ Metrics/MethodLength: Metrics/ParameterLists: Max: 6 -# Offense count: 14 +# Offense count: 15 Metrics/PerceivedComplexity: Max: 32 @@ -336,7 +337,7 @@ Style/ConditionalAssignment: - 'lib/oxidized/hook/githubrepo.rb' - 'lib/oxidized/model/model.rb' -# Offense count: 144 +# Offense count: 150 Style/Documentation: Enabled: false @@ -376,7 +377,7 @@ Style/GuardClause: - 'lib/oxidized/source/sql.rb' - 'lib/oxidized/string.rb' -# Offense count: 104 +# Offense count: 97 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. # SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys @@ -388,7 +389,7 @@ Style/IfInsideElse: Exclude: - 'lib/oxidized/output/file.rb' -# Offense count: 39 +# Offense count: 42 # Cop supports --auto-correct. Style/IfUnlessModifier: Enabled: false @@ -411,7 +412,7 @@ Style/LineEndConcatenation: Exclude: - 'lib/oxidized/hook.rb' -# Offense count: 131 +# Offense count: 137 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: require_parentheses, require_no_parentheses, require_no_parentheses_except_multiline @@ -566,23 +567,13 @@ Style/RedundantSelf: - 'lib/oxidized/node.rb' - 'lib/oxidized/nodes.rb' -# Offense count: 29 +# Offense count: 31 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, AllowInnerSlashes. # SupportedStyles: slashes, percent_r, mixed Style/RegexpLiteral: Enabled: false -# Offense count: 6 -# Cop supports --auto-correct. -Style/RescueModifier: - Exclude: - - 'bin/oxidized' - - 'extra/syslog.rb' - - 'lib/oxidized/input/ssh.rb' - - 'lib/oxidized/node.rb' - - 'lib/oxidized/nodes.rb' - # Offense count: 19 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. @@ -716,8 +707,8 @@ Style/ZeroLengthPredicate: - 'lib/oxidized/model/ciscosmb.rb' - 'lib/oxidized/output/git.rb' -# Offense count: 270 +# Offense count: 300 # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. # URISchemes: http, https Metrics/LineLength: - Max: 257 + Max: 283 diff --git a/CHANGELOG.md b/CHANGELOG.md index a336f39..e90fe56 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Master +* FEATURE: openbsd model (@amarti2038) * FEATURE: comnet model (@jaylik) * FEATURE: add enable to procurve model (@khobbits) * FEATURE: stoneos model (@macaty) diff --git a/docs/Supported-OS-Types.md b/docs/Supported-OS-Types.md index 5850bd1..62c7989 100644 --- a/docs/Supported-OS-Types.md +++ b/docs/Supported-OS-Types.md @@ -129,6 +129,7 @@ * [SR OS (TiMOS)](/lib/oxidized/model/sros.rb) * OneAccess * [OneOS](/lib/oxidized/model/oneos.rb) +* [OpenBSD](/lib/oxidized/model/openbsd.rb) * Opengear * [Opengear](/lib/oxidized/model/opengear.rb) * [OpenWRT](/lib/oxidized/model/openwrt.rb) diff --git a/lib/oxidized/model/openbsd.rb b/lib/oxidized/model/openbsd.rb new file mode 100644 index 0000000..898e9e3 --- /dev/null +++ b/lib/oxidized/model/openbsd.rb @@ -0,0 +1,76 @@ +class Openbsd < Oxidized::Model + # OpenBSD with custom promp, like user@hostname:~$ + # you can edit the one that your user uses, with root would be /root/.profile using the next PS1 def + # export PS1="\033[32m\u@\h\033[00m:\033[36m\w\033[00m$ " + + prompt /^.+@.+\:.+\$/ + comment '# ' + + # Add a comment between files/configs + def add_comment comment + "\n+++++++++++++++++++++++++++++++++++++++++ #{comment} ++++++++++++++++++++++++++++++++++++++++++++++\n" + end + + def add_small_comment comment + "\n=============== #{comment} ===============\n" + end + + cmd :all do |cfg| + cfg.each_line.to_a[1..-2].join + end + + # Issue the show commands + pre do + cfg = add_comment('HOSTNAME FILE') + cfg += cmd('cat /etc/myname') + + cfg += add_comment('HOSTS FILE') + cfg += cmd('cat /etc/hosts') + + cfg += add_comment('INTERFACE FILES') + cfg += cmd('tail -n +1 /etc/hostname.*') + + cfg += add_comment('RESOLV.CONF FILE') + cfg += cmd('cat /etc/resolv.conf') + + cfg += add_comment('NTP.CONF FILE') + cfg += cmd('cat /etc/ntp.conf') + + cfg += add_comment('IP ROUTES PER ROUTING DOMAIN') + cfg += add_small_comment('Routing Domain 0') + cfg += cmd('route -T0 exec netstat -rn') + cfg += add_small_comment('Routing Domain 1') + cfg += cmd('route -T1 exec netstat -rn') + cfg += add_small_comment('Routing Domain 2') + cfg += cmd('route -T2 exec netstat -rn') + cfg += add_small_comment('Routing Domain 3') + cfg += cmd('route -T3 exec netstat -rn') + cfg += add_small_comment('Routing Domain 4') + cfg += cmd('route -T4 exec netstat -rn') + cfg += add_small_comment('Routing Domain 5') + cfg += cmd('route -T5 exec netstat -rn') + + cfg += add_comment('SNMP FILE') + cfg += cmd('cat /etc/snmpd.conf') + + cfg += add_comment('PF FILE') + cfg += cmd('cat /etc/pf.conf') + + cfg += add_comment('MOTD FILE') + cfg += cmd('cat /etc/motd') + + cfg += add_comment('PASSWD FILE') + cfg += cmd('cat /etc/passwd') + + cfg += add_small_comment('END') + end + + cfg :telnet do + username /^Username:/ + password /^Password:/ + end + + cfg :telnet, :ssh do + pre_logout 'exit' + end +end -- cgit v1.2.1