]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/aviator/lib/puppet/feature/aviator/openstack/identity/requests/v2/public/create_token.rb
Revert "add stackforge/keystone to 3rdparty"
[dsa-puppet.git] / 3rdparty / modules / aviator / lib / puppet / feature / aviator / openstack / identity / requests / v2 / public / create_token.rb
1 module Aviator
2
3   define_request :create_token, :inherit => [:openstack, :common, :v2, :public, :base] do
4
5     meta :anonymous, true
6     meta :service,   :identity
7
8     link 'documentation',
9          'http://docs.openstack.org/api/openstack-identity-service/2.0/content/POST_authenticate_v2.0_tokens_.html'
10
11     link 'documentation bug',
12          'https://bugs.launchpad.net/keystone/+bug/1208607'
13
14
15     param :username,   :required => false
16     param :password,   :required => false
17     param :tokenId,    :required => false, :alias => :token_id
18     param :tenantName, :required => false, :alias => :tenant_name
19     param :tenantId,   :required => false, :alias => :tenant_id
20
21
22     def body
23       p = if params[:tokenId]
24             {
25               :auth => {
26                 :token => {
27                   :id => params[:tokenId]
28                 }
29               }
30             }
31           else
32             {
33               :auth => {
34                 :passwordCredentials => {
35                   :username => params[:username],
36                   :password => params[:password]
37                 }
38               }
39             }
40           end
41
42       p[:auth][:tenantName] = params[:tenantName] if params[:tenantName]
43       p[:auth][:tenantId]   = params[:tenantId]   if params[:tenantId]
44
45       p
46     end
47
48
49     def http_method
50       :post
51     end
52
53
54     def url
55       url  = session_data[:auth_service][:host_uri]
56       url += '/v2.0' if (URI(url).path =~ /^\/?\w+/).nil?
57       url += "/tokens"
58     end
59
60   end
61
62 end