Task example - Start bundle

This page provides a real-life example of a task which you can execute on devices running Bosch IoT Edge and have an installed Bosch IoT Edge Services.

The purpose of this task is to start an already installed software component on all devices, included in the scope, on which this component is not active at the time of the task execution.

To achieve the desired outcome, you need to execute the task's groovy action script in the context of device scope, which will target the relevant devices listed in a group with groupId: /My-Test-Devices. No specific execution options are required.

The groovy action script for this particular case is:

bundle = target.feature('Bundle:org.apache.commons.fileupload')
if (bundle.state != 'ACTIVE') {
bundle.start()
}

For the purpose of this task, we assume that the devices included in the scope have an installed Edge Services and software component - an Apache Commons Fileupload bundle. We also assume that this bundle is automatically represented by the system as a feature which has a state property and a start operation - as these elements are used in the task's groovy action script.

Once the task is launched, it will be executed in the following steps:

  1. The system will list all devices belonging to the group called My-Test-Devices.

  2. The action script will be executed on each device that was bound to the target variable.

  3. The script will get the bundle feature and will check whether it is active on each devices. If the bundle is not active on a particular device, the system will send a command to the device to start this bundle.