Microsoft Virtualization Discussions

How to apply an ExportPolicy to a volume

christio
10,699 Views

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
10,699 Views

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

beam
10,700 Views

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

sheelnidhig
10,244 Views

$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
8,722 Views

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
7,164 Views

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.

Public