Bug 1503704

Summary: hammer host-collection list requires organization parameter with host-id provided
Product: Red Hat Satellite Reporter: Roman Plevka <rplevka>
Component: HammerAssignee: Andrew Kofink <akofink>
Status: CLOSED ERRATA QA Contact: Nikhil Kathole <nkathole>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.3.0CC: akarsale, akofink, bbuckingham, dhlavacd, ehelms, kgaikwad, mhulan, nkathole, rabajaj, sabnave, tstrachota
Target Milestone: UnspecifiedKeywords: Regression, Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-02-21 17:30:57 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:

Description Roman Plevka 2017-10-18 14:54:45 UTC
Description of problem:


[root@cisco-b420m3-01 ~]# hammer host-collection list --host-id 2
Error: Could not find organization, please set one of options --organization, --organization-label, --organization-id.
[root@cisco-b420m3-01 ~]# hammer host-collection list --host-id 3 --organization-id 1
Couldn't find Host::Managed with 'id'=3 [WHERE "hosts"."type" IN ('Host::Managed')]
 
This should not happen, since host-id is unique, so satellite should be able to figure out the appt organization.
Also, this is a regression since last snap (6.3.0-19)



Version-Release number of selected component (if applicable):
6.3.0-20

How reproducible:


Steps to Reproduce:
1. create a host collection and create & add a host into it
2. try to list host collection by specifying its member id (host-id)

Actual results:
organization parameter required

Expected results:
should be able to list the HC

Additional info:

Comment 2 Andrew Kofink 2017-10-20 15:46:03 UTC
This is caused by BZ #1480508

Comment 3 Roman Plevka 2017-10-23 12:07:44 UTC
what is the expected behavior?
as in 6.3.0, the org paramaeter is now required even for a simple GET /host_collections call.
From the BZ #1480508 i can see, this should not be required.
Will the fix for this BZ address this issue as well?

thanks

Comment 4 Andrew Kofink 2017-10-23 12:50:11 UTC
organization_id should not be required in host_collections#index. I will investigate if BZ #1480508 is reproducible after making the change.

Comment 5 Andrew Kofink 2017-10-23 17:15:05 UTC
Created redmine issue http://projects.theforeman.org/issues/21435 from this bug

Comment 6 Satellite Program 2017-10-25 20:17:54 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/21435 has been resolved.

Comment 7 Nikhil Kathole 2017-10-31 11:27:55 UTC
VERIFIED

Version Tested:
Satellite-6.3 Snap 22

steps:

# hammer host-collection list
---|------------------------------|-------|------------
ID | NAME                         | LIMIT | DESCRIPTION
---|------------------------------|-------|------------
3  | hostcollectionin another org | None  |
2  | host_collection_test1        | None  |
1  | RHEL 7 Host collection       | None  |
---|------------------------------|-------|------------

# hammer host-collection list --host-id 15
---|------------------------|-------|------------
ID | NAME                   | LIMIT | DESCRIPTION
---|------------------------|-------|------------
1  | RHEL 7 Host collection | None  |
---|------------------------|-------|------------

# hammer host-collection list --organization-id 1
---|------------------------|-------|------------
ID | NAME                   | LIMIT | DESCRIPTION
---|------------------------|-------|------------
2  | host_collection_test1  | None  |
1  | RHEL 7 Host collection | None  |
---|------------------------|-------|------------

# hammer host-collection list --organization-id 1 --host-id 15
---|------------------------|-------|------------
ID | NAME                   | LIMIT | DESCRIPTION
---|------------------------|-------|------------
1  | RHEL 7 Host collection | None  |
---|------------------------|-------|------------

Also verified BZ #1480508 ,

# curl -s -X GET -k -u admin:<passwd> 'https://<satellite>/katello/api/v2/host_collections'| json_reformat
{
    "total": 3,
    "subtotal": 3,
    "page": 1,
    "per_page": 20,
    "error": null,
    "search": null,
    "sort": {
        "by": "name",
        "order": "asc"
    },
    "results": [
        {
            "name": "hostcollectionin another org",
            "organization_id": 8,
            "max_hosts": null,
            "description": null,
            "total_hosts": 0,
            "unlimited_hosts": true,
            "created_at": "2017-10-31 06:53:59 UTC",
            "updated_at": "2017-10-31 06:53:59 UTC",
            "id": 3,
            "permissions": {
                "deletable": true,
                "editable": true
            }
        },
        {
            "name": "host_collection_test1",
            "organization_id": 1,
            "max_hosts": null,
            "description": null,
            "total_hosts": 0,
            "unlimited_hosts": true,
            "created_at": "2017-10-31 06:52:20 UTC",
            "updated_at": "2017-10-31 06:52:20 UTC",
            "id": 2,
            "permissions": {
                "deletable": true,
                "editable": true
            }
        },
        {
            "name": "RHEL 7 Host collection",
            "organization_id": 1,
            "max_hosts": null,
            "description": null,
            "total_hosts": 1,
            "unlimited_hosts": true,
            "created_at": "2017-10-31 06:51:49 UTC",
            "updated_at": "2017-10-31 06:51:49 UTC",
            "id": 1,
            "permissions": {
                "deletable": true,
                "editable": true
            }
        }
    ]
}

# curl -s -X GET -k -u admin:<passwd> 'https://<satellite>/katello/api/v2/host_collections?organization_id=1'| json_reformat
{
    "total": 2,
    "subtotal": 2,
    "page": 1,
    "per_page": 20,
    "error": null,
    "search": null,
    "sort": {
        "by": "name",
        "order": "asc"
    },
    "results": [
        {
            "name": "host_collection_test1",
            "organization_id": 1,
            "max_hosts": null,
            "description": null,
            "total_hosts": 0,
            "unlimited_hosts": true,
            "created_at": "2017-10-31 06:52:20 UTC",
            "updated_at": "2017-10-31 06:52:20 UTC",
            "id": 2,
            "permissions": {
                "deletable": true,
                "editable": true
            }
        },
        {
            "name": "RHEL 7 Host collection",
            "organization_id": 1,
            "max_hosts": null,
            "description": null,
            "total_hosts": 1,
            "unlimited_hosts": true,
            "created_at": "2017-10-31 06:51:49 UTC",
            "updated_at": "2017-10-31 06:51:49 UTC",
            "id": 1,
            "permissions": {
                "deletable": true,
                "editable": true
            }
        }
    ]
}

Comment 8 Bryan Kearney 2018-02-21 17:30:57 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