]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/keystone/lib/puppet/type/keystone_tenant.rb
Update to Kilo
[dsa-puppet.git] / 3rdparty / modules / keystone / lib / puppet / type / keystone_tenant.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 require 'puppet/provider/keystone/util'
5
6 Puppet::Type.newtype(:keystone_tenant) do
7
8   desc 'This type can be used to manage keystone tenants.'
9
10   ensurable
11
12   newparam(:name, :namevar => true) do
13     desc 'The name of the tenant.'
14     newvalues(/\w+/)
15   end
16
17   newproperty(:enabled) do
18     desc 'Whether the tenant should be enabled. Defaults to true.'
19     newvalues(/(t|T)rue/, /(f|F)alse/, true, false )
20     defaultto(true)
21     munge do |value|
22       value.to_s.downcase.to_sym
23     end
24   end
25
26   newproperty(:description) do
27     desc 'A description of the tenant.'
28     defaultto('')
29   end
30
31   newproperty(:id) do
32     desc 'Read-only property of the tenant.'
33     validate do |v|
34       raise(Puppet::Error, 'This is a read only property')
35     end
36   end
37
38   newproperty(:domain) do
39     desc 'Domain for tenant.'
40     newvalues(nil, /\S+/)
41     def insync?(is)
42       raise(Puppet::Error, "The domain cannot be changed from #{self.should} to #{is}") unless self.should == is
43       true
44     end
45   end
46
47   autorequire(:keystone_domain) do
48     # use the domain parameter if given, or the one from name if any
49     self[:domain] || Util.split_domain(self[:name])[1]
50   end
51
52   # This ensures the service is started and therefore the keystone
53   # config is configured IF we need them for authentication.
54   # If there is no keystone config, authentication credentials
55   # need to come from another source.
56   autorequire(:service) do
57     ['keystone']
58   end
59 end