datacenter / cobra

Cobra - Python bindings for the ACI REST API
Other
88 stars 41 forks source link

how to use DeploymentQuery, when i met rsp-subtree-include=full-deployment. #133

Open shoujche opened 6 years ago

shoujche commented 6 years ago

Hi team, when i access this rest api:node/mo/uni/phys-Bare-Domain-Chenzli.json?rsp-subtree-include=full-deployment&target-path=ADomPToEthIf as you see, i must use DeploymentQuery to query it, becasue rsp-subtree-include=full-deployment the codes: polUni = cobra.model.pol.Uni('') physDomP = cobra.model.phys.DomP(polUni, name=self.kwargs['phys_domain'])

    dnQuery = DeploymentQuery(physDomP.dn)
    dnQuery.targetPath ='ADomPToEthIf'
    physDomPs = self.session.query(dnQuery)

but when i put /uni/phys-Bare-Domain-Chenzli DN in DelpoymentQuery. it still return /uni/phys-Bare-Domain-Chenzli DN so i cannot get any results , but the request rest api is ok. i guess this Query is special, right? i hope you can help me , i'm also cisco employee, thanks. my ccid: shoujche

camrossi commented 4 years ago

Not sure if you still need help since was 1y ago but I got this working today in my lab with this code:

print 'Getting all Phys Dom'
q1 = cobra.mit.request.ClassQuery('physDomP')
pDomains = md.query(q1)

#Get the deployment Status for the Physical Domains:
for pDom in pDomains:
    print(pDom.dn)
    #Retruns a PhysDom Deployment object with, as children, the leaves associated to it
    q2 = cobra.mit.request.DeploymentQuery(pDom.dn)
    depStatus = md.query(q2)
    for deployedPhysDom in depStatus:
        for node in deployedPhysDom.children:
            print(node.nodeId)