Class: LogStash::Outputs::Keystone::KeystoneClient

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/outputs/keystone/keystone_client.rb

Instance Method Summary collapse

Constructor Details

#initialize(url, insecure = false) ⇒ KeystoneClient

Returns a new instance of KeystoneClient.



32
33
34
35
36
37
38
39
40
# File 'lib/logstash/outputs/keystone/keystone_client.rb', line 32

def initialize(url, insecure=false)
  @logger = Cabin::Channel.get(LogStash)
  @uri = URI.parse(url)
  @http = Net::HTTP.new(@uri.host, @uri.port)
  if @uri.scheme == 'https'
    @http.use_ssl = true
    @http.verify_mode = OpenSSL::SSL::VERIFY_NONE if insecure
  end
end

Instance Method Details

#authenticate(username, user_domain_name, password, project_name, project_domain_name) ⇒ Object



42
43
44
45
46
47
48
49
50
# File 'lib/logstash/outputs/keystone/keystone_client.rb', line 42

def authenticate(username, user_domain_name, password, project_name, project_domain_name)
  auth_hash = generate_hash(username, user_domain_name, password, project_name, project_domain_name)
  post_header = {
        'Accept' => 'application/json',
        'Content-Type' => 'application/json',
    }
  response = request('/auth/tokens', post_header, auth_hash)
  handle_response(response)
end