Fuel plugin which allows to use LDAP as an authentication backend
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

parse_it.rb 892B

1234567891011121314151617181920212223242526272829303132
  1. module Puppet::Parser::Functions
  2. newfunction(:parse_it, :type => :rvalue, :doc => <<-EOS
  3. This function parses text area, creates hash and returns it
  4. for keystone domains creation
  5. EOS
  6. ) do |args|
  7. domains_hash = {}
  8. args[0].each do |item|
  9. param_hash = {}
  10. cert_chain = item.slice!(/^(ca_chain=-----BEGIN CERTIFICATE-----)(.*[\r\n])+(-----END CERTIFICATE-----[\s\S]*?)$/)
  11. if cert_chain
  12. splited_cert_chain = cert_chain.split('=',2)
  13. param_hash[splited_cert_chain[0]] = splited_cert_chain[1]
  14. end
  15. splited_text = item.split("\n")
  16. splited_text.each do |param|
  17. splited_line = param.split('=',2)
  18. if splited_line[0] and splited_line[0] != :undef
  19. param_hash[splited_line[0]] = splited_line[1]
  20. end
  21. end
  22. domains_hash[param_hash['domain']] = param_hash
  23. end
  24. return domains_hash
  25. end
  26. end