ONTAP Discussions

Request Ontap API 9.8

benji19xx
1,337 Views

Hello,

 

I want to obtain fpolicy information by REST API but unfortunately, with swagger I can retrieve only commons fields, not specific like send-buffer-size ( visible in advanced mode )

 

 fpolicy policy external-engine show -vserver DSI-FS1 -fields send-buffer-size
  (vserver fpolicy policy external-engine show)
vserver engine-name send-buffer-size
------- ----------- ----------------
DSI-FS1 fp_ex_eng   1048576

 

Do you know if this information can be retrieve with REST API ?

 

3 REPLIES 3

mbeattie
1,302 Views

Hi Ben,

 

There are fpolicy REST API's but the attribute you want to enumerate might not be available. You could use the CLI passthrough or resort to ZAPI until it's available in a future release. Here is the ZAPI syntax:

 

<?xml version="1.0" encoding="UTF-8"?>
<netapp  xmlns="http://www.netapp.com/filer/admin" version="1.201">
  <fpolicy-policy-external-engine-get-iter>
    <desired-attributes>
      <fpolicy-external-engine-info>
        <certificate-ca></certificate-ca>
        <certificate-common-name></certificate-common-name>
        <certificate-serial></certificate-serial>
        <engine-name></engine-name>
        <extern-engine-type></extern-engine-type>
        <is-resiliency-enabled></is-resiliency-enabled>
        <keep-alive-interval></keep-alive-interval>
        <max-connection-retries></max-connection-retries>
        <max-server-requests></max-server-requests>
        <port-number></port-number>
        <primary-servers>
          <ip-address></ip-address>
        </primary-servers>
        <recv-buffer-size></recv-buffer-size>
        <request-abort-timeout></request-abort-timeout>
        <request-cancel-timeout></request-cancel-timeout>
        <resiliency-directory-path></resiliency-directory-path>
        <resiliency-max-retention-duration></resiliency-max-retention-duration>
        <secondary-servers>
          <ip-address></ip-address>
        </secondary-servers>
        <send-buffer-size></send-buffer-size>
        <server-progress-timeout></server-progress-timeout>
        <session-timeout></session-timeout>
        <ssl-option></ssl-option>
        <status-request-interval></status-request-interval>
        <vserver></vserver>
      </fpolicy-external-engine-info>
    </desired-attributes>
    <max-records></max-records>
    <query>
      <fpolicy-external-engine-info>
        <certificate-ca></certificate-ca>
        <certificate-common-name></certificate-common-name>
        <certificate-serial></certificate-serial>
        <engine-name></engine-name>
        <extern-engine-type></extern-engine-type>
        <is-resiliency-enabled></is-resiliency-enabled>
        <keep-alive-interval></keep-alive-interval>
        <max-connection-retries></max-connection-retries>
        <max-server-requests></max-server-requests>
        <port-number></port-number>
        <primary-servers>
          <ip-address></ip-address>
        </primary-servers>
        <recv-buffer-size></recv-buffer-size>
        <request-abort-timeout></request-abort-timeout>
        <request-cancel-timeout></request-cancel-timeout>
        <resiliency-directory-path></resiliency-directory-path>
        <resiliency-max-retention-duration></resiliency-max-retention-duration>
        <secondary-servers>
          <ip-address></ip-address>
        </secondary-servers>
        <send-buffer-size></send-buffer-size>
        <server-progress-timeout></server-progress-timeout>
        <session-timeout></session-timeout>
        <ssl-option></ssl-option>
        <status-request-interval></status-request-interval>
        <vserver></vserver>
      </fpolicy-external-engine-info>
    </query>
    <tag></tag>
  </fpolicy-policy-external-engine-get-iter>
</netapp>

 

/Matt

If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

mbeattie
1,300 Views

Hi Ben,

 

Here is a PowerShell example of how to convert the ZAPI XML into code. I don't have a system with Fpolicy configured to test it against to display the output the ZAPI is executed and passes.

 

 

Param(
   [Parameter(Mandatory=$True, HelpMessage="The cluster name or IP Address")]
   [String]$Cluster,
   [Parameter(Mandatory=$True, HelpMessage="The vserver name")]
   [String]$VserverName,
   [Parameter(Mandatory=$True, HelpMessage="The fpolicy engine name")]
   [String]$FPolicyEngine,
   [Parameter(Mandatory = $True, HelpMessage = "The Credentials to authenticate to the cluster")]
   [System.Management.Automation.PSCredential]$Credential
)
#'------------------------------------------------------------------------------
Function Get-FPolicyBufferSize{
   Param(
      [Parameter(Mandatory = $True, HelpMessage = "The vserver name")]
      [String]$VserverName,
      [Parameter(Mandatory = $True, HelpMessage = "The fpolicy engine name")]
      [String]$FPolicyEngine
   )
   $request = @"
   <fpolicy-policy-external-engine-get-iter>
      <desired-attributes>
         <fpolicy-external-engine-info>
            <engine-name></engine-name>
            <send-buffer-size></send-buffer-size>
            <vserver></vserver>
         </fpolicy-external-engine-info>
      </desired-attributes>
      <query>
         <fpolicy-external-engine-info>
            <engine-name>$FPolicyEngine</engine-name>
            <vserver>$VserverName</vserver>
         </fpolicy-external-engine-info>
      </query>
   </fpolicy-policy-external-engine-get-iter>
"@
$request
   #'---------------------------------------------------------------------------
   #'Invoke the API request.
   #'---------------------------------------------------------------------------
   Try{
      $response = Invoke-NcSystemApi -VserverContext $VserverName -Request $request -ErrorAction Stop
   }Catch{
      Write-Warning -Message $("Failed enumerating FPolicy send buffer on vserver ""$VserverName"" on cluster ""$Cluster"". Error " + $_.Exception.Message)
      Break;
   }
   #'---------------------------------------------------------------------------
   #'Ensure the API response was sucessful.
   #'---------------------------------------------------------------------------
   [String]$command = @("fpolicy", "policy", "external-engine", "show", "-vserver", $VserverName, "-engine-name", $FPolicyEngine, "-fields", "send-buffer-size")
   If($response.results.status -eq "Passed"){
      Write-Host $("Executed Command`: " + $([String]::Join(" ", $command)))
   }Else{
      Write-Warning -Message "Failed Executing Command`: $command"
      Return $Null;
   }
   Return $response;
}#'End Function Get-FPolicyBufferSize.
#'------------------------------------------------------------------------------
#'Import the NetApp PSTK Module.
#'------------------------------------------------------------------------------
[String]$moduleName = "DataONTAP"
[String]$command = "Import-Module -Name $moduleName -ErrorAction Stop"
Try{
   Invoke-Expression -Command $command -ErrorAction Stop
   Write-Host "Executed Command: $command"
}Catch{
   Write-Warning -Message $("Failed Executing Command`: $command. Error " + $_.Exception.Message)
   Break;
}
#'------------------------------------------------------------------------------
#'Connect to the cluster
#'------------------------------------------------------------------------------
[String]$command = "Connect-NcController -Name $Cluster -HTTPS -Credential `$Credential -ErrorAction Stop"
Try{
   Invoke-Expression -Command $command -ErrorAction Stop | Out-Null
   Write-Host "Executed Command`: $command"  
}Catch{
   Write-Warning -Message $("Failed connecting to cluster ""$Cluster"". Error " + $_.Exception.Message)
   Break;
}
#'------------------------------------------------------------------------------
#'Enumerate the send buffer size for the vserver's FPolicy Engine. 
#'------------------------------------------------------------------------------
Try{
   $response = Get-FPolicyBufferSize -VserverName $VserverName -FPolicyEngine $FPolicyEngine -ErrorAction Stop 
}Catch{
   Write-Warning -Message $("Failed Enumerating FPpolicy buffer size on vserver ""$VserverName"" on ""$Cluster"". Error " + $_.Exception.Message)
   Break;
}
$response.result
#'------------------------------------------------------------------------------

 

 

The usage and output is something like...

 

PS C:\Scripts\PowerShell\Projects\FPolicy> .\FPolicy.ps1 -Cluster cluster1.testlab.local -VserverName vserver1 -FPolicyEngine policy1 -Credential $credential
Executed Command: Import-Module -Name DataONTAP -ErrorAction Stop
Executed Command: Connect-NcController -Name cluster1.testlab.local -HTTPS -Credential $Credential -ErrorAction Stop
Executed Command: fpolicy policy external-engine show -vserver vserver1 -engine-name policy1 -fields send-buffer-size

 

In theory it would display the send buffer results if FPolicy was configured.

Hope that helps

 

/Matt

 

If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

chenguanghui
14 Views

hello:

Some of the content of this article may help you

https://library.netapp.com/ecmdocs/ECMLP2874673/html/resources/fpolicy.html 

Public