Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1715992

Summary: `hammer hostgroup create --environment` always fails
Product: Red Hat Satellite Reporter: Mirek Długosz <mzalewsk>
Component: Hammer - ContentAssignee: Jonathon Turel <jturel>
Status: CLOSED DUPLICATE QA Contact: Roman Plevka <rplevka>
Severity: high Docs Contact:
Priority: unspecified    
Version: 6.6.0CC: akarsale, apatel, jturel, kgaikwad, mbacovsk, mshira, ofedoren, rabajaj, vijsingh
Target Milestone: 6.6.0Keywords: AutomationBlocker, 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: 2019-06-19 19:36:05 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 Mirek Długosz 2019-05-31 22:03:26 UTC
hammer hostgroup create --environment <puppet_environment_name> always fails with error:

Could not create the hostgroup:
  Error: lifecycle_environment not found.


hammer seems to think that --environment is used to specify lifecycle environment, while it's used to specify Puppet environment. 

In /var/log/foreman/production.log, there is:
2019-05-31T20:54:46 [I|app|b7867ca9] Started GET "/katello/api/organizations/7/environments?name=KT_oMHY60_Library_ZYzexpLbxK_5" for 192.168.121.250 at 2019-05-31 20:54:46 +0000

While in Satellite 6.5, there was:
2019-05-31T20:54:18 [I|app|] Started GET "/api/environments?search=name+%3D+%22KT_mvLeiC_Library_RuZbccweCO_4%22" for 192.168.121.164 at 2019-05-31 20:54:18 +0000

Requested endpoints are different and 6.6 one is incorrect.



Steps to Reproduce:
1. Create new Puppet environment
2. hammer hostgroup create --environment="new_environment" --name="hostgroup_name" --query-organization="Default Organization"


Expected results:
New hostgroup is created


Actual results:
Could not create the hostgroup:
  Error: lifecycle_environment not found.

When running with --debug flag, following will be printed:

[DEBUG 2019-05-31T20:35:16 Exception] Using exception handler HammerCLIForeman::ExceptionHandler#handle_general_exception
[ERROR 2019-05-31T20:35:16 Exception] Error: lifecycle_environment not found.
Could not create the hostgroup:
  Error: lifecycle_environment not found.
[ERROR 2019-05-31T20:35:16 Exception] 

HammerCLIForeman::ResolverError (lifecycle_environment not found.):
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.17.0/lib/hammer_cli_foreman/id_resolver.rb:244:in `pick_result'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.17.0/lib/hammer_cli_foreman/id_resolver.rb:201:in `find_resource'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.17.0/lib/hammer_cli_foreman/id_resolver.rb:149:in `get_id'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.17.0/lib/hammer_cli_foreman/id_resolver.rb:137:in `block (2 levels) in define_id_finders'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_katello-0.18.pre.master/lib/hammer_cli_katello/id_resolver.rb:70:in `environment_id'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.17.0/lib/hammer_cli_foreman/commands.rb:131:in `get_resource_id'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.17.0/lib/hammer_cli_foreman/option_sources/id_params.rb:23:in `block in get_options'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.17.0/lib/hammer_cli_foreman/option_sources/id_params.rb:20:in `each'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.17.0/lib/hammer_cli_foreman/option_sources/id_params.rb:20:in `get_options'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.17.1/lib/hammer_cli/options/sources/base.rb:8:in `process'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.17.1/lib/hammer_cli/options/processor_list.rb:22:in `block in process'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.17.1/lib/hammer_cli/options/processor_list.rb:21:in `each'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.17.1/lib/hammer_cli/options/processor_list.rb:21:in `inject'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.17.1/lib/hammer_cli/options/processor_list.rb:21:in `process'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.17.1/lib/hammer_cli/options/processor_list.rb:22:in `block in process'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.17.1/lib/hammer_cli/options/processor_list.rb:21:in `each'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.17.1/lib/hammer_cli/options/processor_list.rb:21:in `inject'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.17.1/lib/hammer_cli/options/processor_list.rb:21:in `process'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.17.1/lib/hammer_cli/options/option_collector.rb:17:in `all_options_raw'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.17.1/lib/hammer_cli/options/option_collector.rb:21:in `all_options'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.17.1/lib/hammer_cli/options/option_collector.rb:25:in `options'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.17.1/lib/hammer_cli/abstract.rb:312:in `options'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.17.1/lib/hammer_cli/abstract.rb:82:in `parse'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.1.2/lib/clamp/command.rb:62:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.17.1/lib/hammer_cli/abstract.rb:69:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.1.2/lib/clamp/subcommand/execution.rb:11:in `execute'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.1.2/lib/clamp/command.rb:63:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.17.1/lib/hammer_cli/abstract.rb:69:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.1.2/lib/clamp/subcommand/execution.rb:11:in `execute'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.1.2/lib/clamp/command.rb:63:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.17.1/lib/hammer_cli/abstract.rb:69:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.1.2/lib/clamp/command.rb:132:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.17.1/bin/hammer:147:in `<top (required)>'
    /bin/hammer:23:in `load'
    /bin/hammer:23:in `<main>'


Versions:
Satellite 6.6 snap 4
tfm-rubygem-hammer_cli-0.17.1-1.el7sat.noarch
satellite-6.6.0-5.beta.el7sat.noarch
foreman-1.22.0-0.5.RC2.1.el7sat.noarch
pulp-server-2.19.0-14.el7sat.noarch
tfm-rubygem-katello-3.12.0.rc2-11.master.el7sat.noarch

Comment 3 Jonathon Turel 2019-06-19 19:36:05 UTC

*** This bug has been marked as a duplicate of bug 1713222 ***