Subscribe
Accepted Solution

How to apply an ExportPolicy to a volume

Hi

We've exported the exportpolicy and the corresponding rules from an existing volume on a cluster.

$export_policy = Get-NcExportPolicy -Controller $source -Name $policy_name

$export_rules = Get-NcExportRule -Controller $source -Policy $export_policy

We've created the exact policy on another cluster where this volume is vaulted to.

New-NcExportPolicy -Controller $destination -Name $policy_name

$export_rules | ForEach-Object {

     $_ | New-NcExportRule -Controller $destination -Policy $policy_name -EnableSetUid

}

We tried to apply this policy to a clone of this volume, but we didn't found a cmdlet which allows to apply an export policy to a volume.

Get-NcVol returns the Attribut (VolumeExportAttributes.Policy) but Set-NcVol has no paramter that allows to set any additional volume options like the export policy.

Similar command on the cli looks as follows:

volume modify -vserver "vsname" -volume "clonename" -policy "xy"

Is there a way to set options like the ExportPolicy?

We've noticed that there is a Set-NcNfsExport cmdlet but we don't understand how this should work in a clustered DataOntap environment, because it doesn't utilize export policies.

Cmdlet: Set-NcNfsExport

SYNTAX

    Set-NcNfsExport [-Path] <String> [-SecurityFlavors <String[]>] [-Anon <String>] [-ReadOnly <String[]>] [-ReadWrite <String[]>] [-Root <String[]>] [-NoSuid] [-VserverContext <String>] [-Controller <NcController[]>] [<CommonParameters>]

Thanks in advance

Christian

Re: How to apply an ExportPolicy to a volume

Hi Christian,

In order to apply an export policy to a volume, you need to use the Update-NcVol cmdlet to update the VolumeExportAttributes policy.  Here's an example:

PS C:\> $attr = Get-NcVol -Template

PS C:\> Initialize-NcObjectProperty -Object $attr -Name VolumeExportAttributes

PS C:\> $attr.VolumeExportAttributes.Policy = 'default'

PS C:\> $query = Get-NcVol -Template

PS C:\> $query.Name = "powershell"

PS C:\> $query.Vserver = "beam01"

PS C:\> Update-NcVol -Query $query -Attributes $attr

NcController : 10.63.165.62

SuccessCount : 1

FailureCount : 0

SuccessList  : {powershell}

FailureList  : {}

If you are using PowerShell 3 you can shorten this by using a Hashtable as the Query parameter (PowerShell will automatically create the VolumeAttributes object):

PS C:\> Update-NcVol -Query @{Name="powershell";Vserver="beam01"} -Attributes $attr

Let me know if you have any issues,

Steven

Re: How to apply an ExportPolicy to a volume

$source = "iceage"
$policy_name = "esxc:Nux01"
$vserver = "inblrlabp003"
Connect-NcController -Name $cource -Credential admin -Vserver $vserver

$export_policy = Get-NcExportPolicy -Name $policy_name
$export_rules = Get-NcExportRule -Policy ($export_policy).PolicyName

New-NcExportPolicy -Name $policy_name
$export_rules | ForEach-Object {
$_ | New-NcExportRule -Policy $policy_name -EnableSetUid
}

 

I get the following error:

 

New-NcExportRule : The input object cannot be bound because it did not contain the information required to bind all mandatory
parameters: ReadOnlySecurityFlavor ReadWriteSecurityFlavor
At H:\Tools\ncexportpolicy.ps1:11 char:11
+ $_ | New-NcExportRule -Policy $policy_name -EnableSetUid
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (DataONTAP.C.Types.Exports.ExportRuleInfo:PSObject) [New-NcExportRule], ParameterBinding
Exception
+ FullyQualifiedErrorId : InputObjectMissingMandatory,DataONTAP.C.PowerShell.SDK.Cmdlets.Exports.NewNcExportRule

Re: How to apply an ExportPolicy to a volume

the following command can import the rules:

 

$export_policy = Get-NcExportPolicy -Controller $source -Name $policy_name

$export_rules = Get-NcExportRule -Controller $source -Policy $export_policy

$export_rules | ForEach-Object{ new-ncexportrule -Policy testPolicy -VserverContext SVMDes -ClientMatch $_.ClientMatch -ReadOnlySecurityFlavor any -ReadWriteSecurityFlavor any}