Bug 1274683 - hammer host update ... --parameters=... fails if parameters already exist
hammer host update ... --parameters=... fails if parameters already exist
Product: Red Hat Satellite 6
Classification: Red Hat
Component: API (Show other bugs)
All Linux
medium Severity medium (vote)
: GA
: --
Assigned To: Ondřej Pražák
Amit Karsale
: Triaged
Depends On:
Blocks: 1296845
  Show dependency treegraph
Reported: 2015-10-23 06:57 EDT by Evgeni Golov
Modified: 2017-08-15 15:46 EDT (History)
9 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
host update param value for existing param (42.72 KB, image/png)
2017-08-03 08:59 EDT, Amit Karsale
no flags Details

External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 2021603 None None None Never
Foreman Issue Tracker 12294 None None None 2016-04-26 13:06 EDT

  None (edit)
Description Evgeni Golov 2015-10-23 06:57:48 EDT
Description of problem:
I want to create and update hosts using hammer host create/update and pass custom parameters to it. This works fine on create but fails when I want to update a host and pass a parameter that is already present.

Version-Release number of selected component (if applicable):
Satellite 6.1.3

How reproducible:

Steps to Reproduce:
1. hammer host create ... --parameters="foo=bar"
2. hammer host update ... --parameters="foo=bar"

Actual results:
Could not update the host:
  Name has already been taken

Expected results:
Host updated

Additional info:
It does not matter if I want to set the parameter to the same or a new value.
Comment 1 Christian Horn 2015-10-23 07:04:41 EDT
- Changes vias satellite GUI seems to work
- If one needs to stay on the hammer tool, one might also be able to delete and then create with new parameters
- The issue is seen on Satellite 6.1.1 codebase, as well as on current 6.1.3
Comment 3 Evgeni Golov 2015-10-23 09:42:19 EDT
This can be reproduced on upstream Foreman 1.9.0 too.
Comment 4 Evgeni Golov 2015-10-23 10:04:09 EDT
A proper workaround is to use "hammer host create/update" without --parameters and call "hammer host set-parameter" afterwards. This is however slightly silly, as one needs multiple calls to update multiple parameters.
Comment 5 Bryan Kearney 2015-10-23 11:08:42 EDT
Created redmine issue http://projects.theforeman.org/issues/12294 from this bug
Comment 9 orabin 2016-12-14 05:32:20 EST
The correct way to update a parameter is to use hammer host delete-parameter and then set-parameter.
Using hammer host update --parameters does not update certain parameters but all parameters, meaning it should delete all the host_parameters and then creates only those you pass in the update.
Example of expected behavior:

hammer host info --id 1
Id: 1
    abc => d
    example => test

hammer host update --id 1 --parameters "foo=bar"
hammer host info --id 1
Id: 1
    foo => bar

This is common in the api and hammer (look at hammer hostgroup update --organizations for example).

So the correct way is to use --parameters for the initial setup of parameters and from then on use set/delete-parameter.

I am leaving this bug open because the error should not appear, it should delete and add no matter what the original parameters were.
Please note if you are not updating all the parameters you will delete those you don't send.
Comment 10 Evgeni Golov 2016-12-14 06:01:20 EST
Ack, I think the overwrite of ALL params is expected.
But I also think this should be clearly stated in the help output for hammer host update (and probably also point to the hammer host {create/delete/set}-parameter alternative?)
Comment 12 pm-sat@redhat.com 2017-01-25 04:14:58 EST
Upstream bug assigned to oprazak@redhat.com
Comment 13 pm-sat@redhat.com 2017-01-25 04:15:03 EST
Upstream bug assigned to oprazak@redhat.com
Comment 14 pm-sat@redhat.com 2017-02-20 18:15:08 EST
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/12294 has been resolved.
Comment 16 Amit Karsale 2017-08-03 08:58:18 EDT
Issue is addressed in satellite 6.3 beta snap9. Tested and verified. Please find the attached screenshot for verification
Comment 17 Amit Karsale 2017-08-03 08:59 EDT
Created attachment 1308725 [details]
host update param value for existing param

Note You need to log in before you can comment on or make changes to this bug.