Skip to content

Instantly share code, notes, and snippets.

@discreet
Created September 29, 2014 14:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save discreet/8c4febb5589326c71462 to your computer and use it in GitHub Desktop.
Save discreet/8c4febb5589326c71462 to your computer and use it in GitHub Desktop.
Removes duplicate entries in Spacewalk
#!/usr/bin/python
import xmlrpclib,sys
import socket
SATELLITE_URL = "http://serverdnsname/rpc/api"
#User account to connect to satellite server
SATELLITE_LOGIN = "<user to delete account>"
#Password for above connection
SATELLITE_PASSWORD = "<password>"
#Accept an argument
SERVENAME = sys.argv
try:
client = xmlrpclib.Server(SATELLITE_URL, verbose=0)
key = client.auth.login(SATELLITE_LOGIN, SATELLITE_PASSWORD)
except socket.gaierror:
#print SATELLITE_URL + " does not exits."
sys.exit(2)
list = client.system.listUserSystems(key)
#Loop through list and return server name that's matched
for system in list:
#if the server name exists in the server then delete it
if system.get('name') in (SERVENAME):
#print "Found the server " + system.get('name')
#print "System ID is " + `system.get('id')`
#print "Deleting system from satellite server"
returncode = client.system.deleteSystems(key,system.get('id'))
#print returncode
client.auth.logout(key)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment