Remove parameters & absent values from puppetral#find

In order to match the behavior of `puppet resource` this commit removes
all non-property parameters and 'absent' values from puppetral#find
results. The only exception is when ensure is set to absent.

Reviewed-by: Joshua Lifton <lifton@puppetlabs.com>
Merge pull request #11 from MaxMartin/master

Match output of `puppet resource`
Take advantage of puppet resource refactors

Thanks to some refactors to the `puppet resource` application and the
Puppet::Resource class, we can eliminate some code duplication and give
better error messages. Instead of stripping extra parameters and absent
values in the puppetral agent, we can now just call the prune_parameters
method directly on the resource. Also, when resource creation fails, now
instead of just replying with "resource was not created," we can used
the returned report to give better error information. These changes rely
on a specific version of Puppet, so they first test that the methods
they're calling exist, and fall back to simpler functionality.

Paired-with: Matt Robinson <matt@puppetlabs.com>
Added avoid_conflict option to create_resource method of puppetral agent.

Reviewed by Max Martin <max@puppetlabs.com>.
Fixed how puppetral#create_resource handles the avoid_conflict argument.
Merge remote-tracking branch 'lifton/master'

* lifton/master:
  Fixed how puppetral#create_resource handles the avoid_conflict argument.
  Added avoid_conflict option to create_resource method of puppetral agent.

Conflicts (resolved manually):
	agent/puppetral/agent/puppetral.rb
Update puppetral testing & resolve conflicting attributes

This commit adds tests for lots of recently added functionality. In the
process of adding these tests, I uncovered some bugs in our conflict
resolution features (which allow potentially conflicting parameters to
be removed before resource creation). These have been fixed, with tests
to confirm the fixes.

Reviewed-by: Matt Robinson <matt@puppetlabs.com>
Merge pull request #12 from MaxMartin/master

Revise for changes to puppet core
Fix bad input stub => failing test for puppetd agent.

In Ruby you can use an array deference on a Fixnum and get the bits at that
position; when you use a non-integer key you get zero, which is valid.

The test stubbed 0, a Fixnum, as a return value to stimulate an error return,
but it actually worked.  Replacing that with a more invalid value lets us get
the failure expected, and so exercise the right code path.

Signed-off-by: Daniel Pittman <daniel@rimspace.net>
Use 2-space indenting everywhere in the plugins.

This brings the code into line with Puppet Labs coding standards.  There are
no functional changes as part of this, just whitespace at the start of lines.

Signed-off-by: Daniel Pittman <daniel@rimspace.net>
(#9923) Support puppet agent as a daemon from puppetd

The `puppetd` MCollective agent didn't play nicely with a daemonized Puppet
agent; it would notice the lockfile and refuse to run.  Now, instead, it will
send SIGUSR1 to the daemon.

That will trigger an immediate run of Puppet, unless we are still in the
middle of the first (and only) splay interval.  During that window the agent
will just pick a new splay and wait that out; this is a limitation of the
agent and there is nothing else we can do.

Signed-off-by: Daniel Pittman <daniel@rimspace.net>
Handle cases for Puppet running vs idling

If the lock file exists, it can be handled as two cases depending on the
pid file's existance.

Remember to reference `::Process.kill()` from top scope as to not
conflict with `MCollective::Agent::Process`.
maint: Check that the created resource is in the proper form

Previously, to check whether a resource creation succeeded, we only
checked the :ensure value of the resource returned by the
Puppet::Resource indirection#save; however, there are some cases where
resource creation will fail, but this :ensure value will still not be
:absent. Instead, we now check the status of the report returned by
Puppet (only in Puppet 2.7.6 or greater) to see what the status of the
catalog application was; this will also give us any error information we
might want to return to the client.

Also, the avoid_conflict key must be changed to a symbol when accessing
the value from the resources found on the system because
Puppet::Resource#to_pson_hash is indexed by symbol.

Paired-with: Matt Robinson <matt@puppetlabs.com>
Merge pull request #14 from MaxMartin/master

Change how the status of #create is checked
Retain provider when searching packages

Recent changes to the agent caused all non-property parameters to be
trimmed from resources when finding & searching; this is desirable in
all cases except for when dealing with packages, where it is necessary
to know the provider. This commit adds a method for parameter pruning
(which was previously being duplicated between the find and search
action) and also special-cases package providers to retain them.

Reviewed-by: Joshua Lifton <lifton@puppetlabs.com>
Merge pull request #15 from MaxMartin/master

Package provider special-casing
Check the running PID, else start --onetime

The pid file wasn't quite being read correctly, so that's fixed.

The process wasn't being checked if it was alive, so that should be
fixed too
Adding spec test for dead process
Increment puppetd agent version number
Making cleaner status logic

- The status logic is easier to verify than branching conditionals
- Stubbed command calls to not get extra output