Skip to content

Commit 2086a99

Browse files
audunnBethanyZhou
andauthored
[NetAppFiles]Add 2021-10-01 changes (#17767)
* Add 2021-10-01 changes * update help * Add support for shouldprocess * Add exportPolicy helper cmdLet and tests, fix unixpermissions and enableSubvolume * Static Analysis fix * Add static analysis exception * Update src/NetAppFiles/NetAppFiles/ChangeLog.md Co-authored-by: Beisi Zhou <[email protected]> * Update markdown enable GlobalPlacementRule property. ShouldProcess fix * update help, include Restore-AzNetAppFilesSnapshotFile * Fix pipe * add related links * Fix help * Update src/NetAppFiles/NetAppFiles/help/Get-AzNetAppFilesVolumeGroup.md * Fix help. * Rename AzNetAppFilesExportPolicyRule * update changelog and exceptions * Update src/NetAppFiles/NetAppFiles/Snapshot/RestoreNetAppFilesSnapshotFiles.cs Co-authored-by: Beisi Zhou <[email protected]> * fix link * fix exception * Fix related links Co-authored-by: Beisi Zhou <[email protected]>
1 parent 6b83de7 commit 2086a99

File tree

147 files changed

+39057
-21678
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

147 files changed

+39057
-21678
lines changed

src/NetAppFiles/NetAppFiles.Test/NetAppFiles.Test.csproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@
1111
</PropertyGroup>
1212

1313
<ItemGroup>
14-
<PackageReference Include="Microsoft.Azure.Management.NetApp" Version="1.15.0" />
14+
<PackageReference Include="Microsoft.Azure.Management.NetApp" Version="1.16.0" />
1515
<PackageReference Include="Microsoft.Azure.Management.Network" Version="22.0.0" />
1616
</ItemGroup>
1717

18+
<ItemGroup>
19+
<ProjectReference Include="..\NetAppFiles\NetAppFiles.csproj" />
20+
</ItemGroup>
21+
1822
</Project>

src/NetAppFiles/NetAppFiles.Test/ScenarioTests/AccountTests.ps1

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ function Test-AccountActiveDirectory
3131
Password = "sdkpass"
3232
Domain = "sdkdomain"
3333
Dns = "192.0.2.2"
34-
SmbServerName = "PSSMBSName"
34+
SmbServerName = "PSMBSName1"
3535
}
3636
$activeDirectory2 = @{
3737
Username = "sdkuser1"
3838
<#[SuppressMessage("Microsoft.Security", "CS002:SecretInNextLine", Justification="...")]#>
39-
Password = "sdkpass1"
39+
Password = "sdkpass2"
4040
Domain = "sdkdomain"
4141
Dns = "192.0.2.2"
42-
SmbServerName = "PSSMBSName"
42+
SmbServerName = "PSMBSName2"
4343
}
4444

4545
try
@@ -109,6 +109,11 @@ function Test-AccountActiveDirectory
109109
# Assert-AreEqual $activeDirectory2.Password $retrievedAcc.ActiveDirectories[0].Password
110110
Assert-AreEqual $activeDirectory2.Username $retrievedAcc.ActiveDirectories[0].Username
111111
Assert-AreEqual 1 $retrievedAcc.ActiveDirectories.Length
112+
113+
# update (put) the account. The absence of an active directory should result in the removal of any currently associated. Also tags
114+
$retrievedAcc = Set-AzNetAppFilesAccount -ResourceGroupName $resourceGroup -AccountName $accName1 -Location $resourceLocation
115+
Assert-AreEqual $accName1 $retrievedAcc.Name
116+
112117
}
113118
finally
114119
{

src/NetAppFiles/NetAppFiles.Test/ScenarioTests/BackupPolicyTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public BackupPolicyTests(Xunit.Abstractions.ITestOutputHelper output)
2929

3030
[Fact]
3131
[Trait(Category.AcceptanceType, Category.CheckIn)]
32-
public void TestBackupPolicyCrud()
32+
public void TestBackupPolicyCrud()
3333
{
3434
TestController.NewInstance.RunPowerShellTest(_logger, "Test-BackupPolicyCrud");
3535
}

src/NetAppFiles/NetAppFiles.Test/ScenarioTests/BackupTests.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -396,9 +396,9 @@ function Test-VolumeBackupStatus
396396
$gibibyte = 1024 * 1024 * 1024
397397
$usageThreshold = 100 * $gibibyte
398398
#$resourceLocation = Get-ProviderLocation "Microsoft.NetApp" "eastus" -UseCanonical
399-
$resourceLocation = "westus2"
400-
$backupLocation = "eastus2euap"
401-
$backupVNetLocation = "eastus2euap"
399+
$resourceLocation = "eastus2"
400+
$backupLocation = "eastus2"
401+
$backupVNetLocation = "eastus2"
402402
$label = "powershellBackupTest"
403403
#$backupLocation = "eastus2euap"
404404
#$backupVNetLocation = "eastus2euap"
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
16+
using Xunit;
17+
18+
namespace Microsoft.Azure.Commands.NetAppFiles.Test.ScenarioTests.ScenarioTest
19+
{
20+
public class ExportPolicyTests
21+
{
22+
private ServiceManagement.Common.Models.XunitTracingInterceptor _logger;
23+
24+
public ExportPolicyTests(Xunit.Abstractions.ITestOutputHelper output)
25+
{
26+
_logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
27+
ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(_logger);
28+
}
29+
30+
[Fact]
31+
[Trait(Category.AcceptanceType, Category.CheckIn)]
32+
public void TestExportPolicy()
33+
{
34+
TestController.NewInstance.RunPowerShellTest(_logger, "Test-ExportPolicy");
35+
}
36+
}
37+
}
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# ----------------------------------------------------------------------------------
2+
#
3+
# Copyright Microsoft Corporation
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
# ----------------------------------------------------------------------------------
14+
15+
<#
16+
.SYNOPSIS
17+
Test ExportPolicy operations
18+
#>
19+
function Test-ExportPolicy
20+
{
21+
$currentSub = (Get-AzureRmContext).Subscription
22+
$subsid = $currentSub.SubscriptionId
23+
24+
$resourceGroup = Get-ResourceGroupName
25+
$accName = Get-ResourceName
26+
$poolName = Get-ResourceName
27+
$volName1 = Get-ResourceName
28+
$gibibyte = 1024 * 1024 * 1024
29+
$usageThreshold = 100 * $gibibyte
30+
$doubleUsage = 2 * $usageThreshold
31+
#$resourceLocation = Get-ProviderLocation "Microsoft.NetApp" "eastus" -UseCanonical
32+
#$resourceLocation = "eastus2euap"
33+
$resourceLocation = "eastus"
34+
35+
$subnetName = "default"
36+
$poolSize = 4398046511104
37+
$serviceLevel = "Premium"
38+
$vnetName = $resourceGroup + "-vnet"
39+
40+
$subnetId = "/subscriptions/$subsId/resourceGroups/$resourceGroup/providers/Microsoft.Network/virtualNetworks/$vnetName/subnets/$subnetName"
41+
42+
# create the list of protocol types
43+
$protocolTypes = New-Object string[] 1
44+
$protocolTypes[0] = "NFSv3"
45+
46+
try
47+
{
48+
# create the resource group
49+
New-AzResourceGroup -Name $resourceGroup -Location $resourceLocation -Tags @{Owner = 'b-aubald'}
50+
51+
# create virtual network
52+
$virtualNetwork = New-AzVirtualNetwork -ResourceGroupName $resourceGroup -Location $resourceLocation -Name $vnetName -AddressPrefix 10.0.0.0/16
53+
$delegation = New-AzDelegation -Name "netAppVolumes" -ServiceName "Microsoft.Netapp/volumes"
54+
Add-AzVirtualNetworkSubnetConfig -Name $subnetName -VirtualNetwork $virtualNetwork -AddressPrefix "10.0.1.0/24" -Delegation $delegation | Set-AzVirtualNetwork
55+
56+
# create account
57+
$retrievedAcc = New-AzNetAppFilesAccount -ResourceGroupName $resourceGroup -Location $resourceLocation -AccountName $accName
58+
59+
# create pool
60+
$retrievedPool = New-AzNetAppFilesPool -ResourceGroupName $resourceGroup -Location $resourceLocation -AccountName $accName -PoolName $poolName -PoolSize $poolSize -ServiceLevel $serviceLevel
61+
#$exportPolicyRule = New-AzExportPolicyRuleObject -RuleIndex 1 -AllowedClients '0.0.0.0/0' -UnixReadOnly $false -UnixReadWrite $false -Cifs $false -Nfsv3 $true -Nfsv41 $false
62+
$exportPolicyRule = New-AzNetAppFilesExportPolicyRuleObject -RuleIndex 1 -AllowedClient '0.0.0.0/0' -UnixReadOnly -UnixReadWrite -Cifs -Nfsv3
63+
$exportPolicyRules = $($exportPolicyRule)
64+
65+
$newExportPolicy = New-AzNetAppFilesExportPolicyObject -Rule $exportPolicyRules
66+
67+
# create first volume and check
68+
$newTagName = "tag1"
69+
$newTagValue = "tagValue1"
70+
$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 $newExportPolicy -ProtocolType $protocolTypes
71+
Assert-AreEqual "$accName/$poolName/$volName1" $retrievedVolume.Name
72+
Assert-AreEqual $serviceLevel $retrievedVolume.ServiceLevel
73+
Assert-AreEqual True $retrievedVolume.Tags.ContainsKey($newTagName)
74+
Assert-AreEqual "tagValue1" $retrievedVolume.Tags[$newTagName].ToString()
75+
Assert-NotNull $retrievedVolume.ExportPolicy
76+
Assert-AreEqual '0.0.0.0/0' $retrievedVolume.ExportPolicy.Rules[0].AllowedClients
77+
78+
Assert-AreEqual $retrievedVolume.ProtocolTypes[0] 'NFSv3'
79+
Assert-NotNull $retrievedVolume.MountTargets
80+
Assert-Null $retrievedVolume.VolumeType
81+
Assert-Null $retrievedVolume.DataProtection
82+
83+
# use the NFSv4.1
84+
$protocolTypesv4 = New-Object string[] 1
85+
$protocolTypesv4[0] = "NFSv4.1"
86+
87+
#get and check a volume by name
88+
$retrievedVolume = Get-AzNetAppFilesVolume -ResourceGroupName $resourceGroup -AccountName $accName -PoolName $poolName -VolumeName $volName1
89+
Assert-AreEqual "$accName/$poolName/$volName1" $retrievedVolume.Name
90+
}
91+
finally
92+
{
93+
# Cleanup
94+
Clean-ResourceGroup $resourceGroup
95+
}
96+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
16+
using Xunit;
17+
namespace Microsoft.Azure.Commands.NetAppFiles.Test.ScenarioTests.ScenarioTest
18+
{
19+
public class SubvolumeTests
20+
{
21+
private ServiceManagement.Common.Models.XunitTracingInterceptor _logger;
22+
public SubvolumeTests(Xunit.Abstractions.ITestOutputHelper output)
23+
{
24+
_logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
25+
ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(_logger);
26+
}
27+
28+
[Fact]
29+
[Trait(Category.AcceptanceType, Category.CheckIn)]
30+
public void TestSubvolumeCrud()
31+
{
32+
TestController.NewInstance.RunPowerShellTest(_logger, "Test-SubvolumeCrud");
33+
}
34+
35+
36+
}
37+
}
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# ----------------------------------------------------------------------------------
2+
#
3+
# Copyright Microsoft Corporation
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
# ----------------------------------------------------------------------------------
14+
15+
<#
16+
.SYNOPSIS
17+
Test Volume CRUD operations
18+
#>
19+
function Test-SubvolumeCrud
20+
{
21+
$currentSub = (Get-AzureRmContext).Subscription
22+
$subsid = $currentSub.SubscriptionId
23+
$resourceGroup = Get-ResourceGroupName
24+
$accName = Get-ResourceName
25+
$poolName = Get-ResourceName
26+
$volName1 = Get-ResourceName
27+
$subvolName1 = Get-ResourceName
28+
$subvolName2 = Get-ResourceName
29+
$gibibyte = 1024 * 1024 * 1024
30+
$usageThreshold = 100 * $gibibyte
31+
$doubleUsage = 2 * $usageThreshold
32+
$resourceLocation = "eastus"
33+
34+
$subnetName = "default"
35+
$poolSize = 4398046511104
36+
$serviceLevel = "Premium"
37+
$vnetName = $resourceGroup + "-vnet"
38+
39+
$subnetId = "/subscriptions/$subsId/resourceGroups/$resourceGroup/providers/Microsoft.Network/virtualNetworks/$vnetName/subnets/$subnetName"
40+
41+
# create the list of protocol types
42+
$protocolTypes = New-Object string[] 1
43+
$protocolTypes[0] = "NFSv3"
44+
$path = "/subvolumePath"
45+
$updatePath = "/subvolumePath1"
46+
$parentPath = "/parentPath"
47+
$subvolumeSize = 5
48+
try
49+
{
50+
# create the resource group
51+
New-AzResourceGroup -Name $resourceGroup -Location $resourceLocation -Tags @{Owner = 'b-aubald'}
52+
# create virtual network
53+
$virtualNetwork = New-AzVirtualNetwork -ResourceGroupName $resourceGroup -Location $resourceLocation -Name $vnetName -AddressPrefix 10.0.0.0/16
54+
$delegation = New-AzDelegation -Name "netAppVolumes" -ServiceName "Microsoft.Netapp/volumes"
55+
Add-AzVirtualNetworkSubnetConfig -Name $subnetName -VirtualNetwork $virtualNetwork -AddressPrefix "10.0.1.0/24" -Delegation $delegation | Set-AzVirtualNetwork
56+
57+
# create account
58+
$retrievedAcc = New-AzNetAppFilesAccount -ResourceGroupName $resourceGroup -Location $resourceLocation -AccountName $accName
59+
60+
# create pool
61+
$retrievedPool = New-AzNetAppFilesPool -ResourceGroupName $resourceGroup -Location $resourceLocation -AccountName $accName -PoolName $poolName -PoolSize $poolSize -ServiceLevel $serviceLevel
62+
# create first volume and check
63+
$newTagName = "tag1"
64+
$newTagValue = "tagValue1"
65+
$retrievedVolume = New-AzNetAppFilesVolume -ResourceGroupName $resourceGroup -Location $resourceLocation -AccountName $accName -PoolName $poolName -VolumeName $volName1 -CreationToken $volName1 -UsageThreshold $usageThreshold -ServiceLevel $serviceLevel -SubnetId $subnetId -Tag @{$newTagName = $newTagValue} -ProtocolType $protocolTypes -EnableSubvolume
66+
Assert-AreEqual "$accName/$poolName/$volName1" $retrievedVolume.Name
67+
Assert-AreEqual $serviceLevel $retrievedVolume.ServiceLevel
68+
Assert-AreEqual True $retrievedVolume.Tags.ContainsKey($newTagName)
69+
Assert-AreEqual "tagValue1" $retrievedVolume.Tags[$newTagName].ToString()
70+
Assert-AreEqual '0.0.0.0/0' $retrievedVolume.ExportPolicy.Rules[0].AllowedClients
71+
Assert-AreEqual $retrievedVolume.ProtocolTypes[0] 'NFSv3'
72+
73+
# create first subvolume and check
74+
$retrievedSubvolume = New-AzNetAppFilesSubvolume -ResourceGroupName $resourceGroup -Location $resourceLocation -AccountName $accName -PoolName $poolName -VolumeName $volName1 -SubvolumeName $subvolName1 -Size $subvolumeSize -Path $path
75+
Assert-AreEqual $path $retrievedSubvolume.Path
76+
77+
# get first subvolume and check
78+
$getSubvolume = Get-AzNetAppFilesSubvolume -ResourceGroupName $resourceGroup -AccountName $accName -PoolName $poolName -VolumeName $volName1 -SubvolumeName $subvolName1
79+
Assert-AreEqual $path $getSubvolume.Path
80+
81+
# get first subvolume metadata and check
82+
$getSubvolumeMetadata = Get-AzNetAppFilesSubvolumeMetadata -ResourceGroupName $resourceGroup -AccountName $accName -PoolName $poolName -VolumeName $volName1 -SubvolumeName $subvolName1
83+
Assert-AreEqual $path $getSubvolumeMetadata.Path
84+
Assert-NotNull $getSubvolumeMetadata.Permissions
85+
Assert-NotNull $getSubvolumeMetadata.CreationTimeStamp
86+
87+
# Update subvolume and check
88+
$updatedSubvolume = Update-AzNetAppFilesSubvolume -ResourceGroupName $resourceGroup -AccountName $accName -PoolName $poolName -VolumeName $volName1 -SubvolumeName $subvolName1 -Size 3 -Path $updatePath
89+
Assert-AreEqual $updatePath $updatedSubvolume.Path
90+
91+
# create second subvolume and check
92+
$retrievedSubvolume2 = New-AzNetAppFilesSubvolume -ResourceGroupName $resourceGroup -Location $resourceLocation -AccountName $accName -PoolName $poolName -VolumeName $volName1 -SubvolumeName $subvolName2 -Size 5 -Path $path
93+
Assert-AreEqual $path $retrievedSubvolume2.Path
94+
95+
# get list and check
96+
$getSubvolumes = Get-AzNetAppFilesSubvolume -ResourceGroupName $resourceGroup -AccountName $accName -PoolName $poolName -VolumeName $volName1
97+
Assert-AreEqual 2 $getSubvolumes.Length
98+
99+
#Delete subvolume 1
100+
$updatedSubvolume = Remove-AzNetAppFilesSubvolume -ResourceGroupName $resourceGroup -AccountName $accName -PoolName $poolName -VolumeName $volName1 -SubvolumeName $subvolName1
101+
102+
# get list and check again
103+
$getSubvolumes = Get-AzNetAppFilesSubvolume -ResourceGroupName $resourceGroup -AccountName $accName -PoolName $poolName -VolumeName $volName1
104+
Assert-AreEqual 1 $getSubvolumes.Length
105+
}
106+
finally
107+
{
108+
# Cleanup
109+
Clean-ResourceGroup $resourceGroup
110+
}
111+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
16+
using Xunit;
17+
namespace Microsoft.Azure.Commands.NetAppFiles.Test.ScenarioTests.ScenarioTest
18+
{
19+
public class VolumeGroupTests
20+
{
21+
private ServiceManagement.Common.Models.XunitTracingInterceptor _logger;
22+
public VolumeGroupTests(Xunit.Abstractions.ITestOutputHelper output)
23+
{
24+
_logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
25+
ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(_logger);
26+
}
27+
28+
[Fact]
29+
[Trait(Category.AcceptanceType, Category.CheckIn)]
30+
public void TestVolumeGroupCrud()
31+
{
32+
TestController.NewInstance.RunPowerShellTest(_logger, "Test-VolumeGroupCrud");
33+
}
34+
35+
36+
}
37+
}

0 commit comments

Comments
 (0)