def test_tn_cleanup(self, apics, certobject, userobject): if userobject.user == 'rouser': return apic = apics[0] user = apics[2] password = apics[3] secure = False if apics[1] == 'False' else True uni = Uni('') fvTenant = Tenant(uni, name='t') fvTenant.delete() fvBD = BD(fvTenant, 't-bd') fvBD.delete() fvAp = Ap(fvTenant, 't-app') fvAp.delete() session = LoginSession(apic, user, password, secure=secure) moDir = MoDirectory(session) moDir.login() cr = ConfigRequest() cr.addMo(fvTenant) r = moDir.commit(cr) assert r.status_code == 200
def test_tn_cleanup(self, apics, certobject, userobject): if userobject.user == 'rouser': return apic = apics[0] user = apics[2] password = apics[3] secure = False if apics[1] == 'False' else True uni = Uni('') fvTenant = Tenant(uni, name='t') fvTenant.delete() fvBD = BD(fvTenant, 't-bd') fvBD.delete() fvAp = Ap(fvTenant, 't-app') fvAp.delete() session = LoginSession(apic, user, password, secure=secure) moDir = MoDirectory(session) moDir.login() cr = ConfigRequest() cr.addMo(fvTenant) r = moDir.commit(cr) assert r == []
# Obtain the list of tenants and print their names cq = ClassQuery('fvTenant') tenants = md.query(cq) for tenant in tenants: print tenant.name raw_input('Press Enter to continue...') # Define a new tenant polUni = md.lookupByDn('uni') tenant = Tenant(polUni, 'Some-New-Tenant') tenant.descr = 'This tenant was created by cobra' # Push the new tenant configuration to the APIC cr = ConfigRequest() cr.addMo(polUni) md.commit(cr) raw_input('Press Enter to continue...') # Delete the newly created tenant tenant.delete() cr = ConfigRequest() cr.addMo(polUni) md.commit(cr) # Log out of the APIC md.logout()