How to call pyton or bash code


#1

HI,
I am try to automate our OpenStack cluster via MQ and we are pretty far, some were in our steps I would like to call some python or bash script (on local disk), how can I do this?
Can you point me information or examples?

Kind Regards


#2

@hakan

If you are already using Automate then you can use the standard Ruby mechanisms for executing other code. The simple example below is using backticks, but you can find more info in this Stack Overflow post http://stackoverflow.com/questions/2232/calling-shell-commands-from-ruby.

As with any type of code execution, especially as root, remember to be careful of any input you accept so you do not compromise the security of the system.

Example Automate Method

hostname = `hostname | tr -d '\n'`
username = `whoami | tr -d '\n'`

$evm.log(:info, "This command is running on #{hostname} as #{username}.")

exit MIQ_OK