cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
4272
Views
10
Helpful
6
Replies

Static EPG deployment via REST API

dtekaccount10
Level 1
Level 1

Hello!

 

I've planning to deploy a lot of EPGs on bare-metal servers and looking for advice on how to do it via REST API.

Looking on example of existing static deployment 

 

 

{
  "totalCount": "1",
  "imdata": [
    {
      "fvRsPathAtt": {
        "attributes": {
          "annotation": "",
          "descr": "",
          "dn": "uni/tn-EXP/ap-APP1/epg-VL1101_EPG/rspathAtt-[topology/pod-1/protpaths-101-102/pathep-[_Cisco_ME3400_VPC]]",
          "encap": "vlan-1101",
          "instrImedcy": "immediate",
          "mode": "regular",
          "primaryEncap": "unknown",
          "tDn": "topology/pod-1/protpaths-101-102/pathep-[_Cisco_ME3400_VPC]"
        }
      }
    }
  ]
}

and browsing APIC Postman application I found that I need to use fv:RsPathAtt class. As I understand resulting POST message body should look like this:

 

 

{
    "fvRsPathAtt": {
        "attributes": {
            "tDn": "topology/pod-1/protpaths-101-102/pathep-[_AnotherDevice_VPC]",
            "dn": "uni/tn-EXP/ap-APP1/epg-VL1101_EPG/rspathAtt-[topology/pod-1/protpaths-101-102/pathep-[_AnotherDevice_VPC]]",
            "rn": "rspathAtt-{topology/pod-1/protpaths-101-102/pathep-[_AnotherDevice_VPC]}",
            "status": "created,modified",
            "annotation": "",
            "descr": "",
            "encap": "vlan-1101",
            "instrImedcy": "immediate",
            "mode": "regular",
            "primaryEncap": ""
        },
        "children": []
    }
}

Is this a correct request body? And what about endpoint where I should send the request?

Fields annotation, descr, array children are required or I can omit them?

 

Thank you!

2 Accepted Solutions

Accepted Solutions

udo.konstantin
Level 1
Level 1

Hi,

 

 

@dtekaccount10 wrote:

Hello!

 

I've planning to deploy a lot of EPGs on bare-metal servers and looking for advice on how to do it via REST API.

Looking on example of existing static deployment 

 

 

{
  "totalCount": "1",
  "imdata": [
    {
      "fvRsPathAtt": {
        "attributes": {
          "annotation": "",
          "descr": "",
          "dn": "uni/tn-EXP/ap-APP1/epg-VL1101_EPG/rspathAtt-[topology/pod-1/protpaths-101-102/pathep-[_Cisco_ME3400_VPC]]",
          "encap": "vlan-1101",
          "instrImedcy": "immediate",
          "mode": "regular",
          "primaryEncap": "unknown",
          "tDn": "topology/pod-1/protpaths-101-102/pathep-[_Cisco_ME3400_VPC]"
        }
      }
    }
  ]
}

and browsing APIC Postman application I found that I need to use fv:RsPathAtt class. As I understand resulting POST message body should look like this:

 

 

{
    "fvRsPathAtt": {
        "attributes": {
            "tDn": "topology/pod-1/protpaths-101-102/pathep-[_AnotherDevice_VPC]",
            "dn": "uni/tn-EXP/ap-APP1/epg-VL1101_EPG/rspathAtt-[topology/pod-1/protpaths-101-102/pathep-[_AnotherDevice_VPC]]",
            "rn": "rspathAtt-{topology/pod-1/protpaths-101-102/pathep-[_AnotherDevice_VPC]}",
            "status": "created,modified",
            "annotation": "",
            "descr": "",
            "encap": "vlan-1101",
            "instrImedcy": "immediate",
            "mode": "regular",
            "primaryEncap": ""
        },
        "children": []
    }
}

Is this a correct request body? And what about endpoint where I should send the request?

Fields annotation, descr, array children are required or I can omit them?

 

Thank you!


This is the correct body. The Fields annotation, descr, array children are not required. 

The request should be send as a POST with a REST tool  (Postman, curl...) to the controllers IP. What do you mean about endpoint? You specify the EPG after "dn". 

View solution in original post

Hi @dtekaccount10 ,

 

The URL should be "https://APIC-IP/api/node/mo/uni.json"

And the body should be as mentioned before! 

 

Regards

Udo 

 


@dtekaccount10 wrote:

@udo.konstantin 

I mean the API URI. It should be just https://APIC or something else like https://APIC/api/node/mo/uni/tn-EXP/ap-APP1/epg-VL1101_EPG.json ?


 

View solution in original post

6 Replies 6

udo.konstantin
Level 1
Level 1

Hi,

 

 

@dtekaccount10 wrote:

Hello!

 

I've planning to deploy a lot of EPGs on bare-metal servers and looking for advice on how to do it via REST API.

Looking on example of existing static deployment 

 

 

{
  "totalCount": "1",
  "imdata": [
    {
      "fvRsPathAtt": {
        "attributes": {
          "annotation": "",
          "descr": "",
          "dn": "uni/tn-EXP/ap-APP1/epg-VL1101_EPG/rspathAtt-[topology/pod-1/protpaths-101-102/pathep-[_Cisco_ME3400_VPC]]",
          "encap": "vlan-1101",
          "instrImedcy": "immediate",
          "mode": "regular",
          "primaryEncap": "unknown",
          "tDn": "topology/pod-1/protpaths-101-102/pathep-[_Cisco_ME3400_VPC]"
        }
      }
    }
  ]
}

and browsing APIC Postman application I found that I need to use fv:RsPathAtt class. As I understand resulting POST message body should look like this:

 

 

{
    "fvRsPathAtt": {
        "attributes": {
            "tDn": "topology/pod-1/protpaths-101-102/pathep-[_AnotherDevice_VPC]",
            "dn": "uni/tn-EXP/ap-APP1/epg-VL1101_EPG/rspathAtt-[topology/pod-1/protpaths-101-102/pathep-[_AnotherDevice_VPC]]",
            "rn": "rspathAtt-{topology/pod-1/protpaths-101-102/pathep-[_AnotherDevice_VPC]}",
            "status": "created,modified",
            "annotation": "",
            "descr": "",
            "encap": "vlan-1101",
            "instrImedcy": "immediate",
            "mode": "regular",
            "primaryEncap": ""
        },
        "children": []
    }
}

Is this a correct request body? And what about endpoint where I should send the request?

Fields annotation, descr, array children are required or I can omit them?

 

Thank you!


This is the correct body. The Fields annotation, descr, array children are not required. 

The request should be send as a POST with a REST tool  (Postman, curl...) to the controllers IP. What do you mean about endpoint? You specify the EPG after "dn". 

@udo.konstantin 

I mean the API URI. It should be just https://APIC or something else like https://APIC/api/node/mo/uni/tn-EXP/ap-APP1/epg-VL1101_EPG.json ?

Hi @dtekaccount10 ,

 

The URL should be "https://APIC-IP/api/node/mo/uni.json"

And the body should be as mentioned before! 

 

Regards

Udo 

 


@dtekaccount10 wrote:

@udo.konstantin 

I mean the API URI. It should be just https://APIC or something else like https://APIC/api/node/mo/uni/tn-EXP/ap-APP1/epg-VL1101_EPG.json ?


 

Can you stack multiple configuration entries in the json data like below: 

{
  "totalCount": "2",
  "imdata": [
    {
      "fvRsPathAtt": {

}
}
{
"fvRsPathAtt": {

}
}
]
}

 

You can but what you ought to do is write it up with the {{variables}} bracketed in Postman like below. Make a CSV file with those variable names as the top row and then fill in all your iterations.  Then in Postman, you will select "Run Collection" and use the CSV as the data file. That way each run will be separate and you will get a 200 OK when it works or a 4xx code when one fails.

 

https://learning.postman.com/docs/getting-started/creating-the-first-collection/

You will also want to create a login task for the APIC like so and add it to all your collections as the first job. Setup an environment for your ACI environment with the APIC, Username and Password variables stored: 


POST: https://{{APIC}}/api/aaaLogin.json

 

 

{
    "aaaUser": {
        "attributes": {
            "name": "{{UserName}}",
            "pwd": "{{Password}}"
        }
    }
}

 

 POST: https://{{APIC}}/api/mo/uni.json?rsp-subtree=modified

 

{
    "fvRsPathAtt": {
        "attributes": {
            "dn": "uni/tn-{{Tenant}}/ap-{{ANP}}/epg-{{EPG}}/rspathAtt-[topology/pod-{{Pod}}/protpaths-{{Leaf1}}-{{Leaf2}}/pathep-[{{PolGrp}}]]",
            "encap": "vlan-{{VLAN_ID}}",
            "instrImedcy": "immediate",
            "mode": "{{Mode}}",
            "status": "{{Status}}"
        }
    }
}

 

 

{{Tenant}} = the tenant

{{ANP}} = the ANP

{{EPG}} = the EPG

{{Pod}} = pod #

{{Leaf1}} = the node #

{{Leaf2}} = the node #

 

{{PolGrp}} = the VPC interface policy group name

{{VlanID}} = the vlan #

{{Mode}} = "regular" for a standard tagged dot1q trunk configuration (

{{Status}} = "created" (other options are "created,modified", "modified" or "deleted")

 

Your CSV would look something like this:

Tenant ANP EPG Vlan_ID Pod Leaf1 Leaf2 PolGrp Mode Status
INTERNAL  NETCENTRIC_ANP  EPG_VLAN0200  200  1 203 204 VPC_UCS_FI_100A  regular created,modified

cmaskey
Level 1
Level 1

This is great. Is there anyone who has deployed Static Epg from Terraform. Any help is appriciated. 

Thank you. 

Review Cisco Networking for a $25 gift card

Save 25% on Day-2 Operations Add-On License