cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1653
Views
5
Helpful
1
Replies

Cobra SDK for ACI - Error on removeMO(), when try to remove Tenant

tumarha
Level 1
Level 1

I try to test add and remove Tenant by using Cobra, but it return

Traceback (most recent call last):
File "c:/Users/wisit.p.DCS/Documents/Python_temp/test002.py", line 48, in
cfgRequest.removeMo(fvTenantMo)
File "c:\python27\lib\site-packages\acicobra-3.0_1k-py2.7.egg\cobra\mit\request.py", line 823, in removeMo
del self.__configMos[mo.dn]
KeyError: <cobra.mit.naming.Dn object at 0x03B864D0>

here are my code

fvTenantMo = Tenant(uniMo, '4444')
cfgRequest = ConfigRequest()
cfgRequest.addMo(fvTenantMo)
moDir.commit(cfgRequest)
==>Add complete, I can see new tenant on APIC GUI

fvTenantMo = moDir.lookupByDn((r'uni/tn-4444'))
cfgRequest = ConfigRequest()
cfgRequest.removeMo(fvTenantMo)
moDir.commit(cfgRequest)
==> I found error as above message

Please help to give me some advice.

Best regards
Tumarha

1 Reply 1

murasubr
Cisco Employee
Cisco Employee
fvTenantMo = Tenant(uniMo, 'MyTenantName')
fvTenantMo.delete()
tenantCfg = ConfigRequest()
tenantCfg.addMo(fvTenantMo)
moDir.commit(tenantCfg)