]> git.donarmstrong.com Git - dsa-puppet.git/blobdiff - 3rdparty/modules/keystone/lib/puppet/type/keystone_tenant.rb
add stackforge/keystone to 3rdparty
[dsa-puppet.git] / 3rdparty / modules / keystone / lib / puppet / type / keystone_tenant.rb
diff --git a/3rdparty/modules/keystone/lib/puppet/type/keystone_tenant.rb b/3rdparty/modules/keystone/lib/puppet/type/keystone_tenant.rb
new file mode 100644 (file)
index 0000000..3e1de7f
--- /dev/null
@@ -0,0 +1,49 @@
+# LP#1408531
+File.expand_path('../..', File.dirname(__FILE__)).tap { |dir| $LOAD_PATH.unshift(dir) unless $LOAD_PATH.include?(dir) }
+require 'puppet/util/openstack'
+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.'
+    defaultto('')
+  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
+
+  # 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(:service) do
+    ['keystone']
+  end
+
+  auth_param_doc=<<EOT
+If no other credentials are present, the provider will search in
+/etc/keystone/keystone.conf for an admin token and auth url.
+EOT
+  Puppet::Util::Openstack.add_openstack_type_methods(self, auth_param_doc)
+end