cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1876
Views
0
Helpful
2
Replies

APIC VPC clean-up

Ruben31620
Frequent Visitor
Frequent Visitor

I'm running APIC v4.2(7f) and my ACI data center consists of Nexus 9300 Leaf switches. I have over a thousand VPC configurations that need to be cleaned up (removed) and I wanted to ask if there was a site where I can look at scripts in helping do this. I've been using Postman for running some scripts that I've used in the past. Any help is appreciated in directing me to a script site or providing recommendations on completing my task.

Thank you

1 Accepted Solution

Accepted Solutions

AshSe
VIP
VIP

Hello @Ruben31620 

Cleaning up a large number of VPC configurations in an ACI environment can be a daunting task, but using automation tools like Postman or Python scripts with the ACI REST API can make the process much more efficient. Since you're already familiar with Postman, you can leverage the ACI REST API to automate the removal of VPC configurations.

Here are some resources and steps to help you find or create scripts for this task:


1. Cisco DevNet

Cisco DevNet is an excellent resource for finding scripts, APIs, and tools for managing Cisco ACI environments. You can find sample scripts, API documentation, and community-contributed tools.


2. Postman Collections

If you're already using Postman, you can create or download Postman collections for ACI. These collections can include API calls for querying and deleting VPC configurations.

  • ACI Postman Collections:
    Look for pre-built Postman collections for ACI on GitHub or Cisco DevNet. For example:
    https://github.com/datacenter/ACI

  • Steps to Create a Postman Collection for VPC Cleanup:

    1. Use the ACI API to query existing VPC configurations (/api/node/class/fvRsVpc.json).
    2. Parse the response to identify the VPCs you want to delete.
    3. Use the DELETE method to remove the VPCs (/api/node/mo/uni/tn-[tenant]/ap-[app-profile]/epg-[epg-name].json).

3. GitHub Repositories

GitHub is another great place to find community-contributed scripts for ACI. Search for "Cisco ACI VPC cleanup" or similar terms.


4. Python Scripts with ACI Toolkit

The Cisco ACI Toolkit is a Python library that simplifies interactions with the ACI fabric. You can use it to script the removal of VPC configurations.

  • ACI Toolkit:
    https://github.com/datacenter/acitoolkit

  • Example Python Script for Deleting VPCs:

    from acitoolkit.acitoolkit import Session # Login to APIC apic_url = 'https://<APIC-IP>' username = '<USERNAME>' password = '<PASSWORD>' session = Session(apic_url, username, password) session.login() # Query all VPCs vpcs = session.get('/api/node/class/fvRsVpc.json').json()['imdata'] # Loop through and delete each VPC for vpc in vpcs: vpc_dn = vpc['fvRsVpc']['attributes']['dn'] print(f"Deleting VPC: {vpc_dn}") session.delete(f'/api/node/mo/{vpc_dn}.json') print("VPC cleanup complete.")
     

    Replace <APIC-IP>, <USERNAME>, and <PASSWORD> with your APIC details.


5. ACI Ansible Modules

If you're using Ansible for automation, Cisco provides ACI modules that can help manage and remove configurations.

  • Ansible ACI Modules:
    https://docs.ansible.com/ansible/latest/collections/cisco/aci/index.html

  • Example Playbook for Deleting VPCs:

    - name: Delete VPCs in ACI hosts: localhost tasks: - name: Remove VPC cisco.aci.aci_rest: host: "{{ apic_host }}" username: "{{ apic_username }}" password: "{{ apic_password }}" method: delete path: "/api/node/mo/{{ vpc_dn }}.json"
     

6. Best Practices

  • Backup Configuration: Before making bulk changes, ensure you have a backup of your ACI configuration.
  • Test in a Lab: Test your scripts in a lab environment to avoid accidental disruptions.
  • Use Filters: When querying VPCs, use filters to target only the configurations you want to delete.

By leveraging these resources and tools, you should be able to efficiently clean up your VPC configurations. If you need further assistance with a specific script or API call, feel free to ask!

View solution in original post

2 Replies 2

AshSe
VIP
VIP

Hello @Ruben31620 

Cleaning up a large number of VPC configurations in an ACI environment can be a daunting task, but using automation tools like Postman or Python scripts with the ACI REST API can make the process much more efficient. Since you're already familiar with Postman, you can leverage the ACI REST API to automate the removal of VPC configurations.

Here are some resources and steps to help you find or create scripts for this task:


1. Cisco DevNet

Cisco DevNet is an excellent resource for finding scripts, APIs, and tools for managing Cisco ACI environments. You can find sample scripts, API documentation, and community-contributed tools.


2. Postman Collections

If you're already using Postman, you can create or download Postman collections for ACI. These collections can include API calls for querying and deleting VPC configurations.

  • ACI Postman Collections:
    Look for pre-built Postman collections for ACI on GitHub or Cisco DevNet. For example:
    https://github.com/datacenter/ACI

  • Steps to Create a Postman Collection for VPC Cleanup:

    1. Use the ACI API to query existing VPC configurations (/api/node/class/fvRsVpc.json).
    2. Parse the response to identify the VPCs you want to delete.
    3. Use the DELETE method to remove the VPCs (/api/node/mo/uni/tn-[tenant]/ap-[app-profile]/epg-[epg-name].json).

3. GitHub Repositories

GitHub is another great place to find community-contributed scripts for ACI. Search for "Cisco ACI VPC cleanup" or similar terms.


4. Python Scripts with ACI Toolkit

The Cisco ACI Toolkit is a Python library that simplifies interactions with the ACI fabric. You can use it to script the removal of VPC configurations.

  • ACI Toolkit:
    https://github.com/datacenter/acitoolkit

  • Example Python Script for Deleting VPCs:

    from acitoolkit.acitoolkit import Session # Login to APIC apic_url = 'https://<APIC-IP>' username = '<USERNAME>' password = '<PASSWORD>' session = Session(apic_url, username, password) session.login() # Query all VPCs vpcs = session.get('/api/node/class/fvRsVpc.json').json()['imdata'] # Loop through and delete each VPC for vpc in vpcs: vpc_dn = vpc['fvRsVpc']['attributes']['dn'] print(f"Deleting VPC: {vpc_dn}") session.delete(f'/api/node/mo/{vpc_dn}.json') print("VPC cleanup complete.")
     

    Replace <APIC-IP>, <USERNAME>, and <PASSWORD> with your APIC details.


5. ACI Ansible Modules

If you're using Ansible for automation, Cisco provides ACI modules that can help manage and remove configurations.

  • Ansible ACI Modules:
    https://docs.ansible.com/ansible/latest/collections/cisco/aci/index.html

  • Example Playbook for Deleting VPCs:

    - name: Delete VPCs in ACI hosts: localhost tasks: - name: Remove VPC cisco.aci.aci_rest: host: "{{ apic_host }}" username: "{{ apic_username }}" password: "{{ apic_password }}" method: delete path: "/api/node/mo/{{ vpc_dn }}.json"
     

6. Best Practices

  • Backup Configuration: Before making bulk changes, ensure you have a backup of your ACI configuration.
  • Test in a Lab: Test your scripts in a lab environment to avoid accidental disruptions.
  • Use Filters: When querying VPCs, use filters to target only the configurations you want to delete.

By leveraging these resources and tools, you should be able to efficiently clean up your VPC configurations. If you need further assistance with a specific script or API call, feel free to ask!

Ruben31620
Frequent Visitor
Frequent Visitor

Thank you AshSE, very helpful and exactly what I was needing!!

Review Cisco Networking for a $25 gift card

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