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

Python RHN Fun: Cleaning the Satellite

Here’s a little script to delete any systems from your database that haven’t checked in for more than 90 days.

# Removes systems not checking in within the last 90 days

import xmlrpclib
import getpass
import datetime


TARGET_ENTITLEMENT = ['monitoring_entitled']

if __name__ == "__main__":
    client = xmlrpclib.Server(SATELLITE_URL, verbose=0)
    SATELLITE_LOGIN = str(raw_input("RHN Userid: ")).rstrip()
    SATELLITE_PASSWORD = getpass.getpass()

    key = client.auth.login(SATELLITE_LOGIN, SATELLITE_PASSWORD)
    result_array = client.system.listInactiveSystems(key,90)
    id_array = [profile['id'] for profile in result_array]
    client.system.deleteSystems(key, id_array)

Tags: , ,

Comments are closed.