Skip to content

Commit 2d5a787

Browse files
committed
NFSAAS-1707 add initial version of ANF
1 parent ed5b763 commit 2d5a787

File tree

66 files changed

+15543
-0
lines changed

Some content is hidden

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

66 files changed

+15543
-0
lines changed

src/Accounts/Accounts/AzureRmAlias/Mappings.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,24 @@
6363
"Export-AzAnalysisServicesInstanceLog": "Export-AzureAnalysisServicesInstanceLog",
6464
"Sync-AzAnalysisServicesInstance": "Sync-AzureAnalysisServicesInstance"
6565
},
66+
"Az.Anf": {
67+
"New-AzAnfAccount": "New-AzureRmAnfAccount",
68+
"Remove-AzAnfAccount": "Remove-AzureRmAnfAccount",
69+
"Get-AzAnfAccount": "Get-AzureRmAnfAccount",
70+
"New-AzAnfPool": "New-AzureRmAnfPool",
71+
"Set-AzAnfPool": "Set-AzureRmAnfPool",
72+
"Remove-AzAnfPool": "Remove-AzureRmAnfPool",
73+
"Get-AzAnfPool": "Get-AzureRmAnfPool",
74+
"New-AzAnfVolume": "New-AzureRmAnfVolume",
75+
"Update-AzAnfVolume": "Update-AzureRmAnfVolume",
76+
"Set-AzAnfVolume": "Set-AzureRmAnfVolume",
77+
"Remove-AzAnfVolume": "Remove-AzureRmAnfVolume",
78+
"Get-AzAnfVolume": "Get-AzureRmAnfVolume",
79+
"Get-AzAnfMountTarget": "Get-AzureRmAnfMountTarget",
80+
"New-AzAnfSnapshot": "New-AzureRmAnfSnapshot",
81+
"Remove-AzAnfSnapshot": "Remove-AzureRmAnfSnapshot",
82+
"Get-AzAnfSnapshot": "Get-AzureRmAnfSnapshot"
83+
},
6684
"Az.ApiManagement": {
6785
"Add-AzApiManagementRegion": "Add-AzureRmApiManagementRegion",
6886
"Get-AzApiManagementSsoToken": "Get-AzureRmApiManagementSsoToken",

src/Anf/Anf.Test/Anf.Test.csproj

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<PsModuleName>Anf</PsModuleName>
5+
</PropertyGroup>
6+
7+
<Import Project="$(MSBuildThisFileDirectory)..\..\Az.Test.props" />
8+
9+
<PropertyGroup>
10+
<RootNamespace>$(LegacyAssemblyPrefix)$(PsModuleName)$(AzTestAssemblySuffix).ScenarioTests</RootNamespace>
11+
</PropertyGroup>
12+
13+
<ItemGroup>
14+
<PackageReference Include="Microsoft.Azure.Management.NetApp" Version="0.9.0-preview" />
15+
<PackageReference Include="Microsoft.Azure.Management.Network" Version="19.7.0-preview" />
16+
</ItemGroup>
17+
18+
</Project>
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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 System.Reflection;
16+
using System.Runtime.InteropServices;
17+
using Xunit;
18+
19+
// General Information about an assembly is controlled through the following
20+
// set of attributes. Change these attribute values to modify the information
21+
// associated with an assembly.
22+
[assembly: AssemblyTitle("Microsoft.Azure.Commands.Anf.Test")]
23+
[assembly: AssemblyDescription("")]
24+
[assembly: AssemblyConfiguration("")]
25+
[assembly: AssemblyCompany("")]
26+
[assembly: AssemblyProduct("Microsoft.Azure.Commands.Anf.Test")]
27+
[assembly: AssemblyCopyright(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyCopyright)]
28+
[assembly: AssemblyTrademark("")]
29+
[assembly: AssemblyCulture("")]
30+
31+
// Setting ComVisible to false makes the types in this assembly not visible
32+
// to COM components. If you need to access a type in this assembly from
33+
// COM, set the ComVisible attribute to true on that type.
34+
[assembly: ComVisible(false)]
35+
36+
// The following GUID is for the ID of the typelib if this project is exposed to COM
37+
[assembly: Guid("5E5BBB82-2D69-4A12-93AA-E5753F87AF03")]
38+
39+
// Version information for an assembly consists of the following four values:
40+
//
41+
// Major Version
42+
// Minor Version
43+
// Build Number
44+
// Revision
45+
//
46+
// You can specify all the values or you can default the Build and Revision Numbers
47+
// by using the '*' as shown below:
48+
[assembly: AssemblyVersion("0.9.0")]
49+
[assembly: AssemblyFileVersion("0.9.0")]
50+
[assembly: CollectionBehavior(DisableTestParallelization = true)]
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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 System;
17+
using Xunit;
18+
19+
namespace Microsoft.Azure.Commands.Anf.Test.ScenarioTests.ScenarioTest
20+
{
21+
public class AccountTests
22+
{
23+
private ServiceManagement.Common.Models.XunitTracingInterceptor _logger;
24+
25+
public AccountTests(Xunit.Abstractions.ITestOutputHelper output)
26+
{
27+
_logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
28+
ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(_logger);
29+
}
30+
31+
[Fact]
32+
[Trait(Category.AcceptanceType, Category.CheckIn)]
33+
public void TestAccountCrud()
34+
{
35+
TestController.NewInstance.RunPowerShellTest(_logger, "Test-AccountCrud");
36+
}
37+
}
38+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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 Account CRUD operations
18+
#>
19+
function Test-AccountCrud
20+
{
21+
$resourceGroup = RandomString "pws-sdk-tests-rg-" 5
22+
$accName1 = RandomString "pws-sdk-acc-1" 5
23+
$accName2 = RandomString "pws-sdk-acc-2" 5
24+
$resourceLocation = "westus2"
25+
26+
try
27+
{
28+
# create the resource group
29+
New-AzureRmResourceGroup -Name $resourceGroup -Location $resourceLocation
30+
31+
# create and check account 1
32+
$retrievedAcc = New-AzureRmAnfAccount -ResourceGroupName $resourceGroup -Location $resourceLocation -AccountName $accName1
33+
Assert-AreEqual $accName1 $retrievedAcc.Name
34+
35+
# create and check account 2
36+
$retrievedAcc = New-AzureRmAnfAccount -ResourceGroupName $resourceGroup -Location $resourceLocation -AccountName $accName2
37+
Assert-AreEqual $accName2 $retrievedAcc.Name
38+
39+
# get and check accounts by group (list)
40+
$retrievedAcc = Get-AzureRmAnfAccount -ResourceGroupName $resourceGroup
41+
Assert-AreEqual $accName1 $retrievedAcc[0].Name
42+
Assert-AreEqual $accName2 $retrievedAcc[1].Name
43+
Assert-AreEqual 2 $retrievedAcc.Length
44+
45+
# get and check an account by name
46+
$retrievedAcc = Get-AzureRmAnfAccount -ResourceGroupName $resourceGroup -AccountName $accName1
47+
Assert-AreEqual $accName1 $retrievedAcc.Name
48+
49+
# get and check the account again using the resource id just obtained
50+
$retrievedAccById = Get-AzureRmAnfAccount -ResourceId $retrievedAcc.Id
51+
Assert-AreEqual $accName1 $retrievedAccById.Name
52+
53+
# update and check the account (tags)
54+
# since only tags can be patched and no other set or update is possible
55+
# there is no implemented cmdlet
56+
57+
# delete one account retrieved by id and one by name and check removed
58+
Remove-AzureRmAnfAccount -ResourceId $retrievedAccById.Id
59+
Remove-AzureRmAnfAccount -ResourceGroupName $resourceGroup -AccountName $accName2
60+
$retrievedAcc = Get-AzureRmAnfAccount -ResourceGroupName $resourceGroup
61+
Assert-AreEqual 0 $retrievedAcc.Length
62+
}
63+
finally
64+
{
65+
# Cleanup
66+
Clean-ResourceGroup $resourceGroup
67+
}
68+
}
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
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+
Gets valid resource group name
18+
#>
19+
function Get-ResourceGroupName
20+
{
21+
return getAssetName
22+
}
23+
24+
<#
25+
.SYNOPSIS
26+
Gets valid resource name
27+
#>
28+
function Get-ResourceName
29+
{
30+
return getAssetName
31+
}
32+
33+
<#
34+
.SYNOPSIS
35+
Gets the default location for a provider
36+
#>
37+
function Get-ProviderLocation($provider)
38+
{
39+
if ([Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::Mode -ne [Microsoft.Azure.Test.HttpRecorder.HttpRecorderMode]::Playback)
40+
{
41+
$namespace = $provider.Split("/")[0]
42+
if($provider.Contains("/"))
43+
{
44+
$type = $provider.Substring($namespace.Length + 1)
45+
$location = Get-AzureRmResourceProvider -ProviderNamespace $namespace | where {$_.ResourceTypes[0].ResourceTypeName -eq $type}
46+
47+
if ($location -eq $null)
48+
{
49+
return "West US"
50+
} else
51+
{
52+
return $location.Locations[0]
53+
}
54+
}
55+
56+
return "West US"
57+
}
58+
59+
return "WestUS"
60+
}
61+
62+
<#
63+
.SYNOPSIS
64+
Creates a resource group to use in tests
65+
#>
66+
function TestSetup-CreateResourceGroup
67+
{
68+
$resourceGroupName = getAssetName
69+
$rglocation = Get-ProviderLocation "North Europe"
70+
$resourceGroup = New-AzureRmResourceGroup -Name $resourceGroupName -location $rglocation -Force
71+
return $resourceGroup
72+
}
73+
74+
<#
75+
.SYNOPSIS
76+
Asserts if two tags are equal
77+
#>
78+
function Assert-Tags($tags1, $tags2)
79+
{
80+
if($tags1.count -ne $tags2.count)
81+
{
82+
throw "Tag size not equal. Tag1: $tags1.count Tag2: $tags2.count"
83+
}
84+
85+
foreach($key in $tags1.Keys)
86+
{
87+
if($tags1[$key] -ne $tags2[$key])
88+
{
89+
throw "Tag content not equal. Key:$key Tags1:" + $tags1[$key] + "Tags2:" + $tags2[$key]
90+
}
91+
}
92+
}
93+
94+
<#
95+
.SYNOPSIS
96+
Asserts if two compression types are equal
97+
#>
98+
function Assert-CompressionTypes($types1, $types2)
99+
{
100+
if($types1.Count -ne $types1.Count)
101+
{
102+
throw "Array size not equal. Types1: $types1.count Types2: $types2.count"
103+
}
104+
105+
foreach($value1 in $types1)
106+
{
107+
$found = $false
108+
foreach($value2 in $types2)
109+
{
110+
if($value1.CompareTo($value2) -eq 0)
111+
{
112+
$found = $true
113+
break
114+
}
115+
}
116+
if(-Not($found))
117+
{
118+
throw "Compression content not equal. " + $value1 + " cannot be found in second array"
119+
}
120+
}
121+
}
122+
123+
124+
<#
125+
.SYNOPSIS
126+
Cleans the created resource groups
127+
#>
128+
function Clean-ResourceGroup($rgname)
129+
{
130+
Remove-AzureRmResourceGroup -Name $rgname -Force
131+
}
132+
133+
134+
<#
135+
.SYNOPSIS
136+
Create a random string of given length with the provided prefix
137+
#>
138+
function RandomString($prefix, $size)
139+
{
140+
return $prefix + -join ((65..90) + (97..122) | Get-Random -Count $size | % {[char]$_})
141+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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 System;
17+
using Xunit;
18+
19+
namespace Microsoft.Azure.Commands.Anf.Test.ScenarioTests.ScenarioTest
20+
{
21+
public class PoolTests
22+
{
23+
private ServiceManagement.Common.Models.XunitTracingInterceptor _logger;
24+
25+
public PoolTests(Xunit.Abstractions.ITestOutputHelper output)
26+
{
27+
_logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
28+
ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(_logger);
29+
}
30+
31+
[Fact]
32+
[Trait(Category.AcceptanceType, Category.CheckIn)]
33+
public void TestPoolCrud()
34+
{
35+
TestController.NewInstance.RunPowerShellTest(_logger, "Test-PoolCrud");
36+
}
37+
}
38+
}

0 commit comments

Comments
 (0)