Getting Started Developing Workflows

Overview

This tutorial will walk you through the design and development of your first workflow.

Workflows can be used to automate a wide variety of task and processes such as

  • Service configuration chaining
  • VNF lifecycle management
  • Configuration audit and verification
  • Automated Customer on-boading
  • ...

The "Helloworld" workflow

The "Helloworld" workflow will print take a name as IN parameter and will display a message to the user: "Hello NAME".

This workflow will be composed of 3 processes, one to create the new instance of the workflow, one to enter the name and print it and on to delete the instance.

Create a new workflow

Form the workflow repository, select the folder "Helloworld" (you have to create it if it is not there) and create a new workflow:

Workflow_1

In the tab "INFORMATION", leave everything to the default:

Workflow_2

Create a variable "name" in the tab "VARIABLES"

Workflow_3

Save your workflow and attach it to your customer (customer page, tab "SERVICE", sub-tab "Workflows", click on the green "+" icon on the left and select your "Helloworld" workflow from the repository

Create the processes

"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, one "Create" process is sufficient, it is possible to have several "Create" processes to handle 1 or more ways of creating the workflow instance. For this tutorial we will create 1 process name "create instance" and add 1 task to this process. This task will do nothing apart from displaying a message to the process execution console

Workflow_4
<?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, a green "+" icon with the label "create instance" beside. Click on the icon and then "Run now", the process executes and an new workflow instance is created.

the "delete instance" process

Follow the same steps as for the "create instance" process but make sure that the type of the process is set to "Delete"

At this stage, your workflow console should look like this

Workflow_5

the "print message" process

This time, the process type will be "Update" and will take one parameter that will be used to print our 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);

?>
		    				

Execute this process and watch the result on the console

Workflow_6