Using API to get all RH product labels

Hi all,

We’re running a RHS 6.2.13 and I’m in the process of moving all the RHEL7 machines that are connected to RH (customer portal and consuming content from RH CDN) to our RHS.

I’ve written an Ansible playbook to allow fast migration in bulk, and it’s worked well so far. One feature I want to build in to the pre-checks is that any Red Hat YUM repositories that are used by a machine prior to migrating also exist on the RHS. For example, “rhel-7-server-rpms”, “rhel-7-server-supplementary-rpms”, “rhel-7-server-rpms”, etc, etc.

So currently before migration I do a:

subscription-manager repos --list-enabled | awk ‘/Repo ID:/{print $3}’

and backup this, then once the machine has been registered to the RHS I then loop through that list and do a subscription-manager repos --enable= on each of them. Obviously if the YUM repo doesn’t exist on RHS it will fail.

I opened a ticket with RH, and they told me to get these I could query the pgsql db like so:

su - postgres -c “psql -d foreman -c ‘select name,cp_label from katello_repositories;’”

This is all good and well, but I’d much prefer an API call.

Does anyone know how I can get these exact fields that I need please? Quite a few guys on the IRC channel have kindly had a look, but between us we’ve not been able to find a real solution.

Any help or advice would really be appreciated, thanks in advance.


it seems like you were told to go to db, because API does not expose cp_label attribute for repositories. I filed an issue in Redmine and started working on a fix.


1 Like