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

APIC configuration through Python for beginners

Dear Friends,

Coming into from Network Engineer background ,I am looking for a direction on how to start APIC configuration

through python   .  

Following Tips which i would expect from the ACI community experts.

  • Basic/High Level understanding about Python.
  • Sample Template to create Tenants/VRF/BD/EPG.,etc  using python  .
  • Sample template to integrate L4-L7 services & VMWARE using python.

I tried to prepare a template which worked when was executed, but do not understand the concept used for it.

+++++++++++++++++++++++++++++++++++++++   Scirpt output  ++++++++++++

host: 198.18.133.200
name: admin
passwd: C1sco12345

tests:

- type: file
path: /ppi/node/mo/.xml
file: F5_Scripts/F5DevicePackage-149D.zip
pass: "This script will import the F5 device package."
check: "To verify that the device package is imported, go to L4-L7 Services --> Packages and expand Device Types."

- type: xml
path: /api/node/mo/.xml
file: F5_Scripts/CreateL4L7Device-mgmt.xml
pass: "This script will create the shared L4-L7 Device within the mgmt tenant."
check: "TBC."


- type: xml
path: /api/node/mo/.xml
file: F5_Scripts/CreateTenant-DXB11.xml
pass: "This script creates a new tenant name DXB11."
check: "To verify the creation of the tenant, go to Tenants and select DXB11. A private network was created in this tenant and can be verified under this tenant's Networking section."

- type: xml
path: /api/node/mo/.xml
file: F5_Scripts/CreateBD-DXB.xml
pass: "This script creates a new tenant name DXB11."
check: "To verify the creation of the tenant Bridge Domains, go to Tenants and select DXB11. Two bridge domains were created in this tenant and can be verified under this tenant's Networking section."

- type: xml
path: /api/node/mo/.xml
file: F5_Scripts/CreateContract-DXB11.xml
pass: "This script will create a contract for tenant DXB11."
check: "TBC."


- type: xml
path: /api/node/mo/.xml
file: F5_Scripts/CreateEPG-DXB.xml
pass: "This script create an EPG for tenant DXB11."
check: "TBC."

- type: xml
path: /api/node/mo/.xml
file: F5_Scripts/CreateWebGraphTemplate-DXB11.xml
pass: "This script create service graph template webGraph for tenant DXB11."
check: "To verify go to Tenants --> DXB11 Then expand L4-L7 Services --> L4-L7 Service Graph Templates."

- type: xml
path: /api/node/mo/.xml
file: F5_Scripts/CreateWebGraph1Template-DXXB11.xml
pass: "This script create service graph template webGraph1 for tenant DXB11."
check: "To verify go to Tenants --> DXB11. Then expand L4-L7 Services --> L4-L7 Service Graph Templates."


- type: xml
path: /api/node/mo/.xml
file: F5_Scripts/AttachWebGraph-LAX.xml
pass: "This script attached the WebGraph for tenant LAX."
check: "To verify the creation of the imported device cluster, go to Tenants --> LAX. Then expand Security Policies --> Contracts --> http subject. Then expand L4-L7 Services --> Deployed Service Graph."

- type: xml
path: /api/node/mo/.xml
file: F5_Scripts/AttachWebGraph1-LAX.xml
pass: "This script attached the webGraph for tenant LAX."
check: "To verify the creation of the imported device cluster, go to Tenants > LAX. Then expand Security Policies > Contracts > https subject. Then expand L4-L7 Services > Deployed Service Graph."

2) <fvTenant dn="uni/tn-DXB11" name="DXB11" status="created">
<fvCtx pcEnfPref="enforced" ownerTag="" ownerKey="" name="DXBctx1" knwMcastAct="permit" dn="uni/tn-DXB11/ctx-DXBctx1" descr=""/>
</fvTenant>

3)Create BD

<fvTenant dn="uni/tn-DXB11" name="DXB11">
<fvBD unkMcastAct="flood" unkMacUcastAct="proxy" unicastRoute="yes" ownerTag="" ownerKey="" name="DXB11BDApp" dn="uni/tn-DXB11/BD-DXB11BDApp" descr="" arpFlood="no">
<fvRsCtx tnFvCtxName="DXBctx1"/>
<fvSubnet name="" descr="" scope="private" ip="192.168.10.220/24" ctrl=""/>
</fvBD>
<fvBD unkMcastAct="flood" unkMacUcastAct="proxy" unicastRoute="yes" ownerTag="" ownerKey="" name="DXB11BDWeb" dn="uni/tn-DXB11/BD-DXB11BDWeb" descr="" arpFlood="no">
<fvRsCtx tnFvCtxName="DXBctx1"/>
<fvSubnet name="" descr="" scope="private" ip="10.10.10.220/24" ctrl=""/>
</fvBD>
</fvTenant>

4) <fvTenant dn="uni/tn-DXB11" name="DXB11">
<fvAp ownerTag="" ownerKey="" name="App1" descr="" prio="unspecified">
<fvAEPg name="app" descr="" prio="unspecified" matchT="AtleastOne">
<fvRsDomAtt tDn="uni/phys-dCloud-phy-domain" />
<fvRsBd tnFvBDName="DXB11BDApp"/>
</fvAEPg>
<fvAEPg name="web" descr="" prio="unspecified" matchT="AtleastOne">
<fvRsDomAtt tDn="uni/phys-dCloud-phy-domain"/>
<fvRsBd tnFvBDName="DXB11BDWeb"/>
</fvAEPg>
</fvAp>
</fvTenant>

Thank you for your valuable feedback.

Cheer, Akber.

 

1 Reply 1

Venkata Naveen Chapa
Cisco Employee
Cisco Employee

Hi Akber, 

Have you installed Cisco Pyhton SDK for programming APIC using python ? 

From what I understood, For each configuration there is a template which upon invoking is taking certain actions. 

file: F5_Scripts/CreateTenant-DXB11.xml --> Creates tenant when this xml is called. 

2) <fvTenant dn="uni/tn-DXB11" name="DXB11" status="created">
<fvCtx pcEnfPref="enforced" ownerTag="" ownerKey="" name="DXBctx1" knwMcastAct="permit" dn="uni/tn-DXB11/ctx-DXBctx1" descr=""/>
</fvTenant>

file: F5_Scripts/CreateEPG-DXB.xml --> To create EPG 

But these all are based on XML. If you want to use python for APIC configuration it would be best if you start from here. 

Getting started with python SDK:

https://developer.cisco.com/media/apicDcPythonAPI_v0.1/getting-started.html#

Installing python SDK:

https://developer.cisco.com/media/apicDcPythonAPI_v0.1/install.html#

Basic examples using python: 

https://developer.cisco.com/media/apicDcPythonAPI_v0.1/api-examples/index.html#before-you-begin

Overview of python configuration in github

https://github.com/datacenter/ACI/tree/master/configuration-python

Let me know if you need additional informaiton.

Hope this helps. 

Thanks 

Naveen. 

Thanks & Regards Venkata Naveen Chapa

Review Cisco Networking for a $25 gift card

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