]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/keystone/lib/puppet/type/keystone_user_role.rb
try with modules from master
[dsa-puppet.git] / 3rdparty / modules / keystone / lib / puppet / type / keystone_user_role.rb
1 # LP#1408531
2 File.expand_path('../..', File.dirname(__FILE__)).tap { |dir| $LOAD_PATH.unshift(dir) unless $LOAD_PATH.include?(dir) }
3 File.expand_path('../../../../openstacklib/lib', File.dirname(__FILE__)).tap { |dir| $LOAD_PATH.unshift(dir) unless $LOAD_PATH.include?(dir) }
4
5 Puppet::Type.newtype(:keystone_user_role) do
6
7   desc <<-EOT
8     This is currently used to model the creation of
9     keystone users roles.
10
11     User roles are an assignment of a role to a user on
12     a certain tenant. The combination of all of these
13     attributes is unique.
14   EOT
15
16   ensurable
17
18   newparam(:name, :namevar => true) do
19   end
20
21   newproperty(:roles,  :array_matching => :all) do
22     def insync?(is)
23       return false unless is.is_a? Array
24       # order of roles does not matter
25       is.sort == self.should.sort
26     end
27   end
28
29   autorequire(:keystone_user) do
30     self[:name].rpartition('@').first
31   end
32
33   autorequire(:keystone_tenant) do
34     self[:name].rpartition('@').last
35   end
36
37   autorequire(:keystone_role) do
38     self[:roles]
39   end
40
41   # we should not do anything until the keystone service is started
42   autorequire(:service) do
43     ['keystone']
44   end
45 end