Created
October 8, 2017 09:11
-
-
Save sideangleside/fa87c611c3218f1fb47e3c75f34ce236 to your computer and use it in GitHub Desktop.
Listing RHN Systems
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
#!/usr/bin/env python | |
import getpass | |
import sys | |
import xmlrpclib | |
from optparse import OptionParser | |
parser = OptionParser() | |
parser.add_option("-l", "--login", dest="login", help="Login user for satellite", metavar="LOGIN") | |
parser.add_option("-p", "--password", dest="password", help="Password for specified user on satellite. Will prompt if omitted", metavar="PASSWORD") | |
parser.add_option("-s", "--server", dest="serverfqdn", help="FQDN of satellite server - omit https://", metavar="SERVERFQDN") | |
(options, args) = parser.parse_args() | |
if not ( options.login and options.serverfqdn): | |
print "Must specify login, server options. See usage:" | |
parser.print_help() | |
sys.exit(1) | |
else: | |
login = options.login | |
password = options.password | |
serverfqdn = options.serverfqdn | |
if not password: password = getpass.getpass("%s's password:" % login) | |
SATELLITE_URL = "https://%s/rpc/api" % serverfqdn | |
SATELLITE_LOGIN = login | |
SATELLITE_PASSWORD = password | |
client = xmlrpclib.Server(SATELLITE_URL, verbose=0) | |
key = client.auth.login(SATELLITE_LOGIN, SATELLITE_PASSWORD) | |
servers = client.system.listUserSystems(key) | |
print 'Server ID , Server Name , Last Check-in' | |
for server in servers: | |
print str(server['id']) + ' , ' + server['name'] + ' , ' + str(server['last_checkin']) | |
client.auth.logout(key) | |
sys.exit(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment