Project

General

Profile

Bug #24060

hammer host create using wrong API endpoint to list environments

Added by Ivan Necas over 3 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Hosts
Target version:
Difficulty:
Triaged:
Bugzilla link:
Fixed in Releases:
Found in Releases:

Description

Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=1583597

Description of problem:
`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:

# 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,

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

How reproducible:
always

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


Related issues

Related to Katello - Bug #22517: Can't create a hostgroup, organization errorClosed2018-02-06

Associated revisions

Revision 49b48b3c (diff)
Added by Ivan Necas over 3 years ago

Fixes #24060 - fix Puppet environments for host commands (#566)

Before this patch, the --environment option in host command was trying
to search in lifecycle environments. Reusing the resolvable definition
from the hostgroup, as they both should have the same behavior.

History

#1 Updated by Ivan Necas over 3 years ago

  • Related to Bug #22517: Can't create a hostgroup, organization error added

#2 Updated by The Foreman Bot over 3 years ago

  • Assignee set to Ivan Necas
  • Status changed from New to Ready For Testing
  • Pull request https://github.com/Katello/hammer-cli-katello/pull/566 added

#3 Updated by Ivan Necas over 3 years ago

  • % Done changed from 0 to 100
  • Status changed from Ready For Testing to Closed

#4 Updated by Andrew Kofink over 3 years ago

  • Legacy Backlogs Release (now unused) set to 338
  • Subject changed from hammer host create using wrong API endpoint to list environments to hammer host create using wrong API endpoint to list environments

Also available in: Atom PDF