Bug 1336716

Summary: Unable to remove host collection from activation key via hammer
Product: Red Hat Satellite Reporter: Andrii Balakhtar <abalakht>
Component: HammerAssignee: Andrew Kofink <akofink>
Status: CLOSED ERRATA QA Contact: jcallaha
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.2.0CC: bbuckingham, jcallaha, mmccune, sthirugn
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
URL: http://projects.theforeman.org/issues/15162
Whiteboard:
Fixed In Version: rubygem-katello-3.0.0.74-1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-09-14 21:00:56 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Before
none
After none

Description Andrii Balakhtar 2016-05-17 09:57:38 UTC
Description of problem:
Can't remove host collection from activation key using hammer - operation succeeds but host collection remains associated.

Version-Release number of selected component (if applicable):
Sat 6.2.0 GA SNAP11

How reproducible:
Always

Steps to Reproduce:
1. Associate host collection with activation key.
2. Try to remove host collection from activation key via 'hammer activation-key remove-host-collection' command.
3. Check whether host collection was actually removed.

Actual results:
remove-host-collection command succeeds, but host collection remains associated:

2016-05-17 12:33:07 - robottelo.ssh - DEBUG - >>> [dell-t320-01.khw.lab.eng.bos.redhat.com] LANG=en_US.UTF-8  hammer -v -u admin -p changeme  activation-key remove-host-collection --host-collection-id="1" --name="v6ncdpkpdL" --organization="X25dny"
2016-05-17 12:33:13 - robottelo.ssh - DEBUG - <<< stdout
The host collection has been removed

2016-05-17 12:33:13 - robottelo.ssh - DEBUG - >>> [dell-t320-01.khw.lab.eng.bos.redhat.com] LANG=en_US.UTF-8  hammer -v -u admin -p changeme  activation-key info --id="1"
2016-05-17 12:33:18 - robottelo.ssh - DEBUG - <<< stdout
Name:                  v6ncdpkpdL
ID:                    1
Description:           
Host Limit:            Unlimited
Auto Attach:           true
Lifecycle Environment: 
Content View:          
Host Collections:      
 1) ID:   1
    Name: FMpDVYKxmh


Expected results:
Host collection should be removed from activation key.
Also some validation for `activation-key remove-host-collection` command should be present - it shouldn't say 'The host collection has been removed' and finish with 0 return code when operation's failed.

Additional info:
Works as expected via UI (and, basically, 'activation-key info' reflects the changes, so it's an issue with `activation-key remove-host-collection`, not `activation-key info` command)

Comment 2 Andrew Kofink 2016-05-20 19:05:48 UTC
This is us getting bitten by deep_munge: https://github.com/rails/rails/issues/13420

Comment 3 Andrew Kofink 2016-05-24 12:53:05 UTC
Created redmine issue http://projects.theforeman.org/issues/15162 from this bug

Comment 5 Bryan Kearney 2016-06-02 22:16:23 UTC
Moving to POST since upstream bug http://projects.theforeman.org/issues/15162 has been closed

Comment 6 jcallaha 2016-09-01 18:57:37 UTC
Verified in Satellite 6.2.2. See attached screenshots and the commands below.

[root@rhsm-qe-1 tmp]# hammer activation-key remove-host-collection --help
Usage:
    hammer activation-key remove-host-collection [OPTIONS]

Options:
 --host-collection HOST_COLLECTION_NAME                            Host collection name to search by
 --host-collection-id HOST_COLLECTION_ID                           Id of the host collection
 --host-collection-organization-id HOST_COLLECTION_ORGANIZATION_ID Organization ID to search by
 --id ID                                                           ID of the activation key
 --name NAME                                                       Activation key name to search by
 --organization ORGANIZATION_NAME                                  Organization name to search by
 --organization-id ORGANIZATION_ID                                 organization ID
 --organization-label ORGANIZATION_LABEL                           Organization label to search by
 -h, --help                                                        print help

[root@rhsm-qe-1 tmp]# hammer activation-key list --organization-id 1
---|--------|----------------|-----------------------|--------------------------
ID | NAME   | HOST LIMIT     | LIFECYCLE ENVIRONMENT | CONTENT VIEW             
---|--------|----------------|-----------------------|--------------------------
1  | 7tools | 0 of Unlimited | Library               | Default Organization View
---|--------|----------------|-----------------------|--------------------------

[root@rhsm-qe-1 tmp]# hammer -u admin -p changeme host-collection list --organization-id 1
---|--------|-------|------------
ID | NAME   | LIMIT | DESCRIPTION
---|--------|-------|------------
1  | docker | None  |            
---|--------|-------|------------

[root@rhsm-qe-1 tmp]# hammer activation-key remove-host-collection --host-collection-id 1 --id 1 --organization-id 1
The host collection has been removed

Comment 7 jcallaha 2016-09-01 18:58:14 UTC
Created attachment 1196925 [details]
Before

Comment 8 jcallaha 2016-09-01 18:58:30 UTC
Created attachment 1196926 [details]
After

Comment 10 errata-xmlrpc 2016-09-14 21:00:56 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/RHBA-2016:1885