Bug 1427260

Summary: Hammer- can't remove puppet module from content view by id -- uuid is sent instead
Product: Red Hat Satellite Reporter: Stanislav Tkachenko <stkachen>
Component: Content ViewsAssignee: Andrew Kofink <akofink>
Status: CLOSED ERRATA QA Contact: Ales Dujicek <adujicek>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.2.8CC: adujicek, akofink, bbuckingham, bkearney, jcallaha, jsherril, tstrachota
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: tfm-rubygem-hammer_cli_katello-0.10.1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1427261 (view as bug list) Environment:
Last Closed: 2018-02-21 16:54:37 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:
Bug Depends On:    
Bug Blocks: 1427261    

Description Stanislav Tkachenko 2017-02-27 17:35:52 UTC
Description of problem:

Can't remove puppet module from content view by id using hammer. According to hammer debug, uuid is sent instead of id:
>[ INFO 2017-02-27 12:29:08 HammerCLIKatello::ContentView] Called with options: {}
> [ INFO 2017-02-27 12:29:08 HammerCLIKatello::ContentViewPuppetModule] Called with options: {}
> [ INFO 2017-02-27 12:29:08 API] Server: https://localhost/
> [ INFO 2017-02-27 12:29:08 API] GET /katello/api/content_views/118/content_view_puppet_modules
> [DEBUG 2017-02-27 12:29:08 API] Params: {
>    "uuid" => "44"
>}
>[DEBUG 2017-02-27 12:29:08 API] Headers: {
>    :params => {
>        "uuid" => "44"
>    }
>}

Also it is not clear what exactly id should be used, the one from global `puppet-module list` command output, like it is done for `content-view puppet-module add`, or from the `content-view info` output. However, both doesn't allow to remove puppet module. --name and --uuid parameters work as expected.

> # hammer -v content-view info --id 121
> Puppet Modules:         
> 1) ID:      46
>    UUID:    2de63c7f-d0fb-4a29-b301-449a52c026d7
>    Name:    generic_1

> # hammer -v content-view puppet-module remove --content-view-id="121" --id="46"
> [ERROR 2017-02-27 12:05:29 Exception] Error: content_view_puppet_module not found
> Couldn't remove puppet module from the content view:
>  Error: content_view_puppet_module not found

> # hammer -v  puppet-module list
> ID,Name,Author,Version,Uuid
> 3,generic_1,robottelo,0.2.0,2de63c7f-d0fb-4a29-b301-449a52c026d7

> hammer -v content-view puppet-module remove --content-view-id="121" --id="3"
> [ERROR 2017-02-27 12:07:48 Exception] Error: content_view_puppet_module not found
> Couldn't remove puppet module from the content view:
>  Error: content_view_puppet_module not found

Version-Release number of selected component (if applicable):
Satellite 6.2.8 Snap 3.0:
* satellite-6.2.8-1.0.el7sat.noarch
* foreman-1.11.0.66-2.el7sat.noarch
* katello-3.0.0-17.el7sat.noarch

How reproducible:
Always

Steps to Reproduce:
1. Create Content View
2. Create puppet repo with modules
3. Associate puppet module with CV using `hammer content-view puppet-module add`
4. Try to remove using `hammer content-view puppet-module remove --id`

Actual results:
Exception is raised.

Expected results:
Puppet module should removed.

Additional info:

Comment 3 Brad Buckingham 2017-03-01 11:41:14 UTC
*** Bug 1427261 has been marked as a duplicate of this bug. ***

Comment 4 Andrew Kofink 2017-03-15 19:32:48 UTC
Created redmine issue http://projects.theforeman.org/issues/18923 from this bug

Comment 5 Satellite Program 2017-04-07 14:14:56 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/18923 has been resolved.

Comment 6 Justin Sherrill 2017-08-02 15:53:26 UTC
Failed QA  6.3.0 snap 9.0


Getting an error when using --id

[root@jsherrill-test ~]# hammer -vv -p changeme content-view puppet-module remove --content-view-id=2 --id=1
[ERROR 2017-08-02 15:51:12 Exception] Error: content_view_puppet_module not found
Couldn't remove puppet module from the content view:
  Error: content_view_puppet_module not found
[ERROR 2017-08-02 15:51:12 Exception] 

HammerCLIForeman::ResolverError (content_view_puppet_module not found):
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.10.2/lib/hammer_cli_foreman/id_resolver.rb:208:in `pick_result'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.10.2/lib/hammer_cli_foreman/id_resolver.rb:168:in `find_resource'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.10.2/lib/hammer_cli_foreman/id_resolver.rb:143:in `get_id'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.10.2/lib/hammer_cli_foreman/id_resolver.rb:133:in `block (2 levels) in define_id_finders'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_katello-0.10.0/lib/hammer_cli_katello/content_view_puppet_module.rb:59:in `resolve_puppet_module_id_from_uuid'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_katello-0.10.0/lib/hammer_cli_katello/content_view_puppet_module.rb:65:in `all_options'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.10.2/lib/hammer_cli_foreman/commands.rb:125:in `get_resource_id'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.10.2/lib/hammer_cli_foreman/commands.rb:199:in `block in customized_options'


Still works fine with uuid:

[root@jsherrill-test ~]# hammer -p changeme content-view puppet-module remove --content-view-id=2 --uuid=4ca76f05-f98e-407b-b7e6-a779dc5b1660
Puppet module removed from content view

maybe the commit didn't make it in somehow?

tfm-rubygem-hammer_cli_katello-0.10.0-1.el7sat.noarch

Comment 7 Andrew Kofink 2017-09-06 12:39:42 UTC
This change starts in tfm-rubygem-hammer_cli_katello-0.10.1

Comment 8 Brad Buckingham 2017-09-06 12:46:39 UTC
Thanks Andrew!

Adding 'fixed in version' based on comment 7.

Comment 10 Satellite Program 2018-02-21 16:54:37 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