The transition to NetApp MS Azure AD B2C is complete. If you missed the pre-registration, you will be invited to reigister at next log in.
Please note that access to your NetApp data may take up to 1 hour.
To learn more, read the FAQ and watch the video.
Need assistance? Complete this form and select “Registration Issue” as the Feedback Category.

Microsoft Virtualization Discussions

How to apply an ExportPolicy to a volume

christio

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

1 ACCEPTED SOLUTION

beam

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

View solution in original post

4 REPLIES 4

sheelnidhig

$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

Daniel_66

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}

FED_ESB

A simple one liner using the name of volume and the name of the export policy

 

 

PS C:\> update-ncvol -query @{name="<volume_name>"} -Attributes @{volumeexportattributes=@{policy="<export_policy_name>"}}

 

 

When using this type of hack, keep in mind string names are case sensitvie.  So if you have an export policy name as "ALL_UNIX_HOST", if you were to type in "all_unix_host" as the export_policy_name it would fail.

 

Many thanks to all who have contributed to this site.

beam

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

View solution in original post

Announcements
NetApp on Discord Image

We're on Discord, are you?

Live Chat, Watch Parties, and More!

Explore Banner

Meet Explore, NetApp’s digital sales platform

Engage digitally throughout the sales process, from product discovery to configuration, and handle all your post-purchase needs.

NetApp Insights to Action
I2A Banner
Public