Anyone already have a Satellite API script to download packages?

Latest response

I figured I'd post to ask before anyone goes off to reinvent the wheel here.

Does anyone already have a script in use that uses the Satellite API (namely packages.search and getPackage) to pull down rpms matching an expression?

I have a user agitating for the ability to pull some 3rd party (Puppet) rpms from the satellite en-mass so that he can dump to ISO for offline hosts.

Thanks!

Responses

I'm not sure whether it contains what you're looking for, Kodiak, but this might be a good time to bump the Satellite API solutions thread we had going a while back: https://access.redhat.com/site/discussions/683433

Hey Kodiak,
Do you have a separate channel for Puppet, or do you integrate the packages in with another channel?
When you pull the Puppet packages, do you do a reposync, or manage it directly from Satellite?

Hi James,

I guess I was more looking for something agnostic and not necessarily just for like say, the Puppet child channels which are repo-sync'd from repo.puppetlabs.com.

Basically there are some minor outlying networks that don't have internet/intranet access and might need off-line dumps of various RPMs - but not something which is big enough to warrant an offline satellite or even an offline yum repo.

I've started working on a Python script which leverages the xmlrpc / API parts of satellite and am going to play around with the package.findByNvrea and package.getPackage methods.

The goal of that will be to feed the script strings like 'puppet' or 'nagios-plugins*' and have it return a dump of rpm files to the dir I run the script from. I don't know if this is feasable and I can only work on it in my spare time so it'll go pretty slow.

Ah... I misunderstood what you were asking for. And your goal sounds completely reasonable and actually a good idea. For an entire stack, like Puppet, I could see this being possible. However, to pull a subset of packages out of an existing tree, that would seem a lot more challenging. I have a better idea of what you are trying to accomplish now.

I wonder how yum handles a request like
yum list includepkgs=puppet* exclude=all

Even though I cannot really help you (I'm not very good with API-type stuff ;-) I wonder if you could look at the following (and figure out what spacecmd actually does behind the scenes).

[root@rhnsat01 ~]# spacecmd "package_search puppet"
INFO: Connected to https://localhost/rpc/api as satadmin
puppet-2.6.18-3.el5.noarch
puppet-2.7.23-1.el6.noarch
puppet-server-2.6.18-3.el5.noarch
puppet-server-2.7.23-1.el6.noarch
rubygem-puppet-lint-0.3.2-1.el6.noarch
rubygem-puppet-lint-doc-0.3.2-1.el6.noarch

Hello Kodiak,

Do not have ready script to achieve your goal but as you want to search packages based on strings like - 'puppet' or 'nagios-plugins*' , instead of package.findByNvrea API other API " packages.search.name " might help you to list packages as per your search string. Because for package.findByNvrea API you need to pass exact package version details which may not be posible for you every time.

You can get package ID of specific package from output of packages.search.name API and pass it to " package.getPackage " API.

Regards,
Ashish

Close

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