puppet-neutron/lib/puppet/parser/functions/convert_to_json_string.rb
Tim Rozet 63a0004592 Adds support for host config and cleanup
Changes Include:
 - Adds host config necessary per OVS to allow ODL to work with pseudo
   agent binding controller (for port binding)
 - Cleans up some execs and uses the real vswitch provider
 - Fixes parameter spacing


Closes-Bug: 1704206

Change-Id: Icc41c9936cae773f23281d6852a3a5e9cf4b9f89
Signed-off-by: Tim Rozet <trozet@redhat.com>
2017-07-25 20:58:10 +00:00

17 lines
372 B
Ruby

module Puppet::Parser::Functions
newfunction(:convert_to_json_string, :type => :rvalue) do |args|
require 'json'
value = args[0]
if (value.kind_of? Array) && value.all? {|x| x.include? ":"}
h = {}
value.each do |s|
k,v = s.split(/:/)
h[k] = v
end
return h.to_json
else
return value.to_json
end
end
end