class OpenstackBridge::Authentication
Attributes
response[RW]
Public Class Methods
new(*)
click to toggle source
Calls superclass method
# File lib/openstack_bridge/authentication.rb, line 5 def initialize(*) super request = HTTPI::Request.new request.url = tokens_url host request.body = auth_hash.to_json request.headers['Content-Type'] = 'application/json' self.response = JSON.parse(HTTPI.post(request, :curb).body) end
Public Instance Methods
token()
click to toggle source
# File lib/openstack_bridge/authentication.rb, line 14 def token self.response['access']['token']['id'] end
Private Instance Methods
auth_hash()
click to toggle source
# File lib/openstack_bridge/authentication.rb, line 24 def auth_hash { "auth" => { "passwordCredentials" =>{ "username" => username, "password" => password }, "tenantName" => tenant } } end
tokens_url(host)
click to toggle source
# File lib/openstack_bridge/authentication.rb, line 20 def tokens_url(host) host.end_with?('tokens') ? host : File.join(host, 'tokens') end