Browse Source

Add 'Arya_sample.cli'

master
Andrey Prokhorov 1 year ago
parent
commit
0573095868
1 changed files with 38 additions and 0 deletions
  1. +38
    -0
      Arya_sample.cli

+ 38
- 0
Arya_sample.cli View File

@ -0,0 +1,38 @@
$ 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)

Loading…
Cancel
Save