Project

General

Profile

Actions

Bug #12566

closed

New Host API changed host_parameters_attributes behavior

Added by Lukas Zapletal about 9 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Normal
Category:
API
Target version:
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

This API call used to work:

{
    "host": {
        "name": "test",
        "mac": "AA:BB:CC:DD:EE:F1",
        "organization_id": 3,
        "location_id": 2,
        "hostgroup_id": 7,
        "host_parameters_attributes": [
            {
                "name": "compute_resource_id",
                "value": "1",
                "_destroy": "false",
                "nested": "false" 
            }
        ]
    }
}

Now it fails with ActiveRecord::UnknownAttributeError: unknown attribute: nested. Regression, looks like some nesting changes broke this, since oVirt uses this API (via discovery), we should consider a portability fix.


Related issues 3 (0 open3 closed)

Related to Discovery - Bug #12516: PUT request for discovered_hosts/[id] fails with "unknown attribute: nested"ClosedLukas Zapletal11/18/2015Actions
Related to Foreman - Bug #9815: HostGroup Clone doesn't work if the hostgroup has parametersClosedChristine Fouant03/18/2015Actions
Related to Hammer CLI - Bug #12090: foreman-cli 0.4 does not work with foreman 1.10-devClosed10/07/2015Actions
Actions #1

Updated by Lukas Zapletal about 9 years ago

  • Related to Bug #12516: PUT request for discovered_hosts/[id] fails with "unknown attribute: nested" added
Actions #2

Updated by Dominic Cleal about 9 years ago

  • Status changed from New to Feedback

host_parameters_attributes should only be used by the UI, not in the API - this shouldn't be considered a stable API.

We have a stable CRUD interface for parameters under /api/v2/hosts/:id/parameters.

Actions #3

Updated by Lukas Zapletal about 9 years ago

  • Status changed from Feedback to New

Well, we apparently expose this, it is documented and in use apparently. This is a regression and this is a valid ticket.

/home/lzap/work/foreman/app/controllers/api/v1/hosts_controller.rb:
   46          param :puppet_ca_proxy_id, :number
   47          param :image_id, :number
   48:         param :host_parameters_attributes, Array
   49          param :build, :bool
   50          param :enabled, :bool
   ..
   88          param :puppet_ca_proxy_id, :number
   89          param :image_id, :number
   90:         param :host_parameters_attributes, Array
   91          param :build, :bool
   92          param :enabled, :bool

/home/lzap/work/foreman/app/controllers/api/v2/hosts_controller.rb:
   63            param :puppet_ca_proxy_id, :number
   64            param :image_id, :number
   65:           param :host_parameters_attributes, Array
   66            param :build, :bool
   67            param :enabled, :bool

Another CRUD is not a option for discovery users as the host is rebooted immediately.

Actions #4

Updated by Dominic Cleal about 9 years ago

  • Related to Bug #9815: HostGroup Clone doesn't work if the hostgroup has parameters added
Actions #5

Updated by Lukas Zapletal about 9 years ago

Thanks for the link, my plan is to make sure the nested attribute is ignored as oVirt and RHEV already uses this API :-(

I will make a patch.

Actions #6

Updated by Dominic Cleal about 9 years ago

  • Translation missing: en.field_release set to 63

Be sure to mark it as deprecated then, it really shouldn't be used IMHO.

Actions #7

Updated by Lukas Zapletal about 9 years ago

Do you mean to flag whole host_parameters_attributes as deprecated?

In discovery workflow, users cannot do more than one request. What if we simply filter out everything, but key/value pairs for both API V2 controllers (host/hostgroup)? That could do it.

Actions #8

Updated by Dominic Cleal about 9 years ago

Lukas Zapletal wrote:

Do you mean to flag whole host_parameters_attributes as deprecated?

The "nested" attribute. I'd suggest a stern warning too on host_parameters_attributes, but probably not deprecate it formally.

Actions #9

Updated by The Foreman Bot about 9 years ago

  • Status changed from New to Ready For Testing
  • Assignee set to Lukas Zapletal
  • Pull request https://github.com/theforeman/foreman/pull/2928 added
Actions #10

Updated by Dominic Cleal almost 9 years ago

  • Translation missing: en.field_release changed from 63 to 104
Actions #11

Updated by Dominic Cleal almost 9 years ago

  • Related to Bug #12090: foreman-cli 0.4 does not work with foreman 1.10-dev added
Actions #12

Updated by Lukas Zapletal almost 9 years ago

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

Also available in: Atom PDF