Reply

how to restartservices via the Infoblox_client

New Member
Posts: 6
3453     1

Hi,

 

does soembody has an example on how to use the Grid restartservice function via the Infoblox_client?

 

Regards,

 

Remco

 

 

Re: how to restartservices via the Infoblox_client

[ Edited ]
Superuser
Posts: 38
3453     1

Hi Remco,

 

If you are looking for the API example to use the function, I have put the code snippet for that below.

 

curl -k -u admin:infoblox -H 'content-type: application/json' -X POST "https://grid-master/wapi/v2.12/grid/b25lLmNsdXN0ZXIkMA:Infoblox?_function=restartservices" -d '{"service_option": "ALL", "restart_option":"RESTART_IF_NEEDED"}'
Shukran

Re: how to restartservices via the Infoblox_client

[ Edited ]
New Member
Posts: 6
3453     1

Hi,

 

I know how to do an API call to restartservices, but our automation Python scripts are using the infoblox_client and would like to also use this for the service-restart instaed of defining the API call ourself in the script.

 

I did find this definition in the the Grid class:

 

class Grid(InfobloxObject):

    ...

    def restartservices(self, *args, **kwargs):
       return self._call_func("restartservices", *args, **kwargs)

 

But it's unclear to me how to use this function.

Re: how to restartservices via the Infoblox_client

Moderator
Moderator
Posts: 321
3453     1

Here's a brief example:

 

#!/usr/bin/env python3

from infoblox_client import connector
from infoblox_client import objects

gm      = '192.168.1.2'
user    = 'admin'
passwd  = 'infoblox'

""" start Infoblox session """

opts = {'host': gm, 'username': user, 'password': passwd, 'silent_ssl_warnings': 1}
conn = connector.Connector(opts)

""" get reference to grid """

grid = conn.get_object('grid')
grid_ref = grid[0]['_ref']

func_data = {
    "services": ["ALL"],
    "restart_option": "RESTART_IF_NEEDED",
}

result = conn.call_func('restartservices', grid_ref, func_data)

Re: how to restartservices via the Infoblox_client

New Member
Posts: 6
3453     1

Thank, that was the info I was looking for.

Re: how to restartservices via the Infoblox_client

New Member
Posts: 6
3453     1

The code exmaple you shared is working, but can you explain why you are not using the defined function.

 

    def restartservices(self, *args, **kwargs):
       return self._call_func("restartservices", *args, **kwargs)

 

but are directly calling the _call_func?

 

Regards,

 

Remco

Re: how to restartservices via the Infoblox_client

Moderator
Moderator
Posts: 321
3453     1

I coudn't get it to work that way, I tried a few different ways but kept getting messages like "AttributeError: 'Connector' object has no attribute '_call_func'".

Re: how to restartservices via the Infoblox_client

New Member
Posts: 6
3453     1

Ok clear, I had the same issue.

Showing results for 
Search instead for 
Did you mean: 

Recommended for You