Bug 1121768

Summary: [RFE] Subscription Manager should provide a command to search for [and attach] a subscription that provides a specific [Engineering] product.
Product: Red Hat Enterprise Linux 7 Reporter: Rich Jerrido <rjerrido>
Component: subscription-managerAssignee: candlepin-bugs
Status: CLOSED DUPLICATE QA Contact: John Sefler <jsefler>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.0CC: dgoodwin, jhutar, jshubin, mdavis, sgraf
Target Milestone: rcKeywords: FutureFeature
Target Release: 7.1   
Hardware: Unspecified   
OS: Unspecified   
Fixed In Version: Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-10-17 13:28:25 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:
Bug Depends On:    
Bug Blocks: 1005618    

Description Rich Jerrido 2014-07-21 20:15:01 UTC
Description of problem:

When listing/attaching subscriptions to a server, an end user would like the ability to search for a subscription that provides a specific product. This gives the ability to quickly search through large numbers of subscriptions. grep doesn't work too well for this. Additionally, the user would like to influence the auto-attach process so that they can say 'auto attach a sub that product $X'

This would make it easier to write documentation, as well as allowing users to filter the output of 'subscription-manager list' to match a specific product. 

[Proposed] Example:
[root@satellite ~]# subscription-manager list --provides 'Red Hat Software Collections (for RHEL Server)'

Would show all subscriptions that provide the 'Red Hat Software Collections (for RHEL Server)' product. 

[Proposed] Example #2:
[root@satellite ~]# subscription-manager attach --auto --provides 'Red Hat Software Collections (for RHEL Server)'

Would attach an appropriate subscription that provides the 'Red Hat Software Collections (for RHEL Server)' product.

Comment 2 Matthew Davis 2014-07-21 20:43:06 UTC
Please make this a globbing capable feature. So the following should work too:

# subscription-manager attach --auto --provides *Collecitons*
# subscription-manager attach --auto --provides "*Red Hat Software Collecitons*"

Comment 3 Bryan Kearney 2014-07-30 19:23:36 UTC
Acking 7.1

Comment 4 John Sefler 2014-10-02 14:20:59 UTC
(In reply to Rich Jerrido from comment #0)
> [Proposed] Example #2:
> [root@satellite ~]# subscription-manager attach --auto --provides 'Red Hat Software Collections (for RHEL Server)'
> Would attach an appropriate subscription that provides the 'Red Hat Software Collections (for RHEL Server)' product.

In my opinion it is wrong to include the "--auto" option in the syntax of this proposed example.  The meaning of "--auto" is to attach subscriptions that provide a product that is already installed on your system.  In this example, the 'Red Hat Software Collections (for RHEL Server)' is not already installed on the system and therefore the attach --auto request will do nothing.  Instead, the syntax of this example should be simplified to...

[root@satellite ~]# subscription-manager attach --provides 'Red Hat Software Collections (for RHEL Server)'

Note: Since multiple available subscription pools may provide 'Red Hat Software Collections (for RHEL Server)', the attachment should minimally match the service level (if set on the consumer) and attach from the first pool found that provides 'Red Hat Software Collections (for RHEL Server)'

Note: If using wildcards in this example, you may not get what you want when there are multiple pool candidates.

Comment 5 Rich Jerrido 2014-10-02 16:43:46 UTC
re: the usage of '--auto'. I may have overloaded the term a bit.

The use case that I am thinking of is less about attaching to subscription to an existing product, but more of 'I know I need RHSCL, I currently don't have it and I don't really care which pool provides it, as long as it matches (based on facts, SLA preference, etc)'. So the latter part would happen 'automatically', though it is not, in fact, 'auto-attach'. That was my (overloaded) usage of '--auto', and I'll refrain from that usage.

Comment 6 Devan Goodwin 2014-10-17 13:28:25 UTC
Solution for bug #1146125, which will be a new --matches option in the subscription-manager list command, will search for pools matching a given globbing pattern (* and ? supported) in a variety of fields, including provided product names as well as their engineering product IDs. 

I'm going to propose this be closed as a duplicate as I'm afraid "subscription-manager attach --auto --matches "*Collections*" would be confusing.

Firstly today, subscription-manager attach --auto will search out subscriptions matching your currently installed products and automatically attach them for you. The "healing" feature runs the same code and is enabled by default, thus it's safe to assume that if what you wanted with this example were already provided by an installed product, you wouldn't need to be searching for subscriptions.

I think the use case intended is "I don't have an installed product for this, I want to search for pools which provide something new and automatically install them." But where would this CLI option go? We probably shouldn't overload "attach  --auto" in this manner to mean something completely different if --matches is added.

Additionally if we did find a place to put it, we now have to start thinking about what happens if you get multiple matches. We'd have to make assumptions about what you intended and which to use, and what happens if stacking is involved or partially involved. 

Overall adding this to auto would almost certainly result in a lot of unpredictable or unexpected behavior. As such we're proposing to close this and see how we make out with --matches for now.

Rich if you feel strongly against please feel free to re-open.

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