On Sat, May 4, 2013 at 1:00 PM,  <[email protected]> wrote:
>
> I want to new types and providers for my system.
> To get the current state of a property I dont have CLIs, but only C APIs.
>
> For example, suppose I want to set description to an ethernet interface, I
> have to invoke a function (present in dll added to my system), instead of
> issuing a CLI command
>
> Is it possible to invoke the C function in the dll present on the managed
> node? If so how could i add that in my getter/setter methods

There are two approaches I could suggest.

The best is to write a CLI for those queries, and use that; you could
use Puppet to distribute the prebuilt binary to your systems.  That
keeps the two products - Puppet, and your custom queries - separate
and distinct, which makes it much harder for them to mess each other
up.


If you don't want to go down that path, I would still suggest sticking
with the separation: you could write some Ruby code that performed the
queries, depending on the same base interpreter that runs Puppet.
That, again, keeps the two isolated - and makes sure that, say, a bug
or missing dependency in your Ruby code isn't going to blow things up.

(See the `yum` package provider for an example of this technique; they
used some external Python code to build a better API into yum, rather
than trying to futz with the existing command line.)


If you do go down the Ruby route, the `ffi` gem is what you need:
https://github.com/ffi/ffi/wiki/Windows-Examples


Finally, you theoretically could use the `ffi` gem and directly query
this stuff inside a provider that runs in the Puppet process.
Historically, there have been some significant challenges around
getting that to work reliably, mostly relating to "how do I get the
gem installed, if not having it makes my catalog application fail?"

If you do go down that path, I believe the best way to start is using
the built-in "feature" system to load the library, and making sure
that you can run Puppet correctly even without the gem installed.
(Obviously not managing your features, but enough to install the ffi
gem. ;)

--
Daniel Pittman
⎋ Puppet Labs Developer – http://puppetlabs.com
♲ Made with 100 percent post-consumer electrons

-- 
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 post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-dev?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to