Data Infrastructure Management Software Discussions

Highlighted

WFA Set Quota Command not Activating the Quota Status on Volumes

I'm using WFA to create a new qtree in an existing volume, and then using the 'Set Quota' command. The problem I'm having is it's not activating the quota. Here's a screenshot of the issue after going to 'Storage', then 'Quotas'. 

Quota_Status.jpg

You can see it show NA for the space usage. I have to go to the 'Quota Status on Volumes' tab and then click 'Deactivate' and 'Activate' for the volume where the quota resides. Then it will show correctly, like this:

Quota_Status2.jpg

How can I get WFA to handle this so I don't have to manually Deactivate/Activate?

3 REPLIES 3
Highlighted

Re: WFA Set Quota Command not Activating the Quota Status on Volumes

Hi,

 

Have you turned quotas off and on for the volume? Here are some commands for you.

 

Command to Turn quotas off or on:

 

 

#'------------------------------------------------------------------------------
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 Volume name")]
   [String]$VolumeName,
   [Parameter(Mandatory=$True, HelpMessage="The Volume Quota state. Valid options are 'enabled' or 'disabled'")]
   [ValidateSet("enabled","disabled")]
   [String]$QuotaState,
   [Parameter(Mandatory=$False, HelpMessage="The maximum number of ZAPI retry attempts")]
   [String]$ZapiRetryCount 
)
#'------------------------------------------------------------------------------
#'Connect to the cluster.
#'------------------------------------------------------------------------------
Connect-WFACluster $Cluster
#'------------------------------------------------------------------------------
#'Enumerate the Quota status for the volume.
#'------------------------------------------------------------------------------
Try{
   If($ZapiRetryCount){
      [String]$command = "Get-NcQuotaStatus -Volume $VolumeName -Vserver $VserverName -ZapiRetryCount $ZapiRetryCount -ErrorAction Stop"
   }Else{
      [String]$command = "Get-NcQuotaStatus -Volume $VolumeName -Vserver $VserverName -ErrorAction Stop"
   }
   $result = Invoke-Expression -Command $command -ErrorAction Stop
   Get-WFALogger -Info -Message "Executed Command`: $command"
   Get-WFALogger -Info -Message "Enumerated Quota Status for volume ""$VolumeName"" on vserver ""$VserverName"""
}Catch{
   Get-WFALogger -Error -Message $("Failed enumerating Quota Status for volume ""$VolumeName"" on vserver ""$VserverName"". Error " + $_.Exception.Message)
   Throw "Failed enumerating Quota Status for volume ""$VolumeName"" on vserver ""$VserverName"""
}
If($result){
   [String]$status = $result.Status
   Get-WFALogger -Info -Message "The Quota for volume ""$VolumeName"" is ""$status"" on vserver ""$VserverName"""
}Else{
   Throw "A Quota for volume ""$VolumeName"" on vserver ""$VserverName"" was not found"
}
#'------------------------------------------------------------------------------
#'Set the command to enable or disable the quota for the volume.
#'------------------------------------------------------------------------------
[String]$command = "Enable-NcQuota -Volume $VolumeName -VserverContext $VserverName "
If($ZapiRetryCount){
   [String]$command += "-ZapiRetryCount $ZapiRetryCount "
}
[String]$command += "-ErrorAction Stop"
#'------------------------------------------------------------------------------
#'Set the action to enable or disable the quota for the volume.
#'------------------------------------------------------------------------------
If($QuotaState -eq "enabled" -And $status -eq "off"){
   [Bool]$continue  = $True;
   [String]$command = $command.Replace("Disable", "Enable")
}
If($QuotaState -eq "enabled" -And $status -eq "on"){
   [Bool]$continue = $False;
}
If($QuotaState -eq "disabled" -And $status -eq "on"){
   [Bool]$continue  = $True;
   [String]$command = $command.Replace("Enable", "Disable")
}
If($QuotaState -eq "disabled" -And $status -eq "off"){
   [Bool]$continue = $False;
}
#'------------------------------------------------------------------------------
#'Enable or disable the quota for the volume if required.
#'------------------------------------------------------------------------------
If($continue){
   Try{
      Invoke-Expression -Command $command -ErrorAction Stop
      Get-WFALogger -Info -Message "Executed Command`: $command"
      If($QuotaState -eq "enabled"){
         Get-WFALogger -Info -Message "Enabled Quota for Volume ""$VolumeName"" on Vserver ""$VserverName"""
      }Else{
         Get-WFALogger -Info -Message "Disabled Quota for Volume ""$VolumeName"" on Vserver ""$VserverName"""
      }
   }Catch{
      Get-WFALogger -Error -Message $("Failed Executing Command`: $command. Error " + $_.Exception.Message)
      If($QuotaState -eq "enabled"){
         Throw "Failed enabling Quota for Volume ""$VolumeName"" to on vserver ""$VserverName"""
      }Else{
         Throw "Failed disabling Quota for Volume ""$VolumeName"" to on vserver ""$VserverName"""
      }
   }
}
#'------------------------------------------------------------------------------

command to wait for the quota to reach the desired state...

 

 

 

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 volume name")]
   [String]$VolumeName,
   [Parameter(Mandatory=$True, HelpMessage="The desired Quota sub status")]
   [ValidateSet("none")]
   [String]$QuotaSubStatus,
   [Parameter(Mandatory=$True, HelpMessage="The desired Quota state")]
   [ValidateSet("off","on")]
   [String]$QuotaState,
   [Parameter(Mandatory=$True, HelpMessage="The maximum number of seconds to wait for Quota operations")]
   [Long]$TimeOut,
   [Parameter(Mandatory=$True, HelpMessage="The maximum number of seconds to wait inbetween checking Quota operations")]
   [Long]$WaitInterval,
   [Parameter(Mandatory=$False, HelpMessage="The number of times to retry commands that return with errors that may succeed after a retry")]
   [Int]$ZapiRetryCount
)
#'------------------------------------------------------------------------------
Function Wait-QuotaStatus{
   Param(
      [Parameter(Mandatory=$True, HelpMessage="The vserver name")]
      [String]$VserverName,
      [Parameter(Mandatory=$True, HelpMessage="The volume name")]
      [String]$VolumeName,
      [Parameter(Mandatory=$True, HelpMessage="The desired Quota sub status")]
      [ValidateSet("none")]
      [String]$QuotaSubStatus,
      [Parameter(Mandatory=$True, HelpMessage="The desired Quota state")]
      [ValidateSet("off","on")]
      [String]$QuotaState,
      [Parameter(Mandatory=$True, HelpMessage="The maximum number of seconds to wait for Quota operations")]
      [Long]$TimeOut,
      [Parameter(Mandatory=$True, HelpMessage="The maximum number of seconds to wait inbetween checking Quota operations")]
      [Long]$WaitInterval,
      [Parameter(Mandatory=$False, HelpMessage="The number of times to retry commands that return with errors that may succeed after a retry")]
      [Int]$ZapiRetryCount
   )
   #'---------------------------------------------------------------------------
   #'Wait for the volume SnapMirror operation to complete or until the timeout is exceeded.
   #'---------------------------------------------------------------------------
   [Long]$waited           = 0
   [Long]$timeWaited       = $waited
   [Bool]$completionStatus = $False
   Do{
      [Long]$timeWaited += [Long]($waited + $waitInterval)
      #'------------------------------------------------------------------------
      #'Check the Quota status of the volume
      #'------------------------------------------------------------------------
      Try{
         If($ZapiRetryCount){
            [String]$command = "Get-NcQuotaStatus -Volume $VolumeName -Vserver $VserverName -ZapiRetryCount $ZapiRetryCount -ErrorAction Stop"
         }Else{
            [String]$command = "Get-NcQuotaStatus -Volume $VolumeName -Vserver $VserverName -ErrorAction Stop"
         }
         $result = Invoke-Expression -Command $command -ErrorAction Stop
         Get-WFALogger -Info -Message "Executed Command`: $command"
         Get-WFALogger -Info -Message "Enumerated Quota Status for volume ""$VolumeName"" on vserver ""$VserverName"""
      }Catch{
         Get-WFALogger -Error -Message $("Failed enumerating Quota Status for volume ""$VolumeName"" on vserver ""$VserverName"". Error " + $_.Exception.Message)
         Throw "Failed enumerating Quota Status for volume ""$VolumeName"" on vserver ""$VserverName"""
      }
      If($result){
         [String]$status    = $result.Status
         [String]$subStatus = $result.Substatus
         Get-WFALogger -Info -Message "The Quota for volume ""$VolumeName"" is ""$status"" with a sub status of ""$subStatus"" on vserver ""$VserverName"""
      }Else{
         Get-WFALogger -Error -Message "A Quota for volume ""$VolumeName"" on vserver ""$VserverName"" was not found"
         Return $completionStatus;
      }
      If(($status -eq $QuotaState) -And ($timeWaited -le $timeOut) -And $timeOut -gt 0){
         Break;
      }
      Start-Sleep -Seconds $waitInterval         
   }Until(($status -eq $QuotaState) -Or (($timeWaited -ge $timeOut) -And $timeOut -gt 0))
   #'---------------------------------------------------------------------------
   #'Display the destination volume state and set the completion status.
   #'---------------------------------------------------------------------------
   If(($status -eq $QuotaState -And $subStatus -eq $QuotaSubStatus) -And ($timeWaited -lt $timeOut)){
      [Bool]$completionStatus = $True
      Get-WFALogger -Info -Message "The Quota for volume ""$VolumeName"" is ""$status"" and has a sub state of ""$subStatus"" on vserver ""$VserverName"""
   }
   #'---------------------------------------------------------------------------
   #'Raise an error if the timeout is exceeded.
   #'---------------------------------------------------------------------------
   If($timeWaited -ge $timeOut -And $timeOut -gt 0){
      Get-WFALogger -Error -Message "The Quota Status query did not complete within the timeout of ""$timeOut"" seconds"
   }
   Return $completionStatus;
}#End Function
#'------------------------------------------------------------------------------
#'Connect to the cluster.
#'------------------------------------------------------------------------------
Connect-WFACluster $Cluster
#'------------------------------------------------------------------------------
#'Wait for the Quota Status to reach the desired state.
#'------------------------------------------------------------------------------
[String]$command = "Wait-QuotaStatus -VserverName $VserverName -VolumeName $VolumeName -QuotaSubStatus $QuotaSubStatus -QuotaState $QuotaState -TimeOut $TimeOut -WaitInterval $WaitInterval "
If($ZapiRetryCount){
   [String]$command += "-ZapiRetryCount $ZapiRetryCount"
}
[Bool]$result = $False
Try{
   [Bool]$result = Invoke-Expression -Command $command -ErrorAction Stop
   Get-WFALogger -Info -Message "Executed Command`: $command"
}Catch{
   Get-WFALogger -Error -Message $("Failed Executing Command`: $command. Error " + $_.Exception.Message)
}
If(-Not($result)){
   Throw "The Quota Status for volume ""$VolumeName"" did not reach an ""$QuotaState"" state and sub status of ""$QuotaSubStatus"" on vserver ""$VserverName"""
}
#'------------------------------------------------------------------------------

Command to start a quota resize for the volume:

 

 

 

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 volume name")]
   [String]$VolumeName,
   [Parameter(Mandatory=$False, HelpMessage="The maximum number of ZAPI retry attempts")]
   [Int]$ZapiRetryCount
)
#'------------------------------------------------------------------------------
#'Connect to controller
#'------------------------------------------------------------------------------
Connect-WfaCluster $Cluster
#'------------------------------------------------------------------------------
# Create the qtree in the volume.
#'------------------------------------------------------------------------------
Get-WFALogger -Info -Message "Starting Quota resize for volume ""$VolumeName"" on vserver ""$VserverName"""
Try{
   [String]$command = "Start-NcQuotaResize -Volume $VolumeName -VserverContext $VserverName "
   If($ZapiRetryCount){
      [String]$command += "-ZapiRetryCount $ZapiRetryCount "
   }
   [String]$command += "-ErrorAction Stop"
   Invoke-Expression -Command $command -ErrorAction Stop
   Get-WFALogger -Info -Message "Executed Command`: $command"
   Get-WFALogger -Info -Message "Resized Quota for volume ""$VolumeName"" on vserver ""$VserverName"""
}Catch{
   Get-WFALogger -Error -Message $("Failed Executing Command`: $command. Error " + $_.Exception.Message)
   Throw "Failed resizeing Quota for volume ""$VolumeName"" on vserver ""$VserverName"""
}
#'------------------------------------------------------------------------------

/Matt

 

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

View solution in original post

Highlighted

Re: WFA Set Quota Command not Activating the Quota Status on Volumes

Great. Thank you. Quotas are already on, so I think all I need is the code to start a quota resize for the volume. I will try this out and provide results to this thread.

Highlighted

Re: WFA Set Quota Command not Activating the Quota Status on Volumes

I ended up setting IsQuotaInitialize to true in the 'Set Quota' Command, it's false by default. This turns off the quota. Then, I added Netapp command 'Wait for quota off', after the 'Set Quota' step. This waits for the quota to be turned off, then turns it back on. Space Usage now shows correctly when creating a new qtree and setting the quota.

Try the NEW Knowledgebase!
NetApp KB Site
Forums