1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
# LP#1408531
File.expand_path('../..', File.dirname(__FILE__)).tap { |dir| $LOAD_PATH.unshift(dir) unless $LOAD_PATH.include?(dir) }
File.expand_path('../../../../openstacklib/lib', File.dirname(__FILE__)).tap { |dir| $LOAD_PATH.unshift(dir) unless $LOAD_PATH.include?(dir) }
require 'puppet_x/keystone/composite_namevar'
require 'puppet_x/keystone/type'
Puppet::Type.newtype(:keystone_tenant) do
desc 'This type can be used to manage keystone tenants.'
ensurable
newparam(:name, :namevar => true) do
desc 'The name of the tenant.'
newvalues(/\w+/)
end
newproperty(:enabled) do
desc 'Whether the tenant should be enabled. Defaults to true.'
newvalues(/(t|T)rue/, /(f|F)alse/, true, false )
defaultto(true)
munge do |value|
value.to_s.downcase.to_sym
end
end
newproperty(:description) do
desc 'A description of the tenant.'
end
newproperty(:id) do
desc 'Read-only property of the tenant.'
validate do |v|
raise(Puppet::Error, 'This is a read only property')
end
end
newparam(:domain) do
desc 'Domain for tenant.'
isnamevar
include PuppetX::Keystone::Type::DefaultDomain
end
autorequire(:keystone_domain) do
default_domain = catalog.resources.find do |r|
r.class.to_s == 'Puppet::Type::Keystone_domain' &&
r[:is_default] == :true &&
r[:ensure] == :present
end
rv = [self[:domain]]
# Only used to display the deprecation warning.
rv << default_domain.name unless default_domain.nil?
rv
end
# This ensures the service is started and therefore the keystone
# config is configured IF we need them for authentication.
# If there is no keystone config, authentication credentials
# need to come from another source.
autorequire(:anchor) do
['keystone::service::end', 'default_domain_created']
end
def self.title_patterns
PuppetX::Keystone::CompositeNamevar.basic_split_title_patterns(:name, :domain)
end
end
|