Call a UNIX script in HPSA from HPOO flow
I have been searching around for a good solution to call SA scripts from an OO flow, I have been using roch to make my calls directly from the OO flow but would like to fully integrate with HPSA to call those scripts already defined in SA. In the flow I have these variables but I am not getting any results. Is there a good doc on integrating or creating this flow? Variables I am using:
ScriptName false Single Value Value: /Package Repository/Unix Managed Services/scripts/test_OO_flow ScriptName->Value: /Package Repository/Unix Managed Services/scripts/test_OO_flow ServerName false Single Value Value: **** ServerName->Value: **** SAHostname false Single Value Value: **** SAHostname->Value: **** SAUsername false Credentials From System Account: **** SAUsername->From System Account: **** SAPassword false Credentials From System Account: ****
SAPassword->From System Account: ****
I appologize in advance for the ugly paste above, any help on the topic would be apprecieted!
Well after a day of poking around apparently HPSA hooks into OO and creates numerous default flows (quite nice), all the default flows are under integrations and Hewlett-Packard. Now onto the next question. How can I query the a scripts details and tag it to an email. I havnt seen any default flow to do this, plenty to email the jobID but nothing else.
What is your OO and SA versions?
For example we are using OO v9.04 and SA v9.11 and we can run a flow for running scripts in SA. You have to install SA content packs (including OO-SAS-9_00-07) to OO.
In the flow,
1. Call "/Library/Integrations/Hewlett-Packard/Server Automation/Scripts/Get Server Scripts" operation to get ScriptName parameter to check if script exists.
outputs we need: Scriptname
2. Call "/Library/Integrations/Hewlett-Packard/Server Automation/Scripts/Start Server Script" operation to run the script in SA.
scriptToRun->Result of previous step(scriptName)
outputs we need: jobId(id), jobStatus(status)
3. Call "/Library/Integrations/Hewlett-Packard/Server Automation/Jobs/Wait for Job" or "/Library/Integrations/Hewlett-Packard/Server Automation/Jobs/Get Job Info VO" operation if the SA job is finished. To check the job Status with the jobId parameter.
4. If you want to get the script output of SA script from OO you have use python script to print the outputs in SA. You can use the SA jobId to get the output. Check the document "SA development kit guide" for getting outputs from out of SA via scripting. For OO v9.04 we could not get the SA output with a builtin operation(we achieved the output with a python script), maybe it is possible with further versions.
I hope it will help.
Hello. I wonder if you can give more details on your last point (#4) - I would like to have OO call an SA script (which I can do), but I'm not sure exactly how I would get the details of the HPSA job back into OO, so the user who initiated the OO flow can see the results of the SA job.
Any assistance would be appreciated, thanks!
We run the script on our RAS machine. To be able to run the script, SA agent has to be installed on the RAS.
Here is my script. Edit as your own...Do not forget to change "ts.authenticate('username','password')" line with your credentials.
The script is printing out JobId output.
Read the SA development guide for function details..
# Search for script JobOutput by jobId and serverId parameters.
from pytwist import *
from pytwist.com.opsware.script import ScriptJobOutput
from pytwist.com.opsware.job import JobRef
from pytwist.com.opsware.server import ServerRef
# Check for the command-line argument.
if len(sys.argv) != 3:
print 'You must specify JobId and ServerId.'
print "Example: " + "python get_script_output.py" + " " + "JobId" + " " + "ServerId"
searchCommand = sys.argv
searchJobId = sys.argv
searchServerId = sys.argv
#print "User parameters: "
#print "Command: "+ searchCommand
#print "JobId: "+ searchJobId
#print "ServerId: "+ searchServerId
# Create a TwistServer object.
ts = twistserver.TwistServer()
# Authenticate by passing an SA username and password
print "Authentication failed."
#Get the references to the services used by the script
scriptJobRef = JobRef(searchJobId)
scriptServerRef = ServerRef(searchServerId)
serverScriptService = ts.script.ServerScriptService
scriptOutput = ScriptJobOutput()
scriptOutput = serverScriptService.getServerScriptJobOutput(scriptJobRef, scriptServerRef)