Puppetrun API

Hi Arnound,

Your new route is correct. You just need to pass version=2 in the header, since version 1 is the default. Try this.

curl -u admin:secret -H 'Accept:application/json,version=2' http://0.0.0.0:3000/api/hosts/test02.dev.nxs.nl/puppetrun

Joseph Magen
Redhat

··· ----- Original Message ----- From: "Arnoud de Jonge" To: foreman-dev@googlegroups.com Sent: Tuesday, May 21, 2013 6:28:18 PM Subject: [foreman-dev] Puppetrun API

Hi,

I need an API call to trigger a Puppet run. I hacked it into the v1 API,
and that works, but it should be in v2, so that’s what I’m trying to do
now. I’ve added the route to config/routes/api/v2.rb and added the
controller app/controllers/api/v2/hosts_controller.rb which inherits the v1
controller and adds the puppetrun method. But when I call the API I get: No
route matches [GET] “/api/hosts/test02.dev.nxs.nl/puppetrun”. When I run rake
routes it does show the new route:

puppetrun_api_host GET /api/hosts/:id/puppetrun(.:format)
api/v2/hosts#puppetrun {:format=>“json”,
:id=>/[^/]+/}

Probably my inexperience with Rails that I’m missing something totally
obvious :wink:

Could anyone point me in the right direction? Code is here:
https://github.com/arnoudj/foreman

Thanks in advance,

Arnoud.


You received this message because you are subscribed to the Google Groups “foreman-dev” group.
To unsubscribe from this group and stop receiving emails from it, send an email to foreman-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Cool! Works like a charm now :slight_smile:

Regards,
Arnoud.