# File lib/fog/openstack.rb, line 72
   def self.authenticate_v2(options, connection_options = {})
      openstack_auth_url = options[:openstack_auth_url]
      uri = URI.parse(openstack_auth_url)
      connection = Fog::Connection.new(openstack_auth_url, false, connection_options)
      @openstack_api_key  = options[:openstack_api_key]
      @openstack_username = options[:openstack_username]
      @openstack_tenant = options[:openstack_tenant]
      @compute_service_name = options[:openstack_compute_service_name]

      req_body= {
        'auth' => {
          'passwordCredentials'  => {
            'username' => @openstack_username,
            'password' => @openstack_api_key
          }
        }
      }
      req_body['auth']['tenantName'] = @openstack_tenant if @openstack_tenant

      response = connection.request({
        :expects  => [200, 204],
        :headers => {'Content-Type' => 'application/json'},
        :body  => MultiJson.encode(req_body),
        :host     => uri.host,
        :method   => 'POST',
        :path     =>  (uri.path and not uri.path.empty?) ? uri.path : 'v2.0'
      })
      body=MultiJson.decode(response.body)
     
      if svc = body['access']['serviceCatalog'].detect{|x| x['name'] == @compute_service_name}
        mgmt_url = svc['endpoints'].detect{|x| x['publicURL']}['publicURL']
        token = body['access']['token']['id']
        return {
          :token => token,
          :server_management_url => mgmt_url
        } 
      else
        raise "Unable to parse service catalog."
      end
 
    end