QuestionQ422

Cisco Platforms and Development

Question Image

Refer to the exhibit. Drag the code options from the bottom to the boxes with missing code to add a subnet to each bridge domain in the Ten1 tenant. Not all options are used.

Drag & Drop
fvBD
fvTenant
ClassQuery
bdname
DnQuery
ClassName
commit
from cobra.model import fv
from cobra.mit.request import ClassQuery, DnQuery
import cobra.mit.access
import cobra.mit.session

tenname = "Ten1"
ls = cobra.mit.session.LoginSession(
    'https://10.100.1.200', "admin", "Lab123!3")

aci = cobra.mit.access.MoDirectory(ls)
aci.login()
c = cobra.mit.request.ConfigRequest()

qry1 =  (f'uni/tn-{tenname}')
fvTenant = aci.query(qry1)[0]

qry2 =  ("fvBD")
qry2.propFilter = f'and(wcard(fvBD.dn,"{fvTenant.dn}"))'
fvBDs = aci.query(qry2)

i=0
for fvBD in fvBDs:
    fvSubnet = cobra.model.fv.Subnet(  , ip=f'10.114.{i}.1/24')
    c.addMo(fvBD)
    aci.  (c)
    i+=
Explanation

DnQuery retrieves the tenant managed object by its DN, and ClassQuery("fvBD") obtains bridge-domain objects. An fv.Subnet is created as a child of each fvBD object. Adding the modified bridge domain to the configuration request and calling aci.commit(c) sends the changes to APIC.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!