Created
September 29, 2014 14:35
-
-
Save discreet/8c4febb5589326c71462 to your computer and use it in GitHub Desktop.
Removes duplicate entries in Spacewalk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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