Get the results from a job executed with run_from_satellite.py
Needs to be tested from import of old wiki
#!/usr/bin/python
#
# satellite_getScriptResults.py
#
# Get the results of command run with run_from_satellite.py using the execution ID(s) that it returns.
# using the rhel satellite api
#
#
# Author: Jean-Louis Girard
#
#----------------------------- Imports ---------------------------------------
import xmlrpclib
import sys
import socket
import os
#-------------------------- Global Varialbles --------------------------------
SATELLITE_URL = "http:///rpc/api"
SATELLITE_LOGIN = ""
SATELLITE_PASSWORD = ""
client = xmlrpclib.Server(SATELLITE_URL, verbose=0)
key = client.auth.login(SATELLITE_LOGIN, SATELLITE_PASSWORD)
#---------------------------- textColors -------------------------------------
class textColors:
normal = '\033[0m'
red = '\033[91m'
green = '\033[92m'
yellow = '\033[93m'
#------------------------- printResultForId ----------------------------------
def printResultForId(runID):
try:
result = client.system.getScriptResults(key, int(runID))
except:
print textColors.red + "execution ID " , runID , " does not exist." + textColors.normal
sys.exit()
try:
serverID = result[[0]][['serverId']]
except:
print textColors.yellow + "execution ID " , runID , " has not run yet." + textColors.normal
print textColors.yellow + "If the satellite server was just rebooted the osad service may need to be restarted on the client." + textColors.normal
sys.exit()
execOutput = result[[0]][['output']]
statusCode = result[[0]][['returnCode']]
queryName = client.system.getName(key, serverID)
serverName = queryName[['name']]
if statusCode == 0:
status=textColors.green + serverName + " " + "Successful" + textColors.normal
else:
status=textColors.red + serverName + " " + "FAILED" + textColors.normal
print status
print "======================================================================="
print execOutput
#--------------------------------- Main --------------------------------------
if __name__ == "__main__":
if len(sys.argv) < 2:
print " "
print textColors.red + sys.argv[[0]] + " " + textColors.normal
print " "
sys.exit()
for execID in sys.argv[[1:]]:
printResultForId(execID)
client.auth.logout(key)