cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
354
Views
0
Helpful
1
Replies

Create multiple IPGs with GUI POST

Karol Farago
Level 1
Level 1

Hello everyone,

I'm trying to create new Interface Policy Groups (IPG) in ACI with POSTing in GUI.
When I'm posting only one new IPG - its working, but when I POST 7 new IPGs, only the first one is created.


JSON file is valid, this was tested in JSON validator.

Attaching the JSON file as .txt, as JSON file is not accepted for upload here.

Parent DN for POST is: uni/infra/funcprof/

POST_test.png

 

Thank for any suggestion

1 Reply 1

AshSe
VIP
VIP

Hi @Karol Farago 

It sounds like you are encountering an issue where only the first Interface Policy Group (IPG) is being created when you attempt to POST multiple IPGs in a single request. This could be due to several reasons, such as the way the JSON payload is structured, the API endpoint you are using, or limitations in the APIC's handling of bulk requests.

Here are some steps to troubleshoot and resolve the issue:

 

  1. Check JSON Structure:

 

Ensure that your JSON payload is correctly structured for multiple IPGs. Each IPG should be a separate object within a list. Here’s an example of how the JSON should be structured:

 

{

  "polUni": {

    "children": [

      {

        "infraAccPortGrp": {

          "attributes": {

            "name": "IPG1"

          },

          "children": []

        }

      },

      {

        "infraAccPortGrp": {

          "attributes": {

            "name": "IPG2"

          },

          "children": []

        }

      },

      {

        "infraAccPortGrp": {

          "attributes": {

            "name": "IPG3"

          },

          "children": []

        }

      }

      // Add more IPGs as needed

    ]

  }

}

 

2. Use the Correct API Endpoint:

 

Make sure you are using the correct API endpoint for creating Interface Policy Groups. The endpoint should be something like:

https://<APIC-IP>/api/node/mo/uni/infra/funcprof.json

 

3Check for API Rate Limits:

 

Cisco APIC may have rate limits or restrictions on the number of objects that can be created in a single API call. If you are hitting a rate limit, you might need to break your requests into smaller batches.

 

4. Verify API Response:

 

Check the response from the APIC when you POST the JSON payload. The response should give you clues about any errors or issues. Look for any error messages or status codes that indicate why the additional IPGs are not being created.

 

5. Use a Loop for Multiple Requests:

 

If the APIC cannot handle multiple IPGs in a single request, you can script the creation of IPGs in a loop, sending one request per IPG. Here’s an example using Python and the requests library:

import requests

import json

 

# APIC credentials and URL

apic_url = "https://<APIC-IP>/api/node/mo/uni/infra/funcprof.json"

username = "<username>"

password = "<password>"

 

# List of IPGs to create

ipgs = ["IPG1", "IPG2", "IPG3", "IPG4", "IPG5", "IPG6", "IPG7"]

 

# Login to APIC

login_url = "https://<APIC-IP>/api/aaaLogin.json"

login_payload = {

    "aaaUser": {

        "attributes": {

            "name": username,

            "pwd": password

        }

    }

}

session = requests.Session()

response = session.post(login_url, json=login_payload, verify=False)

response.raise_for_status()

 

# Create each IPG

for ipg in ipgs:

    payload = {

        "infraAccPortGrp": {

            "attributes": {

                "name": ipg

            },

            "children": []

        }

    }

    response = session.post(apic_url, json=payload, verify=False)

    if response.status_code == 200:

        print(f"Successfully created {ipg}")

    else:

        print(f"Failed to create {ipg}: {response.text}")

 

# Logout from APIC

logout_url = "https://<APIC-IP>/api/aaaLogout.json"

session.post(logout_url, verify=False)

 

6. Check APIC Logs:

 

If the above steps do not resolve the issue, check the APIC logs for any errors or warnings that might indicate why the additional IPGs are not being created.

 

AshSe

Please rate this post if it was helpful; your feedback is appreciated!

Review Cisco Networking for a $25 gift card

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