Scheduling Configlets for Networks
search cancel

Scheduling Configlets for Networks

book

Article ID: 440037

calendar_today

Updated On:

Products

VMware Smart Assurance Network Observability

Issue/Introduction

Users cannot find a way in the Smarts NCM GUI to schedule a configlet job that automatically includes new devices added to an individual NCM network. Currently, selecting all devices in a network creates a static list for the job, requiring manual updates when the network membership changes.

Environment

All supported NCM versions 

Resolution

To achieve a dynamic push to all devices currently in a network, use the Smarts NCM REST APIs. This allows for a programmatic sequence to fetch the current device list and schedule the job.

Step 1: Obtain token

Run the following command on the NCM Application Server to obtain a token:

curl -k -X POST https://[NCM_ASIP]:8880/ncm-webapp/auth/token -H "Content-Type: application/x-www-form-urlencoded" -d "username=<USERNAME>&password=<PASSWORD>"

Step 2: Authorization

Launch the REST API from NCM landing page, select authorize and paste token obtained in Step 1. Once Authorize is successful, proceed with Step 3. 

Step 3: Retrieve Network and Device Information

Execute the following APIs to prepare the job:

  1. Get Network Keys: GET /api/v1/network 
    Identify the resourceKey for the target network.

  2. Filter Devices in Network: POST /api/v1/network/{networkId}/devices/info 
    Use the resourceKey from the previous step. You can apply filters (e.g., by packageName) to target specific device classes like "Cisco Nexus".
    Example Filter Payload:
    {  
        "filterComponents": [
            {
                "operator": "&&",
                "filterComponents": [
                {
                    "attributeName": "packageName",
                    "operator": "==",
                    "value": "Cisco Nexus"
                }
                ]
            } 
            ]
    }

  3. Schedule the Push Configlet Job: POST /api/v1/job/push/schedulePushConfigletJob
    Use the resourceKey and resourceName identifiers retrieved in previous step to schedule the job.
    Example Job Payload:

{  
    "deviceIdentities": [
        {
            "resourceKey": "0a504209d785d83f44404bf29d010000",
            "resourceType": "DEVICE",
            "resourceName": "device-name-01"
        }
        ],
        "configUnit": "running",
        "pushContent": "ip host testapi [IP_ADDRESS]",
        "jobInfo": {
            "jobName": "Dynamic Network Push",
            "jobStatus": "approved",
            "jobOwner": "sysadmin",
            "approvedBy": "sysadmin",
            "auditTag": null,
            "preserveTaskOrder": false,
            "sharedConfig": false,
            "jobPriority": "low",
            "jobRunOption": "run_upon_approval",
            "maintWindowType": null,
            "runInNextMaintWin": null,
            "recurring": false,
            "maintWinOverride": false,
            "jobType": "push",
            "recurranceInfo": null
            }
        }

By automating this sequence, the job will always target the current members of the network at the time of execution.