summaryrefslogtreecommitdiff
path: root/lib/oxidized/api
diff options
context:
space:
mode:
authornopedial <shafez@ike-2.local>2013-10-14 11:15:12 +0200
committernopedial <shafez@ike-2.local>2013-10-14 11:15:12 +0200
commit5bf9df1ebffd85604206d1baf81a5a92158a117a (patch)
tree211aa5994d0d956a7da60e419e316c3cefef8fcc /lib/oxidized/api
parent6ab1fbb3f9f551b67a6481aafe3591e837905a8b (diff)
implement fetch into output model
Diffstat (limited to 'lib/oxidized/api')
-rw-r--r--lib/oxidized/api/rest.rb19
1 files changed, 5 insertions, 14 deletions
diff --git a/lib/oxidized/api/rest.rb b/lib/oxidized/api/rest.rb
index 4bf464b..d876917 100644
--- a/lib/oxidized/api/rest.rb
+++ b/lib/oxidized/api/rest.rb
@@ -41,20 +41,11 @@ module Oxidized
# /nodes/show/node - returns data about node
when /show\/(.*)/
send res, @nodes.show($1)
- when /fetch\/(.*)/ # primitive node fetch implementation for file config - /nodes/fetch/$ip_address
- if CFG.output[:default] == "file" and $1 != '' # ugly hack to disable configuration fetch for non ascii configurations and ensure that argument is received
- @cfg_root = CFG.output[:file]
- File.open("#{@cfg_root[:directory]}/#{$1}", "r") do |pipe|
- @res_config = []
- while ( line = pipe.gets ) do
- @res_config << line # store configuration into an array to format and send
- end
- end
- send res, @res_config
- elsif CFG.output[:default] != "file" and $1 != ''
- send res, "oxidized 0.0.14 support fetch for ascii configuration files only." # return error to end user
- else # return error if no argument is received
- send res, "missing argument - example: /nodes/fetch/192.0.2.1"
+ when /fetch\/(.*)/
+ begin
+ send res, @nodes.fetch($1)
+ rescue Oxidized::NotSupported => e
+ send res, e
end
end
end