diff options
author | nopedial <shafez@ike-2.local> | 2013-10-10 23:48:29 +0200 |
---|---|---|
committer | nopedial <shafez@ike-2.local> | 2013-10-10 23:48:29 +0200 |
commit | 6ab1fbb3f9f551b67a6481aafe3591e837905a8b (patch) | |
tree | 0f6605443c99420950b60e1cc6ce174bb703d2e9 | |
parent | f5be715f06da3e32557e1b5ecfbe762f7d547a97 (diff) |
add check and rescue for fetch params
-rw-r--r-- | lib/oxidized/api/rest.rb | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/oxidized/api/rest.rb b/lib/oxidized/api/rest.rb index a2ff1ab..4bf464b 100644 --- a/lib/oxidized/api/rest.rb +++ b/lib/oxidized/api/rest.rb @@ -42,7 +42,7 @@ module Oxidized 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" # ugly hack to disable configuration fetch for non ascii configurations + 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 = [] @@ -51,8 +51,10 @@ module Oxidized end end send res, @res_config - else + 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" end end end |