From 25dd702d92721e69dc4185205ad7bd7b65adf0ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eric=20Lindsj=C3=B6?= Date: Fri, 20 Oct 2017 08:48:39 +0200 Subject: Fixed ever-changing output in fiberdriver model --- lib/oxidized/model/fiberdriver.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/oxidized/model/fiberdriver.rb b/lib/oxidized/model/fiberdriver.rb index abe8f68..7cfa847 100644 --- a/lib/oxidized/model/fiberdriver.rb +++ b/lib/oxidized/model/fiberdriver.rb @@ -13,7 +13,7 @@ class FiberDriver < Oxidized::Model cfg.each_line.to_a[3..-1].join cfg.gsub! /^Building configuration.*$/, '' cfg.gsub! /^Current configuration:.*$$/, '' - cfg.gsub! /^! Configuration saved on .*$/, '' + cfg.gsub! /^! Configuration (saved|generated) on .*$/, '' cfg end -- cgit v1.2.1 From b43505e85193c28fbb39689542da229d057524fa Mon Sep 17 00:00:00 2001 From: Neil Lathwood Date: Wed, 1 Nov 2017 22:18:30 +0000 Subject: release: Bump version to 0.21.0 (#1081) --- lib/oxidized/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/oxidized/version.rb b/lib/oxidized/version.rb index 221cffa..9a92133 100644 --- a/lib/oxidized/version.rb +++ b/lib/oxidized/version.rb @@ -1,3 +1,3 @@ module Oxidized - VERSION = '0.20.0' + VERSION = '0.21.0' end -- cgit v1.2.1 From 853480fca54492a38feaa4fa76941e88f54f11a8 Mon Sep 17 00:00:00 2001 From: mortzu Date: Wed, 8 Nov 2017 22:48:51 +0100 Subject: feature: Added hook for XMPP MUC (#951) * Added hook for XMPP MUC * Updated dockerfile * Added timeout to prevent oxidized to stop on XMPP error * Updated README --- lib/oxidized/hook/xmppdiff.rb | 60 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 lib/oxidized/hook/xmppdiff.rb (limited to 'lib') diff --git a/lib/oxidized/hook/xmppdiff.rb b/lib/oxidized/hook/xmppdiff.rb new file mode 100644 index 0000000..396d1b3 --- /dev/null +++ b/lib/oxidized/hook/xmppdiff.rb @@ -0,0 +1,60 @@ +require 'xmpp4r' +require 'xmpp4r/muc/helper/simplemucclient' + +class XMPPDiff < Oxidized::Hook + def validate_cfg! + raise KeyError, 'hook.jid is required' unless cfg.has_key?('jid') + raise KeyError, 'hook.password is required' unless cfg.has_key?('password') + raise KeyError, 'hook.channel is required' unless cfg.has_key?('channel') + raise KeyError, 'hook.nick is required' unless cfg.has_key?('nick') + end + + def run_hook(ctx) + if ctx.node + if ctx.event.to_s == "post_store" + begin + Timeout::timeout(15) do + gitoutput = ctx.node.output.new + diff = gitoutput.get_diff ctx.node, ctx.node.group, ctx.commitref, nil + + interesting = diff[:patch].lines.to_a[4..-1].any? { |line| + ["+", "-"].include?(line[0]) and not ["#", "!"].include?(line[1]) + } + interesting &&= diff[:patch].lines.to_a[5..-1].any? { |line| line[0] == '-' } + interesting &&= diff[:patch].lines.to_a[5..-1].any? { |line| line[0] == '+' } + + if interesting + log "Connecting to XMPP" + client = Jabber::Client.new(Jabber::JID.new(cfg.jid)) + client.connect + sleep 1 + client.auth(cfg.password) + sleep 1 + + log "Connected" + + m = Jabber::MUC::SimpleMUCClient.new(client) + m.join(cfg.channel + "/" + cfg.nick) + + log "Joined" + + title = "#{ctx.node.name.to_s} #{ctx.node.group.to_s} #{ctx.node.model.class.name.to_s.downcase}" + log "Posting diff as snippet to #{cfg.channel}" + + m.say(title + "\n\n" + diff[:patch].lines.to_a[4..-1].join) + + sleep 1 + + client.close + + log "Finished" + + end + end + rescue Timeout::Error + log "timed out" + end + end + end + end +end -- cgit v1.2.1 From aa0e1808f25e5e8b1a76f34c29f2eeb7db75a7c7 Mon Sep 17 00:00:00 2001 From: Nat Morris Date: Thu, 9 Nov 2017 22:14:37 +0000 Subject: feature: Slack hook - optionally disable diff snippets and post custom messages (#763) * continue to diffs by default, but optionally post formatted messages * updated readme * remove static channel name * Update Hooks.md --- lib/oxidized/hook/slackdiff.rb | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) (limited to 'lib') diff --git a/lib/oxidized/hook/slackdiff.rb b/lib/oxidized/hook/slackdiff.rb index 61f1743..728e5a7 100644 --- a/lib/oxidized/hook/slackdiff.rb +++ b/lib/oxidized/hook/slackdiff.rb @@ -1,5 +1,8 @@ require 'slack' +# defaults to posting a diff, if messageformat is supplied them a message will be posted too +# diffenable defaults to true + class SlackDiff < Oxidized::Hook def validate_cfg! raise KeyError, 'hook.token is required' unless cfg.has_key?('token') @@ -17,16 +20,33 @@ class SlackDiff < Oxidized::Hook client = Slack::Client.new client.auth_test log "Connected" - gitoutput = ctx.node.output.new - diff = gitoutput.get_diff ctx.node, ctx.node.group, ctx.commitref, nil - title = "#{ctx.node.name.to_s} #{ctx.node.group.to_s} #{ctx.node.model.class.name.to_s.downcase}" - log "Posting diff as snippet to #{cfg.channel}" - client.files_upload(channels: cfg.channel, as_user: true, - content: diff[:patch].lines.to_a[4..-1].join, - filetype: "diff", - title: title, - filename: "change" - ) + # diff snippet - default + diffenable = true + if cfg.has_key?('diff') == true + if cfg.diff == false + diffenable = false + end + end + if diffenable == true + gitoutput = ctx.node.output.new + diff = gitoutput.get_diff ctx.node, ctx.node.group, ctx.commitref, nil + title = "#{ctx.node.name.to_s} #{ctx.node.group.to_s} #{ctx.node.model.class.name.to_s.downcase}" + log "Posting diff as snippet to #{cfg.channel}" + client.files_upload(channels: cfg.channel, as_user: true, + content: diff[:patch].lines.to_a[4..-1].join, + filetype: "diff", + title: title, + filename: "change" + ) + end + # message custom formatted - optional + if cfg.has_key?('message') == true + log cfg.message + msg = cfg.message % {:node => ctx.node.name.to_s, :group => ctx.node.group.to_s, :commitref => ctx.commitref, :model => ctx.node.model.class.name.to_s.downcase} + log msg + log "Posting message to #{cfg.channel}" + client.chat_postMessage(channel: cfg.channel, text: msg, as_user: true) + end log "Finished" end end -- cgit v1.2.1 From 4203e00cbde157e767e8be39ffdcecb30db14e6b Mon Sep 17 00:00:00 2001 From: Nicholas Meredith Date: Sun, 12 Nov 2017 05:48:55 +1000 Subject: fix: Fix prompt pattern for model/comware.rb to handle ASCII Bell response +fix minor README.md typo (#1094) * comware.rb: update prompt to work when trailing ^G ASCII 7 (bell) is sent * README.md: correct typo 'HTT' to 'HTTP' for Configuration / Outputs paragraph * model/comware.rb: cleaning out some comments --- lib/oxidized/model/comware.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/oxidized/model/comware.rb b/lib/oxidized/model/comware.rb index d926854..a5b7190 100644 --- a/lib/oxidized/model/comware.rb +++ b/lib/oxidized/model/comware.rb @@ -1,8 +1,8 @@ class Comware < Oxidized::Model # HP (A-series)/H3C/3Com Comware - # sometimes the prompt might have a leading nul - prompt /^\0*(<[\w.-]+>)$/ + # sometimes the prompt might have a leading nul or trailing ASCII Bell (^G) + prompt /^\0*(<[\w.-]+>).?$/ comment '# ' # example how to handle pager -- cgit v1.2.1 From 40cfa7b7cfba0d0a655fe2148ad9336414e89737 Mon Sep 17 00:00:00 2001 From: pv2b Date: Wed, 15 Nov 2017 23:02:27 +0100 Subject: fix: Netgear model: Permit . as valid character in prompt (#1099) --- lib/oxidized/model/netgear.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/oxidized/model/netgear.rb b/lib/oxidized/model/netgear.rb index 38aaca7..0ab1349 100644 --- a/lib/oxidized/model/netgear.rb +++ b/lib/oxidized/model/netgear.rb @@ -1,7 +1,7 @@ class Netgear < Oxidized::Model comment '!' - prompt /^(\([\w-]+\)\s[#>])$/ + prompt /^(\([\w\-.]+\)\s[#>])$/ cmd :secret do |cfg| cfg.gsub!(/password (\S+)/, 'password ') -- cgit v1.2.1 From 8bef76580a3e848836f3f12fe9e6c50380dbe01e Mon Sep 17 00:00:00 2001 From: pv2b Date: Sat, 18 Nov 2017 10:59:28 +0100 Subject: model: Procurve Handle switch selection for stack commanders (#1104) When trying to connect to a HP Procurve Switch with stacking enabled, you are asked to choose which switch to connect to to manage. This patch makes it so that if this question is encountered, just press "Enter" to choose the stack commander. This won't make backing up stack members work (they still need to be configured seperately and given IP addresses, making stacking useless) but at least it makes it possible to back up a commander in a stack seperately. Fixed #1070 Credit to @stiltzkin10 for this fix. --- lib/oxidized/model/procurve.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib') diff --git a/lib/oxidized/model/procurve.rb b/lib/oxidized/model/procurve.rb index 180b703..11d7ea9 100644 --- a/lib/oxidized/model/procurve.rb +++ b/lib/oxidized/model/procurve.rb @@ -21,6 +21,11 @@ class Procurve < Oxidized::Model "" end + expect /Enter switch number/ do + send "\n" + "" + end + cmd :all do |cfg| cfg = cfg.each_line.to_a[1..-2].join cfg = cfg.gsub /^\r/, '' -- cgit v1.2.1 From 115764f3b2d20b3732a8d81c38afaea19c11dad8 Mon Sep 17 00:00:00 2001 From: pv2b Date: Mon, 20 Nov 2017 09:16:44 +0100 Subject: feature: Added model information to exec hook (#1105) * Add OX_NODE_MODEL to exec hook * Update docs to reflect added OX_NODE_MSG to hook --- lib/oxidized/hook/exec.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'lib') diff --git a/lib/oxidized/hook/exec.rb b/lib/oxidized/hook/exec.rb index a9a5950..3f984c2 100644 --- a/lib/oxidized/hook/exec.rb +++ b/lib/oxidized/hook/exec.rb @@ -71,6 +71,7 @@ class Exec < Oxidized::Hook "OX_NODE_FROM" => ctx.node.from.to_s, "OX_NODE_MSG" => ctx.node.msg.to_s, "OX_NODE_GROUP" => ctx.node.group.to_s, + "OX_NODE_MODEL" => ctx.node.model.class.name, "OX_REPO_COMMITREF" => ctx.commitref.to_s, "OX_REPO_NAME" => ctx.node.repo.to_s, ) -- cgit v1.2.1 From 99220b9947946d5ad1e53cba6a343e942ce0c498 Mon Sep 17 00:00:00 2001 From: pv2b Date: Tue, 21 Nov 2017 09:03:48 +0100 Subject: model: Added support for Opnsense (#1111) * Add OPNsense model * Fix class name * Mention support for OPNsense in Supported OS types --- lib/oxidized/model/opnsense.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 lib/oxidized/model/opnsense.rb (limited to 'lib') diff --git a/lib/oxidized/model/opnsense.rb b/lib/oxidized/model/opnsense.rb new file mode 100644 index 0000000..b874fca --- /dev/null +++ b/lib/oxidized/model/opnsense.rb @@ -0,0 +1,21 @@ +class OpnSense < Oxidized::Model + + # minimum required permissions: "System: Shell account access" + # must enable SSH and password-based SSH access + + cmd :all do |cfg| + cfg.each_line.to_a[1..-1].join + end + + cmd 'cat /conf/config.xml' do |cfg| + cfg.gsub! /\s\s*