Skip to content

Instantly share code, notes, and snippets.

@alces
Created November 12, 2015 13:18
Show Gist options
  • Save alces/45dda5d816fc999d4836 to your computer and use it in GitHub Desktop.
Save alces/45dda5d816fc999d4836 to your computer and use it in GitHub Desktop.
A function returning a list of hosts whose names matches to a given regexp from a spacewalk server
# Get a list of hosts whose names matches to a regexp from a spacewalk server
import re
import xmlrpclib
def find_hosts(rgx):
spw = xmlrpclib.Server('https://spacewalk.example.com/rpc/api', verbose = 0)
ky = spw.auth.login('admin', 'aVeryS3cretWord')
return [n.lower() for n in [h['name'] for h in spw.system.list_systems(ky)] if re.search(rgx, n)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment