Overview
This tutorial walks you through the design and development of your first workflow.
Workflows can be used to automate a wide variety of tasks and processes, such as:
-
Service configuration chaining
-
VNF lifecycle management
-
Configuration audit and verification
-
Automated customer on-boarding
-
…
The "Helloworld" Workflow
As an example, we’ll use the "Helloworld" workflow. The "Helloworld" workflow will print a name as IN parameter and will display a message to the user ("Hello NAME").
This workflow is composed of 3 processes: one to create the new instance of the workflow, one to enter the name and print it, and one to delete the instance.
Create a new Workflow
From the Developer dashboard click on "+ Create"
In the tab "Information", set a name, a description and set the Workflow variable name to service_id and save your workflow.
Create a variable "Name" in the tab "Variable".
To start testing your workflow, you need to associate it to a customer. Make sure that you have no tenant selected, go to the "Automation" section, you should see your workflow in the list.
You can use the magnifier to search for it.
Use the link "Add to.." to associate the workflow to a customer.
Select the customer to use for designing and testing the workflow.
Once done, you can select your customer, list its workflows and edit it with the pencil icon.
Create the Processes
The "create instance" Process
In order to be used, every Workflow should be instantiated first. This is the role of the process with the type "Create".
even though for most use cases, a single "CREATE" process is sufficient, it is possible to have several "CREATE" processes to support various ways of creating the Workflow instance (You can relate that to having several object constructor in an OOP language such as Java). |
For this tutorial you will create one process named "create instance" and add one task to this process. This task will simply display a message to the process execution console.
<?php
/**
* This file is necessary to include to use all the in-built libraries of /opt/fmc_repository/Reference/Common
*/
require_once '/opt/fmc_repository/Process/Reference/Common/common.php';
/**
* List all the parameters required by the task
*/
function list_args() { }
/**
* End of the task do not modify after this point
*/
task_exit(ENDED, "workflow initialised");
?>
Once done, save the Workflow.
The "delete instance" Process
Follow the same steps as in the "create instance" process, but make sure that the type of the process is set to "DELETE", instead of "CREATE".
In our case, we only need the instance to be deleted, therefore we don’t need a Task to be added to this Process but in a real world use case, your DELETE process will probably take care of removing or cleaning up some parts of your managed system. |
The "print message" Process
For the print process, use the process type "UPDATE". It will take one parameter that will be used to print your message. Use the code below to create a task that will read the name from the user form and print it in the live console.
<?php
/**
* This file is necessary to include to use all the in-built libraries of /opt/fmc_repository/Reference/Common
*/
require_once '/opt/fmc_repository/Process/Reference/Common/common.php';
/**
* List all the parameters required by the task
*/
function list_args()
{
create_var_def('name', 'String');
}
check_mandatory_param('name');
/**
* get the value of name from the context and create a variable out of it
*/
$name=$context['name'];
/**
* print the value in the log file /opt/jboss/latest/log/process.log
*/
logToFile($name);
/**
* End of the task do not modify after this point
*/
task_exit(ENDED, "Hello " . $name);
?>
Test the Workflow
Before you can test the workflow and execute some processes, you need to attach the workflow to your current subtenant.
Use the "+ create instance" action to execute the "create instance" process and create a new instance of your workflow.
A new instance is available and you can execute the process "print message".
The process "print message" will start executing and will executes the tasks sequentially.
The name will be displayed in the task execution status popup, below the name of the task.