Run example workflow using Cisco NSO adapter

This section contains the following topics:

Run example workflow using Cisco NSO adapter

This quick start uses a locally installed Cisco Crosswork Network Service Orchestrator application and the CWM with the Cisco NSO adapter to show you a basic use case scenario for creating and running a successful workflow. It will guide you through how to install an adapter, create a worker for the workflow execution and run the created workflow to quickly get tangible results in Cisco NSO.

Workflow overview

The purpose of the example workflow is to automatically create a VPN service for two NSO devices.

First, we point to the devices in the data input and then try to perform the NSO check-sync operation on them. Then, depending on the result:

  • if not in sync, we push a device to perform a sync-from, and only then try to create a VPN for it;

  • if in sync, we don't perform sync-from but directly create a VPN for the device.

If all the steps are executed successfully, the execution engine reports workflow execution completion and displays the final data input. The results are visible in NSO too. If the engine encounters errors while performing a step, it uses the specified retry policy. In case errors persist beyond the retry limits, the engine ends the execution with a Failed status.

Go through the sections below to learn the details of how data input, functions, states, actions, and data filters are defined. If you want to know how the sausage is made, you can read the Create workflow chapter in the Workflow Creator guide.

Step 1: Install NSO adapter

To interact with Cisco NSO, CWM needs a dedicated Cisco NSO adapter. Here's how you install it using the CWM API:

Upload NSO adapter file

Procedure

Step 1

Get the latest NSO adapter installation file from the CWM Software Package.

Step 2

Go to the CWM User Interface in a browser, and log in using credentials generated upon the installation of CWM. If the application is hosted locally, then the default address is localhost:8443.

Step 3

From the navigation menu on the left, click the swagger icon.

Step 4

In the adapters section, click the POST /adapter endpoint to expand it. Inside the endpoint, click Try it out.

Step 5

In the subsection that appears, click Choose File, select the NSO installation file and click Upload, then click Execute.

If the server response code is 201, the adapter file is successfully uploaded into the CWM database.


Deploy Cisco NSO adapter

Before you can use the adapter, you need to deploy the uploaded adapter file using the CWM API:

Procedure

Step 1

In the CWM API adapters section, click the GET /adapter endpoint to expand it. Inside the endpoint, click Try it out and Execute.

Step 2

From the server response body, copy the value of the id field. It should be cisco.nso.v1.0.0 or similar, depending on your adapter version.

Step 3

In the CWM API adapters section, click the POST /adapter/{adapterId}/deploy endpoint to expand it.

Step 4

Inside the endpoint, click Try it out. Paste the adapter id into the Adapter ID field.

Step 5

In the createWorker field, set the createWorker parameter to true. This will create a worker with the same name as the adapter id.

Step 6

Click Execute.

If the server response code is 201, the adapter plugin is successfully installed and you're good to proceed.

Note

 

If you want to create a worker manually, follow the instructions in the CWM Administrator Guide. Remember that in this case, you will need to update the workflow definition with your created worker name.


Step 2: Create secret and resource

To define the resources and secrets to be passed in securely to the Cisco NSO adapter, you need to create a secret and resource in the CWM API. Here's how to do it:

Create secret

Procedure

Step 1

In the CWM API secrets section, click the POST /secret endpoint to expand it.

Step 2

Inside the endpoint, click Try it out, and paste the following data into the Secret to add field:

{
"secret": {
"username": "admin",
"password": "admin"
},
"secretId": "NSOSecret",
"secretType": "basicAuth"
}

Step 3

Click Execute.

If the server response code is 201, the secret is successfully created and you can start creating your resource.


Create resource

Procedure

Step 1

In the CWM API resources section, click the POST /resource endpoint to expand it.

Step 2

Inside the endpoint, click Try it out, and paste the data into the Resource input field (modify if needed to fit your installation):

{
    "resource": {
        "scheme": "http",
        "host": "127.0.0.1",
        "port": 8080
    },
    "resourceId": "NSOLocal",
    "resourceType": "cisco.nso.resource.v1.0.0",
    "secretId": "NSOSecret"
}

Step 3

Click Execute.

If the server response code is 201, the resource is successfully created and you're good to proceed.


Step 3: Set up NSO example service

The NSO example that we use for the purposes of our workflow is setting up a Layer3 VPN in a service provider MPLS network for two NSO-simulated devices. Here's how you set up the example:

Procedure


Step 1

In a terminal, open your main NSO directory and go to mpls-vpn-new-template:

cd examples.ncs/service-provider/mpls-vpn-new-template

Step 2

Execute the Makefile by running:

make stop clean all start

This command will start your local NSO instance and the sample netsim devices.

Step 3

For the example workflow to execute successfully, execute a Sync from on all the netsim devices beforehand:

devices sync-from

Step 4: Run the workflow

Now that we have the NSO adapter, the worker, and the NSO example all up and running, we can create a workflow in the CWM UI and run the job.

Add new workflow

Procedure

Step 1

In the CWM UI, select the Workflows tile from the navigation menu on the left.

Step 2

In the Workflows panel, click Create new workflow.

Step 3

In the Create new workflow modal, provide the required input:

  1. Workflow definition name: provide name for the example workflow definition: CreateL3VPN.

  2. Version: provide workflow definition version: 1.0.

Step 4

Click Create workflow.

Figure 1. Create workflow

Run job

Procedure

Step 1

In the Workflows panel, enter the newly created workflow definition by clicking its name.

Step 2

Click the Code tab and delete the sample content from the Code field.

Step 3

Download the workflow file using the link below and unzip it. Open the JSON file and copy the contents. Open the file, copy the workflow definition and paste it inside the Code field, then click Save changes.

Workflow_v1.json

Step 4

Click Run.

Step 5

Download the data input file using the link below and unzip it. Open the JSON file and copy the contents. In the Run job modal, provide a name for the job and in the Job variables field, paste the copied data input.

Data_input_v1.json

Step 6

Click Run Job.

Figure 2. Run job

Step 5: Check results

Check the results of example workflow execution:

In CWM UI

Procedure

Step 1

In the CWM UI, select the Job Manager tile from the navigation menu on the left.

Step 2

In the All jobs tab, find your job and check the status of the workflow execution in the Status table column.

  1. If the workflow is executed correctly, a green tick with Completed status will be visible.

  2. If the workflow execution is still in progress or the engine is retrying an action, a blue label with the Running status will be displayed.

Step 3

Click the job name to enter its details.

Step 4

In the Job Event Log table, expand the bottommost WorkflowExecution entry by clicking its name.

Step 5

In the JSON payload displayed, find the data key. It presents the final data output updated by the successful execution of the workflow actions for which toStateData inside the actionDataFilter was defined:

Figure 3. Event log

In NSO

Procedure

Step 1

Log in to your NSO account and in the Application hub view, click the Service manager tile.

Step 2

From the Select service points drop-down, select /l3vpn:vpn/l3vpn.

Step 3

In the table, find testnetwork and click the devices arrow to see that your netsim devices ce0 and ce1 now belong to the testnetwork together with a pe0 device.

Figure 4. L3VPN in NSO