Reply

Multiple Object in Python

New Member
Posts: 1
3090     0

Hi!

 

I need help with one case. I would like to get all hosts from some network where i have name of this network.

 

I work with Python. I also see that in infoblox is option to use multiple object method but i dont know how to use it with Python:/

 

some example:

 

curl -k -u admin:infoblox -H ‘content-type:application/json’ -X POST “https://127.0.0.1/wapi/v2.10/request” – d ‘[{“method”: “STATE:ASSIGN”,”data”:{“member_name”:”member1.localdomain”}},{“method”:”GET”,”object”: “member:dhcpproperties”,”data”: {“host_name”:”##STATE:member_name:##”},”assign_state”: {“host_ref”: “_ref”},”enable_substitution”: true,”discard”: true},{ “method”: “PUT”, “object”: “##STATE:host_ref:##”,”enable_substitution”: true,”data”: {“enable_dhcp”:true}},{“method”: “STATE: DISPLAY”}]’

 

how to transfer this to: 

 

data = {
    '*Name':'ABC'
    ,'_return_fields':'comment,disable,members,enable_ddns,network,extattrs'
    ,'_return_as_object':1
}
resp = requests.get(link,params=data, auth = ("login","pass"),verify=False)

 

It will be realy helpfull if anyone could give me any of example how to use this method.

 

 

Best regards,

Filip

Re: Multiple Object in Python

Adviser
Posts: 181
3091     0

Hi,

 

Could you please try this and see if it works for your specific request?

import requests
requests.packages.urllib3.disable_warnings() # Disable SSL warnings in requests #
url = "https://127.0.0.1/wapi/v2.7/request"
payload = "[{\"method\": \"GET\",\"object\": \"network\",\"data\": {\"name\":\"ABC\"},
 \"args\":{\"_return_fields\":\"comment,disable,members,enable_ddns,network,extattrs\"},{\"_return_as_object\":1}}]"
headers = {'content-type': "application/json"}
response = requests.request("POST", url, auth=('uname', 'pwd'), data=payload, headers=headers,
verify=False)

Regards,

Krishna

Showing results for 
Search instead for 
Did you mean: 

Recommended for You