-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Network] Add Cmdlets for Network Virtual Appliance (NVA) and NVA si…
…te resources. (#12227) * 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]>
- Loading branch information
1 parent
7479c2b
commit e4edf11
Showing
43 changed files
with
18,060 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/Network/Network.Test/ScenarioTests/NetworkVirtualApplianceTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// ---------------------------------------------------------------------------------- | ||
// | ||
// Copyright Microsoft Corporation | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// ---------------------------------------------------------------------------------- | ||
|
||
using Microsoft.Azure.Commands.Network.Test.ScenarioTests; | ||
using Microsoft.WindowsAzure.Commands.ScenarioTest; | ||
using Xunit; | ||
|
||
namespace Commands.Network.Test.ScenarioTests | ||
{ | ||
public class NetworkVirtualApplianceTests : NetworkTestRunner | ||
{ | ||
public NetworkVirtualApplianceTests(Xunit.Abstractions.ITestOutputHelper output) | ||
: base(output) | ||
{ | ||
} | ||
|
||
[Fact] | ||
[Trait(Category.AcceptanceType, Category.CheckIn)] | ||
[Trait(Category.Owner, NrpTeamAlias.pgtm)] | ||
public void TestNetworkVirtualApplianceCRUD() | ||
{ | ||
TestRunner.RunTestScript(string.Format("Test-NetworkVirtualApplianceCRUD")); | ||
} | ||
|
||
[Fact(Skip = "A bug is being fixed by Nfv-Rp team")] | ||
[Trait(Category.AcceptanceType, Category.CheckIn)] | ||
[Trait(Category.Owner, NrpTeamAlias.pgtm)] | ||
public void TestVirtualApplianceSiteCRUD() | ||
{ | ||
TestRunner.RunTestScript("Test-VirtualApplianceSiteCRUD"); | ||
} | ||
} | ||
} |
118 changes: 118 additions & 0 deletions
118
src/Network/Network.Test/ScenarioTests/NetworkVirtualApplianceTests.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
# ---------------------------------------------------------------------------------- | ||
# | ||
# Copyright Microsoft Corporation | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# ---------------------------------------------------------------------------------- | ||
|
||
function Check-CmdletReturnType | ||
{ | ||
param($cmdletName, $cmdletReturn) | ||
|
||
$cmdletData = Get-Command $cmdletName | ||
Assert-NotNull $cmdletData | ||
[array]$cmdletReturnTypes = $cmdletData.OutputType.Name | Foreach-Object { return ($_ -replace "Microsoft.Azure.Commands.Network.Models.","") } | ||
[array]$cmdletReturnTypes = $cmdletReturnTypes | Foreach-Object { return ($_ -replace "System.","") } | ||
$realReturnType = $cmdletReturn.GetType().Name -replace "Microsoft.Azure.Commands.Network.Models.","" | ||
return $cmdletReturnTypes -contains $realReturnType | ||
} | ||
|
||
<# | ||
.SYNOPSIS | ||
Test creating new NetworkVirtualAppliance | ||
#> | ||
function Test-NetworkVirtualApplianceCRUD | ||
{ | ||
$rgname = Get-ResourceGroupName | ||
|
||
# The commands are not supported in all regions yet. | ||
$location = "eastus2" | ||
$nvaname = Get-ResourceName | ||
$wanname = Get-ResourceName | ||
$hubname = Get-ResourceName | ||
$resourceTypeParent = "Microsoft.Network/networkVirtualAppliance" | ||
$vendor = "barracuda sdwan release" | ||
$scaleunit = 1 | ||
$version = 'latest' | ||
$newasn = 1271 | ||
$asn=1270 | ||
$prefix = "10.0.0.0/16" | ||
try{ | ||
$resourceGroup = New-AzResourceGroup -Name $rgname -Location $location | ||
$sku = New-AzVirtualApplianceSkuProperty -VendorName $vendor -BundledScaleUnit $scaleunit -MarketPlaceVersion $version | ||
Assert-NotNull $sku | ||
|
||
$wan = New-AzVirtualWan -ResourceGroupName $rgname -Name $wanname -Location $location | ||
$hub = New-AzVirtualHub -ResourceGroupName $rgname -Name $hubname -Location $location -VirtualWan $wan -AddressPrefix $prefix | ||
$nva = New-AzNetworkVirtualAppliance -ResourceGroupName $rgname -Name $nvaname -Location $location -VirtualApplianceAsn $asn -VirtualHubId $hub.Id -Sku $sku -CloudInitConfiguration "echo hi" | ||
Assert-NotNull $nva | ||
|
||
$getnva = Get-AzNetworkVirtualAppliance -ResourceGroupName $rgname -Name $nvaname | ||
Assert-NotNull $getnva | ||
|
||
## There is a bug in the update call in the nfvrp. The NfvRp team will record the powershell tests once fixed. | ||
# $updatednva = Update-AzNetworkVirtualAppliance -ResourceGroupName $rgname -Name $nvaname -VirtualApplianceAsn $newasn -Force | ||
# Assert-True { $updatednva.VirtualApplianceAsn -eq $newasn} | ||
|
||
$rmresult = Remove-AzNetworkVirtualAppliance -ResourceGroupName $rgname -Name $nvaname -Force -PassThru | ||
Assert-True { $true } | ||
} | ||
finally{ | ||
# Clean up. | ||
Clean-ResourceGroup $rgname | ||
} | ||
} | ||
|
||
<# | ||
.SYNOPSIS | ||
Test creating new VirtualApplianceSite | ||
#> | ||
function Test-VirtualApplianceSiteCRUD | ||
{ | ||
$rgname = Get-ResourceGroupName | ||
|
||
# The commands are not supported in all regions yet. | ||
$location = "eastus2" | ||
$nvaname = Get-ResourceName | ||
$wanname = Get-ResourceName | ||
$hubname = Get-ResourceName | ||
$sitename = Get-ResourceName | ||
$resourceTypeParent = "Microsoft.Network/networkVirtualAppliance" | ||
$vendor = "barracuda sdwan release" | ||
$scaleunit = 1 | ||
$version = 'latest' | ||
$asn = 1270 | ||
$prefix = "10.0.0.0/16" | ||
$siteprefix = "10.0.1.0/24" | ||
$newsiteprefix = "10.0.2.0/24" | ||
try{ | ||
$resourceGroup = New-AzResourceGroup -Name $rgname -Location $location | ||
$sku = New-AzVirtualApplianceSkuProperty -VendorName $vendor -BundledScaleUnit $scaleunit -MarketPlaceVersion $version | ||
Assert-NotNull $sku | ||
|
||
$wan = New-AzVirtualWan -ResourceGroupName $rgname -Name $wanname -Location $location | ||
$hub = New-AzVirtualHub -ResourceGroupName $rgname -Name $hubname -Location $location -VirtualWan $wan -AddressPrefix $prefix | ||
$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" | ||
$getnva = Get-AzNetworkVirtualAppliance -ResourceGroupName $rgname -Name $nvaname | ||
|
||
$o365Policy = New-AzOffice365PolicyProperty -Allow -Optimize | ||
$site = New-AzVirtualApplianceSite -Name $sitename -ResourceGroupName $rgname -AddressPrefix $siteprefix -O365Policy $o365Policy -NetworkVirtualApplianceId $getnva.Id | ||
$getsite = Get-AzVirtualApplianceSite -Name $sitename -ResourceGroupName $rgname -NetworkVirtualApplianceId $getnva.Id | ||
$setsite = Update-AzVirtualApplianceSite -Name $sitename -ResourceGroupName $rgname -NetworkVirtualApplianceId $getnva.Id -AddressPrefix $newsiteprefix -Force | ||
Remove-AzVirtualApplianceSite -Name $sitename -ResourceGroupName $rgname -NetworkVirtualApplianceId $getnva.Id -Force | ||
Remove-AzNetworkVirtualAppliance -ResourceGroupName $rgname -Name $nvaname -Force | ||
} | ||
finally{ | ||
# Clean up. | ||
Clean-ResourceGroup $rgname | ||
} | ||
} | ||
|
||
|
Oops, something went wrong.