Microsoft Virtualization Discussions

Customer question

harrya
1,359 Views

Customer is asking the following question. Any thoughts are appreciated. REST has already been suggested, but the customer is focused on PS.


Is there a PS cmdlet equiv to the following cli cmds:

volume flexcache create -vserver eu-vfilerc-01 -volume amc_cifs_prd_apps01 -origin-volume cifs_prd_apps01 -size 50GB -origin-vserver am-vfilerc-01 -aggr-list aggr1_sata_19

#

flexcache prepopulate start -cache-vserver eu-vfilerc-01 -cache-volume amc_cifs_prd_apps01 -path-list <path>

 

We can’t see anything obvious in the PS toolkit help.

1 REPLY 1

mbeattie
528 Views

Hi,

 

You can use Invoke-NcSystemApi if there is no CmdLet. Here's an example:

 

Param(
   [Parameter(Mandatory = $True, HelpMessage = "The ONTAP Cluster Hostname, FQDN or IP Address")]
   [String]$Cluster,
   [Parameter(Mandatory = $True, HelpMessage = "The Aggregate Name")]
   [String]$Aggregate,
   [Parameter(Mandatory = $True, HelpMessage = "The Vserver Name")]
   [String]$Vserver,
   [Parameter(Mandatory = $True, HelpMessage = "The Volume Name")]
   [String]$Volume,
   [Parameter(Mandatory = $True, HelpMessage = "The Volume Size in GigaBytes")]
   [String]$SizeGB,
   [Parameter(Mandatory = $True, HelpMessage = "The Origin Vserver Name")]
   [String]$OriginVserver,
   [Parameter(Mandatory = $True, HelpMessage = "The Origin Volume Name")]
   [String]$OriginVolume,
   [Parameter(Mandatory = $True, HelpMessage = "The Credential to authenticate to the ONTAP cluster")]
   [ValidateNotNullOrEmpty()]
   [System.Management.Automation.PSCredential]$Credential
)
#'------------------------------------------------------------------------------
#'Connect to the cluster.
#'------------------------------------------------------------------------------
Try{
   Connect-NcController -Name $Cluster -ZapiCall -Credential $Credential -ErrorAction Stop
}Catch{
   Write-Warning -Message $("Failed connecting to cluster ""$Cluster"". Error " + $_.Exception.Message)
   Exit -1
}
#'------------------------------------------------------------------------------
#'Create a flexcache volume.
#'------------------------------------------------------------------------------
[Array]$command = $("set advanced;volume flexcache create -vserver $Vserver -volume $Volume -origin-volume $OriginVolume -size " + $($SizeGB + 'GB') + " -origin-vserver $OriginVserver -aggr-list $Aggregate")
Try{
   $api = $("<system-cli><args><arg>" + ($command -join "</arg><arg>") + "</arg></args></system-cli>")
   Write-Host $("Executed Command`: " + $([String]::Join(" ", $command)))
   $response = Invoke-NcSystemApi -Request $api -ErrorAction Stop
}Catch{
   Write-Warning -Message $("Failed Executing Command`: " + $([String]::Join(" ", $command)))
   Break;
}
#'------------------------------------------------------------------------------

 

Hope that helps

 

/Matt

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