A remediation action is a Directed Acyclic Graph (DAG) that uses Python.

  • Each action is composed of one or more tasks.
  • Each task uses a particular operator. For example, HTTP/ssh/slack/python for connecting to external services.
  • The tasks for HTTP/ssh/slack can refer to the Connections when connecting to an external service. For example, for a HTTP GET/POST operation.
  • The python-operator task is used for writing a Python function that works on the data received from or to is sent to external services.
  • You must specify the paths for the operators and Python modules in the import section of the Python action file.
You must import the success and failure callbacks.
from Success import *
from Failure import *
DAG definition calls must supply the parameters required by the action with default values.
myParams = { 
DAG definition requires the dag name (dag_id), parameters, and references to the success and failure callbacks.
with DAG(
       on_success_callback =success,
       on_failure_callback =failure
) as dag:
Each task of a DAG must specify the task_id, dag name, optional connection id/command, and success and failure callbacks.
# example task 1. run a command on a Cisco router
# ssh-cisco connection id is defined under Connections 
t1 = SSHOperator(ssh_conn_id='ssh-cisco',  
  command='show ip route',
  on_success_callback = success,
  on_failure_callback =failure)
# example task 2, using a HTTP operator on a GET endpoint
# rest_svc_connection connection_id is defined under Connections
t2 = SimpleHttpOperator(
        data = json.dumps({“foo”: “bar” }),
        extra_options = {'verify':False},
        response_filter=lambda response: response.json()['id'],
        on_success_callback = success,
        on_failure_callback =failure
The tasks must be specified at the bottom of the file. The following sequence implies that task t1 is executed first. Then on task t1 success, task t2 is executed. If task t1 fails, task t2 cannot run as the upstream task, and it fails.
t1 >> t2