cancel
Showing results for 
Search instead for 
Did you mean: 

How to stop all cf applications in a space with Automation Pilot?

karstenvoigt
Participant
0 Kudos

Hi there,

I'd like to stop all CF application in a CF space using the automation pilot. I tried to create a command that reads all apps (ListCfApps) and then stop all apps using the ForEach command (execute command TriggerStopCfApp in a loop). The list command creates an output array with all resourceNames like:

["App1", "App2", "App3"]

Using this output as input for the inputs parameter of the ForEach will cause an error:

The value of 'inputs' in ForEach executor is not a valid array of objects:

<["App1","App2","App3"]>

Any ideas how to solve that issue?

Does anyone know a good automation pilot tutorial with detailed examples? I tried to solve the issue using script execution, but this wasn't successful.

Thanks.

Accepted Solutions (0)

Answers (1)

Answers (1)

kostadin_karpachev
Discoverer

Hello Karsten,

Basically the input parameters for the ForEach command are as follows:

1. command - the command to be run by ForEach multiple times.

Example: "applm-sapcp:RestartCfApp:1"

2. inputs - is an array of json objects that holds the keys for the command, that will change with every run of the command. The number of objects in the array denotes the number of repetitions of the ForEach command.

Example: [ { "rollingRestart": false }, {"rollingRestart": true, "useAdditionalInstance": false, "refreshToken": "$(.execution.input.refreshToken)" }, { "rollingRestart": true, "useAdditionalInstance": true} ]

3. defaultValues - is a json object that should hold the keys for the command, that are repeated for every run of the command.

Example: { "region": "cf-eu10", "resourceGroup": "$(.execution.input.resourceGroup)", "resourceName": "$(.execution.input.resourceName)", "subAccount": "$(.execution.input.subAccount)", "password": "$(.execution.input.password)", "user": "$(.execution.input.user)" }

For both 2 and 3:

Note that the keys must be named the same way as are in the command, e.g. for applm-sapcp:RestartCfApp:1 command input key is named "region".

Note that sensitive values like password should be passed as expressions, e.g. $(.execution.input.password)

Note that the fields can also be an expression that at the end evaluates to a valid json array or object, e.g. $(.myCommand.output.body | toArray) and $(.myCommand.output.body | toObject)

You can find additional information from the SAP Automation Pilot documentation here: https://help.sap.com/docs/AUTOMATION_PILOT/de3900c419f5492a8802274c17e07049/0ba2fd92b4c8433aa3fe93a8...

Also, the CompositeCommandExample from the Welcome catalog has an example of the ForEach command.

Kind regards,

Kostadin