RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1159974 - RFE: Add a --pool-only option to the list subcommand
Summary: RFE: Add a --pool-only option to the list subcommand
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: subscription-manager
Version: 7.1
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Chris "Ceiu" Rog
QA Contact: John Sefler
URL:
Whiteboard:
Depends On:
Blocks: rhsm-rhel71
TreeView+ depends on / blocked
 
Reported: 2014-11-03 18:48 UTC by Alex Wood
Modified: 2015-03-05 13:16 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Enhancement
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-03-05 13:16:04 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2015:0502 0 normal SHIPPED_LIVE subscription-manager bug fix and enhancement update 2015-03-05 16:20:39 UTC

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


Note You need to log in before you can comment on or make changes to this bug.