summaryrefslogtreecommitdiff
path: root/lib/oxidized/source/csv.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/oxidized/source/csv.rb')
-rw-r--r--lib/oxidized/source/csv.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/oxidized/source/csv.rb b/lib/oxidized/source/csv.rb
index 9d291c7..113c272 100644
--- a/lib/oxidized/source/csv.rb
+++ b/lib/oxidized/source/csv.rb
@@ -20,11 +20,18 @@ class CSV < Source
nodes = []
open(@cfg.file).each_line do |line|
data = line.chomp.split @cfg.delimiter
+ # map node parameters
keys = {}
@cfg.map.each do |key, position|
keys[key.to_sym] = data[position]
end
keys[:model] = map_model keys[:model] if keys.key? :model
+
+ # map node specific vars, empty value is considered as nil
+ vars = {}
+ @cfg.vars_map.each { |key, position| vars[key.to_sym] = data[position].to_s.empty? ? nil : data[position] }
+ keys[:vars] = vars unless vars.empty?
+
nodes << keys
end
nodes