Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Panel

Table of Contents
maxLevel3

Introduction

Dynamic Commands allow you to add supporting functionality to a task instance.  In this chapter, we will enhance the ue-task Extension developed in the previous chapters by adding a Dynamic Command.  The command we create will reset the task instance - to prepare it for a rerun scenario.

...

  1. Add Dynamic Command to the "UE Task" Universal Template.
  2. Add a backing implementation for Dynamic Command to the extension.py file in the ue-task Extension project.
  3. Rebuild and upload the modified Extension.
  4. Execute the Dynamic Command

Step 1 - Add a Dynamic Command to the "UE Task" Universal Template

Go back to the "UE Task" Universal Template form.  

...

Note that the “Supported Status(es)” is set to: In Doubt, Cancelled, Failed, Finished, and Success.  These are the task instance statuses where the command will be available for execution.  For all other statuses the command will be greyed out.

Save the command.

Step 2 - Add Backing Implementation for Dynamic Command to extension.py

Open file ~/dev/extensions/sample-task/src/extension.py in your editor of choice.

...

Note
titleNote

The value supplied to the dynamic_command decorator must match the command Name of the associated Dynamic Command defined in the Controller's Universal Template (for example, @dynamic_command("reset_environment")).

Step 3 - Build and Upload the Extension Zip Archive Using the UIP VS Code Extension

Save all changes to extension.py.

...

Expand
titleClick here to expand uip-cli details...

Step 3 Supplemental - Build and Upload the Extension Zip Archive Using the CLI

Save all changes to extension.py.

From the command line, cd to the ~/dev/extensions/sample-task directory and execute the push command as shown below:

Recall that the push command builds and uploads the Extension zip archive

Step 4 - Execute Dynamic Command

In the Controller, open the "UE Task tasks" tab.  If the tab is already open, it must be closed and reopened before the the new Dynamic Command will be available on the task instances.

...

The Step 1 and Step 2 Output Only fields have been set to Initial. This is a contrived example, but it demonstrates how a Dynamic Command could be used as a helper command for a task instance by performing some action on the target agent system (or beyond) and then updating the task instance in a meaningful way that may be required for a rerun scenario.

In this case, information flowed from the Dynamic Command execution back to the task instance fields. However, task specific information could also have been passed down to the Dynamic command.

Step 5 - Update the Local template.json

In step 1, we modified the Universal Template by adding a new Dynamic command. Recall that inside ~/dev/extensions/sample-task/src/templates, there is a template.json file. This file should correspond to the Universal Template in the Controller. 

Right now, they are not both the same. The Controller's version of template.json has the Dynamic Choice Fields changes. To grab those changes, use the pull command as shown below:

UIP VS Code Extension

Expand
titleClick here to expand uip-cli details...

Step Supplemental - CLI


Now, both the local and Controller's version of the Universal Template are the same.

< Previous     Next >