postmannexusdashboardcisco

Cisco MSO/NDO API to add/remove staticport request using Postman


I would like to add a StaticPort and add also the domain association for an EPG. But unfortunately when I send the request it returns the "status 204 No Content" and I don't see any changes on Nexus Dashboard Orchestrator.

Request: PATCH https://{{ndo_host}}/mso/api/v1/schemas/{{schema_id}}

Body:

[
    {
        "op": "add",
        "path": "/templates/{{templateName}}/anps/{{appName}}/epgs/{{epgName}}/domainAssociations",
        "value": {
                "dn": "uni/phys-TEST_PHD",
                "domainType": "physicalDomain",
                "deployImmediacy": "immediate",
                "resolutionImmediacy": "immediate",
                "allowMicroSegmentation": false,
                "numPorts": 0
        }
    },
    {
        "op": "add",
        "path": "/templates/{{templateName}}/anps/{{appName}}/epgs/{{epgName}}/staticPorts",
        "value": {
            "deploymentImmediacy": "immediate",
            "mode": "untagged",
            "path": "topology/pod-1/paths-101/pathep-[eth1/1]",
            "portEncapVlan": {{vlan}},
            "type": "port"
            }
    }
]

Please advise if something is missing in this code? I'm using the following NDO:

Nexus Dashboard

Version 3.0.1i
Installed Services
Orchestrator Version 4.2.3e

PS: all variables are checked otherwise the request returns "400 Bad request", I have already tried to split into 2 requests (1 for static port and 1 for domain association) but it still returns "104 No content".

Alternatively, using Ansible with the Cisco MSO/NDO module works but it took about 3 hours to deploy 700 static ports. With Ansible, I don't know how to print into the debug the URL and Payload behind the API request.


Solution

  • Unfortunately I cannot speak to the domain association portion, but I believe I can help with the staticport issue.

    It appears that you are missing the "site-id" from your path variable.

    Here's what I would do for staticpath:

    {
            "op": "add",
            "path": "/sites/{{site-id}}-{{templateName}}/anps/{{appName}}/epgs/{{epgName}}/staticPorts/0",
            "value": {
                "deploymentImmediacy": "immediate",
                "mode": "untagged",
                "path": "topology/pod-1/paths-101/pathep-[eth1/1]",
                "portEncapVlan": {{vlan}},
                "type": "port"
                }
    

    Note***

    1. The "site-id" should also be a UUID instead of the name of the site, similar to your "schema-id". So instead of site-id = "siteA", it'll be some thing like site_id = "165168489044648614574644".
    2. You don't want the word "templates" in the path. You want: "{{site-id}}-{{templateName}}" instead
    3. I also added a "/0" after "staticPorts", I got this to work for me.

    You can add mutliple "add" operations in a single API request, meaning multiple staticPort updates with one request, as long as they are in the same schema. Doing as much as you possibly can within one API request is many orders of magnitude faster than using the MSO module as it currently exists.

    You could also build this into a python script to add mulitple staticPorts in one API request.

    As for the MSO Ansible module taking too long, I’ve also run into this problem. I opened a public issue in Cisco’s GitHub, feel free to take a gander at it and let them know you think their module is inefficient as well:

    https://github.com/CiscoDevNet/ansible-mso/issues/424