Project

General

Profile

Bug #12566

New Host API changed host_parameters_attributes behavior

Added by Lukas Zapletal over 3 years ago. Updated about 1 year ago.

Status:
Closed
Priority:
Normal
Category:
API
Target version:
Difficulty:
Triaged:
Bugzilla link:
Team Backlog:
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

Related to Discovery - Bug #12516: PUT request for discovered_hosts/[id] fails with "unknown attribute: nested"Closed2015-11-18
Related to Foreman - Bug #9815: HostGroup Clone doesn't work if the hostgroup has parametersClosed2015-03-18
Related to Hammer CLI - Bug #12090: foreman-cli 0.4 does not work with foreman 1.10-devClosed2015-10-07

Associated revisions

Revision 7ee381e9 (diff)
Added by Lukas Zapletal over 3 years ago

Fixes #12566 - host_parameters_attributes accepts nested flag

Revision 72ddea3c (diff)
Added by Lukas Zapletal over 3 years ago

Fixes #12566 - host_parameters_attributes accepts nested flag

History

#1 Updated by Lukas Zapletal over 3 years ago

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

#2 Updated by Dominic Cleal over 3 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.

#3 Updated by Lukas Zapletal over 3 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.

#4 Updated by Dominic Cleal over 3 years ago

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

#5 Updated by Lukas Zapletal over 3 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.

#6 Updated by Dominic Cleal over 3 years ago

  • Legacy Backlogs Release (now unused) set to 63

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

#7 Updated by Lukas Zapletal over 3 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.

#8 Updated by Dominic Cleal over 3 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.

#9 Updated by The Foreman Bot over 3 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

#10 Updated by Dominic Cleal over 3 years ago

  • Legacy Backlogs Release (now unused) changed from 63 to 104

#11 Updated by Dominic Cleal over 3 years ago

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

#12 Updated by Lukas Zapletal over 3 years ago

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

Also available in: Atom PDF