Subscription manager list outputs - command subscription-manager list

This module provides parsers for various list outputs of subscription-manager.

Parsers provided by this module are:

SubscriptionManagerListConsumed - command subscription-manager list --consumed

SubscriptionManagerListInstalled - command subscription-manager list --installed

class insights.parsers.subscription_manager_list.SubscriptionManagerList(context, extra_bad_lines=None)[source]

Bases: CommandParser

A general object for parsing the output of subscription-manager list. This should be subclassed to read the specific output - e.g. --consumed or --installed.

records

A list of dict with the output info, it’s empty when the error occurs

Type:

list

error

The raised exception when there is traceback

Type:

str

parse_content(content)[source]

This method must be implemented by classes based on this class.

search(*args, **kwargs)[source]

Search for records that match the given keys and values. See the insights.parsers.keyword_search() function for more details on usage.

Parameters:

**kwargs -- Key-value pairs of search parameters.

Returns:

A list of records that matched the search criteria.

Return type:

(list)

Examples

>>> len(consumed.search(Service_Level='PREMIUM'))
1
>>> consumed.search(Provides__contains='Red Hat Enterprise Virtualization')
[]
class insights.parsers.subscription_manager_list.SubscriptionManagerListConsumed(context, extra_bad_lines=None)[source]

Bases: SubscriptionManagerList

Read the output of subscription-manager list --consumed.

Sample input file:

+-------------------------------------------+
   Consumed Subscriptions
+-------------------------------------------+
Subscription Name: Red Hat Enterprise Linux Server, Premium (1-2 sockets) (Up to 1 guest)
Provides:          Oracle Java (for RHEL Server)
                   Red Hat Software Collections Beta (for RHEL Server)
                   Red Hat Enterprise Linux Server
                   Red Hat Beta
SKU:               RH0155783S
Contract:          12345678
Account:           1000001
Serial:            0102030405060708090
Pool ID:           8a85f981477e5284014783abaf5d4dcd
Active:            True
Quantity Used:     1
Service Level:     PREMIUM
Service Type:      L1-L3
Status Details:    Subscription is current
Subscription Type: Standard
Starts:            11/14/14
Ends:              07/06/15
System Type:       Physical

Examples

>>> type(consumed)
<class 'insights.parsers.subscription_manager_list.SubscriptionManagerListConsumed'>
>>> len(consumed.records)
1
>>> sub1 = consumed.records[0]
>>> sub1['SKU']
'RH0155783S'
>>> sub1['Active']  # Type conversion on Active field
True
>>> sub1['Status Details']  # Keys appear as given
'Subscription is current'
>>> sub1['Provides'][1]
'Red Hat Software Collections Beta (for RHEL Server)'
>>> sub1['Starts']  # Basic field as text - note month/day/year
'11/14/14'
>>> sub1['Starts timestamp'].year
2014
>>> consumed.all_current  # Are all subscriptions listed as current?
True
property all_current

(bool) Does every subscription record have the Status Details value set to ‘Subscription is current’?

class insights.parsers.subscription_manager_list.SubscriptionManagerListInstalled(context, extra_bad_lines=None)[source]

Bases: SubscriptionManagerList

Read the output of subscription-manager list --installed.

Sample input file:

+-------------------------------------------+
Installed Product Status
+-------------------------------------------+
Product Name:   Red Hat Software Collections (for RHEL Server)
Product ID:     201
Version:        2
Arch:           x86_64
Status:         Subscribed
Status Details:
Starts:         04/27/15
Ends:           04/27/16

Product Name:   Red Hat Enterprise Linux Server
Product ID:     69
Version:        7.1
Arch:           x86_64
Status:         Subscribed
Status Details:
Starts:         04/27/15
Ends:           04/27/16

Examples

>>> type(installed)
<class 'insights.parsers.subscription_manager_list.SubscriptionManagerListInstalled'>
>>> len(installed.records)
2
>>> prod1 = installed.records[0]
>>> prod1['Product ID']  # Note - not converted to number
'201'
>>> prod1['Starts']  # String date as is
'04/27/15'
>>> prod1['Starts timestamp'].year  # Extra converted to date
2015
>>> installed.all_subscribed
True
property all_subscribed

(bool) Does every product record have the Status value set to ‘Subscribed’?