]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/keystone/lib/puppet/type/keystone_user_role.rb
9ac24e34e4515561e86f789dadebe354470186ba
[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 require 'puppet/util/openstack'
4 Puppet::Type.newtype(:keystone_user_role) do
5
6   desc <<-EOT
7     This is currently used to model the creation of
8     keystone users roles.
9
10     User roles are an assignment of a role to a user on
11     a certain tenant. The combination of all of these
12     attributes is unique.
13   EOT
14
15   ensurable
16
17   newparam(:name, :namevar => true) do
18     newvalues(/^\S+@\S+$/)
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
46   auth_param_doc=<<EOT
47 If no other credentials are present, the provider will search in
48 /etc/keystone/keystone.conf for an admin token and auth url.
49 EOT
50   Puppet::Util::Openstack.add_openstack_type_methods(self, auth_param_doc)
51 end