Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- hostclass :externalresources do
- scope_h = scope.to_hash.reject { |k,v| !( k.is_a?(String) && v.is_a?(String) ) }
- scope_h.keys.each do |var|
- if scope_h[var][0].chr == '{'
- begin
- #Convert the variable from a string to a hash
- var_h = eval scope_h[var]
- rescue => e
- notice "Couldn't convert variable #{var} to hash: #{e}"
- end
- if var_h.has_key? :type
- type = var_h[:type]
- virtual = var_h.has_key? :virtual and var_h[:virtual] == 'true'
- #Split out our :type parameter
- var_h.reject! { |k,v| k == :type or k == :virtual }
- #Create the virtual resource by sending it the type defined
- begin
- unless virtual
- #Make our resource
- send type.to_sym, var, var_h
- else
- #Call our resource function and pass it to virtual
- virtual send type.to_sym, var, var_h
- end
- rescue => e
- fail "Couldn't create resource #{var}: #{e}"
- end
- end
- end
- end
- end
Add Comment
Please, Sign In to add comment