Infoblox’s global team of threat hunters uncovers a DNS operation with the ability to bypass traditional security measures and control the Great Firewall of China. Read about “Muddling Meerkat” and the many other threat actors discovered by Infoblox Threat Intel here.

API & Integration, DevOps,NetOps,SecOps

Who Me Too'd this solution

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