Cisco ACI – Configuring by POSTing JSON

If you are configuring Cisco ACI datacenter fabric it will sooner or later get to the point that you need to configure multiple objects inside the GUI which will, by using the click-n-click method, take a huge amount of time.

While using POSTMAN to create multiple objects of the same type is the preferred method that everybody is speaking about (because you can generate REST API calls using Python or something similar), the quickest way to do it is using POST of JSON configuration file directly through the GUI.

POSTing JSON config example

As described above, the POST of JSON for some simple yet repetitive configuration is the way to go. Let’s see how it’s done:

Creating multiple BDs inside a tenant in Cisco ACI:

    1. You enter the “test” tenant and save the JSON config of your existing environment – right click on the tenant name and select Save As:
      Cisco ACI - Save json config

      Cisco ACI – Save JSON config

      After Save As config is selected ACI will ask you which kind of config format you would like to download. We are selecting the whole configuration in JSON format by selecting the things below:

      Cisco ACI - Save json config

      Cisco ACI – Save JSON config

       

  1. After you save the config in this way you can open the JSON file to see what’s inside: You see that you downloaded a JSON for a tenant that has no objects created so it is basically empty containing only the placeholders for objects that you want to create.
    Cisco ACI - Empty json file

    Cisco ACI – Empty JSON file

     

  2. In order to ease your orientation inside the JSON file (if you are not an expert in Cisco ACI configuration tree) you should go back to Cisco ACI APIC GUI and create first two objects in Bridge Domains so you see how they look like in JSON file:
    Cisco ACI - Create BD

    Cisco ACI – Create BD

    Add subnet to that BD:

    Cisco ACI - Add subnet to BD

    Cisco ACI – Add subnet to BD

     

  3. Create another one in the same way and name is VLAN2-BD in our example.
  4. Save the json again:
    Cisco ACI - Save json config

    Cisco ACI – Save json config

     

  5. Open that new JSON file to see two BDs that you created:
    Cisco ACI - Open json

    Cisco ACI – Open JSON

  6. Take a look and try to find two BD configurations inside this JSON. You can safely enter blank lines to make the thing more readable – you will soon realize that each BD config starts with “fvBD” attribute:
    Cisco ACI - Edit json by pushing every BD config in its own line

    Cisco ACI – Edit JSON by pushing every BD config in its own line

  7. Turn Word wrap off inside notepad++ or Atom on OSX so that each BD gets its own line of config in the edit and then copy-paste the lines so many times how many BDs you want to create:
    Cisco ACI - Edit json

    Cisco ACI – Edit JSON

  8. Scroll to the right to find DB name attribute:
    Cisco ACI - Edit json and change names of BDs

    Cisco ACI – Edit JSON and change names of BDs

  9. Scroll more to find BD subnet ip and edit it for each BD:
    Cisco ACI - Edit json and change subnet IP of BDs

    Cisco ACI – Edit JSON and change subnet IP of BDs

     

  10. Save the JSON file.
  11. POST the JSON file by POST command on the tenant object:
    Cisco ACI - POST json

    Cisco ACI – POST JSON

     

  12. Select the JSON file and POST the JSON:
    Cisco ACI - POST json

    Cisco ACI – POST JSON

     

  13. Cisco ACI APIC will read the JSON and add to the configuration all objects that do not exist:
Cisco ACI - json config done

Cisco ACI – JSON config done

Note that the POST of json file will not delete a thing. It will only add the objects and their configuration if those objects are missing. POST cannot be used to delete any od the configuration and it can be used only to create or edit existing objects and their attributes.

What is the reasoning behind that way of doing this and not API call?

If you need to get those objects created fast, and you are not planning to do that kind od changes often, creation of multiple objects at once is easier with POST of JSON in the way described below.

POST of JSON is quicker because you don’t need to bother with going through REST calls generation and all that Python process of code generation for something you will do only once or twice.

 

One Response

  1. Robert Pepple January 29, 2021

Leave a Reply