Command line: Remove subscription from ESX host

Latest response

Is there a command line ability to remove Red Hat Subscriptions from ESX hosts (content hosts) through the command line? I can't find a way with hammer. I'd like to set up a script to automatically remove a subscription from a ESX host if there are no servers running on the ESX host.

Thanks for any feedback.

Responses

hammer can do this

hammer host subscription remove --help
Usage:
    hammer host subscription remove [OPTIONS]

Options:
 --host HOST_NAME                  Name to search by
 --host-id HOST_ID                  
 --quantity Quantity               Remove the first instance of a subscription with matching id and quantity
 --subscription-id SUBSCRIPTION_ID ID of subscription
 -h, --help                        print help

You didn't state which version of Satellite are you running. If my memory serves correctly, hammer host subscription remove may have been added in 6.2.2.

Is there any way to list subscriptions attached to a ESX hosts before dong the delete?

Thanks, Rich!

Is there any way to list subscriptions attached to a ESX hosts before dong the delete?

Get the ID of the host you are querying (# hammer host list) and then use that ID to query the subscriptions:

# hammer subscription list --host-id=<host_id>

Hi Rich,

The below command is not listing the complete subscriptions for "Red Hat Enterprise Linux for Virtual Datacenters with Smart Management, Standard". we have 41 virtual datacenter subscriptions for the ESX and in the Satellite UI, we see all are occupied but all the 41 are not getting listed in the command line.

hammer subscription list --organization OURORG

Moreover, we need to have an automated way to remove the subscription from an ESX having zero content hosts / less content hosts, so that the bootstrap can accommodate this subscription to the new VM(from diff ESX).

Using hammer, we are able to list UUID but not the ESX names, and it is tough to identify the Specific ESX using UUID in the satellite webUI.

We need some sorting mechanism for the listing the ESX and number of content hosts in that ESX (sorted) to easily take decision for removing the subscription of the ESX which is having less VMs/ zero VM's.

It may help if, in your virt-who configuration file, you use the option 'hypervisor_id=hostname'. This will use the received hostname from the ESXi host instead of the UUID.

'hammer subscription list' lists the subscriptions in the system and the UUID listed there is the UUID of the subscription itself. There is no information regarding the relationship of the subscription to hosts in that view. You would need to pass '--host-id' to that command to see which subscription was attached to it.

I'm trying to understand your use case for adding and removing subscriptions dynamically. Subscriptions should always be tied to virtualization (ESXi) hosts that can host Red Hat VMs. You have to subscribe every host that is capable (in a vSphere cluster) to host Red Hat VMs. You cannot relocate a subscription simply because a host doesn't currently have any virtual machines on it.

If you have ESXi hosts that are not part of a cluster that hosts Red Hat VMs then you should simply exclude them from being sync'd with virt-who. You can do this with the virt-who options 'exclude-hosts' or 'filter-hosts'.

We have similar situations where having a VDC subscription does not make sense. Sometimes we have ESX hosts that may only have a few guests on them. In that case it makes more sense to use individual subscriptions instead of burning a VDC sub. If virt-who would do the "correct" thing and if a host has no VMs or a configurable limit (like < 10 VMs) transfer a VDC sub over to it instead of defaulting to using up all of the individual subs. If I have a host that gets evacuated and I don't know about it and don't move the host VDC the VMs will get converted to individual subs and I've got to go remove all of them and auto-subscribe to get things back the way I want. It is a real pain to manage. While I know that if I had all of my hosts with VDC subscriptions this wouldn't be an issue that is not how we have chose to manage our subs. We are trying to be as efficient with our subscription usage as we possibly can.

Same problem for me. It is allocating virtual-who were there is no vmguest hosted to it. Really painful and hard to sort out. My environment has 81 ESXi host with Red Hat Guest and I have only 31 virtual-who , I am how to use it efficiently. There are virtual cluster in that virtual centre which host only one vmguest and for that virtual-who is assigned automatically . Any help or tips much appreciated.

Simple answer: VMware affinity rules. Just assign the VM to run on specific hosts and licence only them, from virt-who configuration you can blacklist the rest of the ESXi hosts. It's absolutely not needed to license the whole cluster.

You'd probably want to whitelist in lieu of blacklist. Also, newer versions of virt-who (0.18 and better) support using regular expressions for the filters.

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.