puppetlabs/puppetlabs-razor — pull request #131 by cr3 (2013-05-01 21:56:04+00:00)
Title: (#130) Razor providers should check return value for errors

This change modifies the create and destroy methods in the rz_broker,
rz_image, rz_model and rz_policy providers to raise a Puppet::Error
when an error occurs. This is achieved by passing the output to the
parse method in the PuppetX::PuppetLabs::Razor class. If the output
contains a 'response' key, it is returned, if it contains a 'result' key,
a Puppet::Error exception is raised with it, otherwise a Puppet::Razor
exception is raised with the whole output.

The reason for this change is to enable Puppet manifests using
Razor resources to actually get an error when the razor command
fails. Otherwise, the error is simply ignored and the user has to
reverse engineer the problem from the side effects of the failure.

Note that this change moves the parse method in PuppetX::PuppetLabs::Razor
from being private to public, so that it can be re-used in the
providers. Also note that it did not implement the behavior for the rz_tag
provider because it is much more complicated, having to potentially
manage multiple tags. This can be handled in a separate pull request.

This pull request fixes issue #130.