Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm trying to generate a list of all the packages installed per server without having to go through each using rpm. I'm thinking Satellite should be able to provide this in a decent (hopefully easily parsed) format.

share|improve this question

2 Answers 2

Short answer: yes.

Longer answer: you'll need to look in to to the Satellite API. The documentation available with Satellite is good for a very basic query, but you'll quickly get in to queries that (IMHO) aren't as well documented. At a high level, what you'll end up doing is querying Satellite for a list of all registered systems, then using that list to issue queries for all installed packages on each system. Ultimately, this will only be valid as of the last time each system updated its package profile on the Satellite, but it'll be more central than trolling each individual system via an RPM query.

Here's the code I use (sanitized, of course) to list the systems registered to my Satellite:

#!/usr/bin/python
import xmlrpclib

SAT_URL = "https://<satellite hostname>/rpc/api"
SAT_USER = "<satellite user name>"
SAT_PASS = "<password for above login id>"

client = xmlrpclib.Server(SAT_URL, verbose=0)
key = client.auth.login(SAT_USER, SAT_PASS)

syslist = client.system.listSystems(key)

The syslist variable is them a simple Python list of system objects - I've not yet had need to unzip it any further than:

for sys in syslist:
  print "%s registered with Satellite" % (sys['name'],)
share|improve this answer
    
Ok this is working. Looks like I'll need to dig into it some more but this is a really good start. Thanks. I'll see where I get and update. –  Mark Jul 2 '13 at 12:52
    
I extended your script and posted the script as a solution. I'm not sure if that's the proper etiquette. –  Mark Jul 2 '13 at 13:56

Here's a final script which extends John's answer to provide a full solution.

#!/usr/bin/python
import xmlrpclib

SAT_URL = "https://<SATELLITE_IP>/rpc/api"
SAT_USER = "<USERNAME>"
SAT_PASS = "<PASSWORD>"

client = xmlrpclib.Server(SAT_URL, verbose=0)
key = client.auth.login(SAT_USER, SAT_PASS)

syslist = client.system.listSystems(key)
systems = {}
for system in syslist:
    systems[system['name']] = client.system.listPackages(key, system['id'])

# Print out list in a Markdown-like format.
for system in sorted(systems.keys()):
    print '%s' % system
    print '=' * len(system)
    for package in systems[system]:
        print '- %s %s' % (package['name'], package['version'])
    print
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.