Skip to content

Commit

Permalink
add ParameterSet for SMB and NFS
Browse files Browse the repository at this point in the history
  • Loading branch information
vMarkusK committed Mar 21, 2020
1 parent a0077dc commit 6cc5680
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 53 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Connect-VBRServer -Server localhost


```PowerShell
New-VeeamNetappVolume -VeeamCacheRepo 'Default Backup Repository' -VolType NFS -IP 10.0.2.16 `
-ExportPolicyName veeam -VolName vol_nfs_001 -VolSize 1 -NetAppAggregate aggr1_data01 `
-NetAppVserver svm_veeam_nfs -NetAppInterface svm_veeam_nfs_nfs_lif1 -NetAppSnapshotPolicy default
New-VeeamNetappVolume -NFS -IP 10.0.2.16 -ExportPolicyName veeam -VolName vol_nfs_01Y -VolSize 1 `
-VeeamCacheRepo 'Default Backup Repository' -NetAppAggregate aggr1_data01 -NetAppVserver svm_veeam_nfs `
-NetAppInterface svm_veeam_nfs_nfs_lif1 -NetAppSnapshotPolicy default
```
2 changes: 1 addition & 1 deletion VeeamNetAppToolkit.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ PowerShellVersion = '5.0'
# FormatsToProcess = @()

# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
NestedModules = @('functions/New-VeeamNetappVolume.psm1')
NestedModules = @('functions\New-VeeamNetappVolume.psm1')

# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
FunctionsToExport = 'New-VeeamNetappVolume'
Expand Down
53 changes: 37 additions & 16 deletions docs/en-US/New-VeeamNetappVolume.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,15 @@ schema: 2.0.0

## SYNTAX

### NFS
```
New-VeeamNetappVolume [-VolType] <String> [-IP] <IPAddress> [-ExportPolicyName] <String> [-VolName] <String>
[-VolSize] <Int32> [<CommonParameters>]
New-VeeamNetappVolume [-NFS] -IP <IPAddress> -ExportPolicyName <String> -VolName <String> -VolSize <Int32>
[<CommonParameters>]
```

### SMB
```
New-VeeamNetappVolume [-SMB] -VolName <String> -VolSize <Int32> [<CommonParameters>]
```

## DESCRIPTION
Expand All @@ -23,22 +29,37 @@ Creates a new a NetApp Volume and adds it to Veeam Configuration as a NAS Backup

### EXAMPLE 1
```
New-VeeamNetappVolume -VeeamCacheRepo 'Default Backup Repository' -VolType NFS -IP 10.0.2.16 -ExportPolicyName veeam -VolName vol_nfs_001 -VolSize 1 -NetAppAggregate aggr1_data01 -NetAppVserver svm_veeam_nfs -NetAppInterface svm_veeam_nfs_nfs_lif1 -NetAppSnapshotPolicy default
New-VeeamNetappVolume -NFS -IP 10.0.2.16 -ExportPolicyName veeam -VolName vol_nfs_01 -VolSize 1 -VeeamCacheRepo 'Default Backup Repository' -NetAppAggregate aggr1_data01 -NetAppVserver svm_veeam_nfs -NetAppInterface svm_veeam_nfs_nfs_lif1 -NetAppSnapshotPolicy default
```

## PARAMETERS

### -VolType
Type of the new Volume
### -NFS
NFS Volume

```yaml
Type: String
Parameter Sets: (All)
Type: SwitchParameter
Parameter Sets: NFS
Aliases:

Required: True
Position: 1
Default value: None
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```

### -SMB
SMB Volume

```yaml
Type: SwitchParameter
Parameter Sets: SMB
Aliases:

Required: True
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```
Expand All @@ -48,11 +69,11 @@ IP for the NFS Export

```yaml
Type: IPAddress
Parameter Sets: (All)
Parameter Sets: NFS
Aliases:

Required: True
Position: 2
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Expand All @@ -63,11 +84,11 @@ Name of the Export Policy

```yaml
Type: String
Parameter Sets: (All)
Parameter Sets: NFS
Aliases:

Required: True
Position: 3
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Expand All @@ -82,7 +103,7 @@ Parameter Sets: (All)
Aliases:

Required: True
Position: 4
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Expand All @@ -97,7 +118,7 @@ Parameter Sets: (All)
Aliases:

Required: True
Position: 5
Position: Named
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False
Expand All @@ -113,7 +134,7 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
## NOTES
File Name : New-VeeamNetappVolume.psm1
Author : Markus Kraus
Version : 0.1
Version : 0.2
State : Dev

## RELATED LINKS
Expand Down
79 changes: 46 additions & 33 deletions functions/New-VeeamNetappVolume.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,20 @@ function New-VeeamNetappVolume {
.NOTES
File Name : New-VeeamNetappVolume.psm1
Author : Markus Kraus
Version : 0.1
Version : 0.2
State : Dev
.LINK
https://mycloudrevolution.com/
.EXAMPLE
New-VeeamNetappVolume -VeeamCacheRepo 'Default Backup Repository' -VolType NFS -IP 10.0.2.16 -ExportPolicyName veeam -VolName vol_nfs_001 -VolSize 1 -NetAppAggregate aggr1_data01 -NetAppVserver svm_veeam_nfs -NetAppInterface svm_veeam_nfs_nfs_lif1 -NetAppSnapshotPolicy default
New-VeeamNetappVolume -NFS -IP 10.0.2.16 -ExportPolicyName veeam -VolName vol_nfs_01 -VolSize 1 -VeeamCacheRepo 'Default Backup Repository' -NetAppAggregate aggr1_data01 -NetAppVserver svm_veeam_nfs -NetAppInterface svm_veeam_nfs_nfs_lif1 -NetAppSnapshotPolicy default
.PARAMETER Type
Type of the new Volume
.PARAMETER NFS
NFS Volume
.PARAMETER SMB
SMB Volume
.PARAMETER IP
IP for the NFS Export
Expand All @@ -43,14 +46,16 @@ function New-VeeamNetappVolume {

[CmdletBinding()]
Param (
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="Type of the new Volume")]
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="NFS Volume", ParameterSetName="NFS")]
[ValidateNotNullorEmpty()]
[Switch]$NFS,
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="SMB Volume", ParameterSetName="SMB")]
[ValidateNotNullorEmpty()]
[ValidateSet("NFS")]
[String]$VolType,
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="IP for the NFS Export")]
[Switch]$SMB,
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="IP for the NFS Export", ParameterSetName="NFS")]
[ValidateNotNullorEmpty()]
[ipaddress]$IP,
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="Name of the Export Policy")]
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="Name of the Export Policy", ParameterSetName="NFS")]
[ValidateNotNullorEmpty()]
[String]$ExportPolicyName,
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="Name of the new Volume")]
Expand Down Expand Up @@ -211,32 +216,40 @@ function New-VeeamNetappVolume {

Process {

#$ClientMatch = $IPs -join ","
$ClientMatch = $IP

if(!($NetAppExportPolicy = Get-NcExportPolicy -Name $ExportPolicyName -VserverContext $NetAppVserver )){
"Create new NetApp Export Policy '$($ExportPolicyName)' on SVM '$($NetAppVserver.Name)' ..."
$NetAppExportPolicy = New-NcExportPolicy -Name $ExportPolicyName -VserverContext $NetAppVserver
$NetAppExportRule = New-NcExportRule -VserverContext $NetAppVserver -Policy $NetAppExportPolicy.PolicyName -ClientMatch $ClientMatch `
-Protocol NFS -Index 1 -SuperUserSecurityFlavor any -ReadOnlySecurityFlavor any -ReadWriteSecurityFlavor any
}else{
"NetApp Export Policy '$($ExportPolicyName)' on SVM '$($NetAppVserver.Name)' aleady exists, add IP"
$NetAppExportRule = New-NcExportRule -VserverContext $NetAppVserver -Policy $NetAppExportPolicy.PolicyName -ClientMatch $ClientMatch `
-Protocol NFS -Index 1 -SuperUserSecurityFlavor any -ReadOnlySecurityFlavor any -ReadWriteSecurityFlavor any

}

"Create new NetApp Volume '$VolName' on Aggregate '$($NetAppAggr.AggregateName)' ..."
$NetAppVolume = New-NcVol -VserverContext $NetAppVserver -Name $VolName -Aggregate $NetAppAggr.AggregateName -JunctionPath $("/" + $VolName) `
-ExportPolicy $ExportPolicyName -Size $VolSizeByte -SnapshotReserve 20 -SnapshotPolicy $NetAppSnapshotPolicy.Policy

"Set Advanced Options for NetApp Volume '$VolName' ..."
$NetAppVolume | Set-NcVolOption -Key fractional_reserve -Value 0
$NetAppVolume | Set-NcVolOption -Key guarantee -Value none
if ($NFS) {

#$ClientMatch = $IPs -join ","
$ClientMatch = $IP

if(!($NetAppExportPolicy = Get-NcExportPolicy -Name $ExportPolicyName -VserverContext $NetAppVserver )){
"Create new NetApp Export Policy '$($ExportPolicyName)' on SVM '$($NetAppVserver.Name)' ..."
$NetAppExportPolicy = New-NcExportPolicy -Name $ExportPolicyName -VserverContext $NetAppVserver
$NetAppExportRule = New-NcExportRule -VserverContext $NetAppVserver -Policy $NetAppExportPolicy.PolicyName -ClientMatch $ClientMatch `
-Protocol NFS -Index 1 -SuperUserSecurityFlavor any -ReadOnlySecurityFlavor any -ReadWriteSecurityFlavor any
}else{
"NetApp Export Policy '$($ExportPolicyName)' on SVM '$($NetAppVserver.Name)' aleady exists, add IP"
$NetAppExportRule = New-NcExportRule -VserverContext $NetAppVserver -Policy $NetAppExportPolicy.PolicyName -ClientMatch $ClientMatch `
-Protocol NFS -Index 1 -SuperUserSecurityFlavor any -ReadOnlySecurityFlavor any -ReadWriteSecurityFlavor any

}

"Create new NetApp Volume '$VolName' on Aggregate '$($NetAppAggr.AggregateName)' ..."
$NetAppVolume = New-NcVol -VserverContext $NetAppVserver -Name $VolName -Aggregate $NetAppAggr.AggregateName -JunctionPath $("/" + $VolName) `
-ExportPolicy $ExportPolicyName -Size $VolSizeByte -SnapshotReserve 20 -SnapshotPolicy $NetAppSnapshotPolicy.Policy

"Set Advanced Options for NetApp Volume '$VolName' ..."
$NetAppVolume | Set-NcVolOption -Key fractional_reserve -Value 0
$NetAppVolume | Set-NcVolOption -Key guarantee -Value none

"Add New Veeam NAS Server '$($NetAppInterface.Address):/$($VolName)'"
$VBRNASNFSServer = Add-VBRNASNFSServer -Path "$($NetAppInterface.Address):/$($VolName)" -CacheRepository $VeeamCacheRepo

}
elseif ($SMB) {

"Add New Veeam NAS Server '$($NetAppInterface.Address):/$($VolName)'"
$VBRNASNFSServer = Add-VBRNASNFSServer -Path "$($NetAppInterface.Address):/$($VolName)" -CacheRepository $VeeamCacheRepo
"Not Implemented. Sorry..."

}
}

}

0 comments on commit 6cc5680

Please sign in to comment.