Op vrijdag 31 januari 2014 01:22:20 UTC+1 schreef Luke Kanies:
>
> From: bert hajee bert hajee <javascript:>
> Reply: [email protected] <javascript:>
> [email protected]<javascript:>
> Date: January 28, 2014 at 10:44:42 PM
> To: [email protected] <javascript:>
> [email protected]<javascript:>
> Subject: Re: [Puppet-dev] Puppet Custom Types, the easy way
>
> Just reread my reaction. Maybe it's not clear what a provider looks like
> for an easy_type. To make it really clear, here is the provider:
>
> require 'easy_type'
> require 'utils/oracle_access'
>
> Puppet::Type.type(:oracle_user).provide(:simple) do
> include EasyType::Provider
>
> desc "Manage Oracle users in an Oracle Database via regular SQL"
>
> mk_resource_methods
>
> end
>
> Besides the description. It's actually the same for ant easy_type.
>
> Yeah, I looked at the provider. My question is whether that provided gets
> modified by all the methods in easy_type, or whether it stays like it is,
> and all the work is done in the type.
>
> We used to not have providers, and instead all work was done in types, but
> now ideally the provider is the class that runs the shell scripts, talks to
> the system, etc., and the type is just responsible for modeling the
> resource, doing data validation, etc.
>
> --
> http://puppetlabs.com | http://about.me/lak | @puppetmasterd
>
Yeah, I looked at the provider. My question is whether that provided gets
>> modified by all the methods in easy_type, or whether it stays like it is,
>> and all the work is done in the type.
>>
>> The provider uses callbacks to Type to do the work. In the Type, you
define on_create, on_modify and on_delete methods that take a block. The
block returns the basic os command you need to do the work. The property
also has a callback method, namely the on_apply. The return value of the
on_apply method for any modified property is append to the base command.
An example:
In the type:
do_command(:sql)
on_modify do
"alter tablespace #{resource[:name]}"
end
in the property definition for size
on_apply do
"set size #{resource[:size]}"
end
When the provider notices the size in the manifest is different then the
actual size, it builds the command:
sql alter tablespace set size 10K
--- ---------------- ------------
1 part 2 part 3
part 1 is from the command
part 2 is from the on_modify
part 3 is from the property definition
--
You received this message because you are subscribed to the Google Groups
"Puppet Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-dev/19933bad-0b59-482d-bf62-6dc02f64d7c1%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.