<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
Created from redmine issue http://projects.theforeman.org/issues/9669
Upstream bug assigned to tomckay
Upstream bug component is Hammer
Will this feature be added to the UI in 'Host Collections|Bulk Actions|Subscriptions' once upstream hammer is sorted?
Sorry, correction on the location 'Content Hosts->Bulk Actions->Subscriptions'
Upstream bug assigned to paji
Moving to POST since upstream bug http://projects.theforeman.org/issues/9669 has been closed
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
Upstream bug component is Hammer - Content
Martin, Did you see any tracebacks in production.log for this? -Justin
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.
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.
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