Does anyone have an example of using the NetApp.ONTAP PowerShell templates for requesting specific attributes? I know it’s possible with the raw/direct #1063542514780475493 using ?fields=name. I need the name of all snapshots for a volume, but nothing else. And all the other stuff tends to be expensive/time consuming. One volume of about 10 snaps took 8min to return.
#Template Attributes/Fields
1 messages · Page 1 of 1 (latest)
I've been using it basically like this:
foreach ($lif in $lifs) {
$q = Get-NcNetInterface -template:$true
$q.InterfaceName = $lif.InterfaceName
$q.Vserver = $lif.Vserver
$a = Get-NcNetInterface -template:$true
$a.AdministrativeStatus = "down"
Update-NcNetInterface -Controller $Controller -Query $q -Attributes $a -ZapiCall:$true | Out-Null
}
I don't know if requesting certain attributes (like in ZAPI/REST) is possible with PowerShell templates
Both of those seem to be acting as filters.
That's unfortunate
the first ($q) is the query, so yes, that's a filter. The second ($a) sets the attributes. I don't remember why I had to do it this way, but it wouldn't work otherwise for some weird reason 🙂
Apparently there's a command Invoke-NcSystemApi but it speaks XML which implies ONTAPI/ZAPI only. I found this provides what I need:
PS /> $snapshots = (Invoke-NcCli -Command "snapshot show" -Query '{"volume": "test_vol"}' -Fields "snapshot").value
PS /> $snapshots.Count
13
PS /> $snapshots[0]
{
"vserver": "test_svm",
"volume": "test_vol",
"snapshot": "test_vol_31"
}
PS />