Re: Restarting Infoblox using API giving error
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2022 08:22 AM
This widget could not be displayed.
This widget could not be displayed.
Try this, for initiating the restart:
$niosip = "192.168.1.2" $niosuser = "admin" $niospw = "infoblox" $wapiver = "v2.10" $resturl = 'https://' + $niosip + '/wapi/' + $wapiver + '/request' $resturl $data = ' [ { "method":"GET", "object":"grid", "assign_state": {"grid_ref": "_ref" }, "enable_substitution": true }, { "method":"POST", "object": "##STATE:grid_ref:##", "enable_substitution": true, "args":{"_function":"restartservices"}, "data":{ "mode":"GROUPED", "restart_option":"RESTART_IF_NEEDED" } } ]' $json = $data | ConvertTo-Json $json $cred = New-Object PSCredential $niosuser, ($niospw | ConvertTo-SecureString -AsPlainText -Force) add-type @" using System.Net; using System.Security.Cryptography.X509Certificates; public class IDontCarePolicy : ICertificatePolicy { public IDontCarePolicy() {} public bool CheckValidationResult( ServicePoint sPoint, X509Certificate cert, WebRequest wRequest, int certProb) { return true; } } "@ [System.Net.ServicePointManager]::CertificatePolicy = new-object IDontCarePolicy $out = Invoke-RestMethod -Uri $resturl -Method Post -Credential $cred -Body $data -ContentType 'application/json'
And try this to monitor the restart status of all the appliances:
$niosip = "192.168.1.2" $niosuser = "admin" $niospw = "infoblox" $wapiver = "v2.10" $resturl = 'https://' + $niosip + '/wapi/' + $wapiver + '/request' $resturl $data = ' [ { "method":"GET", "object":"grid", "assign_state": {"grid_ref": "_ref" }, "enable_substitution": true }, { "method":"POST", "object": "##STATE:grid_ref:##", "enable_substitution": true, "args":{"_function":"restartservices"}, "data":{ "mode":"GROUPED", "restart_option":"RESTART_IF_NEEDED" } } ]' $json = $data | ConvertTo-Json $json $cred = New-Object PSCredential $niosuser, ($niospw | ConvertTo-SecureString -AsPlainText -Force) add-type @" using System.Net; using System.Security.Cryptography.X509Certificates; public class IDontCarePolicy : ICertificatePolicy { public IDontCarePolicy() {} public bool CheckValidationResult( ServicePoint sPoint, X509Certificate cert, WebRequest wRequest, int certProb) { return true; } } "@ [System.Net.ServicePointManager]::CertificatePolicy = new-object IDontCarePolicy $out = Invoke-RestMethod -Uri $resturl -Method Post -Credential $cred -Body $data -ContentType 'application/json'
Who Me Too'd this solution