You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.3 KiB
Plaintext

$ cat source_post | arya.py -s
#!/usr/bin/env python
'''
Autogenerated code using arya.py
Original Object Document Input:
{"fvTenant":{"attributes":{"dn":"uni/tn-Prox_Tenant","name":"Prox_Tenant","rn":"tn-Prox_Tenant","status":"created"},"children":[{"fvCtx":{"attributes":{"dn":"uni/tn-Prox_Tenant/ctx-Prox_VRF","name":"Prox_VRF","rn":"ctx-Prox_VRF","status":"created"},"children":[]}}]}}
'''
raise RuntimeError('Please review the auto generated code before ' +
'executing the output. Some placeholders will ' +
'need to be changed')
# list of packages that should be imported for this code to work
import cobra.mit.access
import cobra.mit.request
import cobra.mit.session
import cobra.model.fv
import cobra.model.pol
from cobra.internal.codec.xmlcodec import toXMLStr
# log into an APIC and create a directory object
ls = cobra.mit.session.LoginSession('https://1.1.1.1', 'admin', 'password')
md = cobra.mit.access.MoDirectory(ls)
md.login()
# the top level object on which operations will be made
topMo = cobra.model.pol.Uni('')
# build the request using cobra syntax
fvTenant = cobra.model.fv.Tenant(topMo, name='Prox_Tenant')
fvCtx = cobra.model.fv.Ctx(fvTenant, name='Prox_VRF')
# commit the generated code to APIC
print(toXMLStr(topMo))
c = cobra.mit.request.ConfigRequest()
c.addMo(topMo)
md.commit(c)