Created
October 15, 2015 18:37
-
-
Save sathlan/37f99d5994c67c348fdf to your computer and use it in GitHub Desktop.
Connect to openvstack keystone v3 and make a request using basic faraday.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'faraday' | |
require 'json' | |
conn = Faraday.new(:url => 'http://localhost:5000') | |
responce = conn.post do |post| | |
post.url '/v3/auth/tokens' | |
post.headers['Content-Type'] = 'application/json' | |
post.body = { | |
:auth => { | |
:scope => { | |
:project => { | |
:domain => { :name => 'service_domain' }, | |
:name => 'servicesv3' | |
} | |
}, | |
:identity => { | |
:methods => [:password], | |
:password => { | |
:user => { | |
:name => 'beaker-civ3', | |
:domain => { | |
:name => 'service_domain' | |
}, | |
:project => 'servicesv3', | |
:password => 'secret' | |
} | |
} | |
}, | |
} | |
}.to_json | |
end | |
token = responce.headers['x-subject-token'] | |
3.times.each do | |
responce_1 = conn.get do |get| | |
get.url '/v3/services' | |
get.headers['Content-Type'] = 'application/json' | |
get.headers['X-Auth-Token'] = token | |
end | |
puts JSON.parse(responce_1.body) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment