Bug 1199515

Summary: need way to attach a subscription to a content host w/ hammer
Product: Red Hat Satellite Reporter: Tom McKay <tomckay>
Component: Hammer - ContentAssignee: Partha Aji <paji>
Status: CLOSED ERRATA QA Contact: Martin Korbel <mkorbel>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.2.0CC: akofink, bkearney, cwelton, dataylor, dlezzoum, egolov, jean-pierre.pitout, jsherril, mkorbel, mlele, mtenheuv, rjerrido, tstrachota
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
URL: http://projects.theforeman.org/issues/9669
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1366437 (view as bug list) Environment:
Last Closed: 2018-02-21 16:54:37 UTC Type: ---
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: 1366437    

Description Tom McKay 2015-03-06 14:31:38 UTC
<pre>
hammer subscription attach --content-host-id $id --subscription-id $id

-or-

hammer content-host subscription --attach --subscription-id $id
</pre>

Although subscriptions are normally added to content hosts by running subscription-manager directly on the host itself, there are cases where being able to do it via scripting w/ hammer is better.

This would move towards parity between hammer and the UI

Comment 1 Tom McKay 2015-03-06 14:31:39 UTC
Created from redmine issue http://projects.theforeman.org/issues/9669

Comment 3 Bryan Kearney 2015-08-14 17:00:58 UTC
Upstream bug assigned to tomckay

Comment 4 Bryan Kearney 2015-08-14 17:01:00 UTC
Upstream bug assigned to tomckay

Comment 5 Bryan Kearney 2015-08-25 18:34:14 UTC
Upstream bug component is Hammer

Comment 7 jean-pierre.pitout 2016-05-20 13:00:08 UTC
Will this feature be added to the UI in 'Host Collections|Bulk Actions|Subscriptions' once upstream hammer is sorted?

Comment 8 jean-pierre.pitout 2016-05-20 13:04:50 UTC
Sorry, correction on the location 'Content Hosts->Bulk Actions->Subscriptions'

Comment 9 Bryan Kearney 2016-08-06 00:06:10 UTC
Upstream bug assigned to paji

Comment 10 Bryan Kearney 2016-08-06 00:06:14 UTC
Upstream bug assigned to paji

Comment 12 Bryan Kearney 2016-08-10 14:06:43 UTC
Moving to POST since upstream bug http://projects.theforeman.org/issues/9669 has been closed

Comment 15 Martin Korbel 2016-10-19 12:29:09 UTC
FAILQA on tfm-rubygem-hammer_cli-0.8.0-1

These commands return error:

> hammer host subscription attach --host hostname.redhat.com --subscription-id 1
Failed to attach subscriptions to the host:
  Task 98c9592e-9cee-46e2-af87-f9e49a416ef4: NoMethodError: undefined method `[]' for nil:NilClass
> hammer host subscription attach --host-id 2 --subscription-id 1
Failed to attach subscriptions to the host:
  Task a90acd79-8792-4507-8d5a-49928d8b5bf2: NoMethodError: undefined method `[]' for nil:NilClass

When we try to remove subscription via WebUI, we get this error message. Maybe it is the same problem.

An error occurred removing the subscriptions.Task 86ec0287-8d8b-43e5-a3ff-aff3c4844195: NoMethodError: undefined method `[]' for nil:NilClass


DOC:
In help, there are missing description for "remove" subcommand.

> hammer host subscription --help
Usage:
    hammer host subscription [OPTIONS] SUBCOMMAND [ARG] ...

Parameters:
 SUBCOMMAND                    subcommand
 [ARG] ...                     subcommand arguments

Subcommands:
 attach                        Add a subscription to a host
 auto-attach                   Trigger an auto-attach of subscriptions
 register                      Register a host with subscription and information.
 remove                         
 unregister                    Unregister the host as a subscription consumer

Options:
 -h, --help                    print help




I think, we should have a method for getting of current subscription for host.
Information, which we can see in host-info are insufficient.

> hammer host info --id 2
...
 Subscription Information: 
    UUID:            a861796e-1e17-4a83-9a17-e60b1ae1ed9e
    Last Checkin:    2016-10-19 11:59:38 UTC
    Service Level:   
    Release Version: 
    Autoheal:        true
    Registered At:   2016-10-19 11:59:39 UTC

Comment 16 Bryan Kearney 2016-10-19 14:09:28 UTC
Upstream bug component is Hammer - Content

Comment 17 Justin Sherrill 2016-12-01 16:24:56 UTC
Martin,

Did you see any tracebacks in production.log for this?

-Justin

Comment 18 David Taylor 2017-04-19 16:43:10 UTC
I'm interested in this fix/feature.  Based upon comment 15:

>DOC:
>In help, there are missing description for "remove" subcommand.

In the upstream github pull request that implements this feature https://github.com/Katello/hammer-cli-katello/pull/437 , a comment by the author says it requires another change (one change for host_subscriptions_controller.rb puts in the remove help message):  https://github.com/Katello/katello/pull/6233

The files added/changed in the closed foreman bug http://projects.theforeman.org/projects/katello/repository/hammer-cli-katello/revisions/14c967686b5ef466cd9f30f180cacd7db56507a5

did not include the modified host_subscriptions_controller.rb file.

I'm not sure if this was addressed already, or even helpful as I haven't tested anything.

Comment 19 Martin Korbel 2018-01-11 13:32:45 UTC
Verified on tfm-rubygem-hammer_cli-0.11.0.1-1

The problem with error is gone.
As was mentioned above, the description for "remove" is still missing.

Comment 20 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