Bug 1274683 - hammer host update ... --parameters=... fails if parameters already exist
Summary: hammer host update ... --parameters=... fails if parameters already exist
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: API
Version: 6.1.3
Hardware: All
OS: Linux
medium
medium
Target Milestone: Unspecified
Assignee: Ondřej Pražák
QA Contact: Amit Karsale
URL: http://projects.theforeman.org/issues...
Whiteboard:
Depends On:
Blocks: 1296845
TreeView+ depends on / blocked
 
Reported: 2015-10-23 10:57 UTC by Evgeni Golov
Modified: 2020-03-11 14:58 UTC (History)
9 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-02-21 16:40:54 UTC
Target Upstream Version:
Embargoed:


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


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 12294 0 None None None 2016-04-26 17:06:40 UTC
Red Hat Knowledge Base (Solution) 2021603 0 None None None Never

Description Evgeni Golov 2015-10-23 10:57:48 UTC
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:
always

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 11:04:41 UTC
- 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 13:42:19 UTC
This can be reproduced on upstream Foreman 1.9.0 too.

Comment 4 Evgeni Golov 2015-10-23 14:04:09 UTC
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 15:08:42 UTC
Created redmine issue http://projects.theforeman.org/issues/12294 from this bug

Comment 9 orabin 2016-12-14 10:32:20 UTC
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
...
Parameters:         
    abc => d
    example => test

hammer host update --id 1 --parameters "foo=bar"
hammer host info --id 1
Id: 1
...
Parameters:         
    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 11:01:20 UTC
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 Satellite Program 2017-01-25 09:14:58 UTC
Upstream bug assigned to oprazak

Comment 13 Satellite Program 2017-01-25 09:15:03 UTC
Upstream bug assigned to oprazak

Comment 14 Satellite Program 2017-02-20 23:15:08 UTC
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 12:58:18 UTC
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 12:59:04 UTC
Created attachment 1308725 [details]
host update param value for existing param

Comment 18 Bryan Kearney 2018-02-21 16:39:16 UTC
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA.

For information on the advisory, and where to find the updated files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2018:0336

Comment 19 Bryan Kearney 2018-02-21 16:40:54 UTC
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA.

For information on the advisory, and where to find the updated files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2018:0336

Comment 20 Satellite Program 2018-02-21 16:54:17 UTC
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA.
> 
> For information on the advisory, and where to find the updated files, follow the link below.
> 
> If the solution does not work for you, open a new bug report.
> 
> https://access.redhat.com/errata/RHSA-2018:0336


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