|
| 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