Rice University logo
Top blue bar image
A place to post stuff

Python Yum Fun 1: Kickstartable Grouplist

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()
    # Grab Group List (gl)
    # First index of gl is Installed Group List (igl)
    # Second index of gl is Available Group List (agl)
    # 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: , , ,

Comments are closed.