From f1287a7925901bf3518eb69079304bfb97f7434d Mon Sep 17 00:00:00 2001 From: Saku Ytti Date: Sat, 20 Apr 2013 00:41:23 +0300 Subject: Example of Syslog triggered fetch 'syslog.rb' listed to UDP port (or reads file). When IOS or JunOS style config change/commit message is seen, it triggers immediate update ot config It transports commit message (junos) remote host from which change was mde (ios) and who made the change (junos+ios). This is carried over to the 'output' methods, that is, 'git blame' will show IOS/JunOS user-name who made the change. --- extra/rest_client.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 extra/rest_client.rb (limited to 'extra/rest_client.rb') diff --git a/extra/rest_client.rb b/extra/rest_client.rb new file mode 100644 index 0000000..2c58d04 --- /dev/null +++ b/extra/rest_client.rb @@ -0,0 +1,25 @@ +module Oxidized + class RestClient + require 'net/http' + require 'json' + HOST = 'localhost' + PORT = 8888 + + class << self + def next node, opt={}, host=HOST, port=PORT + web = new host, port + web.next node, opt + end + end + + def initialize host=HOST, port=PORT + @web = Net::HTTP.new host, port + end + + def next node, opt={} + data = JSON.dump :node => node, :user => opt[:user], :msg => opt[:msg], :from => opt[:from] + @web.put '/nodes/next/' + node.to_s, data + end + + end +end -- cgit v1.2.1