Here’s a short python code to load up the local yum database, grab the list of yum groups, and print installed and available groups by short names (which can be used in kickstart scripts more easily than the output of yum grouplist.)
#!/usr/bin/env python import yum import sys if __name__ == "__main__": yb = yum.YumBase() yb.doConfigSetup() yb.doTsSetup() yb.doRpmDBSetup() # Grab Group List (gl) gl=yb.doGroupLists() # First index of gl is Installed Group List (igl) igl=gl[0] # Second index of gl is Available Group List (agl) agl=gl[1] # Print a kickstartable group list print "Installed groups:\n" for grp in igl: print "@" + grp.groupid + ": '" + grp.name + "'" print "Available groups:\n" for grp in agl: print "@" + grp.groupid + ": '" + grp.name + "'"
Thanks to the for publishing a great starting point to yum python programming.
Tags: python, red hat network satellite, sysadmin, yum