Jacob_Peek Absent Member.
Absent Member.
3759 views

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!

Labels (1)
0 Likes
4 Replies
Jacob_Peek Absent Member.
Absent Member.

Re: Call a UNIX script in HPSA from HPOO flow

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.

0 Likes
Highlighted
Absent Member.. ntt00015 Absent Member..
Absent Member..

Re: Call a UNIX script in HPSA from HPOO flow

Hi,

 

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.

coreHost->Value: ${sa_coreHost}
coreUsername->Value: ${sa_coreUsername}
corePassword->Value:
corePort->Value: ${sa_corePort}
coreProtocol->Value: ${sa_coreProtocol}
coreVersion->Value:
scriptName->Value: scriptname_to_run_in_SAserver.ksh

 

outputs we need: Scriptname

 

2. Call "/Library/Integrations/Hewlett-Packard/Server Automation/Scripts/Start Server Script" operation to run the script in SA.

coreUsername->Value: ${sa_coreUsername}
corePassword->Value:
coreHost->Value: ${sa_coreHost}
corePort->Value: ${sa_corePort}
coreProtocol->Value: ${sa_coreProtocol}
coreVersion->Value:
scriptToRun->Result of previous step(scriptName)
targetHosts->Value: ${targetHostName}
targetHostSearchOperator->Value: EQUAL_TO
targetUser->Value:
targetPassword->Value:

 

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.

Best Regards.

 

0 Likes
Martyn Oram Valued Contributor.
Valued Contributor.

Re: Call a UNIX script in HPSA from HPOO flow

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!

0 Likes
Absent Member.. ntt00015 Absent Member..
Absent Member..

Re: Call a UNIX script in HPSA from HPOO flow

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..

#####script start#####
#!/opt/opsware/bin/python
# get_script_output.py
# Search for script JobOutput by jobId and serverId parameters.
import sys
sys.path.append("/opt/opsware/agent/pylibs")
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"
sys.exit(2)
searchCommand = sys.argv[0]
searchJobId = sys.argv[1]
searchServerId = sys.argv[2]
#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
try:
ts.authenticate('username','password')
except:
print "Authentication failed."
sys.exit(2)
#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)
print scriptOutput.getTailStdout()
#####script end#####

 

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.