2 # this script verifies that keystone has
3 # been successfully installed using the instructions
4 # found here: http://keystone.openstack.org/configuration.html
5 # and can use the v3 api http://developer.openstack.org/api-ref-identity-v3.html
10 puts 'Could not require rubygems. This assumes puppet is not installed as a gem'
18 password='a_big_secret'
19 # required to get a real services catalog
22 project_domain='admin'
25 service_token='admin_token'
28 Open3.popen3(cmd) do |stdin, stdout, stderr|
31 puts "Response from token request:#{stdout}"
34 puts "Request failed, this sh*t is borked :( : details: #{e}"
40 puts `puppet apply -e "package {curl: ensure => present }"`
41 get_token = %(curl -D - -d '{"auth":{"identity":{"methods":["password"],"password":{"user":{"domain":{"name":"#{user_domain}"},"name":"#{username}","password": "#{password}"}}},"scope":{"project":{"domain":{"name":"#{project_domain}"},"name": "#{project}"}}}}' -H "Content-type: application/json" http://localhost:35357/v3/auth/tokens)
44 puts "Running auth command: #{get_token}"
45 rawoutput = run_command(get_token)
46 if rawoutput =~ /X-Subject-Token: ([\w]+)/
49 puts "No token in output! #{rawoutput}"
54 puts "We were able to retrieve a token"
56 verify_token = "curl -H 'X-Auth-Token: #{service_token}' 'X-Subject-Token: #{token}' http://localhost:35357/v3/auth/tokens"
57 puts 'verifying token'
58 run_command(verify_token)
59 ['endpoints', 'projects', 'users'].each do |x|
61 get_keystone_data = "curl -H 'X-Auth-Token: #{token}' http://localhost:35357/v3/#{x}"
62 pp PSON.load(run_command(get_keystone_data))