Module: Fog::Nirvanix

Extended by:
Provider
Defined in:
lib/fog/nirvanix.rb

Defined Under Namespace

Modules: Errors

Class Method Summary collapse

Methods included from Provider

[], extended, service, services

Class Method Details

.authenticate(options, connection_options = {}) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/fog/nirvanix.rb', line 18

def self.authenticate(options, connection_options = {})
  nirvanix_auth_url = options[:nirvanix_url]
  url = nirvanix_auth_url.match(/^https?:/) ? \
            nirvanix_auth_url : 'https://' + nirvanix_auth_url
  uri = URI.parse(url)
  connection = Fog::Connection.new(url, false, connection_options)
  authentication_params = {
    'appKey' => options[:nirvanix_app_key],
    'userName' => options[:nirvanix_username],
    'password' => options[:nirvanix_password]
  }
  response = connection.request({
      :expects => [200],
      :host    => uri.host,
      :path => "/ws/Authentication/Login.ashx",
      :query => authentication_params,
      :parser => Fog::ToHashDocument.new,
      :method  => 'GET'
  })
  response.body[:SessionToken]
end