- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
how to restartservices via the Infoblox_client
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2022 02:40 AM
Hi,
does soembody has an example on how to use the Grid restartservice function via the Infoblox_client?
Regards,
Remco
Solved! Go to Solution.
Re: how to restartservices via the Infoblox_client
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2022 02:56 AM - edited 10-12-2022 03:22 AM
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"}'
Re: how to restartservices via the Infoblox_client
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2022 01:01 AM - edited 10-14-2022 01:04 AM
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
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2022 05:10 AM
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
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2022 05:52 AM
Thank, that was the info I was looking for.
Re: how to restartservices via the Infoblox_client
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2022 11:43 PM
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
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2022 06:21 AM
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
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2022 07:29 AM
Ok clear, I had the same issue.