You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 11, 2023. It is now read-only.
I am trying to generate a python script that upgrades the APIC cluster. I am using Arya to build the script from the following JSON code from the API inspector:
Ben, thanks for pointing this out. Looks like the GUI generated JSON is passing the naming properties in through the DN, which doesn't get populated as attributes in the JSON dictionary, hence the missing parameter.
Let's keep this issue open for now, so I can track this for some major rework I'll be doing in arya.
In short the code fix here will be to use the Dn parsing from Cobra, extract naming properties and pass those to the object constructors, but of course I don't want cobra to be a dependency so the fallback code will have to do what's currently in place, meaning this issue will remain if cobra isn't installed on a system.
I am trying to generate a python script that upgrades the APIC cluster. I am using Arya to build the script from the following JSON code from the API inspector:
{"ctrlrInst":{"attributes":{"dn":"uni/controller","status":"modified"},"children":[{"firmwareCtrlrFwP":{"attributes":{"dn":"uni/controller/ctrlrfwpol","version":"apic-1.1(1j)"},"children":[]}},{"maintCtrlrMaintP":{"attributes":{"dn":"uni/controller/ctrlrmaintpol","adminSt":"triggered"},"children":[]}},{"trigSchedP":{"attributes":{"dn":"uni/controller/schedp-ConstSchedP","status":"modified"},"children":[{"trigAbsWindowP":{"attributes":{"dn":"uni/controller/schedp-ConstSchedP/abswinp-ConstAbsWindowP","date":"2015-06-23T02:16:16.402+00:00"},"children":[]}}]}}]}}
Arya built this:
import cobra.mit.access
import cobra.mit.request
import cobra.mit.session
import cobra.model.ctrlr
import cobra.model.firmware
import cobra.model.maint
import cobra.model.pol
import cobra.model.trig
from cobra.internal.codec.xmlcodec import toXMLStr
log into an APIC and create a directory object
ls = cobra.mit.session.LoginSession('https://10.221.79.101', 'admin', 'C!sco123')
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
ctrlrInst = cobra.model.ctrlr.Inst(topMo)
firmwareCtrlrFwP = cobra.model.firmware.CtrlrFwP(ctrlrInst, version=u'apic-1.1(1j)')
maintCtrlrMaintP = cobra.model.maint.CtrlrMaintP(ctrlrInst, adminSt=u'triggered')
trigSchedP = cobra.model.trig.SchedP(ctrlrInst)
trigAbsWindowP = cobra.model.trig.AbsWindowP(trigSchedP, date=u'2015-06-23T02:16:16.402+00:00')
commit the generated code to APIC
print toXMLStr(topMo)
c = cobra.mit.request.ConfigRequest()
c.addMo(topMo)
md.commit(c)
When I try and run the script I get the following error:
Traceback (most recent call last):
File "upgrade_apic.py", line 24, in
trigSchedP = cobra.model.trig.SchedP(ctrlrInst)
TypeError: init() takes at least 3 arguments (2 given)
Thanks
Ben
The text was updated successfully, but these errors were encountered: