Bug 1159974

Summary: RFE: Add a --pool-only option to the list subcommand
Product: Red Hat Enterprise Linux 7 Reporter: Alex Wood <awood>
Component: subscription-managerAssignee: Chris "Ceiu" Rog <crog>
Status: CLOSED ERRATA QA Contact: John Sefler <jsefler>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.1CC: crog, dlah, wpoteat
Target Milestone: rcKeywords: FutureFeature
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-03-05 13:16:04 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: 1005618    

Description Alex Wood 2014-11-03 18:48:51 UTC
This request is an extension of the RFE filed in bug 1146125.  Adding a --pool-only option to the list subcommand will allow users to easily attach to pools matching the string specified in --matches (without requiring an intermediate step using cut or awk)

For example:

$ subscription-manager list --matches "*Enterprise*" --pool-only
poolid123
poolid345
poolid567

This command can then be placed in a loop and the results sent to attach like

$ for pool in $(subscription-manager list --matches "*Enterprise*" --pool-only); do subscription-manager attach --pool $pool; done

Ideally, subscription-manager attach would also be altered to read from stdin when given a certain option so that the user could use a pipe instead of a loop.  For example:

$ subscription-manager list --matches "*Enterprise*" --pool-only | subscription-manager attach -

Comment 4 John Sefler 2014-11-26 22:15:12 UTC
Verifying Version...
[root@jsefler-os7 ~]# subscription-manager version
server type: Red Hat Subscription Management
subscription management server: 0.9.26.4-1
subscription management rules: 5.11
subscription-manager: 1.13.9-1.el7
python-rhsm: 1.13.8-1.el7


[root@jsefler-os7 ~]# subscription-manager list --help | grep -A3 "pool-only"  --pool-only           lists only the pool IDs for applicable available or
                        consumed subscriptions; only used with --available and
                        --consumed
[root@jsefler-os7 ~]# 
[root@jsefler-os7 ~]# subscription-manager list --available --pool-only
8a99f98146b4fa9d0146b5d3c0005253
8a99f98146b4fa9d0146b5d3bcea5152
8a99f98146b4fa9d0146b5d3bdf151c6
8a99f981498757d40149a5a9b04f4b00
8a99f98146b4fa9d0146b5d3bdd951b0
8a99f98146b4fa9d0146b5d3bed75227
8a99f9814931ea74014933dec2b60673
8a99f98146b4fa9d0146b5d3be3e51e0
8a99f98146b4fa9d0146b5d3be5951f8
[root@jsefler-os7 ~]# 
[root@jsefler-os7 ~]# subscription-manager attach --pool 8a99f98146b4fa9d0146b5d3be5951f8
Successfully attached a subscription for: Red Hat Enterprise Linux Workstation, Standard
[root@jsefler-os7 ~]# 
[root@jsefler-os7 ~]# subscription-manager list --consumed --pool-only
8a99f98146b4fa9d0146b5d3be5951f8
8a99f98146b4fa9d0146b5d3bf565237
[root@jsefler-os7 ~]# 
[root@jsefler-os7 ~]# subscription-manager list --installed --pool-only
Error: --pool-only is only applicable with --available and/or --consumed
[root@jsefler-os7 ~]# 

VERIFIED: The new --pool-only correctly lists only the pool ids that are available or consumed.




[root@jsefler-os7 ~]# subscription-manager attach --help | grep -A1 "file"
  --file=FILE           A file from which to read pool IDs. If a hyphen is
                        provided, pool IDs will be read from stdin.
[root@jsefler-os7 ~]# 
[root@jsefler-os7 ~]# subscription-manager list --available --pool-only > /tmp/pools
[root@jsefler-os7 ~]# subscription-manager attach --file=/tmp/pools
Successfully attached a subscription for: Red Hat Enterprise Linux Server, Premium (Physical or Virtual Nodes)
Successfully attached a subscription for: Red Hat Enterprise Linux for IBM POWER, Standard (4 sockets) (Up to 30 LPARs) with Smart Management
Successfully attached a subscription for: Red Hat Enterprise Linux Desktop, Self-support
Successfully attached a subscription for: Red Hat Enterprise Linux Server, Standard (Physical or Virtual Nodes)
Successfully attached a subscription for: Red Hat Enterprise Linux Server for HPC Compute Node, Self-support (8 sockets) (Up to 1 guest)
Successfully attached a subscription for: Red Hat Enterprise Linux Server for HPC Compute Node, Self-support (8 sockets) (Up to 1 guest)
Successfully attached a subscription for: Red Hat Enterprise Linux for Virtual Datacenters, Premium
Successfully attached a subscription for: Red Hat Enterprise Linux Desktop, Self-support
Successfully attached a subscription for: Red Hat Enterprise Linux Server, Premium (8 sockets) (Up to 4 guests)
[root@jsefler-os7 ~]# 

VERIFIED: The new subscription-manager attach --file option allows the attach module to process a list of pool ids from a file.




[root@jsefler-os7 ~]# subscription-manager remove --all
11 subscriptions removed at the server.
11 local certificates have been deleted.
[root@jsefler-os7 ~]# subscription-manager list --available --pool-only | subscription-manager attach --file -
Successfully attached a subscription for: Red Hat Enterprise Linux Server, Premium (Physical or Virtual Nodes)
Successfully attached a subscription for: Red Hat Enterprise Linux for IBM POWER, Standard (4 sockets) (Up to 30 LPARs) with Smart Management
Successfully attached a subscription for: Red Hat Enterprise Linux Desktop, Self-support
Successfully attached a subscription for: Red Hat Enterprise Linux Server, Standard (Physical or Virtual Nodes)
Successfully attached a subscription for: Red Hat Enterprise Linux Server for HPC Compute Node, Self-support (8 sockets) (Up to 1 guest)
Successfully attached a subscription for: Red Hat Enterprise Linux Server for HPC Compute Node, Self-support (8 sockets) (Up to 1 guest)
Successfully attached a subscription for: Red Hat Enterprise Linux for Virtual Datacenters, Premium
Successfully attached a subscription for: Red Hat Enterprise Linux Desktop, Self-support
Successfully attached a subscription for: Red Hat Enterprise Linux Server, Premium (8 sockets) (Up to 4 guests)
Successfully attached a subscription for: Red Hat Enterprise Linux for IBM Power, LE, Premium (IFL) (Up to 4 LPARs)
Successfully attached a subscription for: Red Hat Enterprise Linux Workstation, Standard
[root@jsefler-os7 ~]# 

VERIFIED: The new subscription-manager attach --file - option can also process pool ids from stdin piped from the output of subscription-manager list --available --pool-only

Comment 6 errata-xmlrpc 2015-03-05 13:16:04 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://rhn.redhat.com/errata/RHBA-2015-0502.html