Executing Python Scripts on RHEL Server (411 Views)
Reply
Occasional Visitor
Posts: 1
Registered: ‎02-27-2014
Message 1 of 5 (411 Views)

Executing Python Scripts on RHEL Server

Hello all.  I'm a newbie to both SA and RHEL, so I apologize if this is a dumb question.  I'm having trouble getting a really simple python script to execute from SA on a RHEL server.  I have verified that the script works properly by running it manually locally on the server, but when I add it to SA and try to run it against a server, nothing happens.  I get no error, and no output.  Is there something really simple that I'm missing other than simply copying and pasting the script into the script contents pane when adding a server script?  If anyone has any advice or feedback, please advise.  Thanks for your help!

Frequent Visitor
Posts: 1
Registered: ‎10-04-2011
Message 2 of 5 (316 Views)

Re: Executing Python Scripts on RHEL Server

hi

did you fixed the problem? i got same issue

Occasional Advisor
Posts: 14
Registered: ‎09-17-2014
Message 3 of 5 (131 Views)

Re: Executing Python Scripts on RHEL Server

Please tell me you found a solution, because I just ran into the same issue. I've got a painfully simple Python script that I wrote, just to see if I can get it to work, but when I try executing it does nothing. It generates a job ID, but that job ID doesn't show up anywhere. It emails me that it finishes, but it says it ran against 0 servers. We're also running RHEL and we have HPSA 10.1. Any help would be appreciated.

 

By the way, here's my script:

 

import sys
from pytwist import *

 

print "This is a test"

Occasional Advisor
Posts: 14
Registered: ‎09-17-2014
Message 4 of 5 (99 Views)

Re: Executing Python Scripts on RHEL Server

I just wanted to update everyone, I did find a solution. It turns out, after contacting support, that the Python script type actually does not work.

 

In order to execute a Python script, you instead should choose to make it a Server Script and include the proper flag at the beginning of the script:

#!/opt/opsware/agent/bin/python

 

For example, the simple script from my last post would look like this:

#!/opt/opsware/agent/bin/python

import sys
from pytwist import *

 

print "This is a test"

 

Also, a quick note on the pyTwist API...

If you're expecting it to look and function like its Java implementation, you'll be pleasantly surprised. On the other hand, if you're an experienced python developer, it has some quirks that might make you sad. For example, it uses the old object model, so you can't determine the type of objects by using the standard type(instance).__name__ method, you'll end up using instance.__class__.__name__. A minor detail, but still somewhat annoying from time to time. You might also be annoyed that it feels like you're working with java objects, which you are, so, there's that.

Occasional Advisor
Posts: 18
Registered: ‎12-19-2013
Message 5 of 5 (84 Views)

Re: Executing Python Scripts on RHEL Server

You might also be annoyed that it feels like you're working with java objects, which you are, so, there's that.

 

Heh.

The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.