Skip to content

Commit

Permalink
[NetAppFiles] Update to api-version 2021-02-01 updates (#15104)
Browse files Browse the repository at this point in the history
* Apply 2021-02-01 updates

* Remove accidental comment

Co-authored-by: Audunn Baldvinsson <audunn.baldvinsson@netapp.com>
  • Loading branch information
audunn and audunn authored May 27, 2021
1 parent 4115d19 commit 5d223e1
Show file tree
Hide file tree
Showing 39 changed files with 16,608 additions and 25,645 deletions.
2 changes: 1 addition & 1 deletion src/NetAppFiles/NetAppFiles.Test/NetAppFiles.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.NetApp" Version="1.11.0" />
<PackageReference Include="Microsoft.Azure.Management.NetApp" Version="1.12.0" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="20.3.0" />
</ItemGroup>

Expand Down
114 changes: 113 additions & 1 deletion src/NetAppFiles/NetAppFiles.Test/ScenarioTests/VolumeTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,6 @@ function Test-VolumeReplication
}
}


<#
.SYNOPSIS
Test Volume Set-AzNetAppFilesVolumePool operation
Expand Down Expand Up @@ -518,6 +517,119 @@ function Test-SetVolumePool
}


<#
.SYNOPSIS
Test Volume Update-AzNetAppFilesVolume to set snapshotPolicy
#>
function Update-AzNetAppFilesVolumeSnapshotPolicy
{
$currentSub = (Get-AzureRmContext).Subscription
$subsid = $currentSub.SubscriptionId

$resourceGroup = Get-ResourceGroupName
$accName = Get-ResourceName
$poolName = Get-ResourceName
$volName1 = Get-ResourceName
$snapshotPolicyName1 = Get-ResourceName
$gibibyte = 1024 * 1024 * 1024
$usageThreshold = 100 * $gibibyte
#$resourceLocation = Get-ProviderLocation "Microsoft.NetApp" "eastus" -UseCanonical
$resourceLocation = "westus2"
$subnetName = "default"
$poolSize = 4398046511104
$serviceLevel = "Premium"
$serviceLevelStandard = "Premium"
$vnetName = $resourceGroup + "-vnet"


$subnetId = "/subscriptions/$subsId/resourceGroups/$resourceGroup/providers/Microsoft.Network/virtualNetworks/$vnetName/subnets/$subnetName"

$rule1 = @{
RuleIndex = 1
UnixReadOnly = $false
UnixReadWrite = $true
Cifs = $false
Nfsv3 = $true
Nfsv41 = $false
AllowedClients = '0.0.0.0/0'
}


$exportPolicy = @{
Rules = (
$rule1
)
}

# create the list of protocol types
$protocolTypes = New-Object string[] 1
$protocolTypes[0] = "NFSv3"

try
{
# create the resource group
New-AzResourceGroup -Name $resourceGroup -Location $resourceLocation

# create virtual network
$virtualNetwork = New-AzVirtualNetwork -ResourceGroupName $resourceGroup -Location $resourceLocation -Name $vnetName -AddressPrefix 10.0.0.0/16
$delegation = New-AzDelegation -Name "netAppVolumes" -ServiceName "Microsoft.Netapp/volumes"
Add-AzVirtualNetworkSubnetConfig -Name $subnetName -VirtualNetwork $virtualNetwork -AddressPrefix "10.0.1.0/24" -Delegation $delegation | Set-AzVirtualNetwork

# create account
$retrievedAcc = New-AzNetAppFilesAccount -ResourceGroupName $resourceGroup -Location $resourceLocation -AccountName $accName

# create pool
$retrievedPool = New-AzNetAppFilesPool -ResourceGroupName $resourceGroup -Location $resourceLocation -AccountName $accName -PoolName $poolName -PoolSize $poolSize -ServiceLevel $serviceLevel

# create volume and check
$newTagName = "tag1"
$newTagValue = "tagValue1"
$retrievedVolume = New-AzNetAppFilesVolume -ResourceGroupName $resourceGroup -Location $resourceLocation -AccountName $accName -PoolName $poolName -VolumeName $volName1 -CreationToken $volName1 -UsageThreshold $usageThreshold -ServiceLevel $serviceLevel -SubnetId $subnetId -Tag @{$newTagName = $newTagValue} -ExportPolicy $exportPolicy -ProtocolType $protocolTypes
Assert-AreEqual "$accName/$poolName/$volName1" $retrievedVolume.Name
Assert-AreEqual $serviceLevel $retrievedVolume.ServiceLevel
Assert-AreEqual True $retrievedVolume.Tags.ContainsKey($newTagName)
Assert-AreEqual "tagValue1" $retrievedVolume.Tags[$newTagName].ToString()
Assert-NotNull $retrievedVolume.ExportPolicy
Assert-AreEqual '0.0.0.0/0' $retrievedVolume.ExportPolicy.Rules[0].AllowedClients

Assert-AreEqual $retrievedVolume.ProtocolTypes[0] 'NFSv3'
Assert-NotNull $retrievedVolume.MountTargets
Assert-Null $retrievedVolume.VolumeType
Assert-Null $retrievedVolume.DataProtection

# get and check the volume by name
$retrievedVolume = Get-AzNetAppFilesVolume -ResourceGroupName $resourceGroup -AccountName $accName -PoolName $poolName -VolumeName $volName1
Assert-AreEqual "$accName/$poolName/$volName1" $retrievedVolume.Name

# create and check SnapshotPolicy
$retrievedSnapshotPolicy = New-AzNetAppFilesSnapshotPolicy -ResourceGroupName $resourceGroup -Location $resourceLocation -AccountName $accName1 -Name $snapshotPolicyName1 -Enabled -HourlySchedule $hourlySchedule -DailySchedule $dailySchedule -WeeklySchedule $weeklySchedule -MonthlySchedule $monthlySchedule
Assert-AreEqual "$accName1/$snapshotPolicyName1" $retrievedSnapshotPolicy.Name
Assert-NotNull $retrievedSnapshotPolicy.Id


# get and check a SnapshotPolicy by name and check again
$getRetrievedSnapshotPolicy = Get-AzNetAppFilesSnapshotPolicy -ResourceGroupName $resourceGroup -AccountName $accName1 -Name $snapshotPolicyName1
Assert-AreEqual "$accName1/$snapshotPolicyName1" $retrievedSnapshotPolicy.Name

# Assign snapshotpolicy to volume
$updateRetrievedVolume = Update-AzNetAppFilesVolume -ResourceGroupName $resourceGroup -Location $resourceLocation -AccountName $accName -PoolName $poolName -VolumeName $volName1 -SnapshotPolicyId $retrievedSnapshotPolicy.Id
Assert-AreEqual $retrievedSnapshotPolicy.Id $updateRetrievedVolume.SnapshotPolicyId

# check GET
$getRetrievedVolume = Get-AzNetAppFilesVolume -ResourceGroupName $resourceGroup -AccountName $accName -PoolName $poolName2 -VolumeName $volName1
Assert-AreEqual "$accName/$poolName2/$volName1" $getRetrievedVolume.Name
Assert-AreEqual $serviceLevelStandard $getRetrievedVolume.ServiceLevel
Assert-AreEqual $retrievedSnapshotPolicy.Id $getRetrievedVolume.SnapshotPolicyId

}
finally
{
# Cleanup
Clean-ResourceGroup $resourceGroup
}
}


<#
.SYNOPSIS
Test Volume Pipeline operations (using command aliases)
Expand Down
Loading

0 comments on commit 5d223e1

Please sign in to comment.