Created
November 12, 2015 13:18
-
-
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
This file contains 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
# 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