Bug 1583597

Summary: hammer host create using wrong API endpoint to list environments
Product: Red Hat Satellite Reporter: Roman Plevka <rplevka>
Component: Hosts - ContentAssignee: Ivan Necas <inecas>
Status: CLOSED ERRATA QA Contact: Ondřej Pražák <oprazak>
Severity: high Docs Contact:
Priority: unspecified    
Version: 6.4CC: akarsale, apatel, dhlavacd, ehelms, inecas, jhutar, kgaikwad, mhulan, oprazak, rabajaj, rplevka, tbrisker, tstrachota
Target Milestone: 6.4.0Keywords: Regression, Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: tfm-rubygem-hammer_cli_katello-0.13.3-1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-10-16 19:31:12 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
foreman logs when creating host via hammer none

Description Roman Plevka 2018-05-29 10:38:57 UTC
Description of problem:
this is a regression since 6.3.
`hammer host create` accepts a --environment parameter (which is supposed to be a puppet environment). However, on specifying this, it uses the API endpoint of katello environments, which are lifecycle environments:

<pre>
# hammer -d -u admin -p changeme --output=csv host create --medium-id="31" --ip="142.89.31.218" --location-id="2" --operatingsystem-id="2" --environment="KT_QrEczI_Library_pTBRPfBmGb_168" --domain-id="18" --partition-table-id="91" --mac="86:fa:fa:27:ef:0a" --organization-id="127" --architecture-id="1" --name="GkhWDIhihR" --puppet-classes="generic_1" --root-password="vERLTilA"
...
...
[ INFO 2018-05-29T06:34:03 API] GET /katello/api/organizations/127/environments
[DEBUG 2018-05-29T06:34:03 API] Params: {
    "name" => "KT_QrEczI_Library_pTBRPfBmGb_168"
}
[DEBUG 2018-05-29T06:34:03 API] Headers: {
    :params => {
        "name" => "KT_QrEczI_Library_pTBRPfBmGb_168"
    }
}
[DEBUG 2018-05-29T06:34:03 API] Using authenticator: HammerCLIForeman::Api::InteractiveBasicAuth
[DEBUG 2018-05-29T06:34:03 API] Response: {
       "total" => 0,
    "subtotal" => 0,
</pre>


This obviously always fails to create a host if the --environment parameter is specified.

the correct endpoint to be queried is:
/api/v2/organizations/<id>/environments

Version-Release number of selected component (if applicable):
6.4.0-1

How reproducible:
always

Steps to Reproduce:
1. try to create a host using hammer with specifying an --environment parameter

Comment 2 Marek Hulan 2018-05-29 15:44:45 UTC
Isn't this fixed by http://projects.theforeman.org/issues/22517/ could you check packages versions and compare them to the list in linked issue?

Comment 3 Ivan Necas 2018-06-25 11:40:26 UTC
I was able to reproduce the issue: the problem is we are using the customized resolver in the hostgroup but not in host command. Will send a fix upstream.

Comment 4 Ivan Necas 2018-06-25 11:42:35 UTC
Created redmine issue https://projects.theforeman.org/issues/24060 from this bug

Comment 5 Ivan Necas 2018-06-25 11:48:54 UTC
Proposed fix at https://github.com/Katello/hammer-cli-katello/pull/566

Comment 6 Satellite Program 2018-06-25 16:15:28 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/24060 has been resolved.

Comment 8 Ondřej Pražák 2018-07-17 09:25:53 UTC
Created attachment 1459373 [details]
foreman logs when creating host via hammer

Comment 9 Ivan Necas 2018-07-17 09:42:37 UTC
*** Bug 1595188 has been marked as a duplicate of this bug. ***

Comment 10 Roman Plevka 2018-07-17 12:04:16 UTC
*** Bug 1598569 has been marked as a duplicate of this bug. ***

Comment 11 Roman Plevka 2018-07-17 12:06:26 UTC
verified

since snap#11.
the lce is now properly recognized.

verified by automaed tests:
596322f6-9fdc-441a-a36d-ae2f22132b38
26e406ea-56f5-4813-bb93-e908c9015ee3
...

Comment 13 Bryan Kearney 2018-10-16 19:31:12 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:2927