summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/oxidized/nodes.rb3
-rw-r--r--lib/oxidized/source/http.rb8
-rw-r--r--lib/oxidized/source/sql.rb7
3 files changed, 14 insertions, 4 deletions
diff --git a/lib/oxidized/nodes.rb b/lib/oxidized/nodes.rb
index 84766f0..a159b48 100644
--- a/lib/oxidized/nodes.rb
+++ b/lib/oxidized/nodes.rb
@@ -12,7 +12,8 @@ module Oxidized
@source = Oxidized.config.source.default
Oxidized.mgr.add_source @source
Oxidized.logger.info "lib/oxidized/nodes.rb: Loading nodes"
- Oxidized.mgr.source[@source].new.load.each do |node|
+ nodes = Oxidized.mgr.source[@source].new.load node_want
+ nodes.each do |node|
# we want to load specific node(s), not all of them
next unless node_want? node_want, node
begin
diff --git a/lib/oxidized/source/http.rb b/lib/oxidized/source/http.rb
index 4480cbb..6d7dce3 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
+ def load node_want=nil
nodes = []
uri = URI.parse(@cfg.url)
http = Net::HTTP.new(uri.host, uri.port)
@@ -28,7 +28,11 @@ module Oxidized
headers[header] = value
end
- request = Net::HTTP::Get.new(uri.request_uri, headers)
+ req_uri = uri.request_uri
+ if node_want
+ req_uri = "#{req_uri}/#{node_want}"
+ end
+ request = Net::HTTP::Get.new(req_uri, headers)
if (@cfg.user? && @cfg.pass?)
request.basic_auth(@cfg.user, @cfg.pass)
end
diff --git a/lib/oxidized/source/sql.rb b/lib/oxidized/source/sql.rb
index 5737c93..dfcd7b4 100644
--- a/lib/oxidized/source/sql.rb
+++ b/lib/oxidized/source/sql.rb
@@ -18,11 +18,16 @@ module Oxidized
end
end
- def load
+ def load node_want=nill
nodes = []
db = connect
query = db[@cfg.table.to_sym]
query = query.with_sql(@cfg.query) if @cfg.query?
+
+ if node_want
+ query = query.where(@cfg.map.name.to_sym=>node_want)
+ end
+
query.each do |node|
# map node parameters
keys = {}