Workflows¶
A workflow is a directed graph which nodes are scripts.
Each script in eNMS returns a boolean value:
- True if it ran successfully.
- False otherwise.
There are two types of edge in a workflow: success edge and failure edge.
The success edge indicates where to move in the graph if the source script was executed with success, while the failure edge does the same thing in case of failure.
Workflows are created and managed from the workflows/workflow_management page.
A first example¶
- Let’s consider a workflow made of four scripts:
configure-bgp, aNAPALM configurationscript that configures a BGP neighbor.NAPALM Commit, that commits the changes with NAPALM.validate-bgp, aNetmiko validationscript that checks that the neighbor appears in theshow ip bgp neighborscommand.NAPALM Rollback, that rollbacks the changes with NAPALM.
The workflow below uses these four scripts together to configure a new BGP neighbor and rollbacks in case of problem.
The green color of configure-bgp indicates that this is the beginning of the workflow (the first script to be executed).
If configure-bgp is a success (it returns the boolean value True, the success edge will be used, and the NAPALM Commit script will be executed.
If NAPALM Commit runs successfully, validate-bgp will run and check that the neighbor was properly configured.
If validate-bgp is a success, the workflow will stop here as there is no success edge starting from validate-bgp. On the other hand, if it fails, the workflow will go on using the failure edge and the configuration will be rolled back with NAPALM.
Creation of a workflow¶
In the workflows/workflow_management page, click on the button Add a new workflow and fill the workflow creation form.
The new workflow will be automatically added to the table of worflows.
Clicking on the Manage button in the table of workflows to open the Workflow builder.
Workflow builder¶
- Add script: open a window to select which script you want to add to the workflow.
- Delete selection: delete the selected script or edge.
- Set as start: the selected script is set as the beginning of the workflow. It will be highlighted in green.
- Success edge: switch to the
success edgecreation mode, allowing you to drawsuccess edgebetween scripts. - Failure edge: same as
success edge. - Move node: switch to the motion node, allowing you to drag the scripts on the canvas to better visualize the workflow.
備註
You can double-click on a script to update its properties.
Create a workflow step by step¶
Let’s create the BGP workflow discussed in the first paragraph.
Creation of the validatebgp script¶
In the scripts/script_creation page, we create a NAPALM configuration script to configure the BGP neighbor on the device.
Configuration:
Creation of the validatebgp script¶
In the scripts/script_creation page, we create a Netmiko validation script to check that 1.1.1.1 is indeed considered a BGP neighbor on the device.
Specifically, we are checking that the output of show ip bgp neighbors 1.1.1.1 contains the line BGP neighbor is 1.1.1.1.
Creation of the workflow¶
In the workflows/workflow_management page, click on the button Add a new workflow and fill the workflow creation form.
Building the workflow¶
In the workflows/workflow_management page, click on the button Manage of the newly created workflow. This opens the Workflow builder.
Click on the Add script button, and add all 4 scripts: configurebgp, validatebgp, NAPALM Commit and NAPALM Rollback.
Finally, create:
- a
success edgefromconfigurebgptoNAPALM Commit. - a
success edgefromNAPALM Committovalidatebgp. - a
failure edgefromvalidatebgptoNAPALM Rollback.
Select configurebgp and click on the Set as start button to tell eNMS that this is where the workflow begins.
The workflow is done and ready to be executed: