Adapter XDK for Cisco NSO
The Adapter XDK for NSO (cwm-nsox) is an application that helps you generate interfaces and logic for custom adapters intended to interact with the Cisco Network
Services Orchestrator(NSO).
The primary purpose of cwm-nsox is to reduce the time-consuming and error-prone manual process of constructing paths and payloads required for CWM to communicate
with NSO.
The tool complements the Adapter SDK and is able to automatically define interfaces in .proto files and implementation of logic in the adapter go module. This is achieved by parsing yang files and points of interest provided by the Adapter Developer.
Prerequisites
-
Installed Adapter SDK and dependencies.
-
The NSO
src/ncs/yangfolder for yang module imports. If you don't have it, you may install Cisco NSO to get it as part of a full installation.
Get cwm-nsox
The cwm-nsox is a binary that comes with the Crosswork Workflow Manager Software Package.
Go to Cisco Software Download page to download the .tar file with the CWM Software Package, where the cwm-nsox resides. Unpack the .tar and move the contents of the adapters folder to a desired location
!!! tip It's recommended that you put the binary in a common folder, with the cwm-sdk and other extension binaries like cwm-oasx.
Remember to include the location of the cwm-nsox binary by setting the environment variable path:
export PATH=/path/to/adapter-dev-binaries:$PATH
Use cwm-nsox for creating custom NSO adapter
The cwm-nsox works with yang models of NSO services and NEDs files to identfiy yang paths that you'd like to address using the adapter.
Step 1: Create an adapter stub with Adapter SDK
Run the following command to create a new adapter using SDK:
cwm-sdk create-adapter \
-vendor cisco \
-product nsox \
-feature services \
-ignore-template
![]() Note |
The ignore-template option eliminates tips and descriptions from the generated .proto files.
|
Step 2: Display yang paths and adapter code
display-paths
Use the cwm-nsox display-paths command to extract paths for activities from a source yang file. With the -src option, you specify the desired yang configuration file:
cwm-nsox display-paths -src ../path/to/source/file.yang
You will see a list of yang paths based on which you can generate adapter activities.
display-proto
Optionally, use the display-proto command with the -poi option to display the output for the activity based on your chosen point of interest:
cwm-nsox display-proto \
-src ../path/to/source/file.yang \
-poi your-nsoservice:your-nsoservice-list=%s/example-leaf
The output will look similar to this:
service Activities {
/*
* Description for activity NsoActivity
*/
rpc NsoActivity (NsoActivityRequest) returns (cisco.cwmlib.nso.Response);
}
/*
* Description for NsoActivityRequest
*/
message NsoActivityRequest {
string deviceName = 1; // devices/device={deviceName}
optional string dummyLeaf = 2; // tailf-ned-cwm-dmycli:dummy-leaf
cisco.cwmlib.nso.PutQuery queries = 3;
}
The following options are available:
| Option | Data type | Description | Status |
|---|---|---|---|
| -deps | string | Define paths to yang imports (comma separated list). | optional |
| -poi | string | Point to desired yang path (point of interest) | required |
| -src | string | Point to path of yang configuration file. | required |
| -verbose | string | Show command progress info. Options are: off, on, or very. | optional |
display-json
Optionally, use the display-json command with the required -poi and -src options to display the data payload for the activity based on your chosen point of interest (path):
cwm-nsox display-json \
-src ../path/to/source/file.yang \
-poi your-nsoservice:your-nsoservice-list=%s/example-leaf
| Option | Data type | Description | Status |
|---|---|---|---|
| -deps | string | Define paths to yang imports (comma separated list). | optional |
| -poi | string | Point to desired yang path (point of interest) | required |
| -src | string | Point to path of yang configuration file. | required |
| -verbose | string | Show command progress info. Options are: off, on, or very. | optional |
Step 3: Generate activity
Using the path defined in the previous section, you can now run the generate-activity command.
Go to the main directory of your adapter and execute the following command (adjust the path, activity name, request type and point-of-interest name accordingly):
cwm-nsox generate-activity \
-src ../path/to/source/file.yang \
-feature services \
-activity NsoActivity \
-request PUT \
-poi your-nsoservice:your-nsoservice-list=%s/example-leaf
This will generate a new adapter activity with a predefined rpc and I/O messages in the .proto files (see example in the section above), as well as a ready-to-execute implementation in the .go files.
Here's an example of the output generated by the cwm-nsox and inserted in the activities.go file:
package services
import (
"context"
"www.cisco.com/cwm/adapters/cisco/nsox/common"
"www.cisco.com/cwm/sdk/adapters/logger"
"www.cisco.com/cwm/sdk/adapters/nso"
)
func (adp *Adapter) NsoActivity(ctx context.Context,
req *NsoActivityRequest, cfg *common.Config) (*nso.Response, error) {
logger.GetLogger(ctx).Info("Activity cisco.nsox.services.NsoActivity called...")
return nso.SendCustomRequest(ctx, req, cfg)
}
Create activity (optional)
Optionally, you can create a new activity for a selected feature but without indicating the source file. This will create an activity implementation in the .go files and a stub for you to fill in the logic inside the .proto file:
cwm-nsox create-activity \
-feature device \
-activity TestActivity \
-request GET \
Here's an example of the activity stub generated by the cwm-nsox inserted in the .proto file:
service Activities {
...
/*
* Description for activity Testactivity
*/
rpc Testactivity (TestactivityRequest) returns (TestactivityResponse);
}
...
/*
* Description for TestactivityRequest
*/
message TestactivityRequest {
// NOTE: Developer needs to set vars
}
message TestactivityResponse {
// NOTE: Developer needs to set vars
}
Step 4: Test your adapter
To test your adapter, generate an installable file and install the adapter in CWM.
Generate installable
Go to the main directory of your adapter and run the following command:
cwm-sdk create-installable
Test adapter activity
This will create a .tar file that can be then uploaded into CWM. Follow the detailed instructions in the Install NSO adapter section to install and deploy the adapter, then run a workflow that uses the newly added adapter activity.
Generate installable
Go to the main directory of your adapter and run the following command:
cwm-sdk create-installable
Test adapter activity
The command will produce a .tar file that can be then installed in CWM and tested for proper functioning.

Feedback