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?
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://188.8.131.52', 'admin', 'cisco')
moDir = MoDirectory(session)
dnQuery = DnQuery('uni/tn-TENANT')
dnQuery.subtree = 'children'
tenantMo = moDir.query(dnQuery)
for bdMo in tenantMo.BD:
Request to post your question under APIC community. Also for related information please refer -
Thanks and Regards,
To add to gcheria's answer, the way you can do this is to add a subclass filter to the query that you're doing. This is outlined in the link that they referenced, under the the 4. User query() method section.
You could use the ClassQuery instead of the DN query, which would look like this -
classDn = 'uni/tn-TENANT' + '/fvBD'
classQuery = ClassQuery(classDn)
tenantBdMoList = moDir.query(classQuery)
for tenantBd in tenantBdMoList: