]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/keystone/ext/keystone_test.rb
Make varnish log rotation less noisy
[dsa-puppet.git] / 3rdparty / modules / keystone / ext / keystone_test.rb
1 #!/usr/bin/env ruby
2 # this script verifies that keystone has
3 # been successfully installed using the instructions
4 # found here: http://keystone.openstack.org/configuration.html
5
6 begin
7   require 'rubygems'
8 rescue
9   puts 'Could not require rubygems. This assumes puppet is not installed as a gem'
10 end
11 require 'open3'
12 require 'fileutils'
13 require 'puppet'
14
15 username='admin'
16 password='admin_password'
17 # required to get a real services catalog
18 tenant='openstack'
19
20 # shared secret
21 service_token='service_token'
22
23 def run_command(cmd)
24   Open3.popen3(cmd) do |stdin, stdout, stderr|
25     begin
26       stdout = stdout.read
27       puts "Response from token request:#{stdout}"
28       return stdout
29     rescue Exception => e
30       puts "Request failed, this sh*t is borked :( : details: #{e}"
31       exit 1
32     end
33   end
34 end
35
36 puts `puppet apply -e "package {curl: ensure => present }"`
37
38 get_token = %(curl -d '{"auth":{"passwordCredentials":{"username": "#{username}", "password": "#{password}"}}}' -H "Content-type: application/json" http://localhost:35357/v2.0/tokens)
39 token = nil
40
41 puts "Running auth command: #{get_token}"
42 token = PSON.load(run_command(get_token))["access"]["token"]["id"]
43
44 if token
45   puts "We were able to retrieve a token"
46   puts token
47   verify_token = "curl -H 'X-Auth-Token: #{service_token}' http://localhost:35357/v2.0/tokens/#{token}"
48   puts 'verifying token'
49   run_command(verify_token)
50   ['endpoints', 'tenants', 'users'].each do |x|
51     puts "getting #{x}"
52     get_keystone_data = "curl -H 'X-Auth-Token: #{service_token}' http://localhost:35357/v2.0/#{x}"
53     run_command(get_keystone_data)
54   end
55 end