From d156ac397beffabe3f0cb045f923050a3ab74887 Mon Sep 17 00:00:00 2001 From: Neil Lathwood Date: Tue, 31 Oct 2017 21:38:54 +0000 Subject: Added support for sending single node request to http source --- lib/oxidized/source/http.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib/oxidized/source') diff --git a/lib/oxidized/source/http.rb b/lib/oxidized/source/http.rb index 6c12f29..e4cb58e 100644 --- a/lib/oxidized/source/http.rb +++ b/lib/oxidized/source/http.rb @@ -15,7 +15,7 @@ class HTTP < Source require "uri" require "json" - def load + def load node=nil nodes = [] uri = URI.parse(@cfg.url) http = Net::HTTP.new(uri.host, uri.port) @@ -28,7 +28,11 @@ class HTTP < Source headers[header] = value end - request = Net::HTTP::Get.new(uri.request_uri, headers) + req_uri = uri.request_uri + if node + req_uri = "#{req_uri}/#{node}" + end + request = Net::HTTP::Get.new(req_uri, headers) if (@cfg.user? && @cfg.pass?) request.basic_auth(@cfg.user,@cfg.pass) end -- cgit v1.2.1 From 29704b5f2721a742d312ced784a8076e27e8063b Mon Sep 17 00:00:00 2001 From: laf Date: Fri, 10 Nov 2017 14:12:13 +0000 Subject: Added sql support for calling for single host --- lib/oxidized/source/http.rb | 6 +++--- lib/oxidized/source/sql.rb | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'lib/oxidized/source') diff --git a/lib/oxidized/source/http.rb b/lib/oxidized/source/http.rb index e4cb58e..73df6f7 100644 --- a/lib/oxidized/source/http.rb +++ b/lib/oxidized/source/http.rb @@ -15,7 +15,7 @@ class HTTP < Source require "uri" require "json" - def load node=nil + def load node_want=nil nodes = [] uri = URI.parse(@cfg.url) http = Net::HTTP.new(uri.host, uri.port) @@ -29,8 +29,8 @@ class HTTP < Source end req_uri = uri.request_uri - if node - req_uri = "#{req_uri}/#{node}" + if node_want + req_uri = "#{req_uri}/#{node_want}" end request = Net::HTTP::Get.new(req_uri, headers) if (@cfg.user? && @cfg.pass?) diff --git a/lib/oxidized/source/sql.rb b/lib/oxidized/source/sql.rb index 13fc39b..7e2824d 100644 --- a/lib/oxidized/source/sql.rb +++ b/lib/oxidized/source/sql.rb @@ -18,11 +18,12 @@ class SQL < Source end end - def load + def load node_want=nil nodes = [] db = connect query = db[@cfg.table.to_sym] query = query.with_sql(@cfg.query) if @cfg.query? + query = qeury.where(@cfg.map.name.to_sym node_want) query.each do |node| # map node parameters keys = {} -- cgit v1.2.1 From d96cfac1f09ff4055f54ab604358290865d41f62 Mon Sep 17 00:00:00 2001 From: laf Date: Fri, 10 Nov 2017 14:44:45 +0000 Subject: updated to check if node_want --- lib/oxidized/source/sql.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib/oxidized/source') diff --git a/lib/oxidized/source/sql.rb b/lib/oxidized/source/sql.rb index 7e2824d..97064fa 100644 --- a/lib/oxidized/source/sql.rb +++ b/lib/oxidized/source/sql.rb @@ -23,7 +23,11 @@ class SQL < Source db = connect query = db[@cfg.table.to_sym] query = query.with_sql(@cfg.query) if @cfg.query? - query = qeury.where(@cfg.map.name.to_sym node_want) + + if node_want + query = query.where(@cfg.map.name.to_sym=>node_want) + end + query.each do |node| # map node parameters keys = {} -- cgit v1.2.1 From c65bbfe28eaafa21e7660b51758fafcdafc42bab Mon Sep 17 00:00:00 2001 From: Neil Lathwood Date: Fri, 27 Apr 2018 10:55:47 +0100 Subject: travis fixes --- lib/oxidized/source/http.rb | 2 +- lib/oxidized/source/sql.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/oxidized/source') diff --git a/lib/oxidized/source/http.rb b/lib/oxidized/source/http.rb index 6d7dce3..55dcd4c 100644 --- a/lib/oxidized/source/http.rb +++ b/lib/oxidized/source/http.rb @@ -15,7 +15,7 @@ module Oxidized require "uri" require "json" - def load node_want=nil + def load node_want = nil nodes = [] uri = URI.parse(@cfg.url) http = Net::HTTP.new(uri.host, uri.port) diff --git a/lib/oxidized/source/sql.rb b/lib/oxidized/source/sql.rb index dfcd7b4..8d321a0 100644 --- a/lib/oxidized/source/sql.rb +++ b/lib/oxidized/source/sql.rb @@ -18,7 +18,7 @@ module Oxidized end end - def load node_want=nill + def load node_want = nil nodes = [] db = connect query = db[@cfg.table.to_sym] -- cgit v1.2.1 From 137314377bbc15b651228a0394caf45e6fa8bcbc Mon Sep 17 00:00:00 2001 From: Neil Lathwood Date: Fri, 27 Apr 2018 10:58:19 +0100 Subject: Another travis fix --- lib/oxidized/source/sql.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/oxidized/source') diff --git a/lib/oxidized/source/sql.rb b/lib/oxidized/source/sql.rb index 8d321a0..c5fe650 100644 --- a/lib/oxidized/source/sql.rb +++ b/lib/oxidized/source/sql.rb @@ -25,7 +25,7 @@ module Oxidized query = query.with_sql(@cfg.query) if @cfg.query? if node_want - query = query.where(@cfg.map.name.to_sym=>node_want) + query = query.where(@cfg.map.name.to_sym => node_want) end query.each do |node| -- cgit v1.2.1