How to retrieve a list of hypervisors having valid subscriptions attached in Red Hat Satellite 6 ?

Solution Verified - Updated

Environment

  • Red Hat Satellite 6

Issue

  • Is there a way to collect the names of hypervisors and what subscriptions are attached to them in CSV format?

Resolution

  • In Red Hat Satellite 6.5 - 6.7, to extract the list of hypervisors, use hammer cli and limit the search query to look for only hypervisors as displayed below.

    # hammer csv content-hosts  --verbose --export --file hypervisor_list.csv --itemized-subscriptions  --search "hypervisor =  true"  --columns "Name,Organization,Subscription Name,Subscription Type,Subscription Quantity,Subscription SKU,Subscription Contract,Subscription Account,Subscription Start,Subscription End"
    
    # cat hypervisor_list.csv 
    Name,Organization,Subscription Name,Subscription Type,Subscription Quantity,Subscription SKU,Subscription Contract,Subscription Account,Subscription Start,Subscription End
    virt-who-esx1.example.com-1,Redhat,,,,,,,,
    virt-who-esx2.example.com-1,Redhat,RHEL VDC Standard,Red Hat,2,RH00007,1139XXX,54XXXX,04/26/2017,01/01/2022
    
  • An alternate and much quicker way of retrieving similar information and saving it to a CSV file is to use a database query as displayed below.

       # echo "COPY(select cpo.displayname as organization, cpch.hypervisor_id as Hypervisor, cpp.type,cp2p.product_id,cp2p.name \
         as subscription,cpe.quantity,ccf.element as cpu_socket from cp_consumer_hypervisor cpch left join cp_entitlement cpe on \
         cpch.consumer_id=cpe.consumer_id left join cp_pool cpp on cpp.id=cpe.pool_id left join cp2_products cp2p on \
         cp2p.uuid=cpp.product_uuid left join cp_consumer_facts ccf on cpch.consumer_id=ccf.cp_consumer_id left join cp_owner \
         cpo on cpo.id=cpch.owner_id where cp2p.product_id is not null and ccf.mapkey = 'cpu.cpu_socket(s)' \
         ORDER by cpch.hypervisor_id) TO STDOUT WITH CSV HEADER;" | su - postgres -c "psql candlepin" > hypervisor_list.csv
    
    
       # cat hypervisor_list.csv | column -t -s','
       organization  hypervisor        type    product_id  subscription       quantity  cpu_socket
       RedHat        esx1.example.com  NORMAL                                           2
       RedHat        esx2.example.com  NORMAL  RH00007     RHEL VDC Standard  2         2
    
  • The resulting csv files from either of the approaches, can be viewed by using any spreadsheet type application.

Note: The hammer csv content-hosts command is not available since Red Hat Satellite 6.8 and hence suggested to use the alternate approach as described above.

For more KB articles/solutions related to Virt-who and Virtual Datacenter (VDC) Subscriptions Issues, please refer to the Consolidated Troubleshooting Article for Virt-who and Virtual Datacenter (VDC) Subscriptions Issues

SBR
Product(s)
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.