infobloxopen/infoblox-client

Need to save output of the infoblox-client API call to a csv file

Closed this issue · 3 comments

I want to backup all the Extensible attributes for a Network ,NetworkContainer and host to a csv file.
May I know the way to do it with infoblox-client API

I am searching the objects using
"objects.Network.search()"
"objects.NetworkContainer.search()"

My code :
ib_network = objects.Network.search(connection, network='131.226.217.128/27', network_view='default', return_fields=['default', 'extattrs'])

ib_network_container = objects.NetworkContainer.search(connection, network='131.226.192.0/18', network_view='default', return_fields=['default', 'extattrs'])

I am storing the value into "ib_network" & "ib_network_container" variables

Hi @thepkumar28

We are working on a new release right now, we will look at this issue as soon as we get time.

Hi @thepkumar28,

    import csv

    # open the file in the write mode
    f = open('/Users/username/Documents/repo/infoblox-client/new.csv', 'w')

    # create the csv writer
    writer = csv.writer(f)
    response = objects.Network.search_all(conn, view='default', return_fields=['members'])
    # write a row to the csv file
    writer.writerow(response)

    # close the file
    f.close()

Let me know if this works for you?

Closing this ticket as there is no response from the user.