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 1519779

Summary: puppet classes info doesn't consider puppet environments parameter
Product: Red Hat Satellite Reporter: Sanket Jagtap <sjagtap>
Component: PuppetAssignee: Ondřej Pražák <oprazak>
Status: CLOSED ERRATA QA Contact: Sanket Jagtap <sjagtap>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.2.13CC: akarsale, dhlavacd, egolov, kgaikwad, mhulan, oprazak, rabajaj, sghai, sjagtap
Target Milestone: 6.5.0Keywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: foreman-1.20.0-0, rubygem-foreman_maintain-0.3.0 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-05-14 12:36:46 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
hammer output with debug
none
6.2.13 puppet-class info none

Description Sanket Jagtap 2017-12-01 12:58:58 UTC
Created attachment 1361573 [details]
hammer output with debug

Description of problem:


Version-Release number of selected component (if applicable):
6.2.13 snap1

How reproducible:
Always


Steps to Reproduce:
1. Have two puppet classes with same name in different environment

-bash-4.2#  hammer -u admin -p changeme  puppet-class list --environment="KT_9UEYTp_Library_wrzITAjOEQ_199"
----|----------------------------
ID  | NAME                       
----|----------------------------
1   | access_insights_client     
4   | foreman_scap_client        
5   | foreman_scap_client::params
122 | generic_1                  
2   | stdlib                     
3   | stdlib::stages             
----|----------------------------


-bash-4.2#  hammer -u admin -p changeme  puppet-class info --environment="KT_9UEYTp_Library_wrzITAjOEQ_199" --name="generic_1"
Error: found more than one puppetclass


The environment and environment-id parameter is not consider while looking for the class

Actual results:
Error: found more than one puppetclass

Expected results:
puppet class should be listed

Additional info:
Not a regression

Comment 2 Marek Hulan 2017-12-04 11:05:48 UTC
Sanket, could you please check whether you can achieve it through API? That will help us to find out, where is the issue. Thanks for hammer -d output, that helps too.

Comment 3 Sanket Jagtap 2017-12-04 13:12:44 UTC
Marek , will update you on this, as soon as I could get hold on upgrade RHEL7 box.
This only happens on the Upgrade RHEL7 box, and I was unable to reproduce the same with upgrade RHEL6 box.
On RHEL6 , even though the puppet class shared Environments I was able to list them successfully

hammer> puppet-class list --environment="KT_NPS3rZ_Library_aqaWndLuUR_197"
----|----------------------------
ID  | NAME                       
----|----------------------------
1   | access_insights_client     
2   | foreman_scap_client        
3   | foreman_scap_client::params
123 | generic_1                  
4   | stdlib                     
5   | stdlib::stages             
----|----------------------------
hammer> puppet-class info --environment="KT_NPS3rZ_Library_aqaWndLuUR_197" --name generic_1
Id:                     123
Name:                   generic_1
Smart variables:        
 1) Parameter:     
    Default value:
Smart class parameters: 
    generic_1_scp_001
    <truncated>
Hostgroups:             

Environments:           
    KT_NPS3rZ_Library_aqaWndLuUR_197
    KT_rQjElY_Library_dAXSrxvSDD_213
    KT_SjMpUy_Library_eijWCyKjfe_278
Parameters:

Comment 4 Ondřej Pražák 2017-12-13 12:35:48 UTC
Created attachment 1367326 [details]
6.2.13 puppet-class info

I fail to reproduce on newly installed 6.2.13

Comment 7 Sanket Jagtap 2017-12-26 06:22:54 UTC
Build: Satellite 6.3.0 snap 30 

This also started to appear with snap 30
PFA CLI hammer -d output and via API call

Comment 10 Sanket Jagtap 2018-07-09 11:41:46 UTC
Build: Satellite 6.4 snap 11

We are hitting this again on an upgraded box, which was upgraded from 6.3.z to 6.4. snap 11.

We just have one puppet-class named "generic_1" in that env. puppet class info, has a parameter to search in environment but it doesn't do that.

hammer -v -u admin -p changeme  puppet-class info --name="generic_1" --environment="KT_d9pR4I_Library_PtGKAORQmb_198"
[ERROR 2018-07-09T07:36:58 Exception] Error: Found more than one puppetclass.
Error: Found more than one puppetclass.
[ERROR 2018-07-09T07:36:58 Exception] 

HammerCLIForeman::ResolverError (Found more than one puppetclass.):
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.13.0/lib/hammer_cli_foreman/id_resolver.rb:242:in `pick_result'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.13.0/lib/hammer_cli_foreman/id_resolver.rb:292:in `puppetclass_id'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.13.0/lib/hammer_cli_foreman/commands.rb:131:in `get_resource_id'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.13.0/lib/hammer_cli_foreman/commands.rb:119:in `get_identifier'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.13.0/lib/hammer_cli_foreman/option_sources/self_param.rb:11:in `get_options'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.13.0/lib/hammer_cli/options/option_collector.rb:13:in `block in all_options_raw'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.13.0/lib/hammer_cli/options/option_collector.rb:12:in `each'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.13.0/lib/hammer_cli/options/option_collector.rb:12:in `inject'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.13.0/lib/hammer_cli/options/option_collector.rb:12:in `all_options_raw'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.13.0/lib/hammer_cli/options/option_collector.rb:18:in `all_options'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.13.0/lib/hammer_cli/options/option_collector.rb:22:in `options'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.13.0/lib/hammer_cli/abstract.rb:239:in `options'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.13.0/lib/hammer_cli/abstract.rb:42: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.13.0/lib/hammer_cli/abstract.rb:29: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.13.0/lib/hammer_cli/abstract.rb:29: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.13.0/lib/hammer_cli/abstract.rb:29: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.13.0/bin/hammer:143:in `<top (required)>'
    /usr/bin/hammer:23:in `load'
    /usr/bin/hammer:23:in `<main>'


[root@qe-sat6-upgrade-rhel7 ~]# hammer -v -u admin -p changeme  puppet-class list --environment="KT_d9pR4I_Library_PtGKAORQmb_198"
---|----------------------------
ID | NAME                       
---|----------------------------
1  | access_insights_client     
4  | foreman_scap_client        
5  | foreman_scap_client::params
97 | generic_1                  
2  | stdlib                     
3  | stdlib::stages             
---|----------------------------

[root@qe-sat6-upgrade-rhel7 ~]# hammer -v -u admin -p changeme  puppet-class info --help
Usage:
    hammer puppet-class info [OPTIONS]

Options:
 --environment ENVIRONMENT_NAME          Environment name
 --environment-id ENVIRONMENT_ID          
 --host HOST_NAME                        Host name
 --host-id HOST_ID                        
 --hostgroup HOSTGROUP_NAME              Hostgroup name
 --hostgroup-id HOSTGROUP_ID              
 --hostgroup-title HOSTGROUP_TITLE       Hostgroup title
 --id ID                                 ID of Puppet class
 --location LOCATION_NAME                Location name
 --location-id LOCATION_ID                
 --location-title LOCATION_TITLE         Location title
 --name NAME                             Puppet class name
 --organization ORGANIZATION_NAME        Organization name
 --organization-id ORGANIZATION_ID       Organization ID
 --organization-title ORGANIZATION_TITLE Organization title
 -h, --help                              Print help

Comment 13 Ondřej Pražák 2018-08-16 10:44:58 UTC
Created redmine issue http://projects.theforeman.org/issues/24633 from this bug

Comment 14 Satellite Program 2018-08-31 12:14:51 UTC
Upstream bug assigned to oprazak

Comment 15 Satellite Program 2018-08-31 12:14:55 UTC
Upstream bug assigned to oprazak

Comment 16 Satellite Program 2018-09-18 12:06:19 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue https://projects.theforeman.org/issues/24633 has been resolved.

Comment 21 errata-xmlrpc 2019-05-14 12:36:46 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-2019:1222