Who Me Too'd this solution

Re: Restarting Infoblox using API giving error
Moderator
Moderator
Posts: 321
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'

View solution in original post

Who Me Too'd this solution