Project

General

Profile

Feature #827

add support for retrieving classes per host via the api

Added by Corey Osman over 9 years ago. Updated over 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
API
Target version:
Difficulty:
Triaged:
No
Bugzilla link:
Pull request:
Fixed in Releases:
Found in Releases:

Description

I would like to be able to get the assigned classes on a per host basis. I think it make logical sense to use the following url

GET: http://foreman/hosts/fqdn/puppetclasses

This would return a json object with the classes that the host is assigned.

A change similar to the following would need to be done:

http://pastie.org/1776402

Associated revisions

Revision 31207a31 (diff)
Added by Ohad Levy over 9 years ago

fixes #827 add support for retrieving classes per host via the api

This allows queries like
/hosts/fqdn/puppetclasses
/puppetclasses/klass/hosts

it also changes the puppetclasses urls to include the class name instead of its ID.

Revision a3ab05bd (diff)
Added by Ohad Levy over 9 years ago

fixes an issue with class assignments - refs #827

History

#1 Updated by Ohad Levy over 9 years ago

  • Status changed from New to Ready For Testing
  • % Done changed from 0 to 100

#2 Updated by Ohad Levy over 9 years ago

  • Status changed from Ready For Testing to Closed
  • Assignee set to Ohad Levy
  • Target version set to 0.3

#3 Updated by Corey Osman over 9 years ago

works great.

#4 Updated by Corey Osman over 9 years ago

actually I just noticed that the puppet classids are being returned as integers instead of strings like they were being returned before the patch.

here is how they are returned now (notice the ids are integers:

{"puppet":[{"puppetclass":{"name":"puppet","id":13}}],"newops_default":[{"puppetclass":{"name":"newops_default","id":7}}],"helloworld":[{"puppetclass":{"name":"helloworld","id":1}}],"weblogic":[{"puppetclass":{"name":"weblogic","id":23}}],"baseapps":[{"puppetclass":{"name":"baseapps","id":4}}],"oraclebase":[{"puppetclass":{"name":"oraclebase","id":10}}],"oracleperformance":[{"puppetclass":{"name":"oracleperformance","id":11}}]}

Here is how I submit when I do an update: Notice the ids are strings:

Processing HostsController#update (for 192.168.11.28 at 2011-04-16 15:50:01) [PUT]
  Parameters: {"action"=>"update", "_method"=>"put", "id"=>"cobbler.logicminds.corp", "controller"=>"hosts", "host"=>{"puppetclass_ids"=>["10", "4", "23", "1", "7", "13", "11"]}}
Completed in 24ms (View: 3, DB: 8) | 200 OK [http://192.168.11.8/hosts/cobbler.logicminds.corp]

#5 Updated by Ohad Levy over 9 years ago

Corey Osman wrote:

actually I just noticed that the puppet classids are being returned as integers instead of strings like they were being returned before the patch.

here is how they are returned now (notice the ids are integers:

[...]

Here is how I submit when I do an update: Notice the ids are strings:
[...]

what happens if you send it as integers? afaik, rails doesn't care too much about it.

Also available in: Atom PDF