Skip to content

Commit 10b4d7b

Browse files
3vilbuff3rNeel BhavsarVeryEarly
authored
[Network] Added Cmdlets for Network Virtual Appliance (NVA) and NVA site resources. (#12213)
* Created Model Classes for NVA powershell object. * Added *-NetworkVirtualAppliance commands. * Added *-NVASite commands and export commands. * Added tests for NVA CRUD operations. The tests for NVA Site CRUD operations is in skipped state. Reason for this is a bug in the Nfv-RP which fails the New-AzVirtualApplianceSite command. The fix is underway and Nfv-RP team will record the tests and push it in a separate change. * Added help files for the new 11 Cmdlets. * Added entry in the Changelog * Bug fix for null NVA Id. * Added online version to help files. * Replace real guids with 0000.. in examples. * Add default resource paramsets, rename plural cmds * Supress static analysis errors. Co-authored-by: Neel Bhavsar <[email protected]> Co-authored-by: Yabo Hu <[email protected]>
1 parent a77b31e commit 10b4d7b

File tree

43 files changed

+18060
-1
lines changed

Some content is hidden

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

43 files changed

+18060
-1
lines changed

src/Network/Network.Test/Network.Test.csproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
<PackageReference Include="Microsoft.Azure.Management.ManagedServiceIdentity" Version="0.10.0-preview" />
2424
</ItemGroup>
2525

26+
<ItemGroup>
27+
<Resource Include="SessionRecords\Commands.Network.Test.ScenarioTests.NetworkVirtualApplianceTests\TestNetworkVirtualApplianceCRUD.json" />
28+
</ItemGroup>
29+
2630
<ItemGroup>
2731
<None Update="ScenarioTests\Data\*.*" CopyToOutputDirectory="PreserveNewest" />
2832
<None Update="ScenarioTests\Utils\*.*" CopyToOutputDirectory="PreserveNewest" />
@@ -35,4 +39,8 @@
3539
</None>
3640
</ItemGroup>
3741

42+
<ItemGroup>
43+
<Folder Include="SessionRecords\Commands.Network.Test.ScenarioTests.NetworkVirtualApplianceTests\" />
44+
</ItemGroup>
45+
3846
</Project>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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.Azure.Commands.Network.Test.ScenarioTests;
16+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
17+
using Xunit;
18+
19+
namespace Commands.Network.Test.ScenarioTests
20+
{
21+
public class NetworkVirtualApplianceTests : NetworkTestRunner
22+
{
23+
public NetworkVirtualApplianceTests(Xunit.Abstractions.ITestOutputHelper output)
24+
: base(output)
25+
{
26+
}
27+
28+
[Fact]
29+
[Trait(Category.AcceptanceType, Category.CheckIn)]
30+
[Trait(Category.Owner, NrpTeamAlias.pgtm)]
31+
public void TestNetworkVirtualApplianceCRUD()
32+
{
33+
TestRunner.RunTestScript(string.Format("Test-NetworkVirtualApplianceCRUD"));
34+
}
35+
36+
[Fact(Skip = "A bug is being fixed by Nfv-Rp team")]
37+
[Trait(Category.AcceptanceType, Category.CheckIn)]
38+
[Trait(Category.Owner, NrpTeamAlias.pgtm)]
39+
public void TestVirtualApplianceSiteCRUD()
40+
{
41+
TestRunner.RunTestScript("Test-VirtualApplianceSiteCRUD");
42+
}
43+
}
44+
}
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
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+
function Check-CmdletReturnType
16+
{
17+
param($cmdletName, $cmdletReturn)
18+
19+
$cmdletData = Get-Command $cmdletName
20+
Assert-NotNull $cmdletData
21+
[array]$cmdletReturnTypes = $cmdletData.OutputType.Name | Foreach-Object { return ($_ -replace "Microsoft.Azure.Commands.Network.Models.","") }
22+
[array]$cmdletReturnTypes = $cmdletReturnTypes | Foreach-Object { return ($_ -replace "System.","") }
23+
$realReturnType = $cmdletReturn.GetType().Name -replace "Microsoft.Azure.Commands.Network.Models.",""
24+
return $cmdletReturnTypes -contains $realReturnType
25+
}
26+
27+
<#
28+
.SYNOPSIS
29+
Test creating new NetworkVirtualAppliance
30+
#>
31+
function Test-NetworkVirtualApplianceCRUD
32+
{
33+
$rgname = Get-ResourceGroupName
34+
35+
# The commands are not supported in all regions yet.
36+
$location = "eastus2"
37+
$nvaname = Get-ResourceName
38+
$wanname = Get-ResourceName
39+
$hubname = Get-ResourceName
40+
$resourceTypeParent = "Microsoft.Network/networkVirtualAppliance"
41+
$vendor = "barracuda sdwan release"
42+
$scaleunit = 1
43+
$version = 'latest'
44+
$newasn = 1271
45+
$asn=1270
46+
$prefix = "10.0.0.0/16"
47+
try{
48+
$resourceGroup = New-AzResourceGroup -Name $rgname -Location $location
49+
$sku = New-AzVirtualApplianceSkuProperty -VendorName $vendor -BundledScaleUnit $scaleunit -MarketPlaceVersion $version
50+
Assert-NotNull $sku
51+
52+
$wan = New-AzVirtualWan -ResourceGroupName $rgname -Name $wanname -Location $location
53+
$hub = New-AzVirtualHub -ResourceGroupName $rgname -Name $hubname -Location $location -VirtualWan $wan -AddressPrefix $prefix
54+
$nva = New-AzNetworkVirtualAppliance -ResourceGroupName $rgname -Name $nvaname -Location $location -VirtualApplianceAsn $asn -VirtualHubId $hub.Id -Sku $sku -CloudInitConfiguration "echo hi"
55+
Assert-NotNull $nva
56+
57+
$getnva = Get-AzNetworkVirtualAppliance -ResourceGroupName $rgname -Name $nvaname
58+
Assert-NotNull $getnva
59+
60+
## There is a bug in the update call in the nfvrp. The NfvRp team will record the powershell tests once fixed.
61+
# $updatednva = Update-AzNetworkVirtualAppliance -ResourceGroupName $rgname -Name $nvaname -VirtualApplianceAsn $newasn -Force
62+
# Assert-True { $updatednva.VirtualApplianceAsn -eq $newasn}
63+
64+
$rmresult = Remove-AzNetworkVirtualAppliance -ResourceGroupName $rgname -Name $nvaname -Force -PassThru
65+
Assert-True { $true }
66+
}
67+
finally{
68+
# Clean up.
69+
Clean-ResourceGroup $rgname
70+
}
71+
}
72+
73+
<#
74+
.SYNOPSIS
75+
Test creating new VirtualApplianceSite
76+
#>
77+
function Test-VirtualApplianceSiteCRUD
78+
{
79+
$rgname = Get-ResourceGroupName
80+
81+
# The commands are not supported in all regions yet.
82+
$location = "eastus2"
83+
$nvaname = Get-ResourceName
84+
$wanname = Get-ResourceName
85+
$hubname = Get-ResourceName
86+
$sitename = Get-ResourceName
87+
$resourceTypeParent = "Microsoft.Network/networkVirtualAppliance"
88+
$vendor = "barracuda sdwan release"
89+
$scaleunit = 1
90+
$version = 'latest'
91+
$asn = 1270
92+
$prefix = "10.0.0.0/16"
93+
$siteprefix = "10.0.1.0/24"
94+
$newsiteprefix = "10.0.2.0/24"
95+
try{
96+
$resourceGroup = New-AzResourceGroup -Name $rgname -Location $location
97+
$sku = New-AzVirtualApplianceSkuProperty -VendorName $vendor -BundledScaleUnit $scaleunit -MarketPlaceVersion $version
98+
Assert-NotNull $sku
99+
100+
$wan = New-AzVirtualWan -ResourceGroupName $rgname -Name $wanname -Location $location
101+
$hub = New-AzVirtualHub -ResourceGroupName $rgname -Name $hubname -Location $location -VirtualWan $wan -AddressPrefix $prefix
102+
$nva = New-AzNetworkVirtualAppliance -ResourceGroupName $rgname -Name $nvaname -Location $location -VirtualApplianceAsn $asn -VirtualHubId /subscriptions/5e1e8156-5dec-452a-bfe5-6b6e0947c27a/resourceGroups/sliceTestRG/providers/Microsoft.Network/virtualHubs/sliceHub -Sku $sku -CloudInitConfiguration "echo hi"
103+
$getnva = Get-AzNetworkVirtualAppliance -ResourceGroupName $rgname -Name $nvaname
104+
105+
$o365Policy = New-AzOffice365PolicyProperty -Allow -Optimize
106+
$site = New-AzVirtualApplianceSite -Name $sitename -ResourceGroupName $rgname -AddressPrefix $siteprefix -O365Policy $o365Policy -NetworkVirtualApplianceId $getnva.Id
107+
$getsite = Get-AzVirtualApplianceSite -Name $sitename -ResourceGroupName $rgname -NetworkVirtualApplianceId $getnva.Id
108+
$setsite = Update-AzVirtualApplianceSite -Name $sitename -ResourceGroupName $rgname -NetworkVirtualApplianceId $getnva.Id -AddressPrefix $newsiteprefix -Force
109+
Remove-AzVirtualApplianceSite -Name $sitename -ResourceGroupName $rgname -NetworkVirtualApplianceId $getnva.Id -Force
110+
Remove-AzNetworkVirtualAppliance -ResourceGroupName $rgname -Name $nvaname -Force
111+
}
112+
finally{
113+
# Clean up.
114+
Clean-ResourceGroup $rgname
115+
}
116+
}
117+
118+

0 commit comments

Comments
 (0)