cancel
Showing results for 
Search instead for 
Did you mean: 
cancel

Who Me Too'd this topic

How do I get a specific child of a Mo using subtree query in cobra SDK?

dyoshiha
Cisco Employee
Cisco Employee

I wrote the following code to get all BDs in a specified tenant.

However, I got the error message like: AttributeError: 'list' object has no attribute 'BD'

Could someone tell me what is the problem?

Reference:

Examples — Cisco APIC Python API 0.1 documentation

APIC version: 1.1(3f)

---

from cobra.mit.access import MoDirectory

from cobra.mit.session import LoginSession

from cobra.mit.request import DnQuery

from cobra.model.fv import Tenant, Ctx, BD

session = LoginSession('http://1.1.1.1', 'admin', 'cisco')

moDir = MoDirectory(session)

moDir.login()

dnQuery = DnQuery('uni/tn-TENANT')

dnQuery.subtree = 'children'

tenantMo = moDir.query(dnQuery)

for bdMo in tenantMo.BD:

    print str(bdMo.dn)

Who Me Too'd this topic