Indeni Workflow Tutorial
Introduction
Using Indeni-Workflow, the IKE will have the power to:
Write workflow in an easy way
Debug workflow
Debug workflow block
Run workflow on a real device
Run workflow on mock data
View workflow in a graphic way
Prepare your environment
1. install indeni-parser
indeni-workflow uses indeni-parser methods to parse raw data into objects (parse_data_as_list
etc..)
use this link to install indeni-parser
2. Install indeni-workflow
Using the terminal, install the latest version of indeni-parser
pip3 install "indeni_workflow==0.0.0.*" --extra-index-url https://indeni.jfrog.io/indeni/api/pypi/indeni-pypi-develop/simple |
In Ubuntu systems version 18.X (other Debian based systems could be affected) above command don’t work due the blackout in supporting TLS 1.0 and 1.1 in pip which happened 1-2 years ago. In this cases pip must be updated before to install indeni-parser
curl https://bootstrap.pypa.io/get-pip.py | sudo python3 |
in order to uninstall indeni-workflow use
pip3 uninstall indeni-workflow |
3. Install PyCharm
use this link
4. Define Project Interpreter
use this link
Write your workflow
Files Architecture
Every workflow directory should contain below files, under automation/workflows/<workflow_name>/<vendor_name>/
<workflow_name> should be the rulename
vendor_name
checkpoint
paloaltonetworks
Note: See cross_vendor_next_hop_router_inaccessible in https://bitbucket.org/indeni/indeni-knowledge/src/IKP-3685-ansible-to-slimsible-ate-migration/
File | Description | Details | Example |
---|---|---|---|
| Contains the workflow structure | The workflow contains the following fields
Each block is responsible to route to the next block. The following fields are mandatory in each block:
According to the type of the block, more fields are required. |
|
| Contains supporting parser methods for <workflow_name>_workflow.yaml |
|
|
| Contains mappings of parser input to expected output | Eg. GET_CPU_UTILIZATION_DATA_1 = ('cpu: usage 25%', 25.0) The name should be uppercase, beginning with the name of the parser it tests. Followed by TUPLE_n where n is the appropriate number (1 for first, etc.) See the file at the bottom of this page for more examples, and an example how how to write multi-line strings in Python |
|
| Contains:
| This file should have one function named test_<parser_function_name> per parser function. Each test may have multiple asserts within it. An example is available towards the bottom of this page. |
|
| Contains information required to run WIT (workflow integration tool) for a particular workflow. | The file should define the workflow name, the tags of the device to simulate, and a list of “flows”. Each flow is an execution path through the workflow that terminates in a particular conclusion. | |
| Template files that workflow_name.py require |
|
|
| Pointing to a textfsm file from py file will be in a relative way |
|
|
workflow_catalog.yaml
Block types
Type | Description | Required fields | Example | |
---|---|---|---|---|
1 | device_tags | get the device_tags data as dict[str,str] |
|
|
2 | device_task | run ssh/https command on the device and parse it |
|
|
3 | if | go to next block based on condition |
|
|
4 | logic | run a python logic on args and return result |
|
|
5 | generate_panos_key | generate a panos api-key |
|
|
6 | conclusion | the conclusion. after the conclusion block, the workflow should end |
|
|
7 | issue_items | Get the issue items as a list of strings |
|
|
8 | foreach | Go over each issue item |
| |
9 | ping (not yet merged) | Ping a target server, returns bool (True/False) for success/failure. Note: ping is from the Indeni server to the target server. |
|
|
10 | port_check (not yet merged) | Probe a server’s port and get the status. Returns one of Note: probe is from the Indeni server to the target server. |
|
|
11 | loop | Perform actions in a loop for each item in an iterable |
| |
12 | end_loop | Marks the end of a loop block iteration and registers the final result |
|
Args And Dynamic Text
Currently, args
must have same name into workflow as is defined as argument of the method defined (parser). Example:
Block definition:
Parser definition:
There are string fields in the yaml, where the args can be passed in {{}}, and the workflow will know to replace the expression with the value.
The current dynamic fields are:
device_task.runner.command
conclusion.triage_conclusion
conclusion.triage_remediation_steps
examples:
The device has {{len(num_processors)}} cores
This device was rebooted due a operation identified on logs: {{restart_entries}}
Testing your workflow
WorkflowTestTool
have 2 main methods to run workflows:
run_workflow
- run a full workflow:
Arguments:workflow_path
- the workflow pathdevice_data
- the device IP and credentialsissue_items
- a set of the issue item names. (Optional)
run_workflow_block
run a specific workflow block:
Arguments:
workflow_path
- the workflow pathblock_id
- the block to rundevice_data
- the device IP and credentialsscope
- the current arg scoperun_single_block
- should the workflow stop after finishing running the blockissue_item
- a set of the issue item names. (Optional)
Using WorkflowTestTool
you can run several tests:
| Real device | Mock data |
---|---|---|
Workflow testing |
for example:
|
|
Block testing | Create
For example:
| For example: |
Enabled debug logs
By default, the WorkflowTestTool
shows only Info logs. in case debug logs are wanted, run
Draw workflow
Using the dot language, we can draw a graphical view of the workflow. This should be used as part of the PR, to show that the workflow matches the requirements:
Call WorkflowTestTool.draw_workflow
(requires internet connection). Example:
Guidelines for PR submission
Required files:
<workflow_name>_workflow.yaml
<workflow_name>_parser.py
<workflow_name>_mock_data.py
<workflow_name>_parser_test.py
<workflow_name>_workflow_test.py
ATE folder name should be the same as the rule name
Add a link to the server Knowledge Explorer workflow
Capitals in first letter of
name
Capitals used with acronyms (e.g DNS and not dns)
Fields that are being used by the UI must give meaningful info and should be super descriptive (short as possible, but descriptive). Some comments
If the conclusion is the the problem is now resolved, leave the
triage_remediation_steps
empty in the following manner:
triage_remediation_steps: ””
If the field is empty without a empty string defined in previous example the WorkflowTestTool crash when run
6. Do not state “N/A” in triage_remediation_steps
or triage_conclusion
UI fields are:
triage_remediation_steps
triage_conclusion
name
Tests
An example of a <workflow_name>_parser_test.py
An partial example of <workflow_name>_mock_data.py