Automation Express
  • 23 May 2023
  • Dark
    Light
  • PDF

Automation Express

  • Dark
    Light
  • PDF

Article Summary

RESTCONF Examples

This section provides several restAction examples. Sample input values are used to illustrate the Reference variable you would enter for each Incoming Variable on the task dialog.

GET

This example provides information on NSO for the device name C-IOS1.

Variable: adapterId

"Local NSO"


Variable: params

{
    "path": "/restconf/data/tailf-ncs:devices/device=C-IOS1",
    "contentType": "application/yang-data+json",
    "accept": "application/yang-data+json",
    "method": "GET"
}


Variable: body

{ }

PATCH

This example adds an interface config to the C-IOS1 device.

Variable: adapterId

"Local NSO"


Variable: params

{
    "path": "/restconf/data/tailf-ncs:devices/device=C-IOS1/config",
    "accept": "application/yang-data+json",
    "contentType": "application/yang-data+json",
    "method": "PATCH“
}


Variable: body

{
  "config": {
        "tailf-ned-cisco-ios:interface": {
            "Loopback": [
                {
                    "name": "1",
                    "ip": {
                        "address": {
                            "primary": {
                                "address": "127.0.0.1",
                                "mask": "255.0.0.0"
                            }
                        }
                    }
                }
            ]
        }
    }
}

PUT

This example updates an interface config to the C-IOS1 device.

Variable: adapterId

"Local NSO"


Variable: params

{
    "path": "/restconf/data/tailf-ncs:devices/device=C-IOS1/config/tailf-ned-cisco-ios:interface/Loopback=1/ip",
    "accept": "application/yang-data+json",
    "contentType": "application/yang-data+json",
    "method": "PUT“
}


Variable: body

{
 "ip": {
        "address": {
            "primary": {
                "address": "127.0.0.2",
                "mask": "255.0.0.0"
            }
        }
    }
}

POST

This example creates a device on NSO named C-IOS1.

Variable: adapterId

"Local NSO"


Variable: params

{
    "path": "/restconf/data/tailf-ncs:devices",
    "contentType": "application/yang-data+json",
    "accept": "application/yang-data+json",
    "method": "POST“
}


Variable: body

{
    "tailf-ncs:device": {
        "name": “C-IOS1",
        "address": "127.0.0.1",
        "port": 10022,
        "authgroup": "default",
        "device-type": {
            "cli": {
            "ned-id": "cisco-ios-cli-6.23:cisco-ios-cli-6.23"
            }
        }
    }
}

DELETE

This example deletes the C-IOS1 device.

Variable: adapterId

"Local NSO"


Variable: params

{
   "path": "/restconf/data/tailf-ncs:devices/device=C-IOS1",
    "accept": "application/yang-data+json",
    "contentType": "application/yang-data+json",
    "method": “DELETE“
}


Variable: body

{ }

Automation Examples

Picture below is an example Gen 1 workflow (automation) using RESTCONF to:

  • Onboard a device.
  • Perform a fetch-ssh-key action.
  • Perform a sync-from action.
  • Delete a device.

Figure 1: RESTCONF Workflow

01_restActionAutomation

Add Device

This sample illustrates the Variables used to add a device.


Figure 2: RESTCONF Add Device

04_restActionAddDevice


Fetch SSH Keys

This sample illustrates the Variables used to fetch-host-keys in a device.


Figure 3: RESTCONF Fetch Host Keys

05_restActionFetchKeys


Sync-From

This sample illustrates the Variables used to sync-from a device.


Figure 4: RESTCONF Sync-From

06_restActionSyncFrom


Delete Device

This sample illustrates the Variables used to delete a device.


Figure 5: RESTCONF Delete Device

07_restActionDeleteDevice


Service Model Example

The Variables pictured below illustrate how to apply a Service Model using the commit-queue tag with optional features for optimization (i.e., no-out-of-sync-check, continue-on-error).


Figure 6: RESTCONF Service Model Input

08_restActionServiceModel-Input


Figure 7: RESTCONF Service Model Output

09_restActionServiceModel-Output


Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.